Loading core/java/android/app/ActivityManagerNative.java +18 −0 Original line number Diff line number Diff line Loading @@ -2363,6 +2363,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } case SYSTEM_BACKUP_RESTORED: { data.enforceInterface(IActivityManager.descriptor); systemBackupRestored(); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -5458,5 +5465,16 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void systemBackupRestored() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(SYSTEM_BACKUP_RESTORED, data, reply, 0); reply.readException(); data.recycle(); reply.recycle(); } private IBinder mRemote; } core/java/android/app/IActivityManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,8 @@ public interface IActivityManager extends IInterface { public void notifyLaunchTaskBehindComplete(IBinder token) throws RemoteException; public void notifyEnterAnimationComplete(IBinder token) throws RemoteException; public void systemBackupRestored() throws RemoteException; /* * Private non-Binder interfaces */ Loading Loading @@ -790,4 +792,5 @@ public interface IActivityManager extends IInterface { int START_IN_PLACE_ANIMATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+240; int CHECK_PERMISSION_WITH_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+241; int REGISTER_TASK_STACK_LISTENER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+242; int SYSTEM_BACKUP_RESTORED = IBinder.FIRST_CALL_TRANSACTION+243; } core/java/com/android/server/backup/SystemBackupAgent.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.backup; import android.app.ActivityManagerNative; import android.app.IWallpaperManager; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; Loading Loading @@ -186,4 +187,13 @@ public class SystemBackupAgent extends BackupAgentHelper { } } } @Override public void onRestoreFinished() { try { ActivityManagerNative.getDefault().systemBackupRestored(); } catch (RemoteException e) { // Not possible since this code is running in the system process. } } } services/core/java/com/android/server/am/ActivityManagerService.java +25 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST; import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT; import static org.xmlpull.v1.XmlPullParser.START_TAG; import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID; import static com.android.server.am.TaskRecord.INVALID_TASK_ID; import android.Manifest; import android.app.AppOpsManager; Loading Loading @@ -3907,7 +3908,7 @@ public final class ActivityManagerService extends ActivityManagerNative + endIndex + " " + cur); if (cur == top) { // Verify start of the chain. if (cur.mNextAffiliate != null || cur.mNextAffiliateTaskId != -1) { if (cur.mNextAffiliate != null || cur.mNextAffiliateTaskId != INVALID_TASK_ID) { Slog.wtf(TAG, "Bad chain @" + endIndex + ": first task has next affiliate: " + prev); sane = false; Loading @@ -3926,7 +3927,7 @@ public final class ActivityManagerService extends ActivityManagerNative break; } } if (cur.mPrevAffiliateTaskId == -1) { if (cur.mPrevAffiliateTaskId == INVALID_TASK_ID) { // Chain ends here. if (cur.mPrevAffiliate != null) { Slog.wtf(TAG, "Bad chain @" + endIndex Loading Loading @@ -3991,7 +3992,8 @@ public final class ActivityManagerService extends ActivityManagerNative final void addRecentTaskLocked(TaskRecord task) { final boolean isAffiliated = task.mAffiliatedTaskId != task.taskId || task.mNextAffiliateTaskId != -1 || task.mPrevAffiliateTaskId != -1; || task.mNextAffiliateTaskId != INVALID_TASK_ID || task.mPrevAffiliateTaskId != INVALID_TASK_ID; int N = mRecentTasks.size(); // Quick case: check if the top-most recent task is the same. Loading Loading @@ -6222,6 +6224,17 @@ public final class ActivityManagerService extends ActivityManagerNative } } @Override public void systemBackupRestored() { synchronized (this) { if (mSystemReady) { mTaskPersister.restoreTasksFromOtherDeviceLocked(); } else { Slog.w(TAG, "System backup restored before system is ready"); } } } final void ensureBootCompleted() { boolean booting; boolean enableScreen; Loading Loading @@ -8036,7 +8049,7 @@ public final class ActivityManagerService extends ActivityManagerNative // Compose the recent task info ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); rti.id = tr.getTopActivity() == null ? -1 : tr.taskId; rti.id = tr.getTopActivity() == null ? INVALID_TASK_ID : tr.taskId; rti.persistentId = tr.taskId; rti.baseIntent = new Intent(tr.getBaseIntent()); rti.origActivity = tr.origActivity; Loading Loading @@ -8259,7 +8272,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (trimIdx >= 0) { // If this would have caused a trim, then we'll abort because that // means it would be added at the end of the list but then just removed. return -1; return INVALID_TASK_ID; } final int N = mRecentTasks.size(); Loading Loading @@ -11146,6 +11159,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (mRecentTasks == null) { mRecentTasks = mTaskPersister.restoreTasksLocked(); mTaskPersister.restoreTasksFromOtherDeviceLocked(); if (!mRecentTasks.isEmpty()) { mStackSupervisor.createStackForRestoredTaskHistory(mRecentTasks); } Loading Loading @@ -15792,6 +15806,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } else { removeTasksByRemovedPackageComponentsLocked(ssp, userId); if (userId == UserHandle.USER_OWNER) { mTaskPersister.addOtherDeviceTasksToRecentsLocked(ssp); } } } break; Loading @@ -15809,6 +15826,9 @@ public final class ActivityManagerService extends ActivityManagerNative if (replacing) { removeTasksByRemovedPackageComponentsLocked(ssp, userId); } if (userId == UserHandle.USER_OWNER) { mTaskPersister.addOtherDeviceTasksToRecentsLocked(ssp); } } break; case Intent.ACTION_TIMEZONE_CHANGED: services/core/java/com/android/server/am/ActivityRecord.java +15 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package com.android.server.am; import static com.android.server.am.TaskPersister.DEBUG_PERSISTER; import static com.android.server.am.TaskPersister.DEBUG_RESTORER; import static com.android.server.am.TaskRecord.INVALID_TASK_ID; import android.app.ActivityManager.TaskDescription; import android.os.PersistableBundle; import android.os.Trace; Loading Loading @@ -1052,12 +1056,12 @@ final class ActivityRecord { static int getTaskForActivityLocked(IBinder token, boolean onlyRoot) { final ActivityRecord r = ActivityRecord.forToken(token); if (r == null) { return -1; return INVALID_TASK_ID; } final TaskRecord task = r.task; final int activityNdx = task.mActivities.indexOf(r); if (activityNdx < 0 || (onlyRoot && activityNdx > task.findEffectiveRootIndex())) { return -1; return INVALID_TASK_ID; } return task.taskId; } Loading Loading @@ -1139,7 +1143,7 @@ final class ActivityRecord { } } static ActivityRecord restoreFromXml(XmlPullParser in, int taskId, static ActivityRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException { Intent intent = null; PersistableBundle persistentState = null; Loading @@ -1155,8 +1159,8 @@ final class ActivityRecord { for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { final String attrName = in.getAttributeName(attrNdx); final String attrValue = in.getAttributeValue(attrNdx); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (ATTR_ID.equals(attrName)) { createTime = Long.valueOf(attrValue); } else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) { Loading @@ -1181,15 +1185,15 @@ final class ActivityRecord { (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { if (event == XmlPullParser.START_TAG) { final String name = in.getName(); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); if (TAG_INTENT.equals(name)) { intent = Intent.restoreFromXml(in); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); } else if (TAG_PERSISTABLEBUNDLE.equals(name)) { persistentState = PersistableBundle.restoreFromXml(in); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: persistentState=" + persistentState); } else { Slog.w(TAG, "restoreActivity: unexpected name=" + name); Loading Loading @@ -1232,7 +1236,7 @@ final class ActivityRecord { @Override public String toString() { if (stringName != null) { return stringName + " t" + (task == null ? -1 : task.taskId) + return stringName + " t" + (task == null ? INVALID_TASK_ID : task.taskId) + (finishing ? " f}" : "}"); } StringBuilder sb = new StringBuilder(128); Loading Loading
core/java/android/app/ActivityManagerNative.java +18 −0 Original line number Diff line number Diff line Loading @@ -2363,6 +2363,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } case SYSTEM_BACKUP_RESTORED: { data.enforceInterface(IActivityManager.descriptor); systemBackupRestored(); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -5458,5 +5465,16 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void systemBackupRestored() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(SYSTEM_BACKUP_RESTORED, data, reply, 0); reply.readException(); data.recycle(); reply.recycle(); } private IBinder mRemote; }
core/java/android/app/IActivityManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,8 @@ public interface IActivityManager extends IInterface { public void notifyLaunchTaskBehindComplete(IBinder token) throws RemoteException; public void notifyEnterAnimationComplete(IBinder token) throws RemoteException; public void systemBackupRestored() throws RemoteException; /* * Private non-Binder interfaces */ Loading Loading @@ -790,4 +792,5 @@ public interface IActivityManager extends IInterface { int START_IN_PLACE_ANIMATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+240; int CHECK_PERMISSION_WITH_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+241; int REGISTER_TASK_STACK_LISTENER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+242; int SYSTEM_BACKUP_RESTORED = IBinder.FIRST_CALL_TRANSACTION+243; }
core/java/com/android/server/backup/SystemBackupAgent.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.backup; import android.app.ActivityManagerNative; import android.app.IWallpaperManager; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; Loading Loading @@ -186,4 +187,13 @@ public class SystemBackupAgent extends BackupAgentHelper { } } } @Override public void onRestoreFinished() { try { ActivityManagerNative.getDefault().systemBackupRestored(); } catch (RemoteException e) { // Not possible since this code is running in the system process. } } }
services/core/java/com/android/server/am/ActivityManagerService.java +25 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST; import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT; import static org.xmlpull.v1.XmlPullParser.START_TAG; import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID; import static com.android.server.am.TaskRecord.INVALID_TASK_ID; import android.Manifest; import android.app.AppOpsManager; Loading Loading @@ -3907,7 +3908,7 @@ public final class ActivityManagerService extends ActivityManagerNative + endIndex + " " + cur); if (cur == top) { // Verify start of the chain. if (cur.mNextAffiliate != null || cur.mNextAffiliateTaskId != -1) { if (cur.mNextAffiliate != null || cur.mNextAffiliateTaskId != INVALID_TASK_ID) { Slog.wtf(TAG, "Bad chain @" + endIndex + ": first task has next affiliate: " + prev); sane = false; Loading @@ -3926,7 +3927,7 @@ public final class ActivityManagerService extends ActivityManagerNative break; } } if (cur.mPrevAffiliateTaskId == -1) { if (cur.mPrevAffiliateTaskId == INVALID_TASK_ID) { // Chain ends here. if (cur.mPrevAffiliate != null) { Slog.wtf(TAG, "Bad chain @" + endIndex Loading Loading @@ -3991,7 +3992,8 @@ public final class ActivityManagerService extends ActivityManagerNative final void addRecentTaskLocked(TaskRecord task) { final boolean isAffiliated = task.mAffiliatedTaskId != task.taskId || task.mNextAffiliateTaskId != -1 || task.mPrevAffiliateTaskId != -1; || task.mNextAffiliateTaskId != INVALID_TASK_ID || task.mPrevAffiliateTaskId != INVALID_TASK_ID; int N = mRecentTasks.size(); // Quick case: check if the top-most recent task is the same. Loading Loading @@ -6222,6 +6224,17 @@ public final class ActivityManagerService extends ActivityManagerNative } } @Override public void systemBackupRestored() { synchronized (this) { if (mSystemReady) { mTaskPersister.restoreTasksFromOtherDeviceLocked(); } else { Slog.w(TAG, "System backup restored before system is ready"); } } } final void ensureBootCompleted() { boolean booting; boolean enableScreen; Loading Loading @@ -8036,7 +8049,7 @@ public final class ActivityManagerService extends ActivityManagerNative // Compose the recent task info ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); rti.id = tr.getTopActivity() == null ? -1 : tr.taskId; rti.id = tr.getTopActivity() == null ? INVALID_TASK_ID : tr.taskId; rti.persistentId = tr.taskId; rti.baseIntent = new Intent(tr.getBaseIntent()); rti.origActivity = tr.origActivity; Loading Loading @@ -8259,7 +8272,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (trimIdx >= 0) { // If this would have caused a trim, then we'll abort because that // means it would be added at the end of the list but then just removed. return -1; return INVALID_TASK_ID; } final int N = mRecentTasks.size(); Loading Loading @@ -11146,6 +11159,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (mRecentTasks == null) { mRecentTasks = mTaskPersister.restoreTasksLocked(); mTaskPersister.restoreTasksFromOtherDeviceLocked(); if (!mRecentTasks.isEmpty()) { mStackSupervisor.createStackForRestoredTaskHistory(mRecentTasks); } Loading Loading @@ -15792,6 +15806,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } else { removeTasksByRemovedPackageComponentsLocked(ssp, userId); if (userId == UserHandle.USER_OWNER) { mTaskPersister.addOtherDeviceTasksToRecentsLocked(ssp); } } } break; Loading @@ -15809,6 +15826,9 @@ public final class ActivityManagerService extends ActivityManagerNative if (replacing) { removeTasksByRemovedPackageComponentsLocked(ssp, userId); } if (userId == UserHandle.USER_OWNER) { mTaskPersister.addOtherDeviceTasksToRecentsLocked(ssp); } } break; case Intent.ACTION_TIMEZONE_CHANGED:
services/core/java/com/android/server/am/ActivityRecord.java +15 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package com.android.server.am; import static com.android.server.am.TaskPersister.DEBUG_PERSISTER; import static com.android.server.am.TaskPersister.DEBUG_RESTORER; import static com.android.server.am.TaskRecord.INVALID_TASK_ID; import android.app.ActivityManager.TaskDescription; import android.os.PersistableBundle; import android.os.Trace; Loading Loading @@ -1052,12 +1056,12 @@ final class ActivityRecord { static int getTaskForActivityLocked(IBinder token, boolean onlyRoot) { final ActivityRecord r = ActivityRecord.forToken(token); if (r == null) { return -1; return INVALID_TASK_ID; } final TaskRecord task = r.task; final int activityNdx = task.mActivities.indexOf(r); if (activityNdx < 0 || (onlyRoot && activityNdx > task.findEffectiveRootIndex())) { return -1; return INVALID_TASK_ID; } return task.taskId; } Loading Loading @@ -1139,7 +1143,7 @@ final class ActivityRecord { } } static ActivityRecord restoreFromXml(XmlPullParser in, int taskId, static ActivityRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException { Intent intent = null; PersistableBundle persistentState = null; Loading @@ -1155,8 +1159,8 @@ final class ActivityRecord { for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { final String attrName = in.getAttributeName(attrNdx); final String attrValue = in.getAttributeValue(attrNdx); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (ATTR_ID.equals(attrName)) { createTime = Long.valueOf(attrValue); } else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) { Loading @@ -1181,15 +1185,15 @@ final class ActivityRecord { (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { if (event == XmlPullParser.START_TAG) { final String name = in.getName(); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); if (TAG_INTENT.equals(name)) { intent = Intent.restoreFromXml(in); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); } else if (TAG_PERSISTABLEBUNDLE.equals(name)) { persistentState = PersistableBundle.restoreFromXml(in); if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, if (DEBUG_PERSISTER || DEBUG_RESTORER) Slog.d(TaskPersister.TAG, "ActivityRecord: persistentState=" + persistentState); } else { Slog.w(TAG, "restoreActivity: unexpected name=" + name); Loading Loading @@ -1232,7 +1236,7 @@ final class ActivityRecord { @Override public String toString() { if (stringName != null) { return stringName + " t" + (task == null ? -1 : task.taskId) + return stringName + " t" + (task == null ? INVALID_TASK_ID : task.taskId) + (finishing ? " f}" : "}"); } StringBuilder sb = new StringBuilder(128); Loading