am a764816b: Merge "Hide notifications until the device is provisioned." into jb-dev
* commit 'a764816b1ae961218bd7c628ab9f0ad384eab8cd': Hide notifications until the device is provisioned.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user