I am trying to access info about notification badges from Huawei Launcher Android 23+ (which requires runtime permissions).
I already have in my manifest these lines:
<uses-permission
android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission
android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
And yet I am getting this RuntimeException with the message:
Permission Denial: reading com.huawei.android.launcher.LauncherProvider
uri content://com.huawei.android.launcher.settings/badge/ from pid=16687,
uid=10192 requires com.huawei.android.launcher.permission.READ_SETTINGS, or grantUriPermission()
Requesting permissions using ActivityCompat.requestPermissions
immediately returns "-1" == DENIED
.
Even trying to set permission through ADB doesn't help:
adb -d shell pm grant com.yandex.launcher com.huawei.android.launcher.permission.READ_SETTINGS
Operation not allowed: java.lang.SecurityException: Permission com.huawei.android.launcher.permission.READ_SETTINGS is not a changeable permission type
I've tried to grant the URI access through
context.grantUriPermission(context.getPackageName(), getBadgeContentUri(), Intent.FLAG_GRANT_READ_URI_PERMISSION);
or
context.grantUriPermission("com.huawei.android", getBadgeContentUri(), Intent.FLAG_GRANT_READ_URI_PERMISSION);
but that doesn't help either.
So what should I write in order to get proper permission to read: content://com.huawei.android.launcher.settings/badge/
You need <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
in the manifest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With