Merge "Fix test cases broken"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4453e2c..22ec007 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6897,6 +6897,8 @@
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="app_and_notification_dashboard_summary">Permissions, default apps</string>
+ <!-- Toast text for notification settings in the work profile. This is shown when an app in the work profile attempts to open notification settings. [CHAR LIMIT=NONE] -->
+ <string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
<!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
<string name="account_dashboard_title">Accounts</string>
<!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java
index 17739f9..ad721ba 100644
--- a/src/com/android/settings/notification/NotificationAccessSettings.java
+++ b/src/com/android/settings/notification/NotificationAccessSettings.java
@@ -23,10 +23,12 @@
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
+import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -62,6 +64,18 @@
private NotificationManager mNm;
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ final Context ctx = getContext();
+ if (UserManager.get(ctx).isManagedProfile()) {
+ // Apps in the work profile do not support notification listeners.
+ Toast.makeText(ctx, R.string.notification_settings_work_profile, Toast.LENGTH_SHORT)
+ .show();
+ finish();
+ }
+ }
+
+ @Override
public int getMetricsCategory() {
return MetricsEvent.NOTIFICATION_ACCESS;
}