济南建网站app,金华专业做网站公司,连江建设局网站,中国软装网为了方便跟踪启动过程相关流程#xff0c;打开debug开关#xff0c;并添加Log打印
1.Log打点
1#xff09;打开debug开关
打开 WindowManagerDebugConfig开关#xff0c;会打开InputMonitor InputManagerCallback PhoneWindowManager中的input向相关日志打印
public st…为了方便跟踪启动过程相关流程打开debug开关并添加Log打印
1.Log打点
1打开debug开关
打开 WindowManagerDebugConfig开关会打开InputMonitor InputManagerCallback PhoneWindowManager中的input向相关日志打印
public static boolean DEBUG_INPUT true;
打开Activity中的debug开关可以直接看到activity生命周期变化 private static final boolean DEBUG_LIFECYCLE true; if (DEBUG_LIFECYCLE) Slog.v(TAG, onCreate this : savedInstanceState);if (DEBUG_LIFECYCLE) Slog.v(TAG, onStart this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onResume this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onSaveInstanceState this : outState);if (DEBUG_LIFECYCLE) Slog.v(TAG, onSaveInstanceState this : outState if (DEBUG_LIFECYCLE) Slog.v(TAG, onPause this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onStop this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onDestroy this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onConfigurationChanged this : newConfig);if (DEBUG_LIFECYCLE) Slog.v(TAG, onLowMemory this);if (DEBUG_LIFECYCLE) Slog.v(TAG, onTrimMemory this : level);if (DEBUG_LIFECYCLE) Slog.v(TAG, dispatchMultiWindowModeChanged this : isInMultiWindowMode newConfig);if (DEBUG_LIFECYCLE) Slog.v(TAG, dispatchPictureInPictureModeChanged this : isInPictureInPictureMode newConfig);
打开ActivityTaskManagerDebugConfig的debug开关可以查看activity的销毁、调度、释放 public static boolean DEBUG_ALL_ACTIVITIES DEBUG_ALL || true; public static boolean DEBUG_APP DEBUG_ALL_ACTIVITIES || false; public static boolean DEBUG_IDLE DEBUG_ALL_ACTIVITIES || false; public static boolean DEBUG_RELEASE DEBUG_ALL_ACTIVITIES || false; //ActivityRecord.javaif (DEBUG_APP) Slog.v(TAG_APP, Clearing app during destroy for activity this);if (DEBUG_APP) Slog.v(TAG_APP, Clearing app during remove for activity this);if (DEBUG_APP) Slog.v(TAG_APP, Clearing app during cleanUp for activity this);if (DEBUG_APP) Slog.v(TAG_APP, Keeping entry during removeHistory for activity this);//ActivityTaskSupervisor.javaif (DEBUG_IDLE) Slog.d(TAG_IDLE, activityIdleInternal: Callers Debug.getCallers(4));if (DEBUG_IDLE) Slogf.i(TAG, activityIdleInternal(): r%s, mStartingUsers%s, r, mStartingUsers);if (DEBUG_IDLE) Slog.d(TAG_IDLE, scheduleIdleTimeout: Callers Debug.getCallers(4));if (DEBUG_IDLE) Slog.d(TAG_IDLE, scheduleIdle: Callers Debug.getCallers(4));if (DEBUG_IDLE) Slog.d(TAG_IDLE, removeTimeoutsForActivity: Callers Debug.getCallers(4));if (DEBUG_IDLE) Slog.d(TAG_IDLE, handleMessage: IDLE_TIMEOUT_MSG: r msg.obj);if (DEBUG_IDLE) Slog.d(TAG_IDLE, handleMessage: IDLE_NOW_MSG: r msg.obj);//WindowProcessController.javaif (DEBUG_RELEASE) Slog.d(TAG_RELEASE, Trying to release some activities in this);if (DEBUG_RELEASE) Slog.d(TAG_RELEASE, Abort release; already destroying: r);if (DEBUG_RELEASE) Slog.d(TAG_RELEASE, Not releasing in-use activity: r);if (DEBUG_RELEASE) Slog.v(TAG_RELEASE, Destroying r in state r.getState() for reason reason);
2添加Log打印
技巧new Throwable()方法可以打印当前整个方法的调用链
ActivityRecord运行在system_server进程中ActivityThread运行在App进程中。两处tag可以查看整个Acitivity的变化过程
//ActivityRecord.java
void setState(State state, String reason) {
Slog.e(TAG_STATES, wei242.wang State movement: this from: getState() to: state reason: reason,new Throwable());
//ActivityThread.java
public void setState(LifecycleState int newLifecycleState) {
Slog.e(TAG,wei242.wang setState newLifecycleState newLifecycleState ,new Throwable());
TaskRecord中可查看record的创建及关联T/U弃用需要重新研究Task调用关系 Lcom/android/server/wm/TaskRecord;-topRunningActivityLocked()Lcom/android/server/wm/ActivityRecord;
ActivityStarter.java
//设置ActivityRecord 和TaskRecord的关系/** Places {link #mStartActivity} in {code task} or an embedded {link TaskFragment}. */private void addOrReparentStartingActivity(NonNull Task task, String reason) {Slog.d(TAG,wei242.wang addOrReparentStartingActivity,new Throwable());
ActivityStackT/U弃用需要重新研究Task调用关系 注
参考https://blog.csdn.net/weixin_42695485/article/details/108632021
本文使用U代码