Android kill Launcher 3次后黑屏

平台

rk3288 + android 5.11

问题

在adb shell中, 连续调用3次kill Launcher后, Launcher无法正常显示.
关键LOG:

01-01 20:14:27.738 W/ActivityManagerService(  475): Force removing ActivityRecord{323bcec9 u0 com.android.launcher3/.Launcher t1}: app died, no saved state

分析:

一个关键的计数: launchCount

|-- frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java

	int launchCount;        // count of launches since last state

|-- frameworks/base/services/core/java/com/android/server/am/ActivityStack.java

		boolean removeHistoryRecordsForAppLocked(ProcessRecord app) {
			//判断是否已经尝试启动2次以上
					} else if (r.launchCount > 2 &&
                            r.lastLaunchTime > (SystemClock.uptimeMillis()-60000)) {
                        // We have launched this activity too many times since it was
                        // able to run, so give up and remove it.
                        remove = true;
                    }

					...
					//LOG 输出的地方:
					 Slog.w(TAG, "Force removing " + r + ": app died, no saved state");
                            EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY,
                                    r.userId, System.identityHashCode(r),
                                    r.task.taskId, r.shortComponentName,
                                    "proc died without state saved");
		}


    final void activityStoppedLocked(ActivityRecord r, Bundle icicle,
            PersistableBundle persistentState, CharSequence description) {
			...
			//正常退出后清0
            r.launchCount = 0;
        }

|-- frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java

   final boolean realStartActivityLocked(ActivityRecord r,
           ProcessRecord app, boolean andResume, boolean checkConfig)
           throws RemoteException {
   	//启动一次自加1
   	r.launchCount++;
   }

猜你喜欢

转载自blog.csdn.net/ansondroider/article/details/85838744