Android Do not Disturb (DnD) permission in managed profile-ThrowExceptions

Exception or error:

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.

Screenshot image

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.

How to solve:

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.

###

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

###

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.

###

Apparently there is issure reported regarding this on Google Issue Tracker
https://issuetracker.google.com/issues/77939714

This is the reply from Google:

Status: Won’t Fix (Intended Behavior) 11:41AM You can not change DND
settings from a managed profile app. We will be updating the
documentation to clarify this.

There is also a reply stating:

Microsoft Intune has released their fully managed Android Enterprise
profile setup for Android Devices. … and it can now access and
grant the DnD permission. Not sure if its the fact that we have gone
to fully managed devices or if something else has changed.

And I would believe this is actually because the device is fully managed.

So according to my understadning there are two options:

  • Fully managed device (will require a factory reset on the phone)
  • Install it on the personal profile

###

Try this –

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

Leave a Reply

Your email address will not be published. Required fields are marked *