Update Backup & reset settings to launch the configured activity.
Check for configured backup settings activity to be used for
Settings->Backup & reset.
Bug: 28942163
Change-Id: I8b937fde5b400afdb81463c9c278b3e3ad42688b
diff --git a/src/com/android/settings/BackupSettingsActivity.java b/src/com/android/settings/BackupSettingsActivity.java
new file mode 100644
index 0000000..94e9691
--- /dev/null
+++ b/src/com/android/settings/BackupSettingsActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.R;
+
+import java.net.URISyntaxException;
+
+/**
+ * A trampoline activity used to launch the configured Backup activity.
+ * This activity used the theme NoDisplay to minimize the flicker that might be seen for the launch-
+ * finsih transition.
+ */
+public class BackupSettingsActivity extends Activity {
+ private static final String TAG = "BackupSettingsActivity";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ String backup = getResources().getString(R.string.config_backup_settings_intent);
+ if (!TextUtils.isEmpty(backup)) {
+ try {
+ Intent intent = Intent.parseUri(backup, 0);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ // use startActivityForResult to let the activity check the caller signature
+ startActivityForResult(intent, -1);
+ } else {
+ Log.e(TAG, "Backup component not found!");
+ }
+ } catch (URISyntaxException e) {
+ Log.e(TAG, "Invalid backup component URI!", e);
+ }
+ }
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 17ce8a1..8cc9085 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -131,6 +131,7 @@
import com.android.settingslib.drawer.SettingsDrawerActivity;
import com.android.settingslib.drawer.Tile;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -1099,6 +1100,23 @@
}
}
}
+
+ String backupIntent = getResources().getString(R.string.config_backup_settings_intent);
+ boolean useDefaultBackup = TextUtils.isEmpty(backupIntent);
+ setTileEnabled(new ComponentName(packageName,
+ Settings.PrivacySettingsActivity.class.getName()), useDefaultBackup, isAdmin, pm);
+ boolean hasBackupActivity = false;
+ if (!useDefaultBackup) {
+ try {
+ Intent intent = Intent.parseUri(backupIntent, 0);
+ hasBackupActivity = !getPackageManager().queryIntentActivities(intent, 0).isEmpty();
+ } catch (URISyntaxException e) {
+ Log.e(LOG_TAG, "Invalid backup intent URI!", e);
+ }
+ }
+ setTileEnabled(new ComponentName(packageName,
+ BackupSettingsActivity.class.getName()), hasBackupActivity, isAdmin, pm);
+
}
private void setTileEnabled(ComponentName component, boolean enabled, boolean isAdmin,