当前位置: 首页 > news >正文

堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41),framework修改,去除第三方app的倒计时页面

文章目录

  • 堆栈打印跟踪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 View's 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

注入一个点击事件

在这里插入图片描述

这样模拟点击事件跳过也可以的

http://www.lryc.cn/news/343392.html

相关文章:

  • 只允许内网访问时,如何设置hosts
  • nature《自然》期刊文献怎么在家查看下载
  • python作业五
  • 经典的设计模式和Python示例(一)
  • Ubuntu服务器如何安装桌面
  • 填报表如何实现电话号码的校验
  • 揭秘全网热门话题:抖音快速涨粉方法,巨量千川投流助你日增10000粉
  • 电脑提示‘找不到msvcr110dll,无法继续执行代码’的解决方法,3分钟快速修复
  • 如何在Hostease的Linux虚拟主机上永久移除WordPress网站
  • 【云原生】Docker 的网络通信
  • 如何优雅的实现浏览器多标签通讯
  • 刷题之不相同的字符串(卡码网模拟)
  • JS-导入导出
  • 【代码随想录——数组篇】
  • 使用 js 类封装项目中音频播放功能的工具方法utils
  • 【超详细】R语言贝叶斯方法在生态环境领域中的高阶技术应用
  • Python 正则表达式 re . 符号
  • 智慧监控 高效运维
  • JAVA每日面试题(一)
  • Java数组创建与使用
  • EMAP如何建数据源
  • 在 Linux 中创建文件
  • 高德地图+HTML+点击事件+自定心信息窗体
  • 流畅的python-学习笔记_协议+继承优缺点
  • 哪个文件加密软件好?迅软加密软件特性解析
  • Ubuntu 根目录扩容
  • 人证比对API接口如何对接
  • NIO(非阻塞I/O)和IO(阻塞I/O)详解
  • 【网络】传输层的特点总结
  • Scala 多版本下载指南