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

android10 系统定制:增加应用锁功能

实现效果如下,上锁应用在桌面或最近任务打开弹出解锁界面,需要解锁成功才能打开应用。解锁界面可点击返回或Home键关闭,非上锁应用可直接打开。
在这里插入图片描述

基本思路:拦截系统应用启动,判断应用是否在锁住状态,弹出解锁Window。解锁完成后再正常启动应用。分为从桌面启动和最近任务启动两种情况。
1.资源的添加
在这里插入图片描述
在frameworks/base/core/res下增加了我的资源目录jia_res,添加了解锁界面用到的资源文件,文件目录如图。
需要在frameworks/base/core/res/Android.bp中添加引用:

android_app {...resource_dirs: ["res","jia_res"],...
}

另外新增的资源需要在symbols.xml或pubulic.xml声明,例如:

<resources><java-symbol type="layout" name="window_unmber_unlock_app" /><java-symbol type="id" name="appNumberLogoImg" /><java-symbol type="id" name="appNumberNameText" /><java-symbol type="id" name="subTitleNumber" /><java-symbol type="id" name="pswNumberPointView" /><java-symbol type="id" name="errorNumberTipsText" /><java-symbol type="id" name="numberKeyView" /><java-symbol type="string" name="lock_app_number_subtitle" /><java-symbol type="string" name="lock_app_number_error_tip" /><java-symbol type="drawable" name="ic_lock_delete" /><java-symbol type="drawable" name="selector_keyboard_number" />...
</resources>

2.拦截从桌面启动
之前分析过Activity启动流程 ,无论冷启动还是热启动都会先走ActivityStarter的startActivityMayWait方法,因此在此方法进行拦截:

private int startActivityMayWait( ...){...// Collect information about the target of the Intent.ActivityInfo aInfo = mSupervisor.resolveActivity(intent, rInfo, startFlags, profilerInfo);if (AppLockManager.isAppLocked(aInfo.packageName)) {IApplicationThread caller1 = caller;int callingUid1 = callingUid;Intent intent1 = intent;String resolvedType1 = resolvedType;AppLockManager.ShowLockWindow(mService.mContext,aInfo.packageName, new Runnable() {@Overridepublic void run() {startActivityMayWait(caller1, callingUid1,callingPackage, requestRealCallingPid, requestRealCallingUid,intent1, resolvedType1, voiceSession,voiceInteractor, resultTo, resultWho, requestCode,startFlags, profilerInfo, outResult,globalConfig, options, ignoreTargetSecurity,userId, inTask, reason,
http://www.lryc.cn/news/420143.html

相关文章:

  • 数据结构----队列
  • 【python】实现对文件夹中的图像连续重命名方法
  • 【nginx 第一篇章】认识一下 NGINX 服务器
  • 【物联网】(防水篇)哪些电子产品需要通过 IPX7 防水级别测试?
  • 高级java每日一道面试题-2024年8月09日-网络篇-什么是XSS攻击如何避免?
  • Linux时间管理:命令与脚本的完美结合
  • 基于ssm+vue+uniapp的微信外卖小程序
  • lvs(linux virtual server)实例
  • Unity游戏开发
  • 5. MQTT消息类型详解(三)
  • TypeScript JSX
  • java里的序列化反序列化、HttpMessageConverter、Jackson、消息转化器、对象转化器...都是啥?
  • GNU/Linux - memtool使用
  • Qt5.12.8源码交叉编译带openssl版本
  • 串行并行数据转换
  • 推荐一个优秀的 .NET MAUI 组件库
  • 用Manim创建条形图【BarChart】
  • iMES工厂管家:强大的工厂管理系统
  • iOS ------ 事件响应链
  • Go 语言 switch 语句的特点
  • 【递归】什么是递归-C语言为例
  • vue针对低版本浏览器不兼容es6特性解决方案,
  • 嵌入式内存管理高频面试题及参考答案(4万字长文)
  • TinyWebserver的复现与改进(2):项目的整体框架
  • R 语言学习教程,从入门到精通,R 字符串(10)
  • QT 简易音乐播放器
  • 代码随想录八股训练营day32
  • 11.面试题——消息队列RabbitMQ
  • MySQL运维-日志
  • synchronized重量级锁的实现原理是怎样的