use of android.app.INotificationManager in project android_frameworks_base by crdroidandroid.
the class ConditionProviders method onPackagesChanged.
@Override
public void onPackagesChanged(boolean removingPackage, String[] pkgList) {
if (removingPackage) {
INotificationManager inm = NotificationManager.getService();
if (pkgList != null && (pkgList.length > 0)) {
for (String pkgName : pkgList) {
try {
inm.removeAutomaticZenRules(pkgName);
inm.setNotificationPolicyAccessGranted(pkgName, false);
} catch (Exception e) {
Slog.e(TAG, "Failed to clean up rules for " + pkgName, e);
}
}
}
}
super.onPackagesChanged(removingPackage, pkgList);
}
use of android.app.INotificationManager in project android_frameworks_base by crdroidandroid.
the class NotificationBackupHelper method applyRestoredPayload.
@Override
protected void applyRestoredPayload(String key, byte[] payload) {
if (DEBUG) {
Slog.v(TAG, "Got restore of " + key);
}
if (KEY_NOTIFICATIONS.equals(key)) {
try {
INotificationManager nm = INotificationManager.Stub.asInterface(ServiceManager.getService("notification"));
// TODO: http://b/22388012
nm.applyRestore(payload, UserHandle.USER_SYSTEM);
} catch (Exception e) {
Slog.e(TAG, "Couldn't communicate with notification manager");
}
}
}
use of android.app.INotificationManager in project platform_frameworks_base by android.
the class ActivityManagerService method clearApplicationUserData.
@Override
public boolean clearApplicationUserData(final String packageName, final IPackageDataObserver observer, int userId) {
enforceNotIsolatedCaller("clearApplicationUserData");
int uid = Binder.getCallingUid();
int pid = Binder.getCallingPid();
userId = mUserController.handleIncomingUser(pid, uid, userId, false, ALLOW_FULL_ONLY, "clearApplicationUserData", null);
long callingId = Binder.clearCallingIdentity();
try {
IPackageManager pm = AppGlobals.getPackageManager();
int pkgUid = -1;
synchronized (this) {
if (getPackageManagerInternalLocked().isPackageDataProtected(userId, packageName)) {
throw new SecurityException("Cannot clear data for a protected package: " + packageName);
}
try {
pkgUid = pm.getPackageUid(packageName, MATCH_UNINSTALLED_PACKAGES, userId);
} catch (RemoteException e) {
}
if (pkgUid == -1) {
Slog.w(TAG, "Invalid packageName: " + packageName);
if (observer != null) {
try {
observer.onRemoveCompleted(packageName, false);
} catch (RemoteException e) {
Slog.i(TAG, "Observer no longer exists.");
}
}
return false;
}
if (uid == pkgUid || checkComponentPermission(android.Manifest.permission.CLEAR_APP_USER_DATA, pid, uid, -1, true) == PackageManager.PERMISSION_GRANTED) {
forceStopPackageLocked(packageName, pkgUid, "clear data");
} else {
throw new SecurityException("PID " + pid + " does not have permission " + android.Manifest.permission.CLEAR_APP_USER_DATA + " to clear data" + " of package " + packageName);
}
// Remove all tasks match the cleared application package and user
for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
final TaskRecord tr = mRecentTasks.get(i);
final String taskPackageName = tr.getBaseIntent().getComponent().getPackageName();
if (tr.userId != userId)
continue;
if (!taskPackageName.equals(packageName))
continue;
removeTaskByIdLocked(tr.taskId, false, REMOVE_FROM_RECENTS);
}
}
final int pkgUidF = pkgUid;
final int userIdF = userId;
final IPackageDataObserver localObserver = new IPackageDataObserver.Stub() {
@Override
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
synchronized (ActivityManagerService.this) {
finishForceStopPackageLocked(packageName, pkgUidF);
}
final Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED, Uri.fromParts("package", packageName, null));
intent.putExtra(Intent.EXTRA_UID, pkgUidF);
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(pkgUidF));
broadcastIntentInPackage("android", Process.SYSTEM_UID, intent, null, null, 0, null, null, null, null, false, false, userIdF);
if (observer != null) {
observer.onRemoveCompleted(packageName, succeeded);
}
}
};
try {
// Clear application user data
pm.clearApplicationUserData(packageName, localObserver, userId);
synchronized (this) {
// Remove all permissions granted from/to this package
removeUriPermissionsForPackageLocked(packageName, userId, true);
}
// Remove all zen rules created by this package; revoke it's zen access.
INotificationManager inm = NotificationManager.getService();
inm.removeAutomaticZenRules(packageName);
inm.setNotificationPolicyAccessGranted(packageName, false);
} catch (RemoteException e) {
}
} finally {
Binder.restoreCallingIdentity(callingId);
}
return true;
}
use of android.app.INotificationManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChannelNotificationSettingsTest method launchNotificationSettings_blockedChannel.
@Test
public void launchNotificationSettings_blockedChannel() throws Exception {
NotificationChannel blocked = new NotificationChannel("blocked", "blocked", IMPORTANCE_NONE);
mNm.createNotificationChannel(blocked);
INotificationManager sINM = INotificationManager.Stub.asInterface(ServiceManager.getService(Context.NOTIFICATION_SERVICE));
blocked.setImportance(IMPORTANCE_NONE);
sINM.updateNotificationChannelForPackage(mTargetContext.getPackageName(), Process.myUid(), blocked);
final Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).putExtra(Settings.EXTRA_APP_PACKAGE, mTargetContext.getPackageName()).putExtra(Settings.EXTRA_CHANNEL_ID, blocked.getId()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mInstrumentation.startActivitySync(intent);
onView(allOf(withText("At your request, Android is blocking this category of notifications" + " from appearing on this device"))).check(matches(isDisplayed()));
try {
onView(allOf(withText("On the lock screen"))).check(matches(isDisplayed()));
fail("settings appearing for blocked channel");
} catch (Exception e) {
// expected
}
}
Aggregations