Merge "Backup OS service now processes unlock off the main thread"
This commit is contained in:
@@ -401,45 +401,53 @@ public class BackupManagerService implements BackupManagerServiceInterface {
|
||||
@Override
|
||||
public void onUnlockUser(int userId) {
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
sInstance.initialize(userId);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
// Migrate legacy setting
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup migrate");
|
||||
if (!backupSettingMigrated(userId)) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup enable apparently not migrated");
|
||||
}
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
final int enableState = Settings.Secure.getIntForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, -1, userId);
|
||||
if (enableState >= 0) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Migrating enable state " + (enableState != 0));
|
||||
}
|
||||
writeBackupEnableState(enableState != 0, userId);
|
||||
Settings.Secure.putStringForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, null, userId);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup not yet configured; retaining null enable state");
|
||||
}
|
||||
}
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable");
|
||||
try {
|
||||
sInstance.setBackupEnabled(readBackupEnableState(userId));
|
||||
} catch (RemoteException e) {
|
||||
// can't happen; it's a local object
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
sInstance.unlockSystemUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called through the trampoline from onUnlockUser(), then we buck the work
|
||||
// off to the background thread to keep the unlock time down.
|
||||
public void unlockSystemUser() {
|
||||
mBackupHandler.post(() -> {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
sInstance.initialize(UserHandle.USER_SYSTEM);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
// Migrate legacy setting
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup migrate");
|
||||
if (!backupSettingMigrated(UserHandle.USER_SYSTEM)) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup enable apparently not migrated");
|
||||
}
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
final int enableState = Settings.Secure.getIntForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, -1, UserHandle.USER_SYSTEM);
|
||||
if (enableState >= 0) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Migrating enable state " + (enableState != 0));
|
||||
}
|
||||
writeBackupEnableState(enableState != 0, UserHandle.USER_SYSTEM);
|
||||
Settings.Secure.putStringForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, null, UserHandle.USER_SYSTEM);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup not yet configured; retaining null enable state");
|
||||
}
|
||||
}
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable");
|
||||
try {
|
||||
sInstance.setBackupEnabled(readBackupEnableState(UserHandle.USER_SYSTEM));
|
||||
} catch (RemoteException e) {
|
||||
// can't happen; it's a local object
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
});
|
||||
}
|
||||
|
||||
class ProvisionedObserver extends ContentObserver {
|
||||
public ProvisionedObserver(Handler handler) {
|
||||
super(handler);
|
||||
|
||||
@@ -39,6 +39,8 @@ import java.io.PrintWriter;
|
||||
*/
|
||||
public interface BackupManagerServiceInterface {
|
||||
|
||||
void unlockSystemUser();
|
||||
|
||||
// Utility: build a new random integer token
|
||||
int generateRandomIntegerToken();
|
||||
|
||||
|
||||
@@ -548,45 +548,53 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter
|
||||
@Override
|
||||
public void onUnlockUser(int userId) {
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
sInstance.initialize(userId);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
// Migrate legacy setting
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup migrate");
|
||||
if (!backupSettingMigrated(userId)) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup enable apparently not migrated");
|
||||
}
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
final int enableState = Settings.Secure.getIntForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, -1, userId);
|
||||
if (enableState >= 0) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Migrating enable state " + (enableState != 0));
|
||||
}
|
||||
writeBackupEnableState(enableState != 0, userId);
|
||||
Settings.Secure.putStringForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, null, userId);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup not yet configured; retaining null enable state");
|
||||
}
|
||||
}
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable");
|
||||
try {
|
||||
sInstance.setBackupEnabled(readBackupEnableState(userId));
|
||||
} catch (RemoteException e) {
|
||||
// can't happen; it's a local object
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
sInstance.unlockSystemUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called through the trampoline from onUnlockUser(), then we buck the work
|
||||
// off to the background thread to keep the unlock time down.
|
||||
public void unlockSystemUser() {
|
||||
mBackupHandler.post(() -> {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
sInstance.initialize(UserHandle.USER_SYSTEM);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
// Migrate legacy setting
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup migrate");
|
||||
if (!backupSettingMigrated(UserHandle.USER_SYSTEM)) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup enable apparently not migrated");
|
||||
}
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
final int enableState = Settings.Secure.getIntForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, -1, UserHandle.USER_SYSTEM);
|
||||
if (enableState >= 0) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Migrating enable state " + (enableState != 0));
|
||||
}
|
||||
writeBackupEnableState(enableState != 0, UserHandle.USER_SYSTEM);
|
||||
Settings.Secure.putStringForUser(r,
|
||||
Settings.Secure.BACKUP_ENABLED, null, UserHandle.USER_SYSTEM);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup not yet configured; retaining null enable state");
|
||||
}
|
||||
}
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable");
|
||||
try {
|
||||
sInstance.setBackupEnabled(readBackupEnableState(UserHandle.USER_SYSTEM));
|
||||
} catch (RemoteException e) {
|
||||
// can't happen; it's a local object
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
});
|
||||
}
|
||||
|
||||
// Bookkeeping of in-flight operations for timeout etc. purposes. The operation
|
||||
// token is the index of the entry in the pending-operations list.
|
||||
public static final int OP_PENDING = 0;
|
||||
|
||||
@@ -139,6 +139,13 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
void unlockSystemUser() {
|
||||
BackupManagerServiceInterface svc = mService;
|
||||
if (svc != null) {
|
||||
svc.unlockSystemUser();
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackupServiceActive(final int userHandle, boolean makeActive) {
|
||||
// Only the DPM should be changing the active state of backup
|
||||
final int caller = binderGetCallingUid();
|
||||
|
||||
Reference in New Issue
Block a user