MTK屏蔽谷歌服务报错对话框KK

该代码段展示了在Android系统中,如何在ActivityManagerService.java文件中添加逻辑,以检查进程是否属于谷歌服务(com.google.android.gms),如果是,则不显示错误或ANR对话框。这一改动可能用于特定设备上阻止谷歌服务的相关提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MTK屏蔽谷歌服务报错对话框KK

frameworks/base/services/java/com/android/server/am/ActivityManagerService.java

@@ -1211,8 +1211,17 @@ public final class ActivityManagerService extends ActivityManagerNative
                     if (mShowDialogs && !mSleeping && !mShuttingDown) {
                         Dialog d = new AppErrorDialog(mContext,
                                 ActivityManagerService.this, res, proc);
+                       if(d != null){
+                       if(proc != null && (proc.info.packageName.equals("com.google.android.gms"))){
+                               d = null;
+                             }
+                        }
+                       if(d != null){ // modify by sqx  s
                         d.show();
                         proc.crashDialog = d;
+                       } // modify by sqx  s
                     } else {
                         // The device is asleep, so just pretend that the user
                         // saw a crash dialog and hit "force quit".
@@ -1246,8 +1255,17 @@ public final class ActivityManagerService extends ActivityManagerNative
                         Dialog d = new AppNotRespondingDialog(ActivityManagerService.this,
                                 mContext, proc, (ActivityRecord)data.get("activity"),
                                 msg.arg1 != 0);

+                          if(d != null){
+                          if(proc != null && (proc.info.packageName.equals("com.google.android.gms"))){
+                                  d = null;
+                              }
+                         }
+                       if(null != d) { // modify by sqx  s
                         d.show();
                         proc.anrDialog = d;
+                       } 
                     } else {
                         // Just kill the app if there is no dialog to be shown.
                         killAppAtUsersRequest(proc, null);
@@ -14315,11 +14333,11 @@ public final class ActivityManagerService extends ActivityManagerNative
         intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);

         /// M: ALPS00601880, Fix Settings and RemoteView ANR, Avoid send broadcast to FG queue. @{
-        if (intent.getCategories() != null) {
+        /*if (intent.getCategories() != null) {
             if (intent.getCategories().contains("android.intent.category.ALTERNATIVE")) {
                 intent.setFlags(intent.getFlags()&~(Intent.FLAG_RECEIVER_FOREGROUND));
             }
-        }
+        }*/
         /// @}

         if (FeatureOption.MTK_LCA_RAM_OPTIMIZE) {
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值