慢的问题2

01-03 03:16:38.955 842 2369 I am_new_intent: [0,252403316,63,com.android.launcher3/.Launcher,android.intent.action.MAIN,NULL,NULL,268435712]
01-03 03:16:39.025 842 2369 I am_focused_stack: [0,0,1,bringingFoundTaskToFront]
01-03 03:16:39.113 842 2369 I am_pause_activity: [0,14608435,com.android.settings/.SubSettings]
01-03 03:16:39.280 842 2369 I am_set_resumed_activity: [0,com.android.launcher3/.Launcher,resumeTopActivityInnerLocked]
01-03 03:16:39.370 842 2369 I am_uid_active: 10025
01-03 03:16:40.337 842 2369 I am_resume_activity: [0,252403316,63,com.android.launcher3/.Launcher]
01-03 03:16:57.203 842 2369 I am_task_to_front: [0,63]
01-03 03:16:58.674 842 951 I am_stop_activity: [0,14608435,com.android.settings/.SubSettings]
01-03 03:16:58.739 12737 12737 I am_on_paused_called: [0,com.android.settings.SubSettings,handlePauseActivity]
01-03 03:16:58.751 842 5734 I am_failed_to_pause: [0,14608435,com.android.settings/.SubSettings,(none)]
01-03 03:17:11.507 12737 12737 I am_on_stop_called: [0,com.android.settings.SubSettings,handleStopActivity]
01-03 03:17:11.541 3973 3973 I am_on_resume_called: [0,com.android.launcher3.Launcher,RESUME_ACTIVITY]
01-03 03:17:12.350 842 950 I am_pss : [3973,10025,com.android.launcher3,26974208,16146432,8455168]
01-03 03:17:15.915 842 950 I am_pss : [18493,10031,com.google.android.setupwizard,6391808,3411968,1949696]
01-03 03:17:16.057 842 950 I am_pss : [8314,10017,com.google.android.apps.nbu.files,38444032,20512768,13848576]

01-01 18:18:20.729 842 4423 W jackywei: ======== removeTask ========
01-01 18:18:20.729 842 4423 W jackywei: java.lang.Throwable
01-01 18:18:20.729 842 4423 W jackywei: at com.android.server.am.ActivityStack.removeTask(ActivityStack.java:5221)
01-01 18:18:20.729 842 4423 W jackywei: at com.android.server.am.ActivityStack.removeActivityFromHistoryLocked(ActivityStack.java:4217)
01-01 18:18:20.729 842 4423 W jackywei: at com.android.server.am.ActivityStack.activityDestroyedLocked(ActivityStack.java:4446)
01-01 18:18:20.729 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.activityDestroyed(ActivityManagerService.java:7646)
01-01 18:18:20.729 842 4423 W jackywei: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:960)
01-01 18:18:20.729 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2978)
01-01 18:18:20.729 842 4423 W jackywei: at android.os.Binder.execTransact(Binder.java:697)

01-01 18:19:30.787 842 4423 W jackywei: ======== removeTask ========
01-01 18:19:30.789 842 4423 W jackywei: java.lang.Throwable
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityStack.removeTask(ActivityStack.java:5221)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityStack.removeActivityFromHistoryLocked(ActivityStack.java:4217)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityStack.removeHistoryRecordsForAppLocked(ActivityStack.java:4554)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityStack.handleAppDiedLocked(ActivityStack.java:5105)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityStackSupervisor.handleAppDiedLocked(ActivityStackSupervisor.java:2008)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.handleAppDiedLocked(ActivityManagerService.java:5414)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.appDiedLocked(ActivityManagerService.java:5595)
01-01 18:19:30.789 842 4423 W jackywei: at com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied(ActivityManagerService.java:1642)
01-01 18:19:30.789 842 4423 W jackywei: at android.os.BinderProxy.sendDeathNotice(Binder.java:844)

01-01 18:46:11.088 842 4423 W jackywei: ======== createTaskRecord ========
01-01 18:46:11.088 842 2236 V WindowManager: Window{b40586f u0 com.google.android.apps.photos/com.google.android.apps.photos.pager.HostPhotoPagerActivity}: wasAnimating=false, nowAnimating=false
01-01 18:46:11.089 842 4423 W jackywei: java.lang.Throwable
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStack.createTaskRecord(ActivityStack.java:5280)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.setTaskFromReuseOrCreateNewTask(ActivityStarter.java:1799)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.startActivityUnchecked(ActivityStarter.java:1188)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:1000)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:577)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:283)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:822)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4623)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4610)
01-01 18:46:11.089 842 4423 W jackywei: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:121)
01-01 18:46:11.089 842 4423 W jackywei: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2978)
01-01 18:46:11.089 842 4423 W jackywei: at android.os.Binder.execTransact(Binder.java:697)

7594 @Override
7595 public final void activityResumed(IBinder token) {
7596 final long origId = Binder.clearCallingIdentity();
7597 synchronized(this) {
7598 ActivityRecord.activityResumedLocked(token);
7599 mWindowManager.notifyAppResumedFinished(token);
7600 }
7601 Binder.restoreCallingIdentity(origId);
7602 }

1720 static void activityResumedLocked(IBinder token) {
1721 final ActivityRecord r = ActivityRecord.forTokenLocked(token);
1722 if (DEBUG_SAVED_STATE) Slog.i(TAG_STATES, “Resumed activity; dropping state of: “ + r);
1723 if (r != null) {
1724 r.icicle = null;
1725 r.haveState = false;
1726 }
1727 }
1728

只有 activityResumedLocked 才会导致 r.haveState 置成false.

而haveState存在的话,就不会remove = true;

也就不会
if (remove) {
removeActivityFromHistoryLocked(r, “appDied”);
}

827 ActivityRecord(ActivityManagerService _service, ProcessRecord _caller, int _launchedFromPid,
828 int _launchedFromUid, String _launchedFromPackage, Intent _intent, String _resolvedType,
829 ActivityInfo aInfo, Configuration _configuration,
830 ActivityRecord _resultTo, String _resultWho, int _reqCode,
831 boolean _componentSpecified, boolean _rootVoiceInteraction,
832 ActivityStackSupervisor supervisor, ActivityOptions options,
833 ActivityRecord sourceRecord) {
834 service = _service;
835 appToken = new Token(this);
836 info = aInfo;
837 launchedFromPid = _launchedFromPid;
838 launchedFromUid = _launchedFromUid;
839 launchedFromPackage = _launchedFromPackage;
840 userId = UserHandle.getUserId(aInfo.applicationInfo.uid);
841 intent = _intent;
842 shortComponentName = _intent.getComponent().flattenToShortString();
843 resolvedType = _resolvedType;
844 componentSpecified = _componentSpecified;
845 rootVoiceInteraction = _rootVoiceInteraction;
846 mLastReportedConfiguration = new MergedConfiguration(_configuration);
847 resultTo = _resultTo;
848 resultWho = _resultWho;
849 requestCode = _reqCode;
850 state = INITIALIZING;
851 frontOfTask = false;
852 launchFailed = false;
853 stopped = false;
854 delayedResume = false;
855 finishing = false;
856 deferRelaunchUntilPaused = false;
857 keysPaused = false;
858 inHistory = false;
859 visible = false;
860 nowVisible = false;
861 idle = false;
862 hasBeenLaunched = false;
863 mStackSupervisor = supervisor;
864
865 mRotationAnimationHint = aInfo.rotationAnimation;
866
867 if (options != null) {
868 pendingOptions = options;
869 mLaunchTaskBehind = pendingOptions.getLaunchTaskBehind();
870
871 final int rotationAnimation = pendingOptions.getRotationAnimationHint();
872 // Only override manifest supplied option if set.
873 if (rotationAnimation >= 0) {
874 mRotationAnimationHint = rotationAnimation;
875 }
876 PendingIntent usageReport = pendingOptions.getUsageTimeReport();
877 if (usageReport != null) {
878 appTimeTracker = new AppTimeTracker(usageReport);
879 }
880 }
881
882 // This starts out true, since the initial state of an activity is that we have everything,
883 // and we shouldn’t never consider it lacking in state to be removed if it dies.
884 haveState = true; //这里就直接会置为true
885
886 // If the class name in the intent doesn’t match that of the target, this is
887 // probably an alias. We have to create a new ComponentName object to keep track
888 // of the real activity name, so that FLAG_ACTIVITY_CLEAR_TOP is handled properly.

void notifyTaskPersisterLocked(TaskRecord task, boolean flush) {
    final ActivityStack stack = task != null ? task.getStack() : null;
    if (stack != null && stack.isHomeOrRecentsStack()) {
        // Never persist the home or recents stack.
        return;
    }
    syncPersistentTaskIdsLocked();
    mTaskPersister.wakeup(task, flush);
}

for i in {1..10000};do adb shell input tap 201 109 && adb shell input keyevent 3 && adb shell input tap 201 109 && adb shell input tap 432 508 && adb shell input tap 406 812 && adb shell input tap 31 80 && adb shell input keyevent 3;done