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.youkuaiyun.com/baidu_41666295/article/details/124562947
每日赠言
无人问津也好,技不如人也罢,你都要试着让自己安静下来,做自己该做的事情,而不是让内心的烦躁不安,毁掉你本就不多的热情和定力。