Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I grant permission for Huawei Launcher settings SDK 23+?

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/

like image 659
Nick Pakhomov Avatar asked Nov 08 '22 09:11

Nick Pakhomov


1 Answers

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

like image 178
David Riha Avatar answered Nov 14 '22 21:11

David Riha