搜索
开发文档
应用开发
快应用开发
快游戏开发
开发文档/应用开发/系统适配/使用规范/应用删除前台服务通知导致的闪退问题说明
应用删除前台服务通知导致的闪退问题说明更新时间: 2024-09-24 18:26:00
  • 近期发现较多应用出现闪退现象,具体trace如下:
AndroidRuntime: FATAL EXCEPTION: main
AndroidRuntime: Process: com.xxx.app, PID: 25339
AndroidRuntime: java.lang.SecurityException: Not allowed to delete channel XXX with a foreground service
AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:2376)
AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2360)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2343)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2285)
AndroidRuntime: at android.app.INotificationManager$Stub$Proxy.deleteNotificationChannel(INotificationManager.java:4040)
AndroidRuntime: at android.app.NotificationManager.deleteNotificationChannel(NotificationManager.java:909)
AndroidRuntime: at androidx.core.app.NotificationManagerCompat.deleteNotificationChannel(SourceFile:2)
AndroidRuntime: at com.gyf.cactus.ext.c$a.run(SourceFile:1)
AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime: at android.os.Looper.loop(Looper.java:236)
AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8142)
AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
AndroidRuntime: at com.android.server.notification.NotificationManagerService$10.enforceDeletingChannelHasNoFgService(NotificationManagerService.java:3427)
AndroidRuntime: at com.android.server.notification.NotificationManagerService$10.deleteNotificationChannel(NotificationManagerService.java:3440)
AndroidRuntime: at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:1737)
AndroidRuntime: at android.os.Binder.execTransactInternal(Binder.java:1160)
AndroidRuntime: at android.os.Binder.execTransact(Binder.java:1129)
  • 原因是受Google的一笔安全校验Patch影响:

详见:操作引导

private void enforceDeletingChannelHasNoFgService(String pkg, int userId,
String channelId) {
if (mAmi.hasForegroundServiceNotification(pkg, userId, channelId)) {
Slog.w(TAG, "Package u" + userId + "/" + pkg
+ " may not delete notification channel '"
+ channelId + "' with fg service");
throw new SecurityException("Not allowed to delete channel " + channelId
+ " with a foreground service");
}
}

也就是Google限制了存在前台服务时,不允许应用删除与前台服务绑定的channel。

以上,请开发者检查处理,感谢支持!


上一篇:双开应用修改头像失败等场景适配说明
下一篇:应用频繁获取设备标识符
文档内容是否有帮助?
有帮助
无帮助