5

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/

Aj 27
  • 2,316
  • 21
  • 29
Nick Pakhomov
  • 313
  • 4
  • 13

1 Answers1

1

You need <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/> in the manifest.

David Riha
  • 1,368
  • 14
  • 29