我在一种设备上遇到了一个非常具体的问题。我正在处理的应用程序在华为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引起的。
答案 0 :(得分:1)
当我写这个问题时,我偶然发现了答案。
在华为,你必须将应用程序添加到电池管理中的受保护应用程序,以防止服务被杀死。在执行检查时,用户可以被告知: “华为” .equalsIgnoreCase(android.os.Build.MANUFACTURER) 显然,无法检查应用程序是否已在此处启用。