Implement per-app sensitivity settings toggle.
Change-Id: Iaa1de63b720bf93bdf432117604740e509fe3ab0 Depends-On: I2d5cf6782273744cbf9b309dec76780cc0a4c39e Bug: 16324353
This commit is contained in:
@@ -41,6 +41,7 @@ import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
@@ -568,13 +569,28 @@ public class NotificationAppList extends PinnedHeaderListFragment
|
||||
}
|
||||
|
||||
public boolean getSensitive(String pkg, int uid) {
|
||||
// TODO get visibility state from NoMan
|
||||
return false;
|
||||
INotificationManager nm = INotificationManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
try {
|
||||
return nm.getPackageVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setSensitive(String pkg, int uid, boolean sensitive) {
|
||||
// TODO save visibility state to NoMan
|
||||
return true;
|
||||
INotificationManager nm = INotificationManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
try {
|
||||
nm.setPackageVisibilityOverride(pkg, uid,
|
||||
sensitive ? Notification.VISIBILITY_PRIVATE
|
||||
: NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user