Android Do not Disturb (DnD) permission in managed profile

和自甴很熟 提交于 2019-12-12 12:56:42

问题


I have the following problem:

My app is distributed over an MDM system and runs in Android for Work. In certain situation, the app must temporarily terminate the DnD mode. To achieve this, the user must grant the DnD permission when the app is started.

So far so good. If I install the app in the unmanaged area, the app shows up in the list and the permission can be granted without any problems. As soon as the app is distributed via an MDM system, the app no longer appears in the list and the permission cannot be granted. All authorizations have been granted in the MDM system. As an example, I have distributed the Google App over the MDM system. This app appears in the list.

In the Manifest I have set the following permission:

<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />

When the app is started, the following code is executed:

NotificationManager nm = (NotificationManager).getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && !nm.isNotificationPolicyAccessGranted()) {
  Intent intent = new
  Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
  startActivity(intent);
}

The problem only occurs with DnD permission. All other permissions such as overlay permission, are displayed without problems.

I hope anyone can help me.


回答1:


According to Android documentation: NOT POSSIBLE

Users can grant and deny access to Do Not Disturb configuration from here. Managed profiles cannot grant Do Not Disturb access.




回答2:


I haven't found a proper solution for the problem yet but I found a workaround to display the app in the work area. It seems that the app is only displayed in the dialog if the same app is also installed in the private area. If the app is not installed in the private area, it will also not appear in the work area. My workaround was to install the app in the private and work area. After the permission in the work area was granted, I removed the app from the private area. Like I said, it's not a solution to the problem itself, but it worked. To me this looks like a bug in Android, because for all other permissions the app appears in the list




回答3:


We have the same issue with the app SignOnSite. Can't get access to the DnD function for emergency evacuations unless we also install the app in the Personal space as well. Makes it to risky doing it this way, so ended up just installing the app in the Personal space. Using Intune for our MDM.




回答4:


Try this -

Intent intent = new Intent("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS");
    startActivity(intent);


来源:https://stackoverflow.com/questions/48567956/android-do-not-disturb-dnd-permission-in-managed-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!