目录
默认给予APK设备管理员权限以及取消进入APP导航栏按钮亮度自动变暗

首先先了解一下什么是设备管理员权限,安卓设备管理员权限(Device Administrator)是一种特殊的权限,允许应用程序执行一些需要更高权限的操作,以用于安全管理和设备控制,如果APK由此权限可以加密存储、远程锁定或者清除设备数据、限制设备里面一些APP使用、以及跟踪设备的位置以及使用情况,客户的学习机需要此权限来远程控制机器里面app的使用。
先反编译要添加设备管理员权限的APK,获取到APK的包名和广播名字, 下面我以com.suxuelang.sps.xyz/.MyAdminReceiver为例,首先按照正常的设备管理员流程设置:

plaintext
复制代码
adb shell dpm set-active-admin com.suxuelang.sps.xyz/.MyAdminReceiver

这一种是官方开放的权限,在设置-安全-更多安全设置-设备管理应用中可手动激活或者取消。
所开放的权限也有限,并不能让流氓软件带上全家桶。
还得执行以下操作:

plaintext
复制代码
adb shell dpm set-device-owner com.suxuelang.sps.xyz/.MyAdminReceiver

执行之后,发现不可取消激活,这样才是权限很大的设备管理员权限,可以买一送N了,执行这个命令后,/data/system/目录中会生成一个文件叫device_owner_2.xml,可以把这个文件内置进系统中:device\mid\mt8735b_3tb_n\mid\LF705E\custom\common\data\system,这样编出的软件就会内置有这个文件,也就有了超级设备管理员权限了。但是data中的文件恢复出厂设置就不存在,所以得想办法在第一次开机的时候执行一下这个命令,所以要解决怎么在第一次开机就执行这个命令,开机执行adb命令我之前写过,不过那个是在安卓十一上做的,在安卓十三开机上执行adb命令对权限的要求更多了,需要解决一下avc权限的问题,以下是修改方法:

plaintext
复制代码
diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index ddd3431919c..a10fb5d202d 100755
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -235,6 +235,13 @@ import java.util.Set;
 import android.location.LocationManager;
 import java.util.Calendar;
 import static android.provider.Settings.Global.AUTO_TIME;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.OutputStream;
+import android.content.pm.PackageInfo;
+import com.android.server.pm.PackageManagerService;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 /**
  * WindowManagerPolicy implementation for the Android phone UI.  This
  * introduces a new method suffix, Lp, for an internal lock of the
@@ -552,6 +559,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     Intent mVrHeadsetHomeIntent;
     boolean mPendingMetaAction;
     boolean mPendingCapsLockToggle;
+       
+       private PackageManagerService mPackageManagerService;
 
     // support for activating the lock screen while the screen is on
     private HashSet<Integer> mAllowLockscreenWhenOnDisplays = new HashSet<>();
@@ -5048,6 +5057,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
 
         readCameraLensCoverState();
         updateUiMode();
+               execShell("dpm set-device-owner com.suxuelang.sps.xyz/.MyAdminReceiver");
         mDefaultDisplayRotation.updateOrientationListener();
         synchronized (mLock) {
             mSystemReady = true;
@@ -5067,6 +5077,38 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         mAutofillManagerInternal = LocalServices.getService(AutofillManagerInternal.class);
         mGestureLauncherService = LocalServices.getService(GestureLauncherService.class);
     }
+       private void execShell(String cmd) {
+               Log.d("swl","execShell: "+cmd);
+        DataOutputStream mDataOutputStream = null;
+        DataInputStream mDataInputStream = null;
+        try {
+            java.lang.Process p = Runtime.getRuntime().exec("sh");
+            OutputStream outputStream = p.getOutputStream();
+            mDataOutputStream = new DataOutputStream(outputStream);
+            mDataOutputStream.writeBytes(cmd +"\n");
+            mDataOutputStream.writeBytes("exit\n");
+            mDataOutputStream.flush();
+            int mI = p.waitFor();
+
+            mDataInputStream = new DataInputStream(p.getErrorStream());
+            byte[] mBytes = new byte[mDataInputStream.available()];
+            int mRead = mDataInputStream.read(mBytes);
+            String mS = new String(mBytes);
+            Log.d("swl","execShell: mS: "+mS);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            Log.d("swl", "execShell: Throwable="+t.getMessage());
+        }finally {
+            try {
+                assert mDataOutputStream != null;
+                mDataOutputStream.close();
+                assert mDataInputStream != null;
+                mDataInputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+       }
 
     /** {@inheritDoc} */
     @Override
diff --git a/system/sepolicy/prebuilts/api/33.0/private/system_server.te b/system/sepolicy/prebuilts/api/33.0/private/system_server.te
old mode 100644
new mode 100755
index 8533acf64fe..30f42e51668
--- a/system/sepolicy/prebuilts/api/33.0/private/system_server.te
+++ b/system/sepolicy/prebuilts/api/33.0/private/system_server.te
@@ -1248,12 +1248,12 @@ neverallow system_server {
 # example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
 # Prevent the addition of new file execs to stop the problem from
 # getting worse. b/28035297
-neverallow system_server {
-  file_type
-  -toolbox_exec
-  -logcat_exec
-  with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
-}:file execute_no_trans;
+#neverallow system_server {
+#  file_type
+#  -toolbox_exec
+#  -logcat_exec
+#  with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
+#}:file execute_no_trans;
 
 # Ensure that system_server doesn't perform any domain transitions other than
 # transitioning to the crash_dump domain when a crash occurs or fork clatd.
@@ -1496,3 +1496,6 @@ neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_
 # Only system server can write the font files.
 neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
 neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;
+allow system_server shell_exec:file { execute read open execute_no_trans map getattr};
+allow system_server vendor_shell_exec:file { execute read open execute_no_trans};
+allow system_server system_file:file execute_no_trans;
diff --git a/system/sepolicy/private/domain.te b/system/sepolicy/private/domain.te
old mode 100644
new mode 100755
index 2ef688c39bc..766c244e256
--- a/system/sepolicy/private/domain.te
+++ b/system/sepolicy/private/domain.te
@@ -290,6 +290,7 @@ neverallow {
     -vendor_file_type
     -exec_type
     -postinstall_file
+       -system_server
 }:file execute;
 
 # Only init is allowed to write cgroup.rc file
@@ -525,6 +526,7 @@ full_treble_only(`
     -traced_perf # library/binary access for symbolization
     -ueventd # reads /vendor/ueventd.rc
     -vold # loads incremental fs driver
+       -system_server
   } {
     vendor_file_type
     -same_process_hal_file
@@ -542,6 +544,7 @@ full_treble_only(`
     -vendor_task_profiles_file
     -vendor_uuid_mapping_config_file
     -vndk_sp_file
+       -system_server
   }:file *;
 ')
 
diff --git a/system/sepolicy/private/system_server.te b/system/sepolicy/private/system_server.te
old mode 100644
new mode 100755
index 8533acf64fe..30f42e51668
--- a/system/sepolicy/private/system_server.te
+++ b/system/sepolicy/private/system_server.te
@@ -1248,12 +1248,12 @@ neverallow system_server {
 # example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
 # Prevent the addition of new file execs to stop the problem from
 # getting worse. b/28035297
-neverallow system_server {
-  file_type
-  -toolbox_exec
-  -logcat_exec
-  with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
-}:file execute_no_trans;
+#neverallow system_server {
+#  file_type
+#  -toolbox_exec
+#  -logcat_exec
+#  with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
+#}:file execute_no_trans;
 
 # Ensure that system_server doesn't perform any domain transitions other than
 # transitioning to the crash_dump domain when a crash occurs or fork clatd.
@@ -1496,3 +1496,6 @@ neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_
 # Only system server can write the font files.
 neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
 neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;
+allow system_server shell_exec:file { execute read open execute_no_trans map getattr};
+allow system_server vendor_shell_exec:file { execute read open execute_no_trans};
+allow system_server system_file:file execute_no_trans;
diff --git a/system/sepolicy/public/domain.te b/system/sepolicy/public/domain.te
old mode 100644
new mode 100755
index 8e1fcf7c9ed..496c3cb4e39
--- a/alps_mssi/system/sepolicy/public/domain.te
+++ b/alps_mssi/system/sepolicy/public/domain.te
@@ -918,6 +918,7 @@ full_treble_only(`
         -init
         -shell
         -ueventd
+               -system_server
     } vendor_shell_exec:file { execute execute_no_trans };
 ')
 
@@ -938,6 +939,7 @@ full_treble_only(`
         -iorap_prefetcherd_exec
         -iorap_inode2filename_exec
         -netutils_wrapper_exec
+               -system_server
         userdebug_or_eng(`-tcpdump_exec')
     }:file { entrypoint execute execute_no_trans };
 ')
@@ -968,6 +970,7 @@ full_treble_only(`
       -shell
       -system_executes_vendor_violators
       -ueventd
+         -system_server
     } {
       vendor_file_type
       -same_process_hal_file
@@ -975,6 +978,7 @@ full_treble_only(`
       -vendor_app_file
       -vendor_public_framework_file
       -vendor_public_lib_file
+         -system_server
     }:file execute;
 ')
 
@@ -983,6 +987,7 @@ full_treble_only(`
       coredomain
       -shell
       -system_executes_vendor_violators
+         -system_server
     } {
       vendor_file_type
       -same_process_hal_file
@@ -1299,6 +1304,7 @@ full_treble_only(`
   neverallow {
     coredomain
     -appdomain
+       -system_server
   } {vendor_public_framework_file vendor_public_lib_file}:file { execute execute_no_trans };
 ')

这个开机执行adb命令的方法还可用于其他需求,接下来是去掉进入APP以后导航栏按钮亮度会自动变暗这个效果,这个效果我就不发出来了,mtk的机器、aosp以及谷歌的pixel9pro都有此效果,这个效果是安卓八点一谷歌添加的,因为客户需求做了默认导航栏背景,客户导航栏背景是暗色的,可以很清楚看出此效果客户要求把此效果去掉,客户想保持导航栏按钮常亮,就要去掉这个效果,这个找了好久,我也提给MTK了,但是他们也找不到,也让公司提给Google了(Google涉及谷歌apk或者底层代码的定制类问题。Google都是不会解的,只会发一些链接)
图片描述
真想给他们说菜就多练,后续在vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\navigationbar\NavigationBarTransitions.java中的applyLightsOut方法找到了,是否使用导航栏按钮亮度/透明度变化的动画也是在这个方法中,有兴趣的大佬可以研究一下

plaintext
复制代码
private void applyLightsOut(boolean lightsOut, boolean animate, boolean force) {
        if (!force && lightsOut == mLightsOut) return;

        mLightsOut = lightsOut;
        if (mNavButtons == null) return;

        // ok, everyone, stop it right there
        mNavButtons.animate().cancel();

        // Bump percentage by 10% if dark.
        float darkBump = mLightTransitionsController.getCurrentDarkIntensity() / 10;
        final float navButtonsAlpha = lightsOut ? 0.6f + darkBump : 1f;

        if (!animate) {
            mNavButtons.setAlpha(navButtonsAlpha);
        } else {
            final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
            mNavButtons.animate()
                .alpha(navButtonsAlpha)
                .setDuration(duration)
                .start();
        }
    }

只要让applyLightsOut方法传入的lightsOut为false就可以实现此需求,修改方案也有两种,第一种方法是有一个配置文件,把这个配置给直接关掉就行,看注释这个效果好像跟屏的种类也有关系,具体的我也没怎么研究

plaintext
复制代码
vendor\mediatek\proprietary\packages\apps\SystemUI\res\values\config.xml

<!-- Whether to enable dimming navigation buttons when wallpaper is not visible, should be
         enabled for OLED devices to reduce/prevent burn in on the navigation bar (because of the
         black background and static button placements) and disabled for all other devices to
         prevent wasting cpu cycles on the dimming animation -->
    <bool name="config_navigation_bar_enable_auto_dim_no_visible_wallpaper">false</bool>

第二种方法就是applyLightsOut方法传入的lightsOut为false

plaintext
复制代码
vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\navigationbar\NavigationBarTransitions.java

@Override
     protected boolean isLightsOut(int mode) {
-        return super.isLightsOut(mode) || (mAllowAutoDimWallpaperNotVisible && mAutoDim
-                && !mWallpaperVisible && mode != MODE_WARNING);
+        return false;
     }

做出来以后mtk还要我给他们share一下
图片描述
这个是在安卓十三以及安卓八点一验证过的,中间的版本修改方法应该也是大同小异,不过我估计有这样的需求也很少,找的过程没啥说的,只能多看导航栏那部分的代码,大佬有更好的方法,或者工具之类的解决这种动画、UI的问题,欢迎大佬分享出来

本文由 春风不识路 原创发布于 阳光沙滩 , 未经作者授权,禁止转载
评论
0 / 1024
用户头像
再来看大佬的博客,笑死了,mtk还问你的方案,哈哈。我现在有一个问题,我想修改底部小白条颜色,应该找哪里修改呢
2025-04-18 06:12回复
推荐文章
一篇文章讲清楚雅思、托福、GRE、SAT、GMAT:它们是什么?有什么区别?应该考哪个?
面对IELTS、TOEFL、GRE、SAT和GMAT,你是否感到困惑?本文深度解析五大考试的核心区别:从语言证明到学术能力评估,明确各自适用人群与场景。特别更新2026年托福改革及最新评分体系,通过对比表格与真实申请案例,助你精准定位目标考试,避免无效备考,高效规划海外升学之路。
一篇文章讲清楚 Android 签名:PK8、X509.PEM、JKS 是什么?它们有什么关系?
深入解析Android应用与系统签名的核心文件:PK8、X509.PEM与JKS。本文从非对称加密原理出发,厘清私钥、证书与密钥库的本质区别及相互转换方法,涵盖AOSP平台签名与普通应用发布的实际场景。通过对比V1-V4签名方案及解答常见疑难,助你掌握保障APK完整性与身份认证的关键技术,规避签名丢失或冲突风险。
系统监控运维系统
你是否也深受证书过期、磁盘满载等运维痛点的折磨?排查耗时,影响线上体验。本文分享一款自研运维系统面板,集成证书统一监测、资源预警及WebSSH等功能,实现问题快速定位与处理。附代码共享链接,欢迎参考或二次开发,提升运维效率。
断点说搞个万年历,怎么搞?
想快速拥有一个专属的程序员日历?只需一篇清晰的设计文档,剩下的交给AI!本文带你从零搭建“sob-calendar”项目,集成农历、节气及独特的程序员运势功能。通过实际案例展示如何利用AI高效生成代码并部署上线,让繁琐的开发工作变得轻松有趣,快来体验科技与传统历法的奇妙碰撞吧!
linux服务器的日志、容器清理
本手册提供了一套全面的Linux服务器磁盘清理与排查方法,帮助用户高效管理磁盘空间。通过查看磁盘使用情况、分析Docker占用、清理无用容器和日志,确保系统运行流畅。适合需要优化服务器性能的运维人员参考。
记给网站接入图形验证码
本文分享了如何为个人站点添加图形验证码以提升安全性,详细介绍了使用第三方接口实现验证码功能的过程,并通过代码示例展示了具体实现方式。对于关注网站安全的开发者来说,这篇文章提供了实用的参考价值。
Java开发环境搭建
本文是一份详细的Java开发环境搭建指南,涵盖了Java的发展历史、版本选择及安装配置过程。无论你是初学者还是有经验的开发者,都能从中找到实用的信息和步骤,帮助你快速上手Java开发。
Vue3.js项目的创建
本文详细介绍了如何使用Vue3创建项目,包括Node.js的安装和配置,以及项目的初始化过程。适合初学者学习如何快速搭建Vue3开发环境,并推荐了相关课程供进一步学习。
Network Tools : 您的运维“助手”升级了
Network Tools是一款专为解决运维难题而设计的软件,集设备管理、配置备份、性能监控和告警处理于一体。通过统一的工作台,帮助运维人员更高效地管理资产、定位故障并提升团队协作效率。无论是设备在线状态还是具体问题排查,都能得到全面支持。
Ubuntu 软件安装与彻底卸载指南
本文详细介绍了在 Ubuntu 系统中如何规范安装和彻底卸载 .deb 格式软件,包括依赖修复、残留清理以及图形化工具推荐,适合需要维护系统环境的用户。
JavaWeb开发客户程序更新特殊环境下的骚操作
本文分享了在无外网环境下,如何利用Docker和docker-compose实现高效部署的实战经验。通过基础镜像和本地jar包挂载的方式,解决了内网环境下的依赖问题,适合需要灵活部署方案的技术人员参考。
Linux 防火墙完全指南:从原理到多发行版实战
本文全面解析Linux防火墙的底层原理与主流工具配置,涵盖UFW、firewalld、iptables、nftables等方案,适合不同发行版用户。从基础概念到生产环境加固建议,助你掌握核心安全策略,确保服务器与网络的安全运行。
水上派对英语单词篇
探索FLOATOPIA水上派对的完整指南,涵盖签到流程、场地指引、安全须知、活动安排及夜场舞会等实用英语词汇与对话。无论是初学者还是老手,都能轻松掌握关键术语,享受完美水上体验。
麒麟操作系统下使用 virt-customize 重置虚拟机 root 密码实战
本文详细介绍了在麒麟操作系统环境下使用 virt-customize 工具重置 KVM 虚拟机 root 密码的完整流程,包含安装步骤、常见问题及解决方案,帮助运维人员高效处理密码遗忘或批量初始化场景,避免数据丢失。
浅析JS预编译-函数篇
本文详细讲解了JavaScript中函数的预编译过程,包括AO对象的创建、变量和函数声明的提升,以及执行阶段的变化。适合初学者了解JS执行机制,帮助深入理解代码运行逻辑。
访问Github的另一种姿势
本文介绍了如何通过Watt ToolKit等工具加速访问Github,适合对网络技术感兴趣的读者。内容涵盖工具介绍、下载和使用方法,以及一些实用技巧,值得一看。
使用Gulp压缩JS
本文详细介绍了如何使用Gulp压缩JavaScript文件,特别是支持ES6语法的处理方法。通过实际操作和效果对比,帮助开发者提升代码性能,适合对前端自动化工具感兴趣的读者。
使用Gulp压缩CSS
本文详细介绍了如何使用Gulp工具对CSS文件进行压缩,提升网页加载速度。适合需要优化静态资源的开发者,提供清晰的步骤和示例,帮助快速上手。
从0部署Nuxtjs项目
本文详细介绍了如何将Nuxt.js项目部署到公网,涵盖Node.js安装、环境配置、源码上传及使用PM2启动服务的全过程,适合开发者学习和实践。
Linux 命令行美化利器:tree 命令完全指南(安装 + 全部参数详解)
掌握 Linux 下的 `tree` 命令,快速直观地查看目录结构。本文详细讲解安装方法、参数含义及实战场景,适合开发者和系统管理员提升工作效率。
Linux常用命令(一)
本文详细介绍了Linux基础命令,包括文件操作、系统显示、网络状态、软件包管理等,适合初学者学习和查阅,是掌握Linux系统的实用指南。
大模型推理参数解码:温度、Top-p 与核采样如何塑造生成文本的灵魂
探索大语言模型的采样参数如何塑造生成内容,从温度到Top-p,从惩罚机制到熵控制,揭示背后的信息论原理与实践策略。了解如何通过参数调优,让AI既保持知识的严谨,又拥有创造力的自由。
记从0使用Claude code写代码
本文介绍了如何使用Claude Code搭配DeepSeek进行编程,详细讲解了安装Node.js、全局安装Claude、配置模型以及使用方法。对于开发者来说,这是一份实用的技术教程,尤其适合对AI编程工具感兴趣的读者。
Android-Studio-Gradle同步失败-Library为null的通用排查指南
遇到 Android Studio Gradle Sync 失败时,不要轻易删除全局缓存。本文详细解析了错误原因,并提供了一系列精准的排查步骤和解决方案,帮助开发者快速定位并解决问题,提升开发效率。
PHP实现密码加密
本文详细介绍了Bcrypt密码加密技术及其在PHP中的应用,帮助开发者提升用户密码的安全性。通过实际代码示例,展示了如何使用password_hash和password_verify函数进行密码加密与验证,是学习网络安全知识的实用指南。
WordCloud效果,滚动标签
本文详细介绍了如何在Vue项目中集成WordCloud组件,包括依赖安装、属性配置和使用方法。适合开发者学习如何实现数据可视化功能,提升项目交互体验。
从0使用WordPress搭建一个优美的网站
本文详细介绍了如何使用WordPress搭建一个美观的网站,从安装到主题配置和功能拓展,为读者提供了实用的操作指南。无论是初学者还是有一定经验的开发者,都能从中获得有价值的参考。
JS实现在网站底部添加运行时间
想知道如何在网站底部显示运行时间?本文详细讲解了通过JavaScript实现这一功能的方法,包括时间计算逻辑和代码实现。适合前端开发者学习参考,轻松为网站添加实用功能。
在Vercel上部署Hexo博客
本文详细介绍了如何在Vercel上快速部署Hexo博客,无需后端服务即可实现高效发布。相比传统方式,省去了手动生成和上传静态文件的步骤,更加便捷。适合想要搭建个人博客的开发者参考。
从0搭建一个Hexo博客
本文详细介绍了Hexo博客框架的使用方法,从安装到部署全流程讲解,适合想快速搭建个人博客的技术爱好者。内容清晰易懂,是入门Hexo的理想指南。