diff options
author | Daniel Sandler <dsandler@android.com> | 2012-06-03 11:46:13 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-03 11:46:13 -0700 |
commit | a764816b1ae961218bd7c628ab9f0ad384eab8cd (patch) | |
tree | 4c8d843d6b89c731b909df54023df6826ef3305c /packages/SystemUI/src/com/android/systemui | |
parent | da652f6e51e5b255019ac020d56e262e477c2a46 (diff) | |
parent | 26cda27d2e6f1341514943b39a4da1e55ba2197e (diff) | |
download | frameworks_base-a764816b1ae961218bd7c628ab9f0ad384eab8cd.zip frameworks_base-a764816b1ae961218bd7c628ab9f0ad384eab8cd.tar.gz frameworks_base-a764816b1ae961218bd7c628ab9f0ad384eab8cd.tar.bz2 |
Merge "Hide notifications until the device is provisioned." into jb-dev
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java | 26 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 25 |
2 files changed, 46 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index f088e0e..cf2690b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.database.ContentObserver; import android.graphics.Rect; import android.net.Uri; import android.os.Build; @@ -123,7 +124,7 @@ public abstract class BaseStatusBar extends SystemUI implements protected Display mDisplay; private IWindowManager mWindowManager; - + private boolean mDeviceProvisioned = false; public IWindowManager getWindowManager() { return mWindowManager; @@ -137,10 +138,31 @@ public abstract class BaseStatusBar extends SystemUI implements return mBarService; } + protected boolean isDeviceProvisioned() { + return mDeviceProvisioned; + } + + private ContentObserver mProvisioningObserver = new ContentObserver(new Handler()) { + @Override + public void onChange(boolean selfChange) { + final boolean provisioned = 0 != Settings.Secure.getInt( + mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0); + if (provisioned != mDeviceProvisioned) { + mDeviceProvisioned = provisioned; + updateNotificationIcons(); + } + } + }; + public void start() { mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); + mProvisioningObserver.onChange(false); // set up + mContext.getContentResolver().registerContentObserver( + Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED), true, + mProvisioningObserver); + mWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); @@ -754,7 +776,7 @@ public abstract class BaseStatusBar extends SystemUI implements protected abstract boolean shouldDisableNavbarGestures(); protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) { - return parent.indexOfChild(entry.row) == 0; + return parent != null && parent.indexOfChild(entry.row) == 0; } public void updateNotification(IBinder key, StatusBarNotification notification) { 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 d40a763..6842b17 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -745,13 +745,19 @@ public class PhoneStatusBar extends BaseStatusBar { } private void loadNotificationShade() { + if (mPile == null) return; + int N = mNotificationData.size(); ArrayList<View> toShow = new ArrayList<View>(); + final boolean provisioned = isDeviceProvisioned(); + // If the device hasn't been through Setup, we only show system notifications for (int i=0; i<N; i++) { - View row = mNotificationData.get(N-i-1).row; - toShow.add(row); + Entry ent = mNotificationData.get(N-i-1); + if (provisioned || "android".equals(ent.notification.pkg)) { + toShow.add(ent.row); + } } ArrayList<View> toRemove = new ArrayList<View>(); @@ -772,6 +778,8 @@ public class PhoneStatusBar extends BaseStatusBar { mPile.addView(v, i); } } + + mSettingsButton.setEnabled(isDeviceProvisioned()); } private void reloadAllNotificationIcons() { @@ -782,6 +790,8 @@ public class PhoneStatusBar extends BaseStatusBar { @Override protected void updateNotificationIcons() { + if (mNotificationIcons == null) return; + loadNotificationShade(); final LinearLayout.LayoutParams params @@ -795,9 +805,12 @@ public class PhoneStatusBar extends BaseStatusBar { ArrayList<View> toShow = new ArrayList<View>(); + final boolean provisioned = isDeviceProvisioned(); + // If the device hasn't been through Setup, we only show system notifications for (int i=0; i<N; i++) { Entry ent = mNotificationData.get(N-i-1); - if (ent.notification.score >= HIDE_ICONS_BELOW_SCORE) { + if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE) + || "android".equals(ent.notification.pkg)) { toShow.add(ent.icon); } } @@ -1660,6 +1673,9 @@ public class PhoneStatusBar extends BaseStatusBar { // no ticking in lights-out mode if (!areLightsOn()) return; + // no ticking in Setup + if (!isDeviceProvisioned()) return; + // Show the ticker if one is requested. Also don't do this // until status bar window is attached to the window manager, // because... well, what's the point otherwise? And trying to @@ -2028,6 +2044,9 @@ public class PhoneStatusBar extends BaseStatusBar { private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { public void onClick(View v) { + // We take this as a good indicator that Setup is running and we shouldn't + // allow you to go somewhere else + if (!isDeviceProvisioned()) return; try { // Dismiss the lock screen when Settings starts. ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |