我在一种类型的设备上有一个非常具体的问题。我正在使用的应用程序在任何设备上都没有任何问题,除了华为P9。

该应用程序启动了一项服务,该服务应该在后台运行,但是,在该设备上,锁定设备后该服务将被终止。我将问题归结为:

09-20 14:31:14.799 1854-1878/? I/PgedBinderListener: kstate callback type:8 value1=2656 value2=KILLED


我不知道可能是什么原因。我在日志中看到的唯一可疑的东西应该是Keyguard产生的错误。与华为相关的错误和仅在华为设备上出现的问题的事实似乎表明存在连接。这是错误:

09-20 14:31:10.804 1364-1584/? I/KeyguardService: KGSvcCall onStartedGoingToSleep. 2
09-20 14:31:10.837 1902-1902/? I/HwLauncher: Launcher onStop()
09-20 14:31:10.841 1902-1912/? I/HwLauncher: Launcher.LauncherProvider  begin check permission at checkPermission
09-20 14:31:10.843 1902-1912/? W/System.err: java.lang.SecurityException: Permission Denial: reading com.huawei.android.launcher.LauncherProvider from pid=1364, uid=10029 requires com.huawei.android.launcher.permission.WRITE_SETTINGS: uid 10029 does not have com.huawei.android.launcher.permission.WRITE_SETTINGS.
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.app.ContextImpl.enforce(ContextImpl.java:1599)
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.app.ContextImpl.enforcePermission(ContextImpl.java:1612)
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.content.ContextWrapper.enforcePermission(ContextWrapper.java:664)
09-20 14:31:10.843 1902-1912/? W/System.err:     at com.huawei.android.launcher.LauncherProvider.checkPermission(LauncherProvider.java:1615)
09-20 14:31:10.843 1902-1912/? W/System.err:     at com.huawei.android.launcher.LauncherProvider.call(LauncherProvider.java:1854)
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.content.ContentProvider$Transport.call(ContentProvider.java:398)
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:283)
09-20 14:31:10.843 1902-1912/? W/System.err:     at android.os.Binder.execTransact(Binder.java:453)
09-20 14:31:10.844 1902-1912/? E/DatabaseUtils: Writing exception to parcel
                                                java.lang.SecurityException: Permission Denial: reading com.huawei.android.launcher.LauncherProvider from pid=1364, uid=10029 requires com.huawei.android.launcher.permission.WRITE_SETTINGS: uid 10029 does not have com.huawei.android.launcher.permission.WRITE_SETTINGS.
                                                    at android.app.ContextImpl.enforce(ContextImpl.java:1599)
                                                    at android.app.ContextImpl.enforcePermission(ContextImpl.java:1612)
                                                    at android.content.ContextWrapper.enforcePermission(ContextWrapper.java:664)
                                                    at com.huawei.android.launcher.LauncherProvider.checkPermission(LauncherProvider.java:1615)
                                                    at com.huawei.android.launcher.LauncherProvider.call(LauncherProvider.java:1854)
                                                    at android.content.ContentProvider$Transport.call(ContentProvider.java:398)
                                                    at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:283)
                                                    at android.os.Binder.execTransact(Binder.java:453)
09-20 14:31:10.845 1364-1650/? E/LauncherInteractiveUtil: Call launcher evnt fail. lock=true
                                                          java.lang.SecurityException: Permission Denial: reading com.huawei.android.launcher.LauncherProvider from pid=1364, uid=10029 requires com.huawei.android.launcher.permission.WRITE_SETTINGS: uid 10029 does not have com.huawei.android.launcher.permission.WRITE_SETTINGS.
                                                              at android.os.Parcel.readException(Parcel.java:1602)
                                                              at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
                                                              at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
                                                              at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
                                                              at android.content.ContentProviderClient.call(ContentProviderClient.java:437)
                                                              at com.huawei.keyguard.support.LauncherInteractiveUtil$Caller.run(LauncherInteractiveUtil.java:59)
                                                              at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)
                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                              at java.lang.Thread.run(Thread.java:833)


我确实尝试向清单添加com.huawei.android.launcher.permission.WRITE_SETTINGS权限,但是它没有任何区别,因为记录的错误似乎是由Keyguard引起的。

最佳答案

在写问题时,我偶然发现了答案。

在华为上,您必须将该应用程序添加到“电池管理”中的“受保护的应用程序”中,以防止该服务被终止。可以在执行检查时通知用户:
“ huawei” .equalsIgnoreCase(android.os.Build.MANUFACTURER)
显然,无法检查该应用程序是否已启用。

关于android - 华为P9上的PgedBinderListener杀死了Android 6.0粘性服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46323539/

10-09 04:45