blob: b376f6b0d995b68bf91b1df0f733a04c4ececdcf [file] [log] [blame]
Anton Philippovadfec552017-01-25 20:37:36 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.settings.backup;
18
19import android.app.Activity;
Anton Philippov18dd11f2017-02-03 16:01:52 +000020import android.content.Intent;
21import android.content.pm.PackageManager;
Anton Philippovadfec552017-01-25 20:37:36 +000022import android.os.Bundle;
23import android.util.Log;
24
25
26/**
27 * The activity used to launch the configured Backup activity or the preference screen
28 * if the manufacturer provided their backup settings.
29 */
30public class BackupSettingsActivity extends Activity {
31 private static final String TAG = "BackupSettingsActivity";
32
33 @Override
34 public void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36
37 BackupSettingsHelper backupHelper = new BackupSettingsHelper(this);
38
39 if (!backupHelper.isBackupProvidedByManufacturer()) {
40 // If manufacturer specific backup settings are not provided then launch
41 // the backup settings provided by backup transport or the default one directly.
42 if (Log.isLoggable(TAG, Log.DEBUG)) {
43 Log.d(TAG,
44 "No manufacturer settings found, launching the backup settings directly");
45 }
Anton Philippov18dd11f2017-02-03 16:01:52 +000046 Intent intent = backupHelper.getIntentForBackupSettings();
47 // enable the activity before launching it
48 getPackageManager().setComponentEnabledSetting(intent.getComponent(),
49 PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
50
Anton Philippovadfec552017-01-25 20:37:36 +000051 // use startActivityForResult to let the activity check the caller signature
Anton Philippov18dd11f2017-02-03 16:01:52 +000052 startActivityForResult(intent, 1);
Anton Philippovadfec552017-01-25 20:37:36 +000053 finish();
54 } else {
55 if (Log.isLoggable(TAG, Log.DEBUG)) {
56 Log.d(TAG, "Manufacturer provided backup settings, showing the preference screen");
57 }
58 getFragmentManager().beginTransaction()
59 .replace(android.R.id.content, new BackupSettingsFragment())
60 .commit();
61 }
62 }
63}