diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 68f894e88a1b..28b26ae0aa0a 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -54,9 +54,6 @@ interface INotificationManager
void setShowNotificationForPackageOnKeyguard(String pkg, int uid, int status);
int getShowNotificationForPackageOnKeyguard(String pkg, int uid);
- void setHeadsUpNotificationsEnabledForPackage(String pkg, int uid, int headsUp);
- int getHeadsUpNotificationsEnabledForPackage(String pkg, int uid);
-
// TODO: Remove this when callers have been migrated to the equivalent
// INotificationListener method.
StatusBarNotification[] getActiveNotifications(String callingPkg);
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index cb48edab5643..5769954a3575 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -271,34 +271,11 @@ public boolean matchesCallFilter(Bundle extras) {
public int getShowNotificationForPackageOnKeyguard(String pkg, int uid) {
INotificationManager service = getService();
try {
- return service.getShowNotificationForPackageOnKeyguard(pkg, uid);
+ return getService().getShowNotificationForPackageOnKeyguard(pkg, uid);
} catch (RemoteException e) {
return Notification.SHOW_ALL_NOTI_ON_KEYGUARD;
}
}
- /**
- * @hide
- */
- public int getHeadsUpNotificationsEnabledForPackage(String pkg, int uid) {
- INotificationManager service = getService();
- try {
- return service.getHeadsUpNotificationsEnabledForPackage(pkg, uid);
- } catch (RemoteException e) {
- return Notification.HEADS_UP_NEVER;
- }
- }
-
- /**
- * @hide
- */
- public void setHeadsUpNotificationsEnabledForPackage(String pkg, int uid, int headsUp) {
- INotificationManager service = getService();
- try {
- service.setHeadsUpNotificationsEnabledForPackage(pkg, uid, headsUp);
- } catch (RemoteException e) {
- }
- }
-
private Context mContext;
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 1b6db3b277f0..d5e7e5ddf81d 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2189,20 +2189,6 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
public static final String LOCKSCREEN_SHORTCUTS_LONGPRESS =
"lockscreen_shortcuts_longpress";
- /**
- * Defines global heads up snooze time if user want to snooze it.
- *
- * @hide
- */
- public static final String HEADS_UP_SNOOZE_TIME = "heads_up_snooze_time";
-
- /**
- * Defines the global heads up notification decay
- *
- * @hide
- */
- public static final String HEADS_UP_NOTIFCATION_DECAY = "heads_up_notification_decay";
-
/**
* Timeout for ambient display notification
* @hide
@@ -2993,6 +2979,18 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String SIP_CALL_OPTIONS = "sip_call_options";
+ /**
+ * Hide notification instead of remove when swiping headsup
+ * @hide
+ */
+ public static final String HEADS_UP_DISMISS_ON_REMOVE = "heads_up_dismiss_on_remove";
+
+ /**
+ * Hide notification 1 second after touching outside
+ * @hide
+ */
+ public static final String HEADS_UP_TOUCH_OUTSIDE = "heads_up_touch_outside";
+
/**
* One of the sip call options: Always use SIP with network access.
* @hide
@@ -3507,8 +3505,36 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
public static final String ANIMATION_CONTROLS_DURATION = "animation_controls_duration";
public static final String ANIMATION_CONTROLS_EXIT_ONLY = "animation_controls_exit_only";
public static final String ANIMATION_CONTROLS_REVERSE_EXIT = "animation_controls_reverse_exit";
-
- /**
+
+ /**
+ * Heads Up Notifications
+ *
+ * @hide
+ */
+ public static final String HEADS_UP_NOTIFICATION = "heads_up_enabled";
+
+ /**
+ * Which applications to disable heads up notifications for
+ *
+ * @hide
+ */
+ public static final String HEADS_UP_CUSTOM_VALUES = "heads_up_custom_values";
+
+ /**
+ * Which applications to disable heads up notifications for
+ *
+ * @hide
+ */
+ public static final String HEADS_UP_BLACKLIST_VALUES = "heads_up_blacklist_values";
+
+ /**
+ * Defines the global heads up notification decay
+ *
+ * @hide
+ */
+ public static final String HEADS_UP_NOTIFCATION_DECAY = "heads_up_notification_decay";
+
+ /**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
*
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index b56378fe6310..8a3d63375063 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -1337,6 +1337,17 @@ static void scheduleCheckFocusLocked(View view) {
}
}
+ /**
+ * @hide
+ */
+ public boolean isImeShowing() {
+ try {
+ return mService.isImeShowing();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
/**
* @hide
*/
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 34a0ebef57b3..90ba2ba59d6a 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -38,8 +38,6 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -53,8 +51,6 @@
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
-import com.android.internal.statusbar.IStatusBarService;
-
import libcore.util.Objects;
import java.lang.annotation.ElementType;
@@ -666,13 +662,6 @@ private class SetOnClickPendingIntent extends Action {
public SetOnClickPendingIntent(int id, PendingIntent pendingIntent) {
this.viewId = id;
this.pendingIntent = pendingIntent;
- this.clearHeadsUp = false;
- }
-
- public SetOnClickPendingIntent(int id, PendingIntent pendingIntent, boolean clearHeadsUp) {
- this.viewId = id;
- this.pendingIntent = pendingIntent;
- this.clearHeadsUp = clearHeadsUp;
}
public SetOnClickPendingIntent(Parcel parcel) {
@@ -682,8 +671,6 @@ public SetOnClickPendingIntent(Parcel parcel) {
if (parcel.readInt() != 0) {
pendingIntent = PendingIntent.readPendingIntentOrNullFromParcel(parcel);
}
- // Read possible clearHeadsUp state from parcel
- clearHeadsUp = parcel.readInt() != 0;
}
public void writeToParcel(Parcel dest, int flags) {
@@ -695,8 +682,6 @@ public void writeToParcel(Parcel dest, int flags) {
if (pendingIntent != null) {
pendingIntent.writeToParcel(dest, 0 /* no flags */);
}
- // Write possible clearHeadsUp state to parcel
- dest.writeInt(clearHeadsUp ? 1 : 0);
}
@Override
@@ -724,24 +709,6 @@ public void apply(View root, ViewGroup rootParent, final OnClickHandler handler)
if (pendingIntent != null) {
listener = new OnClickListener() {
public void onClick(View v) {
- // If clearHeadsUp == true we know that we are a notification button.
- // A lot apps do not directly dismiss the notification
- // if the user pressed an action button. This is ok for normal
- // notifications. But with heads up the notficiation stays and
- // disturbes the workflow for the user. So we hide the heads up view, push
- // the notification into background and let the app handle everything else.
- if (clearHeadsUp) {
- final IStatusBarService barService =
- IStatusBarService.Stub.asInterface(
- ServiceManager.getService(Context.STATUS_BAR_SERVICE));
- try {
- if (barService != null) {
- barService.scheduleHeadsUpClose();
- }
- } catch (RemoteException e) {
- // Ooops that should never happen.
- }
- }
// Find target view location in screen coordinates and
// fill into PendingIntent before sending.
final Rect rect = getSourceBounds(v);
@@ -760,7 +727,6 @@ public String getActionName() {
}
PendingIntent pendingIntent;
- boolean clearHeadsUp;
public final static int TAG = 1;
}
@@ -2170,27 +2136,6 @@ public void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent) {
addAction(new SetOnClickPendingIntent(viewId, pendingIntent));
}
- /**
- * Equivalent to calling
- * {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
- * to launch the provided {@link PendingIntent}.
- *
- * This method is only called by notifications when adding an action button
- * {@link android.app.Notification}
- *
- * @param viewId The id of the view that will trigger the {@link PendingIntent} when clicked
- * @param pendingIntent The {@link PendingIntent} to send when user clicks
- * @param whether notification is tombstone, but mainly used to indicate that the new
- * SetOnClickPendingIntent knows that a notification is calling.
- *
- * @hide
- */
- public void setOnClickPendingIntent(int viewId,
- PendingIntent pendingIntent, boolean tombstone) {
- if (tombstone) return;
- addAction(new SetOnClickPendingIntent(viewId, pendingIntent, true));
- }
-
/**
* When using collections (eg. {@link ListView}, {@link StackView} etc.) in widgets, it is very
* costly to set PendingIntents on the individual items, and is hence not permitted. Instead
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index 8557ff9ac306..1f381791f4a2 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -1,4 +1,4 @@
-/**
+ /**
* Copyright (c) 2007, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,8 +46,6 @@ oneway interface IStatusBar
void cancelPreloadRecentApps();
void setAutoRotate(boolean enabled);
void showCustomIntentAfterKeyguard(inout Intent intent);
- void hideHeadsUpCandidate(String packageName);
- void scheduleHeadsUpClose();
void toggleScreenshot();
void toggleLastApp();
void toggleKillApp();
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index b45fc7df13a0..045257eef139 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -62,8 +62,6 @@ interface IStatusBarService
void cancelPreloadRecentApps();
void setAutoRotate(boolean enabled);
void showCustomIntentAfterKeyguard(inout Intent intent);
- void hideHeadsUpCandidate(String packageName);
- void scheduleHeadsUpClose();
void toggleScreenshot();
void toggleLastApp();
void toggleKillApp();
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index 6f104dd0eb24..079aa4f9aee1 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -78,4 +78,5 @@ interface IInputMethodManager {
void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes);
int getInputMethodWindowVisibleHeight();
oneway void notifyUserAction(int sequenceNumber);
+ boolean isImeShowing();
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index eb0ef389ff37..67001d326ec4 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2317,14 +2317,6 @@
android:description="@string/permdesc_changeComponentState"
android:protectionLevel="signature|system" />
-
-
-
Turn Wi-Fi AP off
-
- enable or disable heads up
- Allows the application to change whether another application is allowed to show normal notifications as heads up notification.
+
+ access torch service
+
+ Allows an app to access the torch service. Should never be needed for normal apps.
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 317579179357..35b7001889b2 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -197,6 +197,12 @@
1
+
+
+
+
+
+
%1$s %2$s
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 67a259bba6d3..30fcca255906 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2273,6 +2273,18 @@ private void loadVibrateWhenRingingSetting(SQLiteDatabase db) {
}
}
+ private void loadHeadsUpSetting(SQLiteStatement stmt) {
+ String dndValues = mContext.getResources()
+ .getString(R.string.def_heads_up_notification_dnd_values);
+ String blackListValues = mContext.getResources()
+ .getString(R.string.def_heads_up_notification_blacklist_values);
+ if (!TextUtils.isEmpty(dndValues)) {
+ loadSetting(stmt, Settings.System.HEADS_UP_NOTIFICATION, "0");
+ loadSetting(stmt, Settings.System.HEADS_UP_CUSTOM_VALUES, dndValues);
+ loadSetting(stmt, Settings.System.HEADS_UP_BLACKLIST_VALUES, blackListValues);
+ }
+ }
+
private void loadSettings(SQLiteDatabase db) {
loadSystemSettings(db);
loadSecureSettings(db);
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index def0c067b2b1..f0bcfd86e59f 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -115,9 +115,6 @@
-
-
-
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_heads_up.png b/packages/SystemUI/res/drawable-hdpi/ic_heads_up.png
deleted file mode 100644
index c6721fe24dfa..000000000000
Binary files a/packages/SystemUI/res/drawable-hdpi/ic_heads_up.png and /dev/null differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_heads_up.png b/packages/SystemUI/res/drawable-mdpi/ic_heads_up.png
deleted file mode 100644
index 439e7adbf1d4..000000000000
Binary files a/packages/SystemUI/res/drawable-mdpi/ic_heads_up.png and /dev/null differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_heads_up.png b/packages/SystemUI/res/drawable-xhdpi/ic_heads_up.png
deleted file mode 100644
index 6e33da807ca1..000000000000
Binary files a/packages/SystemUI/res/drawable-xhdpi/ic_heads_up.png and /dev/null differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_heads_up.png b/packages/SystemUI/res/drawable-xxhdpi/ic_heads_up.png
deleted file mode 100644
index d046af823b63..000000000000
Binary files a/packages/SystemUI/res/drawable-xxhdpi/ic_heads_up.png and /dev/null differ
diff --git a/packages/SystemUI/res/drawable/ic_heads_up_snooze.xml b/packages/SystemUI/res/drawable/ic_heads_up_snooze.xml
deleted file mode 100644
index 4a62ded9a3a3..000000000000
--- a/packages/SystemUI/res/drawable/ic_heads_up_snooze.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
diff --git a/packages/SystemUI/res/layout/heads_up.xml b/packages/SystemUI/res/layout/heads_up.xml
index 4da5bcaab73d..61a1104f67ad 100644
--- a/packages/SystemUI/res/layout/heads_up.xml
+++ b/packages/SystemUI/res/layout/heads_up.xml
@@ -14,12 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+
-
-
-
-
-
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml
index 58b45d35aa14..d52c27465dbb 100644
--- a/packages/SystemUI/res/layout/notification_guts.xml
+++ b/packages/SystemUI/res/layout/notification_guts.xml
@@ -86,16 +86,6 @@
android:visibility="gone"
/>
-
-
700
-
- 300000
-
1
diff --git a/packages/SystemUI/res/values/slim_strings.xml b/packages/SystemUI/res/values/slim_strings.xml
index bdeacb0f4359..af00d0ad8c0b 100644
--- a/packages/SystemUI/res/values/slim_strings.xml
+++ b/packages/SystemUI/res/values/slim_strings.xml
@@ -22,12 +22,6 @@
Delete
Screenshot deleted.
-
- Heads up is disabled for %d minutes.
- Snooze heads up
- Enable heads up for this application
- Disable heads up for this application
-
%d~
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 21e8fd578bae..f6b6b4859a66 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -31,6 +31,7 @@
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
+import android.content.ContentResolver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
@@ -45,6 +46,7 @@
import android.database.ContentObserver;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
@@ -81,6 +83,7 @@
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AnimationUtils;
+import android.view.inputmethod.InputMethodManager;
import android.widget.DateTimeView;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -140,8 +143,9 @@ public abstract class BaseStatusBar extends SystemUI implements
protected static final int MSG_TOGGLE_KILL_APP = 1034;
protected static final int MSG_TOGGLE_SCREENSHOT = 1035;
+ protected static final boolean ENABLE_HEADS_UP = true;
// scores above this threshold should be displayed in heads up mode.
- protected static final int INTERRUPTION_THRESHOLD = 10;
+ protected static final int INTERRUPTION_THRESHOLD = 1;
protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up";
// Should match the value in PhoneWindowManager
@@ -185,12 +189,10 @@ public abstract class BaseStatusBar extends SystemUI implements
private Locale mLocale;
private float mFontScale;
+ protected boolean mUseHeadsUp = false;
+ protected boolean mHeadsUpTicker = false;
protected boolean mDisableNotificationAlerts = false;
- private int mHeadsUpSnoozeTime;
- private long mHeadsUpSnoozeStartTime;
- protected String mHeadsUpPackageName;
-
protected DevicePolicyManager mDevicePolicyManager;
protected IDreamManager mDreamManager;
PowerManager mPowerManager;
@@ -228,6 +230,9 @@ public abstract class BaseStatusBar extends SystemUI implements
protected int mZenMode;
+ private ArrayList mDndList;
+ private ArrayList mBlacklist;
+
// which notification is currently being longpress-examined by the user
private NotificationGuts mNotificationGutsExposed;
@@ -249,6 +254,10 @@ public boolean isDeviceProvisioned() {
return mDeviceProvisioned;
}
+ public Handler getHandler() {
+ return mHandler != null ? mHandler : createHandler();
+ }
+
protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
@@ -277,6 +286,38 @@ public void onChange(boolean selfChange) {
}
};
+ private class SettingsObserver extends ContentObserver {
+ public SettingsObserver(Handler handler) {
+ super(handler);
+ }
+
+ public void observe() {
+ ContentResolver resolver = mContext.getContentResolver();
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HEADS_UP_CUSTOM_VALUES),
+ false, this);
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HEADS_UP_BLACKLIST_VALUES),
+ false, this);
+ update();
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ update();
+ }
+
+ private void update() {
+ ContentResolver resolver = mContext.getContentResolver();
+ final String dndString = Settings.System.getString(mContext.getContentResolver(),
+ Settings.System.HEADS_UP_CUSTOM_VALUES);
+ final String blackString = Settings.System.getString(mContext.getContentResolver(),
+ Settings.System.HEADS_UP_BLACKLIST_VALUES);
+ splitAndAddToArrayList(mDndList, dndString, "\\|");
+ splitAndAddToArrayList(mBlacklist, blackString, "\\|");
+ }
+ };
+
private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
@Override
public boolean onClickHandler(
@@ -478,6 +519,12 @@ public void start() {
ServiceManager.checkService(DreamService.DREAM_SERVICE));
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+ mDndList = new ArrayList();
+ mBlacklist = new ArrayList();
+
+ SettingsObserver observer = new SettingsObserver(mHandler);
+ observer.observe();
+
mSettingsObserver.onChange(false); // set up
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
@@ -822,8 +869,6 @@ private void inflateGuts(ExpandableNotificationRow row) {
final View settingsButton = guts.findViewById(R.id.notification_inspect_item);
final View appSettingsButton
= guts.findViewById(R.id.notification_inspect_app_provided_settings);
- final View headsUpButton
- = guts.findViewById(R.id.notification_inspect_heads_up);
if (appUid >= 0) {
final int appUidF = appUid;
settingsButton.setOnClickListener(new View.OnClickListener() {
@@ -857,62 +902,11 @@ public void onClick(View v) {
} else {
appSettingsButton.setVisibility(View.GONE);
}
-
- if (isThisASystemPackage(pkg, pmUser)) {
- headsUpButton.setVisibility(View.GONE);
- } else {
- boolean isHeadsUpEnabled = mNoMan.getHeadsUpNotificationsEnabledForPackage(
- pkg, appUidF) != Notification.HEADS_UP_NEVER;
- headsUpButton.setAlpha(isHeadsUpEnabled ? 1f : 0.5f);
- setHeadsUpButtonContentDescription((View) headsUpButton, isHeadsUpEnabled);
- headsUpButton.setVisibility(View.VISIBLE);
- headsUpButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- int headsUp =
- mNoMan.getHeadsUpNotificationsEnabledForPackage(pkg, appUidF);
-
- if (headsUp != Notification.HEADS_UP_NEVER) {
- headsUp = Notification.HEADS_UP_NEVER;
- ((ImageButton) v).setAlpha(0.5f);
- } else {
- headsUp = Notification.HEADS_UP_ALLOWED;
- ((ImageButton) v).setAlpha(1f);
- }
- setHeadsUpButtonContentDescription(
- v, headsUp != Notification.HEADS_UP_NEVER);
- mNoMan.setHeadsUpNotificationsEnabledForPackage(pkg, appUidF, headsUp);
- }
- });
- }
} else {
settingsButton.setVisibility(View.GONE);
appSettingsButton.setVisibility(View.GONE);
- headsUpButton.setVisibility(View.GONE);
- }
-
- }
-
- private void setHeadsUpButtonContentDescription(View v, boolean enabled) {
- if (v == null) return;
- if (enabled) {
- v.setContentDescription(mContext.getString(
- R.string.notification_inspect_heads_up_title_disabled));
- } else {
- v.setContentDescription(mContext.getString(
- R.string.notification_inspect_heads_up_title_enabled));
}
- }
- private boolean isThisASystemPackage(String packageName, PackageManager pm) {
- try {
- PackageInfo packageInfo = pm.getPackageInfo(packageName,
- PackageManager.GET_SIGNATURES);
- PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
- return (packageInfo != null && packageInfo.signatures != null &&
- sys.signatures[0].equals(packageInfo.signatures[0]));
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
}
protected SwipeHelper.LongPressListener getNotificationLongClicker() {
@@ -1206,6 +1200,7 @@ public void onVisibilityChanged(boolean visible) {
}
public abstract void resetHeadsUpDecayTimer();
+ public abstract void hideHeadsUp();
public abstract void scheduleHeadsUpOpen();
@@ -1879,6 +1874,7 @@ public abstract void addNotification(StatusBarNotification notification,
RankingMap ranking);
protected abstract void updateNotificationRanking(RankingMap ranking);
public abstract void removeNotification(String key, RankingMap ranking);
+ public abstract boolean isExpandedVisible();
public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");
@@ -2131,36 +2127,6 @@ private boolean alertAgain(Entry oldEntry, Notification newNotification) {
|| (newNotification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == 0;
}
- public void snoozeHeadsUp() {
- scheduleHeadsUpClose();
- mHeadsUpSnoozeStartTime = System.currentTimeMillis();
- Toast.makeText(mContext,
- mContext.getString(R.string.heads_up_snooze_message,
- mHeadsUpSnoozeTime / 60 / 1000), Toast.LENGTH_LONG).show();
- }
-
- protected boolean isHeadsUpInSnooze() {
- return (mHeadsUpSnoozeStartTime + mHeadsUpSnoozeTime - System.currentTimeMillis()) > 0;
- }
-
- protected void setHeadsUpSnoozeTime(int snoozeTime) {
- mHeadsUpSnoozeTime = snoozeTime;
- }
-
- protected void resetHeadsUpSnoozeTimer() {
- mHeadsUpSnoozeStartTime = 0;
- }
-
- @Override // CommandQueue
- public void hideHeadsUpCandidate(String packageName) {
- // Activity stack notifies us that probably the the current heads up
- // is from the package which is opening now. If this is the case hide
- // our heads up immediatelly to do not disturb the workflow.
- if (mHeadsUpPackageName != null && mHeadsUpPackageName.equals(packageName)) {
- scheduleHeadsUpClose();
- }
- }
-
protected boolean shouldInterrupt(StatusBarNotification sbn) {
if (mNotificationData.shouldFilterOut(sbn)) {
if (DEBUG) {
@@ -2169,10 +2135,12 @@ protected boolean shouldInterrupt(StatusBarNotification sbn) {
return false;
}
Notification notification = sbn.getNotification();
- // we are snoozing
- if (isHeadsUpInSnooze()) {
+
+ // check if notification from the package is blacklisted first
+ if (isPackageBlacklisted(sbn.getPackageName())) {
return false;
}
+
// some predicates to make the boolean logic legible
boolean isNoisy = (notification.defaults & Notification.DEFAULT_SOUND) != 0
|| (notification.defaults & Notification.DEFAULT_VIBRATE) != 0
@@ -2180,52 +2148,86 @@ protected boolean shouldInterrupt(StatusBarNotification sbn) {
|| notification.vibrate != null;
boolean isHighPriority = sbn.getScore() >= INTERRUPTION_THRESHOLD;
boolean isFullscreen = notification.fullScreenIntent != null;
+ boolean hasTicker = mHeadsUpTicker && !TextUtils.isEmpty(notification.tickerText);
int asHeadsUp = notification.extras.getInt(Notification.EXTRA_AS_HEADS_UP,
Notification.HEADS_UP_ALLOWED);
boolean isAllowed = asHeadsUp != Notification.HEADS_UP_NEVER;
+ boolean isOngoing = sbn.isOngoing();
boolean accessibilityForcesLaunch = isFullscreen
&& mAccessibilityManager.isTouchExplorationEnabled();
+
final KeyguardTouchDelegate keyguard = KeyguardTouchDelegate.getInstance(mContext);
boolean keyguardIsShowing = keyguard.isShowingAndNotOccluded()
&& keyguard.isInputRestricted();
- boolean interrupt = (isFullscreen || (isHighPriority && isNoisy)
+ boolean interrupt = (isFullscreen || (isHighPriority && (isNoisy || hasTicker))
|| asHeadsUp == Notification.HEADS_UP_REQUESTED)
&& isAllowed
&& !accessibilityForcesLaunch
&& mPowerManager.isScreenOn()
- && !keyguardIsShowing;
-
- if (!interrupt) {
- boolean isHeadsUpPackage = mNoMan.getHeadsUpNotificationsEnabledForPackage(
- sbn.getPackageName(), sbn.getUid()) != Notification.HEADS_UP_NEVER;
-
- boolean isExpanded = false;
- if (mStackScroller != null) {
- isExpanded = mStackScroller.getIsExpanded();
- }
- // Possibly a heads up package set from the user.
- interrupt = isHeadsUpPackage
- && !sbn.isOngoing()
- && mPowerManager.isScreenOn()
- && !accessibilityForcesLaunch
- && !isExpanded
- && !keyguardIsShowing;
-
- if (interrupt) {
- mHeadsUpPackageName = sbn.getPackageName();
- }
- }
+ && !keyguardIsShowing
+ && !isImeShowing();;
try {
interrupt = interrupt && !mDreamManager.isDreaming();
} catch (RemoteException e) {
Log.d(TAG, "failed to query dream manager", e);
}
+
+ // its below our threshold priority, we might want to always display
+ // notifications from certain apps
+ if (!isHighPriority && !isOngoing && !keyguardIsShowing) {
+ // However, we don't want to interrupt if we're in an application that is
+ // in Do Not Disturb
+ if (!isPackageInDnd(getTopLevelPackage())) {
+ return true;
+ }
+ }
+
if (DEBUG) Log.d(TAG, "interrupt: " + interrupt);
return interrupt;
}
+ private String getTopLevelPackage() {
+ final ActivityManager am = (ActivityManager)
+ mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ List taskInfo = am.getRunningTasks(1);
+ ComponentName componentInfo = taskInfo.get(0).topActivity;
+ return componentInfo.getPackageName();
+ }
+
+ private boolean isPackageInDnd(String packageName) {
+ return mDndList.contains(packageName);
+ }
+
+ private boolean isPackageBlacklisted(String packageName) {
+ return mBlacklist.contains(packageName);
+ }
+
+ private void splitAndAddToArrayList(ArrayList arrayList,
+ String baseString, String separator) {
+ // clear first
+ if (arrayList != null) {
+ arrayList.clear();
+ if (baseString != null) {
+ final String[] array = TextUtils.split(baseString, separator);
+ for (String item : array) {
+ arrayList.add(item.trim());
+ }
+ }
+ }
+ }
+
+ /**
+ * @return Whether IME input is showing.
+ */
+ public boolean isImeShowing() {
+ final InputMethodManager inputMethodManager = (InputMethodManager)
+ mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+
+ return inputMethodManager != null ? inputMethodManager.isImeShowing() : false;
+ }
+
public boolean inKeyguardRestrictedInputMode() {
return KeyguardTouchDelegate.getInstance(mContext).isInputRestricted();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index c2c0b06d97cf..3456b179fae4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -59,11 +59,10 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_NOTIFICATION_LIGHT_PULSE = 17 << MSG_SHIFT;
private static final int MSG_SET_AUTOROTATE_STATUS = 18 << MSG_SHIFT;
private static final int MSG_START_CUSTOM_INTENT_AFTER_KEYGUARD = 19 << MSG_SHIFT;
- private static final int MSG_HIDE_HEADS_UP_CANDIDATE = 20 << MSG_SHIFT;
- private static final int MSG_HIDE_HEADS_UP = 21 << MSG_SHIFT;
- private static final int MSG_TOGGLE_LAST_APP = 22 << MSG_SHIFT;
- private static final int MSG_TOGGLE_KILL_APP = 23 << MSG_SHIFT;
- private static final int MSG_TOGGLE_SCREENSHOT = 24 << MSG_SHIFT;
+ private static final int MSG_HIDE_HEADS_UP = 20 << MSG_SHIFT;
+ private static final int MSG_TOGGLE_LAST_APP = 21 << MSG_SHIFT;
+ private static final int MSG_TOGGLE_KILL_APP = 22 << MSG_SHIFT;
+ private static final int MSG_TOGGLE_SCREENSHOT = 23 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -106,10 +105,9 @@ public void setImeWindowStatus(IBinder token, int vis, int backDisposition,
public void buzzBeepBlinked();
public void notificationLightOff();
public void notificationLightPulse(int argb, int onMillis, int offMillis);
+ public void scheduleHeadsUpClose();
public void setAutoRotate(boolean enabled);
public void showCustomIntentAfterKeyguard(Intent intent);
- public void hideHeadsUpCandidate(String packageName);
- public void scheduleHeadsUpClose();
public void toggleLastApp();
public void toggleKillApp();
public void toggleScreenshot();
@@ -271,14 +269,6 @@ public void showCustomIntentAfterKeyguard(Intent intent) {
}
}
- public void hideHeadsUpCandidate(String packageName) {
- synchronized (mList) {
- mHandler.removeMessages(MSG_HIDE_HEADS_UP_CANDIDATE);
- mHandler.obtainMessage(MSG_HIDE_HEADS_UP_CANDIDATE,
- 0, 0, packageName).sendToTarget();
- }
- }
-
public void scheduleHeadsUpClose() {
synchronized (mList) {
mHandler.removeMessages(MSG_HIDE_HEADS_UP);
@@ -386,18 +376,15 @@ public void handleMessage(Message msg) {
case MSG_NOTIFICATION_LIGHT_PULSE:
mCallbacks.notificationLightPulse((Integer) msg.obj, msg.arg1, msg.arg2);
break;
+ case MSG_HIDE_HEADS_UP:
+ mCallbacks.scheduleHeadsUpClose();
+ break;
case MSG_SET_AUTOROTATE_STATUS:
mCallbacks.setAutoRotate(msg.arg1 != 0);
break;
case MSG_START_CUSTOM_INTENT_AFTER_KEYGUARD:
mCallbacks.showCustomIntentAfterKeyguard((Intent) msg.obj);
break;
- case MSG_HIDE_HEADS_UP_CANDIDATE:
- mCallbacks.hideHeadsUpCandidate((String) msg.obj);
- break;
- case MSG_HIDE_HEADS_UP:
- mCallbacks.scheduleHeadsUpClose();
- break;
case MSG_TOGGLE_LAST_APP:
mCallbacks.toggleLastApp();
break;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 7cf2eb8f97c5..beb9885e9c3e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -424,14 +424,16 @@ void observe() {
Settings.System.STATUS_BAR_TICKER_ENABLED),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.HEADS_UP_NOTIFCATION_DECAY),
+ Settings.System.BATTERY_SAVER_MODE_COLOR),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.HEADS_UP_SNOOZE_TIME),
- false, this, UserHandle.USER_ALL);
+ Settings.System.HEADS_UP_DISMISS_ON_REMOVE), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.BATTERY_SAVER_MODE_COLOR),
+ Settings.System.HEADS_UP_NOTIFCATION_DECAY),
false, this, UserHandle.USER_ALL);
+ resolver.registerContentObserver(Settings.System.getUriFor(
+ Settings.System.HEADS_UP_TOUCH_OUTSIDE),
+ false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT),
false, this, UserHandle.USER_ALL);
@@ -441,38 +443,19 @@ void observe() {
update();
}
+ void unobserve() {
+ ContentResolver resolver = mContext.getContentResolver();
+ resolver.unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ update();
+ }
+
@Override
public void onChange(boolean selfChange, Uri uri) {
if (uri.equals(Settings.System.getUriFor(
- Settings.System.HEADS_UP_SNOOZE_TIME))) {
- final int snoozeTime = Settings.System.getIntForUser(
- mContext.getContentResolver(),
- Settings.System.HEADS_UP_SNOOZE_TIME,
- mContext.getResources().getInteger(
- R.integer.heads_up_snooze_time),
- UserHandle.USER_CURRENT);
- setHeadsUpSnoozeTime(snoozeTime);
- if (mHeadsUpNotificationView != null) {
- mHeadsUpNotificationView.setSnoozeVisibility(snoozeTime != 0);
- }
- } else if (uri.equals(Settings.System.getUriFor(
- Settings.System.HEADS_UP_NOTIFCATION_DECAY))) {
- mHeadsUpNotificationDecay = Settings.System.getIntForUser(
- mContext.getContentResolver(),
- Settings.System.HEADS_UP_NOTIFCATION_DECAY,
- mContext.getResources().getInteger(
- R.integer.heads_up_notification_decay),
- UserHandle.USER_CURRENT);
- resetHeadsUpDecayTimer();
- } else if (uri.equals(Settings.System.getUriFor(
- Settings.System.HEADS_UP_NOTIFCATION_DECAY))) {
- mTickerEnabled = Settings.System.getIntForUser(
- mContext.getContentResolver(),
- Settings.System.STATUS_BAR_TICKER_ENABLED,
- mContext.getResources().getBoolean(R.bool.enable_ticker)
- ? 1 : 0, UserHandle.USER_CURRENT) == 1;
- initTickerView();
- } else if (uri.equals(Settings.System.getUriFor(
Settings.System.BATTERY_SAVER_MODE_COLOR))) {
mBatterySaverWarningColor = Settings.System.getIntForUser(
mContext.getContentResolver(),
@@ -489,6 +472,15 @@ public void onChange(boolean selfChange, Uri uri) {
mBatteryView.updateBatteryIconSettings();
mHeader.updateBatteryIconSettings();
mKeyguardStatusBar.updateBatteryIconSettings();
+ } else if (uri.equals(Settings.System.getUriFor(
+ Settings.System.HEADS_UP_NOTIFCATION_DECAY))) {
+ mHeadsUpNotificationDecay = Settings.System.getIntForUser(
+ mContext.getContentResolver(),
+ Settings.System.HEADS_UP_NOTIFCATION_DECAY,
+ mContext.getResources().getInteger(
+ R.integer.heads_up_notification_decay),
+ UserHandle.USER_CURRENT);
+ resetHeadsUpDecayTimer();
}
update();
}
@@ -505,6 +497,13 @@ public void update() {
loadShowBatteryTextSetting();
updateBatteryLevelText();
mBatteryLevel.setVisibility(mShowBatteryText ? View.VISIBLE : View.GONE);
+
+ mHeadsUpSwype = Settings.System.getInt(
+ resolver, Settings.System.HEADS_UP_DISMISS_ON_REMOVE, 0) == 1;
+
+ mHeadsUpTouchOutside = Settings.System.getInt(
+ resolver, Settings.System.HEADS_UP_TOUCH_OUTSIDE, 0) == 1;
+
}
}
@@ -565,6 +564,29 @@ public void onChange(boolean selfChange) {
}
};
+ final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ boolean wasUsing = mUseHeadsUp;
+ mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts && Settings.System.getIntForUser(
+ mContext.getContentResolver(),
+ Settings.System.HEADS_UP_NOTIFICATION, 0, UserHandle.USER_CURRENT) == 1;
+ mHeadsUpTicker = mUseHeadsUp && 0 != Settings.Global.getInt(
+ mContext.getContentResolver(), SETTING_HEADS_UP_TICKER, 0);
+ Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
+ if (wasUsing != mUseHeadsUp) {
+ if (!mUseHeadsUp) {
+ Log.d(TAG, "dismissing any existing heads up notification on disable event");
+ setHeadsUpVisibility(false);
+ mHeadsUpNotificationView.release();
+ removeHeadsUpView();
+ } else {
+ addHeadsUpView();
+ }
+ }
+ }
+ };
+
private int mInteractingWindows;
private boolean mAutohideSuspended;
private int mStatusBarMode;
@@ -605,6 +627,9 @@ public void run() {
private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER);
+ private boolean mHeadsUpSwype;
+ public boolean mHeadsUpTouchOutside;
+
private MediaSessionManager mMediaSessionManager;
private MediaController mMediaController;
private String mMediaNotificationKey;
@@ -750,11 +775,14 @@ public void start() {
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController);
mSettingsObserver.onChange(false); // set up
- // If system disabled system wide notification alert
- // we do not add the view here and will do it later
- // when StatusBarManager notifies us that the state has changed.
- if (!mDisableNotificationAlerts) {
- addHeadsUpView();
+ mHeadsUpObserver.onChange(true); // set up
+ if (ENABLE_HEADS_UP) {
+ mContext.getContentResolver().registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HEADS_UP_NOTIFICATION), true,
+ mHeadsUpObserver, mCurrentUserId);
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true,
+ mHeadsUpObserver);
}
mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
@@ -817,24 +845,20 @@ public boolean onTouch(View v, MotionEvent event) {
R.color.notification_panel_solid_background)));
}
- mHeadsUpNotificationView =
- (HeadsUpNotificationView) View.inflate(context, R.layout.heads_up, null);
-
- mHeadsUpNotificationView.setVisibility(View.GONE);
- mHeadsUpNotificationView.setBar(this);
- mHeadsUpNotificationDecay = Settings.System.getIntForUser(
- mContext.getContentResolver(),
- Settings.System.HEADS_UP_NOTIFCATION_DECAY,
- res.getInteger(R.integer.heads_up_notification_decay),
- UserHandle.USER_CURRENT);
- final int snoozeTime = Settings.System.getIntForUser(
- mContext.getContentResolver(),
- Settings.System.HEADS_UP_SNOOZE_TIME,
- res.getInteger(R.integer.heads_up_snooze_time),
- UserHandle.USER_CURRENT);
- setHeadsUpSnoozeTime(snoozeTime);
- mHeadsUpNotificationView.setSnoozeVisibility(snoozeTime != 0);
+ if (ENABLE_HEADS_UP) {
+ mHeadsUpNotificationView =
+ (HeadsUpNotificationView) View.inflate(context, R.layout.heads_up, null);
+ mHeadsUpNotificationView.setVisibility(View.GONE);
+ mHeadsUpNotificationView.setBar(this);
+ mHeadsUpNotificationView.setVisibility(View.GONE);
+ mHeadsUpNotificationView.setBar(this);
+ mHeadsUpNotificationDecay = Settings.System.getIntForUser(
+ mContext.getContentResolver(),
+ Settings.System.HEADS_UP_NOTIFCATION_DECAY,
+ res.getInteger(R.integer.heads_up_notification_decay),
+ UserHandle.USER_CURRENT);
+ }
if (MULTIUSER_DEBUG) {
mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(
R.id.header_debug_info);
@@ -1416,35 +1440,34 @@ private WindowManager.LayoutParams getNavigationBarLayoutParams() {
}
private void addHeadsUpView() {
- if (!mHeadsUpViewAttached) {
- int headsUpHeight = mContext.getResources()
- .getDimensionPixelSize(R.dimen.heads_up_window_height);
- WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
- LayoutParams.MATCH_PARENT, headsUpHeight,
- WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
- WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
- | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
- | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
- | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
- | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
- PixelFormat.TRANSLUCENT);
- lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
- lp.gravity = Gravity.TOP;
- lp.setTitle("Heads Up");
- lp.packageName = mContext.getPackageName();
- lp.windowAnimations = R.style.Animation_StatusBar_HeadsUp;
-
- mWindowManager.addView(mHeadsUpNotificationView, lp);
- mHeadsUpViewAttached = true;
+ if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
+ return;
}
+
+ int headsUpHeight = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.heads_up_window_height);
+ WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ LayoutParams.MATCH_PARENT, headsUpHeight,
+ WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
+ | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
+ PixelFormat.TRANSLUCENT);
+ lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+ lp.gravity = Gravity.TOP;
+ lp.setTitle("Heads Up");
+ lp.packageName = mContext.getPackageName();
+ lp.windowAnimations = R.style.Animation_StatusBar_HeadsUp;
+
+ mWindowManager.addView(mHeadsUpNotificationView, lp);
}
private void removeHeadsUpView() {
- if (mHeadsUpViewAttached) {
- mWindowManager.removeView(mHeadsUpNotificationView);
- mHeadsUpViewAttached = false;
- }
+ mWindowManager.removeView(mHeadsUpNotificationView);
}
public void refreshAllStatusBarIcons() {
@@ -1499,7 +1522,7 @@ public UserHandle getCurrentUserHandle() {
@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey());
- if (!mDisableNotificationAlerts && shouldInterrupt(notification)) {
+ if (mUseHeadsUp && shouldInterrupt(notification) && !isExpandedVisible()) {
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
Entry interruptionCandidate = new Entry(notification, null);
ViewGroup holder = mHeadsUpNotificationView.getHolder();
@@ -1558,20 +1581,25 @@ public void displayNotificationFromHeadsUp(StatusBarNotification notification) {
@Override
public void resetHeadsUpDecayTimer() {
mHandler.removeMessages(MSG_DECAY_HEADS_UP);
- if (!mDisableNotificationAlerts && mHeadsUpNotificationDecay > 0
+ if (mUseHeadsUp && mHeadsUpNotificationDecay > 0
&& mHeadsUpNotificationView.isClearable()) {
mHandler.sendEmptyMessageDelayed(MSG_DECAY_HEADS_UP, mHeadsUpNotificationDecay);
}
}
+ @Override
+ public void hideHeadsUp() {
+ mHandler.removeMessages(MSG_HIDE_HEADS_UP);
+ mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
+ }
+
@Override
public void scheduleHeadsUpOpen() {
mHandler.sendEmptyMessage(MSG_SHOW_HEADS_UP);
}
- @Override // CommandQueue
+ @Override
public void scheduleHeadsUpClose() {
- mHandler.removeMessages(MSG_HIDE_HEADS_UP);
mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
}
@@ -1588,7 +1616,7 @@ protected void updateNotificationRanking(RankingMap ranking) {
@Override
public void removeNotification(String key, RankingMap ranking) {
- if (mHeadsUpNotificationView.getEntry() != null
+ if (ENABLE_HEADS_UP && mHeadsUpNotificationView.getEntry() != null
&& key.equals(mHeadsUpNotificationView.getEntry().notification.getKey())) {
mHeadsUpNotificationView.clear();
}
@@ -2256,6 +2284,7 @@ public void disable(int state, boolean animate) {
if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
if ((state & StatusBarManager.DISABLE_EXPAND) != 0) {
animateCollapsePanels();
+ hideHeadsUp();
}
}
@@ -2285,21 +2314,9 @@ public void disable(int state, boolean animate) {
}
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) {
- boolean wasDisabled = mDisableNotificationAlerts;
mDisableNotificationAlerts =
(state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
-
- if (wasDisabled != mDisableNotificationAlerts) {
- if (mDisableNotificationAlerts) {
- if (DEBUG) Log.d(TAG, "dismissing any existing heads"
- + "up notification on disable event");
- setHeadsUpVisibility(false);
- mHeadsUpNotificationView.release();
- removeHeadsUpView();
- } else {
- addHeadsUpView();
- }
- }
+ mHeadsUpObserver.onChange(true);
}
}
@@ -2470,6 +2487,11 @@ boolean panelsEnabled() {
return (mDisabled & StatusBarManager.DISABLE_EXPAND) == 0;
}
+ @Override
+ public boolean isExpandedVisible() {
+ return mExpandedVisible;
+ }
+
void makeExpandedVisible(boolean force) {
if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible);
if (!force && (mExpandedVisible || !panelsEnabled())) {
@@ -2545,6 +2567,17 @@ public void animateCollapsePanels(int flags, boolean force) {
mStatusBarWindow.cancelExpandHelper();
mStatusBarView.collapseAllPanels(true);
}
+
+ if(mHeadsUpTouchOutside) {
+ // Hide HeadsUp if is showing when animateCollapsePanels() is called,
+ // i.e. within home button pressing.
+ // Hide after 0.5 sec from pressing home button.
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ scheduleHeadsUpClose();
+ }
+ }, 500);
+ }
}
private void runPostCollapseRunnables() {
@@ -3250,6 +3283,8 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.print(" mDozing="); pw.println(mDozing);
pw.print(" mZenMode=");
pw.println(Settings.Global.zenModeToString(mZenMode));
+ pw.print(" mUseHeadsUp=");
+ pw.println(mUseHeadsUp);
pw.print(" interrupting package: ");
pw.println(hunStateToString(mHeadsUpNotificationView.getEntry()));
dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions());
@@ -3455,7 +3490,6 @@ else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
finishBarAnimations();
stopNotificationLogging();
resetUserExpandedStates();
- resetHeadsUpSnoozeTimer();
}
else if (Intent.ACTION_SCREEN_ON.equals(action)) {
mScreenOn = true;
@@ -3571,28 +3605,27 @@ private void resetUserSetupObserver() {
}
private void setHeadsUpVisibility(boolean vis) {
+ if (!ENABLE_HEADS_UP) return;
if (DEBUG) Log.v(TAG, (vis ? "showing" : "hiding") + " heads up window");
EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_STATUS,
vis ? mHeadsUpNotificationView.getKey() : "",
vis ? 1 : 0);
- mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
- if (!vis) {
- mHeadsUpPackageName = null;
+ if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
+ mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
}
}
public void onHeadsUpDismissed(boolean direction) {
- // If direction == true we know that the notification
- // was dismissed to the right. So we just hide it that
- // the notification will stay in our notification
- // drawer. Left swipe as usual dismisses the notification
+ // If mHeadsUpSwype == true we know that the notification
+ // has to be hidden so it will stay in our notification
+ // drawer. Else as usual dismisses the notification
// completely if the notification is clearable.
- if (direction) {
+ if (mHeadsUpSwype) {
scheduleHeadsUpClose();
} else {
mHeadsUpNotificationView.dismiss();
}
- }
+ }
/**
* Reload some of our resources when the configuration changes.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index e44a7780d4d1..d713ac96c847 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -22,7 +22,6 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
-import android.view.animation.Interpolator;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -30,8 +29,7 @@
import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
-import android.widget.LinearLayout;
-import android.widget.ImageButton;
+import android.widget.FrameLayout;
import com.android.systemui.ExpandHelper;
import com.android.systemui.Gefingerpoken;
@@ -41,7 +39,7 @@
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
-public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper.Callback, ExpandHelper.Callback,
+public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.Callback, ExpandHelper.Callback,
ViewTreeObserver.OnComputeInternalInsetsListener {
private static final String TAG = "HeadsUpNotificationView";
private static final boolean DEBUG = false;
@@ -60,13 +58,11 @@ public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper
private long mStartTouchTime;
private ViewGroup mContentHolder;
- private ViewGroup mBelowContentContainer;
- private ImageButton mSnoozeButton;
- private boolean mIsSnoozeButtonNowVisible;
- private boolean mSnoozeButtonVisibility;
private NotificationData.Entry mHeadsUp;
+ private boolean mTouchOutside;
+
public HeadsUpNotificationView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -78,18 +74,10 @@ public HeadsUpNotificationView(Context context, AttributeSet attrs, int defStyle
}
public void updateResources() {
- final int width = getResources().getDimensionPixelSize(R.dimen.notification_panel_width);
- final int gravity = getResources().getInteger(R.integer.notification_panel_layout_gravity);
- if (mBelowContentContainer != null) {
- final LayoutParams lp = (LayoutParams) mBelowContentContainer.getLayoutParams();
- lp.width = width;
- lp.gravity = gravity;
- mBelowContentContainer.setLayoutParams(lp);
- }
if (mContentHolder != null) {
final LayoutParams lp = (LayoutParams) mContentHolder.getLayoutParams();
- lp.width = width;
- lp.gravity = gravity;
+ lp.width = getResources().getDimensionPixelSize(R.dimen.notification_panel_width);
+ lp.gravity = getResources().getInteger(R.integer.notification_panel_layout_gravity);
mContentHolder.setLayoutParams(lp);
}
}
@@ -98,13 +86,6 @@ public void setBar(PhoneStatusBar bar) {
mBar = bar;
}
- public void setSnoozeVisibility(boolean show) {
- mSnoozeButtonVisibility = show;
- if (mSnoozeButton != null) {
- mSnoozeButton.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- }
-
public ViewGroup getHolder() {
return mContentHolder;
}
@@ -116,19 +97,27 @@ public boolean showNotification(NotificationData.Entry headsUp) {
}
mHeadsUp = headsUp;
+
+ if (mBar.isExpandedVisible() || mBar.isImeShowing()) {
+ releaseAndClose();
+ return false; // There is really no need, right?
+ }
+
if (mContentHolder != null) {
mContentHolder.removeAllViews();
+ } else {
+ // too soon! Reparent and exit here.
+ releaseAndClose();
+ return false;
}
+ mTouchOutside = false;
+
if (mHeadsUp != null) {
mHeadsUp.row.setSystemExpanded(true);
mHeadsUp.row.setSensitive(false);
mHeadsUp.row.setHideSensitive(
false, false /* animated */, 0 /* delay */, 0 /* duration */);
- if (mContentHolder == null) {
- // too soon!
- return false;
- }
mContentHolder.setX(0);
mContentHolder.setVisibility(View.VISIBLE);
mContentHolder.setAlpha(mMaxAlpha);
@@ -138,11 +127,6 @@ public boolean showNotification(NotificationData.Entry headsUp) {
mSwipeHelper.snapChild(mContentHolder, 1f);
mStartTouchTime = System.currentTimeMillis() + mTouchSensitivityDelay;
- if (mSnoozeButton != null) {
- mSnoozeButton.setAlpha(mMaxAlpha);
- mIsSnoozeButtonNowVisible = true;
- }
-
mHeadsUp.setInterruption();
// 2. Animate mHeadsUpNotificationView in
@@ -177,10 +161,10 @@ public void dismiss() {
if (mHeadsUp == null) return;
if (mHeadsUp.notification.isClearable()) {
mBar.onNotificationClear(mHeadsUp.notification);
+ mHeadsUp = null;
} else {
release();
}
- mHeadsUp = null;
mBar.scheduleHeadsUpClose();
}
@@ -188,8 +172,8 @@ public void dismiss() {
public void release() {
if (mHeadsUp != null) {
mBar.displayNotificationFromHeadsUp(mHeadsUp.notification);
+ mHeadsUp = null;
}
- mHeadsUp = null;
}
public void releaseAndClose() {
@@ -233,27 +217,17 @@ public void onAttachedToWindow() {
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
mExpandHelper = new ExpandHelper(getContext(), this, minHeight, maxHeight);
- mBelowContentContainer = (ViewGroup) findViewById(R.id.below_content_container);
-
mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
mContentHolder.setOutlineProvider(CONTENT_HOLDER_OUTLINE_PROVIDER);
- mSnoozeButton = (ImageButton) findViewById(R.id.heads_up_snooze_button);
- if (mSnoozeButton != null) {
- mSnoozeButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- mBar.snoozeHeadsUp();
- }
- });
- mSnoozeButton.setVisibility(mSnoozeButtonVisibility ? View.VISIBLE : View.GONE);
- }
-
if (mHeadsUp != null) {
// whoops, we're on already!
showNotification(mHeadsUp);
}
getViewTreeObserver().addOnComputeInternalInsetsListener(this);
+
+ mTouchOutside = false;
}
@Override
@@ -289,11 +263,26 @@ public boolean onTouchEvent(MotionEvent ev) {
if (System.currentTimeMillis() < mStartTouchTime) {
return false;
}
- mBar.resetHeadsUpDecayTimer();
- return mEdgeSwipeHelper.onTouchEvent(ev)
- || mSwipeHelper.onTouchEvent(ev)
- || mExpandHelper.onTouchEvent(ev)
- || super.onTouchEvent(ev);
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_OUTSIDE:
+ if (mTouchOutside) return true;
+ if (mBar.mHeadsUpTouchOutside) {
+ // Hide headsup, after 1 sec.
+ mBar.getHandler().postDelayed(new Runnable() {
+ public void run() {
+ mBar.scheduleHeadsUpClose();
+ }
+ }, 1000);
+ }
+ mTouchOutside = true;
+ return true;
+ default:
+ mBar.resetHeadsUpDecayTimer();
+ return mEdgeSwipeHelper.onTouchEvent(ev)
+ || mSwipeHelper.onTouchEvent(ev)
+ || mExpandHelper.onTouchEvent(ev)
+ || super.onTouchEvent(ev);
+ }
}
@Override
@@ -305,36 +294,6 @@ protected void onConfigurationChanged(Configuration newConfig) {
mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
}
- /**
- * Animate the snooze button to a new visibility.
- *
- * @param nowVisible should it now be visible
- */
- private void animateSnoozeButton(boolean nowVisible) {
- if (mSnoozeButton == null) {
- return;
- }
- mSnoozeButton.animate().cancel();
- if (!mSnoozeButtonVisibility) {
- return;
- }
- if (nowVisible != mIsSnoozeButtonNowVisible) {
- mIsSnoozeButtonNowVisible = nowVisible;
- // Animate snooze button
- float endValue = nowVisible ? mMaxAlpha : 0.0f;
- Interpolator interpolator;
- if (nowVisible) {
- interpolator = PhoneStatusBar.ALPHA_IN;
- } else {
- interpolator = PhoneStatusBar.ALPHA_OUT;
- }
- mSnoozeButton.animate()
- .alpha(endValue)
- .setInterpolator(interpolator)
- .setDuration(260);
- }
- }
-
// ExpandHelper.Callback methods
@Override
@@ -392,20 +351,17 @@ public float getFalsingThresholdFactor() {
public void onChildDismissed(View v, boolean direction) {
if (DEBUG) Log.v(TAG, "User swiped heads up to dismiss");
mBar.onHeadsUpDismissed(direction);
- if (mSnoozeButton != null) {
- mSnoozeButton.animate().cancel();
- }
}
@Override
public void onBeginDrag(View v) {
- animateSnoozeButton(false);
+ // Prevent any surrounding View from intercepting us now.
+ requestDisallowInterceptTouchEvent(true);
}
@Override
public void onDragCancelled(View v) {
mContentHolder.setAlpha(mMaxAlpha); // sometimes this isn't quite reset
- animateSnoozeButton(true);
}
@Override
@@ -448,6 +404,7 @@ public String getKey() {
private class EdgeSwipeHelper implements Gefingerpoken {
private static final boolean DEBUG_EDGE_SWIPE = false;
+ private static final boolean ENABLE_AOSP_BEHAVIOUR = false;
private final float mTouchSlop;
private boolean mConsuming;
private float mFirstY;
@@ -474,14 +431,21 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
final float daY = Math.abs(dY);
if (!mConsuming && (4f * daX) < daY && daY > mTouchSlop) {
if (dY > 0) {
- // User want to swipe in notification panel. Allow it
- // and hide the headsup notification so that the user
- // can see it now in the notification panel.
- if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found an open");
- mBar.animateExpandNotificationsPanel();
- mBar.onHeadsUpDismissed(true);
+ if (ENABLE_AOSP_BEHAVIOUR) {
+ if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found an open");
+ mBar.animateExpandNotificationsPanel();
+ } else {
+ mConsuming = true;
+ }
+ } else if (dY < 0) {
+ if (ENABLE_AOSP_BEHAVIOUR) {
+ if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found a close");
+ mBar.onHeadsUpDismissed(true);
+ } else {
+ releaseAndClose();
+ }
+ mConsuming = true;
}
- mConsuming = true;
}
break;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index b821ab5c7760..5b39e464c6ef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -1947,10 +1947,6 @@ public void onExpansionStopped() {
}
}
- public boolean getIsExpanded() {
- return mIsExpanded;
- }
-
private void setIsExpanded(boolean isExpanded) {
boolean changed = isExpanded != mIsExpanded;
mIsExpanded = isExpanded;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
index d1561ed58ebc..b93b74852a36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -112,10 +112,6 @@ public void setAutoRotate(boolean enabled) {
public void showCustomIntentAfterKeyguard(Intent intent) {
}
- @Override // CommandQueue
- public void hideHeadsUpCandidate(String packageName) {
- }
-
@Override
protected WindowManager.LayoutParams getSearchLayoutParams(
LayoutParams layoutParams) {
@@ -147,6 +143,11 @@ protected boolean shouldDisableNavbarGestures() {
return true;
}
+ @Override
+ public boolean isExpandedVisible() {
+ return false;
+ }
+
public View getStatusBarView() {
return null;
}
@@ -163,7 +164,7 @@ public void scheduleHeadsUpOpen() {
public void scheduleHeadsUpEscalation() {
}
- @Override // CommandQueue
+ @Override
public void scheduleHeadsUpClose() {
}
@@ -180,6 +181,10 @@ public void animateExpandSettingsPanel() {
protected void createAndAddWindows() {
}
+ @Override
+ public void hideHeadsUp() {
+ }
+
@Override
protected void refreshLayout(int layoutDirection) {
}
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 65061dc61794..e1d5b60dc2ea 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -2143,6 +2143,11 @@ public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder wind
return res;
}
+ @Override
+ public boolean isImeShowing() {
+ return mInputShown;
+ }
+
@Override
public void showInputMethodPickerFromClient(IInputMethodClient client) {
if (!calledFromValidUser()) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 2d565d1b93c0..5e72422769bb 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1115,7 +1115,6 @@ private void completeResumeLocked(ActivityRecord next) {
mActivityContainer.mActivityDisplay.setVisibleBehindActivity(null);
}
- updateHeadsUpState(next);
updatePrivacyGuardNotificationLocked(next);
}
@@ -1999,6 +1998,7 @@ private final void updatePrivacyGuardNotificationLocked(ActivityRecord next) {
1, UserHandle.USER_CURRENT) == 0) {
return;
}
+
String privacyGuardPackageName = mStackSupervisor.mPrivacyGuardPackageName;
if (privacyGuardPackageName != null && privacyGuardPackageName.equals(next.packageName)) {
return;
@@ -2020,27 +2020,6 @@ private final void updatePrivacyGuardNotificationLocked(ActivityRecord next) {
}
}
- private final void updateHeadsUpState(ActivityRecord next) {
- String headsUpPackageName = mStackSupervisor.mHeadsUpPackageName;
- if (headsUpPackageName != null && headsUpPackageName.equals(next.packageName)) {
- return;
- }
-
- if (!mStackSupervisor
- .getHeadsUpNotificationsEnabledForPackage(next.packageName, next.userId)) {
- // Next package has no heads up enabled. So we do not need to notify
- // statusbar service that the package has changed. Why bother with it?
- mStackSupervisor.mHeadsUpPackageName = null;
- return;
- } else {
- // Next package has heads up enabled. Notify statusbar service,
- // let it decide if the heads up which is currently shown is
- // from this package and hide it if this is the case.
- mStackSupervisor.hideHeadsUpCandidate(next.packageName);
- mStackSupervisor.mHeadsUpPackageName = next.packageName;
- }
- }
-
final void startActivityLocked(ActivityRecord r, boolean newTask,
boolean doResume, boolean keepCurTransition, Bundle options) {
TaskRecord rTask = r.task;
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index cbfaa86184c2..0951b7c97a72 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -44,8 +44,6 @@
import android.app.IActivityContainerCallback;
import android.app.IActivityManager;
import android.app.IApplicationThread;
-import android.app.Notification;
-import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProfilerInfo;
import android.app.ActivityManager.RunningTaskInfo;
@@ -172,8 +170,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
WindowManagerService mWindowManager;
DisplayManager mDisplayManager;
- private NotificationManager mNoMan;
-
/** Identifier counter for all ActivityStacks */
private int mLastStackId = HOME_STACK_ID;
@@ -236,6 +232,13 @@ public final class ActivityStackSupervisor implements DisplayListener {
* setWindowManager is called. **/
private boolean mLeanbackOnlyDevice;
+ /**
+ * Is the privacy guard currently enabled? Shared between ActivityStacks
+ */
+ String mPrivacyGuardPackageName = null;
+
+ private PowerManager mPm;
+
/**
* We don't want to allow the device to go to sleep while in the process
* of launching an activity. This is primarily to allow alarm intent
@@ -297,16 +300,6 @@ static class PendingActivityLaunch {
}
}
- /**
- * Is heads up currently enabled? Shared between ActivityStacks
- */
- String mHeadsUpPackageName = null;
-
- /**
- * Is the privacy guard currently enabled? Shared between ActivityStacks
- */
- String mPrivacyGuardPackageName = null;
-
public ActivityStackSupervisor(ActivityManagerService service) {
mService = service;
mHandler = new ActivityStackSupervisorHandler(mService.mHandler.getLooper());
@@ -339,13 +332,6 @@ private IStatusBarService getStatusBarService() {
}
}
- private void initNotificationManager() {
- if (mNoMan == null) {
- mNoMan = (NotificationManager) mService.mContext
- .getSystemService(Context.NOTIFICATION_SERVICE);
- }
- }
-
private IDevicePolicyManager getDevicePolicyManager() {
synchronized (mService) {
if (mDevicePolicyManager == null) {
@@ -4063,22 +4049,4 @@ private boolean isLeanbackOnlyDevice() {
return onLeanbackOnly;
}
-
- void hideHeadsUpCandidate(String packageName) {
- try {
- IStatusBarService statusbar = getStatusBarService();
- if (statusbar != null) {
- statusbar.hideHeadsUpCandidate(packageName);
- }
- } catch (RemoteException e) {
- // re-acquire status bar service next time it is needed.
- mStatusBarService = null;
- }
- }
-
- boolean getHeadsUpNotificationsEnabledForPackage(String packageName, int uid) {
- initNotificationManager();
- return mNoMan.getHeadsUpNotificationsEnabledForPackage(
- packageName, uid) != Notification.HEADS_UP_NEVER;
- }
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 4a6a77fd20ae..650d51450483 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1256,27 +1256,6 @@ public int getShowNotificationForPackageOnKeyguard(String pkg, int uid) {
return mRankingHelper.getShowNotificationForPackageOnKeyguard(pkg, uid);
}
- @Override
- public void setHeadsUpNotificationsEnabledForPackage(
- String pkg, int uid, int headsUp) {
- // enforce() will ensure the calling uid has the correct permission
- getContext().enforceCallingOrSelfPermission(
- android.Manifest.permission.CHANGE_HEADS_UP_STATE,
- "NotificationManagerService.setHeadsUpNotificationsEnabledForPackage");
- mRankingHelper.setHeadsUpNotificationsEnabledForPackage(pkg, uid, headsUp);
- savePolicyFile();
- }
-
- @Override
- public int getHeadsUpNotificationsEnabledForPackage(String pkg, int uid) {
- // enforce() will ensure the calling uid has the correct permission
- getContext().enforceCallingOrSelfPermission(
- android.Manifest.permission.CHANGE_HEADS_UP_STATE,
- "NotificationManagerService.getHeadsUpNotificationsEnabledForPackage");
- return mRankingHelper.getHeadsUpNotificationsEnabledForPackage(pkg, uid);
- }
-
-
/**
* System-only API for getting a list of current (i.e. not cleared) notifications.
*
diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java
index b880b5a71782..6b85e965325d 100644
--- a/services/core/java/com/android/server/notification/RankingConfig.java
+++ b/services/core/java/com/android/server/notification/RankingConfig.java
@@ -28,8 +28,4 @@ public interface RankingConfig {
int getShowNotificationForPackageOnKeyguard(String packageName, int uid);
- void setHeadsUpNotificationsEnabledForPackage(String packageName, int uid, int headsUp);
-
- int getHeadsUpNotificationsEnabledForPackage(String packageName, int uid);
-
}
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 94d53b44342f..ed24ba4491c8 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -53,7 +53,6 @@ public class RankingHelper implements RankingConfig {
private static final String ATT_PRIORITY = "priority";
private static final String ATT_VISIBILITY = "visibility";
private static final String ATT_KEYGUARD = "keyguard";
- private static final String ATT_HEADSUP = "headsup";
private final NotificationSignalExtractor[] mSignalExtractors;
private final NotificationComparator mPreliminaryComparator = new NotificationComparator();
@@ -63,7 +62,6 @@ public class RankingHelper implements RankingConfig {
private final ArrayMap mPackagePriorities;
private final ArrayMap mPackageVisibilities;
private final ArrayMap mPackageOnKeyguard;
- private final ArrayMap mPackageHeadsUp;
private final ArrayMap mProxyByGroupTmp;
private final Context mContext;
@@ -75,7 +73,6 @@ public RankingHelper(Context context, Handler rankingHandler, String[] extractor
mPackagePriorities = new ArrayMap();
mPackageVisibilities = new ArrayMap();
mPackageOnKeyguard = new ArrayMap();
- mPackageHeadsUp = new ArrayMap();
final int N = extractorNames.length;
mSignalExtractors = new NotificationSignalExtractor[N];
@@ -147,7 +144,6 @@ public void readXml(XmlPullParser parser) throws XmlPullParserException, IOExcep
NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE);
int keyguard = safeInt(parser, ATT_KEYGUARD,
Notification.SHOW_ALL_NOTI_ON_KEYGUARD);
- int headsUp = safeInt(parser, ATT_HEADSUP, Notification.HEADS_UP_NEVER);
String name = parser.getAttributeValue(null, ATT_NAME);
if (!TextUtils.isEmpty(name)) {
@@ -175,14 +171,6 @@ public void readXml(XmlPullParser parser) throws XmlPullParserException, IOExcep
}
keyguardByUid.put(uid, keyguard);
}
- if (headsUp != Notification.HEADS_UP_NEVER) {
- SparseIntArray headsUpByUid = mPackageHeadsUp.get(name);
- if (headsUpByUid == null) {
- headsUpByUid = new SparseIntArray();
- mPackageHeadsUp.put(name, headsUpByUid);
- }
- headsUpByUid.put(uid, headsUp);
- }
}
}
}
@@ -199,14 +187,12 @@ public void writeXml(XmlSerializer out) throws IOException {
packageNames.addAll(mPackagePriorities.keySet());
packageNames.addAll(mPackageVisibilities.keySet());
packageNames.addAll(mPackageOnKeyguard.keySet());
- packageNames.addAll(mPackageHeadsUp.keySet());
final Set packageUids = new ArraySet<>();
for (String packageName : packageNames) {
packageUids.clear();
SparseIntArray priorityByUid = mPackagePriorities.get(packageName);
SparseIntArray visibilityByUid = mPackageVisibilities.get(packageName);
SparseIntArray keyguardByUid = mPackageOnKeyguard.get(packageName);
- SparseIntArray headsUpByUid = mPackageHeadsUp.get(packageName);
if (priorityByUid != null) {
final int M = priorityByUid.size();
@@ -226,12 +212,6 @@ public void writeXml(XmlSerializer out) throws IOException {
packageUids.add(keyguardByUid.keyAt(j));
}
}
- if (headsUpByUid != null) {
- final int M = headsUpByUid.size();
- for (int j = 0; j < M; j++) {
- packageUids.add(headsUpByUid.keyAt(j));
- }
- }
for (Integer uid : packageUids) {
out.startTag(null, TAG_PACKAGE);
out.attribute(null, ATT_NAME, packageName);
@@ -253,12 +233,6 @@ public void writeXml(XmlSerializer out) throws IOException {
out.attribute(null, ATT_KEYGUARD, Integer.toString(keyguard));
}
}
- if (headsUpByUid != null) {
- final int headsUp = headsUpByUid.get(uid);
- if (headsUp != Notification.HEADS_UP_NEVER) {
- out.attribute(null, ATT_HEADSUP, Integer.toString(headsUp));
- }
- }
out.attribute(null, ATT_UID, Integer.toString(uid));
out.endTag(null, TAG_PACKAGE);
}
@@ -439,32 +413,6 @@ public void setShowNotificationForPackageOnKeyguard(
updateConfig();
}
- @Override
- public int getHeadsUpNotificationsEnabledForPackage(String packageName, int uid) {
- int headsUp = Notification.HEADS_UP_NEVER;
- SparseIntArray headsUpByUid = mPackageHeadsUp.get(packageName);
- if (headsUpByUid != null) {
- headsUp = headsUpByUid.get(uid, Notification.HEADS_UP_NEVER);
- }
- return headsUp;
- }
-
- @Override
- public void setHeadsUpNotificationsEnabledForPackage(
- String packageName, int uid, int headsUp) {
- if (headsUp == getHeadsUpNotificationsEnabledForPackage(packageName, uid)) {
- return;
- }
- SparseIntArray headsUpByUid = mPackageHeadsUp.get(packageName);
- if (headsUpByUid == null) {
- headsUpByUid = new SparseIntArray();
- mPackageHeadsUp.put(packageName, headsUpByUid);
- }
- headsUpByUid.put(uid, headsUp);
- updateConfig();
- }
-
-
public void dump(PrintWriter pw, String prefix, NotificationManagerService.DumpFilter filter) {
if (filter == null) {
final int N = mSignalExtractors.length;
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 847fdb367d4a..5b57980e25f3 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -485,31 +485,6 @@ public void showCustomIntentAfterKeyguard(Intent intent) {
}
}
- /**
- * @hide
- */
- @Override
- public void hideHeadsUpCandidate(String packageName) {
- enforceStatusBarService();
- if (mBar != null) {
- try {
- mBar.hideHeadsUpCandidate(packageName);
- } catch (RemoteException ex) {}
- }
- }
-
- /**
- * @hide
- */
- @Override
- public void scheduleHeadsUpClose() {
- enforceStatusBarService();
- if (mBar != null) {
- try {
- mBar.scheduleHeadsUpClose();
- } catch (RemoteException ex) {}
- }
- }
@Override
public void toggleScreenshot() {