网站建设里的知识,长沙网络营销公司,网站建设需要营业执照吗,微信怎么注册文章目录 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41)#xff0c;framework修改#xff0c;去除第三方app的倒计时页面1.打印异常堆栈2.去除第三方app的倒计时页面3.模拟点击事件跳过首页进入主页 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41)#x… 文章目录 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41)framework修改去除第三方app的倒计时页面1.打印异常堆栈2.去除第三方app的倒计时页面3.模拟点击事件跳过首页进入主页 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41)framework修改去除第三方app的倒计时页面
1.打印异常堆栈
查看Activity的onCreate如何回调的 Log.i(TAG, onCreate: , new Exception());编译 logcat -c清除日志缓存
logcat -s qfh过滤tag 跟踪堆栈调试发现onCreate的回调大致从这里开始 走到这 往下走 那系统又是怎么调用handleLaunchActivity的
系统Handler发消息以及处理消息 执行 从这里就能看出系统调用handleLaunchActivity的过程
2.去除第三方app的倒计时页面
查看位于最上层的activity想办法去掉这个倒计时页面直接进入主页面 adb shell dumpsys activity activities | grep “Resumed”
查看最顶层 framework中修改一般都是lanucher界面启动我们的第三方app
Overridepublic void startActivity(Intent intent, Nullable Bundle options) {//qfh addComponentName originCom new ComponentName(com.example.myapplication2, com.example.myapplication.WelcomeActivity);ComponentName targetCom new ComponentName(com.example.myapplication2, com.example.myapplication.MainActivity);if (intent.getComponent() ! null intent.getComponent().equals(originCom)) {intent.setComponent(targetCom);}//qfh endif (options ! null) {startActivityForResult(intent, -1, options);} else {// Note we want to go through this call for compatibility with// applications that may have overridden the method.startActivityForResult(intent, -1);}}这样就可以拦截我们想要拦截的Activity了
进到倒计时的下一个页面 3.模拟点击事件跳过首页进入主页
自定义一个方法处理点击按钮事件
CallSuperprotected void onResume() {if (DEBUG_LIFECYCLE) Slog.v(TAG, onResume this);dispatchActivityResumed();mActivityTransitionState.onResume(this);enableAutofillCompatibilityIfNeeded();if (mAutoFillResetNeeded) {if (!mAutoFillIgnoreFirstResumePause) {View focus getCurrentFocus();if (focus ! null focus.canNotifyAutofillEnterExitEvent()) {// TODO: in Activity killed/recreated case, i.e. SessionLifecycleTest#// testDatasetVisibleWhileAutofilledAppIsLifecycled: the Views initial// window visibility after recreation is INVISIBLE in onResume() and next frame// ViewRootImpl.performTraversals() changes window visibility to VISIBLE.// So we cannot call View.notifyEnterOrExited() which will do nothing// when View.isVisibleToUser() is false.getAutofillManager().notifyViewEntered(focus);}}}notifyContentCaptureManagerIfNeeded(CONTENT_CAPTURE_RESUME);mCalled true;//qfh addComponentName originCom new ComponentName(com.example.myapplication2, com.example.myapplication.TestWelcomeActivity);if (originCom.equals(getComponentName())){Log.i(TAG, originCom.equals(getComponentName()) true);mHandler.postDelayed(new Runnable() {Overridepublic void run() {injectClick(420,52);}}, 1000);}//qfh end}//qfh add //处理跳过按钮的坐标模拟点击跳过广告页按钮private void injectClick(int x, int y) {MotionEvent downAction MotionEvent.obtain(android.os.SystemClock.uptimeMillis(),android.os.SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, 0);dispatchTouchEvent(downAction);MotionEvent upAction MotionEvent.obtain(android.os.SystemClock.uptimeMillis(),android.os.SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0);mHandler.postDelayed(new Runnable() {Overridepublic void run() {Log.i(TAG, injectClick);dispatchTouchEvent(upAction);}},100);}//qfh end注入一个点击事件 这样模拟点击事件跳过也可以的