android.app.INotificationManager Java Examples
The following examples show how to use
android.app.INotificationManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConditionProviders.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void onPackagesChanged(boolean removingPackage, String[] pkgList, int[] uid) { 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, uid); }
Example #2
Source File: Toast.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * 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 } }
Example #3
Source File: MediaSessionService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public MediaSessionService(Context context) { super(context); mSessionManagerImpl = new SessionManagerImpl(); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mMediaEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "handleMediaEvent"); mLongPressTimeout = ViewConfiguration.getLongPressTimeout(); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); mPackageManager = AppGlobals.getPackageManager(); }
Example #4
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ protected final INotificationManager getNotificationInterface() { if (mNoMan == null) { mNoMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); } return mNoMan; }
Example #5
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Request that the listener be rebound, after a previous call to {@link #requestUnbind}. * * <p>This method will fail for listeners that have * not been granted the permission by the user. */ public static void requestRebind(ComponentName componentName) { INotificationManager noMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); try { noMan.requestBindListener(componentName); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } }
Example #6
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Request that the service be unbound. * * <p>Once this is called, you will no longer receive updates and no method calls are * guaranteed to be successful, until you next receive the {@link #onListenerConnected()} event. * The service will likely be killed by the system after this call. * * <p>The service should wait for the {@link #onListenerConnected()} event * before performing this operation. I know it's tempting, but you must wait. */ public final void requestUnbind() { if (mWrapper != null) { INotificationManager noMan = getNotificationInterface(); try { noMan.requestUnbindListener(mWrapper); // Disable future messages. isConnected = false; } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } }
Example #7
Source File: ConditionProviderService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private final INotificationManager getNotificationInterface() { if (mNoMan == null) { mNoMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); } return mNoMan; }
Example #8
Source File: ConditionProviderService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Request that the provider be rebound, after a previous call to (@link #requestUnbind). * * <p>This method will fail for providers that have not been granted the permission by the user. */ public static final void requestRebind(ComponentName componentName) { INotificationManager noMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); try { noMan.requestBindProvider(componentName); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } }
Example #9
Source File: ConditionProviderService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Request that the provider service be unbound. * * <p>This will no longer receive subscription updates and will not be able to update the * state of conditions until {@link #requestRebind(ComponentName)} is called. * The service will likely be killed by the system after this call. * * <p>The service should wait for the {@link #onConnected()} event before performing this * operation. */ public final void requestUnbind() { INotificationManager noMan = getNotificationInterface(); try { noMan.requestUnbindProvider(mProvider); // Disable future messages. mProvider = null; } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } }
Example #10
Source File: Toast.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
static private INotificationManager getService() { if (sService != null) { return sService; } sService = INotificationManager.Stub.asInterface(ServiceManager.getService("notification")); return sService; }
Example #11
Source File: JsWindow.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
static private INotificationManager getService() { if (sService != null) { return sService; } sService = INotificationManager.Stub.asInterface(ServiceManager .getService("notification")); return sService; }
Example #12
Source File: VrManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { LocalServices.getService(ActivityManagerInternal.class) .registerScreenObserver(this); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); synchronized (mLock) { Looper looper = Looper.getMainLooper(); Handler handler = new Handler(looper); ArrayList<EnabledComponentChangeListener> listeners = new ArrayList<>(); listeners.add(this); mComponentObserver = EnabledComponentsObserver.build(mContext, handler, Settings.Secure.ENABLED_VR_LISTENERS, looper, android.Manifest.permission.BIND_VR_LISTENER_SERVICE, VrListenerService.SERVICE_INTERFACE, mLock, listeners); mComponentObserver.rebuildAll(); } //TODO: something more robust than picking the first one ArraySet<ComponentName> defaultVrComponents = SystemConfig.getInstance().getDefaultVrComponents(); if (defaultVrComponents.size() > 0) { mDefaultVrService = defaultVrComponents.valueAt(0); } else { Slog.i(TAG, "No default vr listener service found."); } DisplayManager dm = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE); mVr2dDisplay = new Vr2dDisplay( dm, LocalServices.getService(ActivityManagerInternal.class), LocalServices.getService(WindowManagerInternal.class), mVrManager); mVr2dDisplay.init(getContext(), mBootsToVr); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_UNLOCKED); getContext().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { VrManagerService.this.setUserUnlocked(); } } }, intentFilter); } }
Example #13
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 3 votes |
/** * 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 * @removed */ @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); }
Example #14
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 3 votes |
/** * Directly unregister this service from the Notification Manager. * * <p>This method will fail for listeners that were not registered * with (@link registerAsService). * @hide * @removed */ @SystemApi public void unregisterAsSystemService() throws RemoteException { if (mWrapper != null) { INotificationManager noMan = getNotificationInterface(); noMan.unregisterListener(mWrapper, mCurrentUser); } }