Catch SecurityException from enabling backup activity
Cases where the activity is already enabled and the account is an unicorn account. Test: Opened activity from backup settings w/ unicorn account, verified no crash Bug: 74199770 Change-Id: I7dc30d22b186ff19cf7c40fda0363ff1288224d1
This commit is contained in:
@@ -58,9 +58,17 @@ public class BackupSettingsActivity extends Activity implements Indexable {
|
|||||||
"No manufacturer settings found, launching the backup settings directly");
|
"No manufacturer settings found, launching the backup settings directly");
|
||||||
}
|
}
|
||||||
Intent intent = backupHelper.getIntentForBackupSettings();
|
Intent intent = backupHelper.getIntentForBackupSettings();
|
||||||
|
try {
|
||||||
// enable the activity before launching it
|
// enable the activity before launching it
|
||||||
getPackageManager().setComponentEnabledSetting(intent.getComponent(),
|
getPackageManager().setComponentEnabledSetting(
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
intent.getComponent(),
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, "Trying to enable activity " + intent.getComponent() + " but couldn't: "
|
||||||
|
+ e.getMessage());
|
||||||
|
// the activity may already be enabled
|
||||||
|
}
|
||||||
|
|
||||||
// use startActivityForResult to let the activity check the caller signature
|
// use startActivityForResult to let the activity check the caller signature
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
|
Reference in New Issue
Block a user