Disable quick settings for users until USER_SETUP_COMPLETE.

If the current user has not yet made it through the setup wizard,
disable the quick settings panel entirely.

Use Settings.Secure.USER_SETUP_COMPLETE as the signal.  This is a
per-user setting, so be careful to observe only on the current user's
behalf.

Bug:6712493
Change-Id: I3076a8a550165a9eeccf7fb129d470ef4ddeaed4
This commit is contained in:
John Spurlock
2012-10-02 16:41:12 -04:00
parent 30ed33b141
commit 919adac28b
2 changed files with 41 additions and 2 deletions

View File

@ -83,7 +83,11 @@ public class PanelBar extends FrameLayout {
// figure out which panel needs to be talked to here
if (event.getAction() == MotionEvent.ACTION_DOWN) {
final PanelView panel = selectPanelForTouchX(event.getX());
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, panel);
boolean enabled = panel.isEnabled();
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s %s", mState, panel,
(enabled ? "" : " (disabled)"));
if (!enabled)
return false;
startOpeningPanel(panel);
}
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);

View File

@ -30,6 +30,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
@ -39,6 +40,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
@ -259,6 +261,26 @@ public class PhoneStatusBar extends BaseStatusBar {
}
};
// ensure quick settings is disabled until the current user makes it through the setup wizard
private boolean mUserSetup = false;
private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
final boolean userSetup = 0 != Settings.Secure.getIntForUser(
mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE,
0 /*default */,
mCurrentUserId);
if (userSetup != mUserSetup) {
mUserSetup = userSetup;
if (mSettingsPanel != null)
mSettingsPanel.setEnabled(mUserSetup);
if (!mUserSetup && mStatusBarView != null)
animateCollapseQuickSettings();
}
}
};
@Override
public void start() {
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
@ -461,6 +483,9 @@ public class PhoneStatusBar extends BaseStatusBar {
filter.addAction(Intent.ACTION_SCREEN_ON);
context.registerReceiver(mBroadcastReceiver, filter);
// listen for USER_SETUP_COMPLETE setting (per-user)
resetUserSetupObserver();
return mStatusBarView;
}
@ -1827,8 +1852,18 @@ public class PhoneStatusBar extends BaseStatusBar {
if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId);
animateCollapsePanels();
updateNotificationIcons();
resetUserSetupObserver();
}
private void resetUserSetupObserver() {
mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver);
mUserSetupObserver.onChange(false);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true,
mUserSetupObserver,
mCurrentUserId);
}
private void setIntruderAlertVisibility(boolean vis) {
if (!ENABLE_INTRUDERS) return;
if (DEBUG) {