Search in sources :

Example 26 with INotificationManager

use of android.app.INotificationManager in project android_frameworks_base by crdroidandroid.

the class NotificationListenerService method unregisterAsSystemService.

/**
     * Directly unregister this service from the Notification Manager.
     *
     * <p>This method will fail for listeners that were not registered
     * with (@link registerAsService).
     * @hide
     */
@SystemApi
public void unregisterAsSystemService() throws RemoteException {
    if (mWrapper != null) {
        INotificationManager noMan = getNotificationInterface();
        noMan.unregisterListener(mWrapper, mCurrentUser);
    }
}
Also used : INotificationManager(android.app.INotificationManager) SystemApi(android.annotation.SystemApi)

Example 27 with INotificationManager

use of android.app.INotificationManager in project android_frameworks_base by crdroidandroid.

the class Toast method show.

/**
     * Show the view for the specified duration.
     */
public void show() {
    if (mNextView == null) {
        throw new RuntimeException("setView must have been called");
    }
    INotificationManager service = getService();
    String pkg = mContext.getOpPackageName();
    TN tn = mTN;
    tn.mNextView = mNextView;
    try {
        service.enqueueToast(pkg, tn, mDuration);
    } catch (RemoteException e) {
    // Empty
    }
}
Also used : INotificationManager(android.app.INotificationManager) RemoteException(android.os.RemoteException)

Example 28 with INotificationManager

use of android.app.INotificationManager in project android_frameworks_base by crdroidandroid.

the class AccountManagerService method cancelNotification.

protected void cancelNotification(int id, String packageName, UserHandle user) {
    long identityToken = clearCallingIdentity();
    try {
        INotificationManager service = INotificationManager.Stub.asInterface(ServiceManager.getService(Context.NOTIFICATION_SERVICE));
        service.cancelNotificationWithTag(packageName, null, id, user.getIdentifier());
    } catch (RemoteException e) {
    /* ignore - local call */
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
Also used : INotificationManager(android.app.INotificationManager) RemoteException(android.os.RemoteException)

Example 29 with INotificationManager

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;
}
Also used : IPackageManager(android.content.pm.IPackageManager) INotificationManager(android.app.INotificationManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException) Point(android.graphics.Point) IPackageDataObserver(android.content.pm.IPackageDataObserver)

Example 30 with INotificationManager

use of android.app.INotificationManager in project platform_frameworks_base by android.

the class NotificationListenerService method registerAsSystemService.

/**
     * Directly register this service with the Notification Manager.
     *
     * <p>Only system services may use this call. It will fail for non-system callers.
     * Apps should ask the user to add their listener in Settings.
     *
     * @param context Context required for accessing resources. Since this service isn't
     *    launched as a real Service when using this method, a context has to be passed in.
     * @param componentName the component that will consume the notification information
     * @param currentUser the user to use as the stream filter
     * @hide
     */
@SystemApi
public void registerAsSystemService(Context context, ComponentName componentName, int currentUser) throws RemoteException {
    if (mWrapper == null) {
        mWrapper = new NotificationListenerWrapper();
    }
    mSystemContext = context;
    INotificationManager noMan = getNotificationInterface();
    mHandler = new MyHandler(context.getMainLooper());
    mCurrentUser = currentUser;
    noMan.registerListener(mWrapper, componentName, currentUser);
}
Also used : INotificationManager(android.app.INotificationManager) SystemApi(android.annotation.SystemApi)

Aggregations

INotificationManager (android.app.INotificationManager)48 RemoteException (android.os.RemoteException)28 SystemApi (android.annotation.SystemApi)10 Context (android.content.Context)4 Configuration (android.content.res.Configuration)4 Theme (android.content.res.Resources.Theme)4 IMountService (android.os.storage.IMountService)4 DisplayMetrics (android.util.DisplayMetrics)4 WindowManager (android.view.WindowManager)4 ILockSettings (com.android.internal.widget.ILockSettings)4 AccessibilityManagerService (com.android.server.accessibility.AccessibilityManagerService)4 AudioService (com.android.server.audio.AudioService)4 ClipboardService (com.android.server.clipboard.ClipboardService)4 DevicePolicyManagerService (com.android.server.devicepolicy.DevicePolicyManagerService)4 InputManagerService (com.android.server.input.InputManagerService)4 MediaRouterService (com.android.server.media.MediaRouterService)4 NetworkPolicyManagerService (com.android.server.net.NetworkPolicyManagerService)4 NetworkStatsService (com.android.server.net.NetworkStatsService)4 SchedulingPolicyService (com.android.server.os.SchedulingPolicyService)4 ShortcutService (com.android.server.pm.ShortcutService)4