Migrate package notification controls to AppOps.
We still show the [X] Show Notifications box in InstalledAppDetails for now, however the information should be mostly in sync with the AppOps screen. ("Mostly" because there's no way to register for changes to AppOp modes at present.) Change-Id: Ia5cdda26c140aed8ee7329caaeedac04b8cbd8f1
This commit is contained in:
@@ -573,6 +573,7 @@
|
||||
<item>Read calendar</item>
|
||||
<item>Write calendar</item>
|
||||
<item>Wi-Fi scan</item>
|
||||
<item>Post notification</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Titles for the list of long press timeout options. -->
|
||||
|
@@ -107,7 +107,8 @@ public class AppOpsState {
|
||||
);
|
||||
|
||||
public static final OpsTemplate DEVICE_TEMPLATE = new OpsTemplate(
|
||||
new int[] { AppOpsManager.OP_VIBRATE }
|
||||
new int[] { AppOpsManager.OP_VIBRATE,
|
||||
AppOpsManager.OP_POST_NOTIFICATION }
|
||||
);
|
||||
|
||||
public static final OpsTemplate[] ALL_TEMPLATES = new OpsTemplate[] {
|
||||
|
@@ -385,7 +385,8 @@ public class InstalledAppDetails extends Fragment
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
boolean enabled = true; // default on
|
||||
try {
|
||||
enabled = nm.areNotificationsEnabledForPackage(mAppEntry.info.packageName);
|
||||
enabled = nm.areNotificationsEnabledForPackage(mAppEntry.info.packageName,
|
||||
mAppEntry.info.uid);
|
||||
} catch (android.os.RemoteException ex) {
|
||||
// this does not bode well
|
||||
}
|
||||
@@ -1263,7 +1264,7 @@ public class InstalledAppDetails extends Fragment
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
try {
|
||||
final boolean enable = mNotificationSwitch.isChecked();
|
||||
nm.setNotificationsEnabledForPackage(packageName, enabled);
|
||||
nm.setNotificationsEnabledForPackage(packageName, mAppEntry.info.uid, enabled);
|
||||
} catch (android.os.RemoteException ex) {
|
||||
mNotificationSwitch.setChecked(!enabled); // revert
|
||||
}
|
||||
|
@@ -1129,7 +1129,7 @@ public class ManageApplications extends Fragment implements
|
||||
ApplicationInfo app = apps.get(i);
|
||||
try {
|
||||
if (DEBUG) Log.v(TAG, "Enabling notifications: " + app.packageName);
|
||||
nm.setNotificationsEnabledForPackage(app.packageName, true);
|
||||
nm.setNotificationsEnabledForPackage(app.packageName, app.uid, true);
|
||||
} catch (android.os.RemoteException ex) {
|
||||
}
|
||||
if (!app.enabled) {
|
||||
|
Reference in New Issue
Block a user