Tell sublaunched backup settings activities about policy state am: ee564e9cfc am: 8953a28597

am: d35a29884b

Change-Id: I350bcabcef6702ae9b12b81767afc504031998ad
This commit is contained in:
Christopher Tate
2016-09-23 21:45:12 +00:00
committed by android-build-merger

View File

@@ -17,8 +17,13 @@
package com.android.settings; package com.android.settings;
import android.app.Activity; import android.app.Activity;
import android.app.backup.BackupManager;
import android.app.backup.IBackupManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -43,6 +48,17 @@ public class BackupSettingsActivity extends Activity {
Intent intent = Intent.parseUri(backup, 0); Intent intent = Intent.parseUri(backup, 0);
if (intent.resolveActivity(getPackageManager()) != null) { if (intent.resolveActivity(getPackageManager()) != null) {
// use startActivityForResult to let the activity check the caller signature // use startActivityForResult to let the activity check the caller signature
IBackupManager bmgr = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
boolean backupOkay;
try {
backupOkay = bmgr.isBackupServiceActive(UserHandle.myUserId());
} catch (Exception e) {
// things go wrong talking to the backup system => ignore and
// pass the default 'false' as the "backup is a thing?" state.
backupOkay = false;
}
intent.putExtra(BackupManager.EXTRA_BACKUP_SERVICES_AVAILABLE, backupOkay);
startActivityForResult(intent, -1); startActivityForResult(intent, -1);
} else { } else {
Log.e(TAG, "Backup component not found!"); Log.e(TAG, "Backup component not found!");