Android 11 去掉性能受到影响,要停用.请查看引导加载程序通知

本文介绍了在Android11Frameworks开发中遇到的开机性能通知问题,定位到`ActivityManagerService`中的`showConsoleNotificationIfActive()`方法,通过修改代码屏蔽该通知。解决方案包括grep命令查找和代码注释删除相应部分。
摘要由CSDN通过智能技术生成

Android 11 去掉性能受到影响,要停用.请查看引导加载程序通知


前言

在进行Frameworks开发过程中开机的时候会弹出一个系统通知,内容是"性能受到影响。要停用,请查看引导加载程序。",所以需要找到通知位置将其去掉。
如下图所示
在这里插入图片描述

一、问题解决

1.定位问题

通过在framework搜索"性能受到影响。要停用,请查看引导加载程序。"字段找到定位位置,
请添加图片描述
再通过查询console_running_notification_message 找到使用字段的位置
在这里插入图片描述
最终定位到解决问题的位置

/frameworks/base/core/res/res/values-zh-rCN/strings.xml
/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

2.解决问题

通过查看ActivityManagerService.java的代码发现在showConsoleNotificationIfActive(),发起了这个系统通知.

    private void showConsoleNotificationIfActive() {
        if (!SystemProperties.get("init.svc.console").equals("running")) {
            return;
        }
        String title = mContext
                .getString(com.android.internal.R.string.console_running_notification_title);
        String message = mContext
                .getString(com.android.internal.R.string.console_running_notification_message);
        Notification notification =
                new Notification.Builder(mContext, SystemNotificationChannels.DEVELOPER)
                        .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
                        .setWhen(0)
                        .setOngoing(true)
                        .setTicker(title)
                        .setDefaults(0)  // please be quiet
                        .setColor(mContext.getColor(
                                com.android.internal.R.color
                                        .system_notification_accent_color))
                        .setContentTitle(title)
                        .setContentText(message)
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .build();

        NotificationManager notificationManager =
                mContext.getSystemService(NotificationManager.class);
        notificationManager.notifyAsUser(
                null, SystemMessage.NOTE_SERIAL_CONSOLE_ENABLED, notification, UserHandle.ALL);

    }

解决问题,在调用showConsoleNotificationIfActive()方法的地方屏蔽掉然后就可以解决这个问题。

--- a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5568,7 +5568,8 @@ public class ActivityManagerService extends IActivityManager.Stub
             mUserController.scheduleStartProfiles();
         }
         // UART is on if init's console service is running, send a warning notification.
-        showConsoleNotificationIfActive();
+        // showConsoleNotificationIfActive();  delete by ltj  去掉性能收到影响弹窗
+
 

总结

通过查询弹出框字段,通过grep 命令 找到字段id然后定位到弹出框位置,粗暴解决

参考

https://blog.csdn.net/baidu_41666295/article/details/124562947

每日赠言

无人问津也好,技不如人也罢,你都要试着让自己安静下来,做自己该做的事情,而不是让内心的烦躁不安,毁掉你本就不多的热情和定力。

  • 6
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值