19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.app;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
19b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlockimport android.annotation.SdkConstant;
204600f9b60753adab4e65258a05744a46938fce86Christoph Studerimport android.app.Notification.Builder;
21b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlockimport android.content.ComponentName;
229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.Context;
232b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlockimport android.os.Bundle;
249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Handler;
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.IBinder;
2669ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkeyimport android.os.RemoteException;
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.ServiceManager;
28a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkeyimport android.os.StrictMode;
294120375d46091df8527bb701882e056fbb0e6b06Dianne Hackbornimport android.os.UserHandle;
309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.util.Log;
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Class to notify the user of events that happen.  This is how you tell
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the user that something has happened in the background. {@more}
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Notifications can take different forms:
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ul>
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      <li>A persistent icon that goes in the status bar and is accessible
399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          through the launcher, (when the user selects it, a designated Intent
409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          can be launched),</li>
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      <li>Turning on or flashing LEDs on the device, or</li>
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      <li>Alerting the user by flashing the backlight, playing a sound,
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *          or vibrating.</li>
449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ul>
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>
47b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * Each of the notify methods takes an int id parameter and optionally a
48b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * {@link String} tag parameter, which may be {@code null}.  These parameters
49b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * are used to form a pair (tag, id), or ({@code null}, id) if tag is
50b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * unspecified.  This pair identifies this notification from your app to the
51b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * system, so that pair should be unique within your app.  If you call one
52b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * of the notify methods with a (tag, id) pair that is currently active and
53b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * a new set of notification parameters, it will be updated.  For example,
54b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * if you pass a new status bar icon, the old icon in the status bar will
55b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * be replaced with the new one.  This is also the same tag and id you pass
56b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * to the {@link #cancel(int)} or {@link #cancel(String, int)} method to clear
57b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne * this notification.
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You do not instantiate this class directly; instead, retrieve it through
619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Context#getSystemService}.
629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
63558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * <div class="special reference">
64558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * <h3>Developer Guides</h3>
65558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * <p>For a guide to creating notifications, read the
66558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * <a href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Status Bar Notifications</a>
67558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * developer guide.</p>
68558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez * </div>
69558459fe85f56f29a6ed6a4d0adb4a0bd6665884Joe Fernandez *
709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @see android.app.Notification
719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @see android.content.Context#getSystemService
729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class NotificationManager
749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{
759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private static String TAG = "NotificationManager";
7643a17654cf4bfe7f1ec22bd8b7b32daccdf27c09Joe Onorato    private static boolean localLOGV = false;
779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
78b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    /**
79b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     * Intent that is broadcast when the state of {@link #getEffectsSuppressor()} changes.
80b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     * This broadcast is only sent to registered receivers.
81b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     *
82b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     * @hide
83b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     */
84b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
85b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    public static final String ACTION_EFFECTS_SUPPRESSOR_CHANGED
86b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock            = "android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED";
87b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock
889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private static INotificationManager sService;
899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
90d8a43f61680bacf0d4b52a03ff3c7a07307377fcDianne Hackborn    /** @hide */
91d8a43f61680bacf0d4b52a03ff3c7a07307377fcDianne Hackborn    static public INotificationManager getService()
929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    {
939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (sService != null) {
949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return sService;
959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        IBinder b = ServiceManager.getService("notification");
979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        sService = INotificationManager.Stub.asInterface(b);
989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return sService;
999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /*package*/ NotificationManager(Context context, Handler handler)
1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    {
1039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mContext = context;
1049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
10669ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkey    /** {@hide} */
10769ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkey    public static NotificationManager from(Context context) {
10869ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkey        return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
10969ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkey    }
11069ddab4575ff684c533c995e07ca15fe18543fc0Jeff Sharkey
1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
112e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * Post a notification to be shown in the status bar. If a notification with
113e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * the same id has already been posted by your application and has not yet been canceled, it
114e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * will be replaced by the updated information.
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param id An identifier for this notification unique within your
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *        application.
118e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * @param notification A {@link Notification} object describing what to show the user. Must not
119e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     *        be null.
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void notify(int id, Notification notification)
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    {
1236ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana        notify(null, id, notification);
1246ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    }
1256ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana
1266ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    /**
127e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * Post a notification to be shown in the status bar. If a notification with
128e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * the same tag and id has already been posted by your application and has not yet been
129e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * canceled, it will be replaced by the updated information.
1306ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     *
131b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne     * @param tag A string identifier for this notification.  May be {@code null}.
132b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne     * @param id An identifier for this notification.  The pair (tag, id) must be unique
133b97c34948e5fcb765f46d655bbf358d06ef89a67Peter Collingbourne     *        within your application.
134e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     * @param notification A {@link Notification} object describing what to
135e97a3bce3c91d76b623f57d309f7bf74947494daDaniel Sandler     *        show the user. Must not be null.
1366ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     */
1376ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    public void notify(String tag, int id, Notification notification)
1386ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    {
1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        int[] idOut = new int[1];
1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        INotificationManager service = getService();
1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String pkg = mContext.getPackageName();
14265c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey        if (notification.sound != null) {
14365c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey            notification.sound = notification.sound.getCanonicalUri();
144a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey            if (StrictMode.vmFileUriExposureEnabled()) {
145a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey                notification.sound.checkFileUriExposed("Notification.sound");
146a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey            }
14765c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey        }
1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
1494600f9b60753adab4e65258a05744a46938fce86Christoph Studer        Notification stripped = notification.clone();
1504600f9b60753adab4e65258a05744a46938fce86Christoph Studer        Builder.stripForDelivery(stripped);
1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
15295d785346b4dae808a2d8f77356175e55a572d96Dianne Hackborn            service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
1534600f9b60753adab4e65258a05744a46938fce86Christoph Studer                    stripped, idOut, UserHandle.myUserId());
1544120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn            if (id != idOut[0]) {
1554120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn                Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]);
1564120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn            }
1574120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        } catch (RemoteException e) {
1584120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        }
1594120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    }
1604120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn
1614120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    /**
1624120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn     * @hide
1634120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn     */
1644120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    public void notifyAsUser(String tag, int id, Notification notification, UserHandle user)
1654120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    {
1664120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        int[] idOut = new int[1];
1674120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        INotificationManager service = getService();
1684120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        String pkg = mContext.getPackageName();
16965c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey        if (notification.sound != null) {
17065c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey            notification.sound = notification.sound.getCanonicalUri();
171a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey            if (StrictMode.vmFileUriExposureEnabled()) {
172a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey                notification.sound.checkFileUriExposed("Notification.sound");
173a14acd20b8d563319ea1a5974dca0e9a29f0aaefJeff Sharkey            }
17465c4a2b26cd8776b0927e9b0e07ecf53bd31b627Jeff Sharkey        }
1754120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
1764600f9b60753adab4e65258a05744a46938fce86Christoph Studer        Notification stripped = notification.clone();
1774600f9b60753adab4e65258a05744a46938fce86Christoph Studer        Builder.stripForDelivery(stripped);
1784120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        try {
17995d785346b4dae808a2d8f77356175e55a572d96Dianne Hackborn            service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
1804600f9b60753adab4e65258a05744a46938fce86Christoph Studer                    stripped, idOut, user.getIdentifier());
1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (id != idOut[0]) {
1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]);
1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Cancel a previously shown notification.  If it's transient, the view
1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * will be hidden.  If it's persistent, it will be removed from the status
1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * bar.
1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void cancel(int id)
1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    {
1956ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana        cancel(null, id);
1966ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    }
1976ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana
1986ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    /**
1996ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     * Cancel a previously shown notification.  If it's transient, the view
2006ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     * will be hidden.  If it's persistent, it will be removed from the status
2016ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     * bar.
2026ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana     */
2036ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    public void cancel(String tag, int id)
2046ecaff15836581336b1e8fad6ac42f3ff4a13544Fred Quintana    {
2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        INotificationManager service = getService();
2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String pkg = mContext.getPackageName();
2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")");
2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2094120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn            service.cancelNotificationWithTag(pkg, tag, id, UserHandle.myUserId());
2104120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        } catch (RemoteException e) {
2114120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        }
2124120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    }
2134120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn
2144120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    /**
2154120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn     * @hide
2164120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn     */
2174120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    public void cancelAsUser(String tag, int id, UserHandle user)
2184120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn    {
2194120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        INotificationManager service = getService();
2204120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        String pkg = mContext.getPackageName();
2214120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")");
2224120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn        try {
2234120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn            service.cancelNotificationWithTag(pkg, tag, id, user.getIdentifier());
2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Cancel all previously shown notifications. See {@link #cancel} for the
2309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * detailed behavior.
2319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void cancelAll()
2339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    {
2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        INotificationManager service = getService();
2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String pkg = mContext.getPackageName();
2369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (localLOGV) Log.v(TAG, pkg + ": cancelAll()");
2379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2384120375d46091df8527bb701882e056fbb0e6b06Dianne Hackborn            service.cancelAllNotifications(pkg, UserHandle.myUserId());
2399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
243b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    /**
244b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     * @hide
245b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock     */
246b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    public ComponentName getEffectsSuppressor() {
247b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock        INotificationManager service = getService();
248b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock        try {
249b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock            return service.getEffectsSuppressor();
250b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock        } catch (RemoteException e) {
251b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock            return null;
252b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock        }
253b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock    }
254b4782526f5600d9759baac64b23e0c0cd05e2050John Spurlock
2552b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock    /**
2562b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock     * @hide
2572b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock     */
2582b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock    public boolean matchesCallFilter(Bundle extras) {
2592b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock        INotificationManager service = getService();
2602b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock        try {
2612b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock            return service.matchesCallFilter(extras);
2622b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock        } catch (RemoteException e) {
2632b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock            return false;
2642b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock        }
2652b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock    }
2662b122f4c2e691f0319e4f9ea5873989792bb56a6John Spurlock
2679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private Context mContext;
2689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
269