diff options
13 files changed, 192 insertions, 227 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 8f542bb..b13bf88 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -233,4 +233,9 @@ interface IWindowManager * Device is in safe mode. */ boolean isSafeModeEnabled(); + + /** + * Enables the screen if all conditions are met. + */ + void enableScreenIfNeeded(); } diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index bd203c8..db8de66 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -1007,6 +1007,14 @@ public interface WindowManagerPolicy { public void dismissKeyguardLw(); /** + * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method + * returns true as soon as we know that Keyguard is disabled. + * + * @return true if the keyguard has drawn. + */ + public boolean isKeyguardDrawnLw(); + + /** * Given an orientation constant, returns the appropriate surface rotation, * taking into account sensors, docking mode, rotation lock, and other factors. * diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index a721262..2d00eb9 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -84,6 +84,7 @@ <uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" /> <application + android:name=".SystemUIApplication" android:persistent="true" android:allowClearUserData="false" android:allowBackup="false" diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java new file mode 100644 index 0000000..8265c86 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui; + +import android.app.Application; +import android.content.res.Configuration; +import android.util.Log; + +import java.util.HashMap; +import java.util.Map; + +/** + * Application class for SystemUI. + */ +public class SystemUIApplication extends Application { + + private static final String TAG = "SystemUIService"; + private static final boolean DEBUG = false; + + /** + * The classes of the stuff to start. + */ + private final Class<?>[] SERVICES = new Class[] { + com.android.systemui.keyguard.KeyguardViewMediator.class, + com.android.systemui.recent.Recents.class, + com.android.systemui.statusbar.SystemBars.class, + com.android.systemui.usb.StorageNotification.class, + com.android.systemui.power.PowerUI.class, + com.android.systemui.media.RingtonePlayer.class, + com.android.systemui.settings.SettingsUI.class, + }; + + /** + * Hold a reference on the stuff we start. + */ + private final SystemUI[] mServices = new SystemUI[SERVICES.length]; + private final Map<Class<?>, Object> mComponents = new HashMap<Class<?>, Object>(); + + @Override + public void onCreate() { + final int N = SERVICES.length; + for (int i=0; i<N; i++) { + Class<?> cl = SERVICES[i]; + if (DEBUG) Log.d(TAG, "loading: " + cl); + try { + mServices[i] = (SystemUI)cl.newInstance(); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } + mServices[i].mContext = this; + mServices[i].mComponents = mComponents; + if (DEBUG) Log.d(TAG, "running: " + mServices[i]); + mServices[i].start(); + } + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + int len = mServices.length; + for (int i = 0; i < len; i++) { + mServices[i].onConfigurationChanged(newConfig); + } + } + + @SuppressWarnings("unchecked") + public <T> T getComponent(Class<T> interfaceType) { + return (T) mComponents.get(interfaceType); + } + + public SystemUI[] getServices() { + return mServices; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIService.java b/packages/SystemUI/src/com/android/systemui/SystemUIService.java index ca5f7d1..da8654c 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIService.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIService.java @@ -18,65 +18,13 @@ package com.android.systemui; import android.app.Service; import android.content.Intent; -import android.content.res.Configuration; import android.os.IBinder; -import android.util.Log; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.util.HashMap; public class SystemUIService extends Service { - private static final String TAG = "SystemUIService"; - /** - * The classes of the stuff to start. - */ - private final Class<?>[] SERVICES = new Class[] { - com.android.systemui.recent.Recents.class, - com.android.systemui.statusbar.SystemBars.class, - com.android.systemui.usb.StorageNotification.class, - com.android.systemui.power.PowerUI.class, - com.android.systemui.media.RingtonePlayer.class, - com.android.systemui.settings.SettingsUI.class, - }; - - /** - * Hold a reference on the stuff we start. - */ - private final SystemUI[] mServices = new SystemUI[SERVICES.length]; - - @Override - public void onCreate() { - HashMap<Class<?>, Object> components = new HashMap<Class<?>, Object>(); - final int N = SERVICES.length; - for (int i=0; i<N; i++) { - Class<?> cl = SERVICES[i]; - Log.d(TAG, "loading: " + cl); - try { - mServices[i] = (SystemUI)cl.newInstance(); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } catch (InstantiationException ex) { - throw new RuntimeException(ex); - } - mServices[i].mContext = this; - mServices[i].mComponents = components; - Log.d(TAG, "running: " + mServices[i]); - mServices[i].start(); - } - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - for (SystemUI ui: mServices) { - ui.onConfigurationChanged(newConfig); - } - } - - /** - * Nobody binds to us. - */ @Override public IBinder onBind(Intent intent) { return null; @@ -84,14 +32,15 @@ public class SystemUIService extends Service { @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + SystemUI[] services = ((SystemUIApplication) getApplication()).getServices(); if (args == null || args.length == 0) { - for (SystemUI ui: mServices) { + for (SystemUI ui: services) { pw.println("dumping service: " + ui.getClass().getName()); ui.dump(fd, pw, args); } } else { String svc = args[0]; - for (SystemUI ui: mServices) { + for (SystemUI ui: services) { String name = ui.getClass().getName(); if (name.endsWith(svc)) { ui.dump(fd, pw, args); diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index c7d29f0..fdf374f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -16,15 +16,6 @@ package com.android.systemui.keyguard; -import com.android.internal.policy.IKeyguardExitCallback; -import com.android.internal.policy.IKeyguardService; -import com.android.internal.policy.IKeyguardServiceConstants; -import com.android.internal.policy.IKeyguardShowCallback; -import com.android.internal.widget.LockPatternUtils; -import com.android.systemui.statusbar.phone.PhoneStatusBar; -import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowManager; - import android.app.Service; import android.content.Intent; import android.os.Binder; @@ -33,7 +24,12 @@ import android.os.Debug; import android.os.IBinder; import android.util.Log; import android.view.MotionEvent; -import android.view.ViewGroup; + +import com.android.internal.policy.IKeyguardExitCallback; +import com.android.internal.policy.IKeyguardService; +import com.android.internal.policy.IKeyguardServiceConstants; +import com.android.internal.policy.IKeyguardShowCallback; +import com.android.systemui.SystemUIApplication; import static android.content.pm.PackageManager.PERMISSION_GRANTED; @@ -41,23 +37,17 @@ public class KeyguardService extends Service { static final String TAG = "KeyguardService"; static final String PERMISSION = android.Manifest.permission.CONTROL_KEYGUARD; - public static final String ACTION_STATUS_BAR_BIND = "action.status_bar_bind"; - private KeyguardViewMediator mKeyguardViewMediator; @Override public void onCreate() { - LockPatternUtils lockPatternUtils = new LockPatternUtils(this); - mKeyguardViewMediator = new KeyguardViewMediator(this, lockPatternUtils); + mKeyguardViewMediator = + ((SystemUIApplication) getApplication()).getComponent(KeyguardViewMediator.class); } @Override public IBinder onBind(Intent intent) { - if (ACTION_STATUS_BAR_BIND.equals(intent.getAction())) { - return mKeyguardStatusBarBinder; - } else { - return mBinder; - } + return mBinder; } void checkPermission() { @@ -68,16 +58,6 @@ public class KeyguardService extends Service { } } - private final KeyguardStatusBarBinder mKeyguardStatusBarBinder = new KeyguardStatusBarBinder() { - - @Override - public void registerStatusBar(PhoneStatusBar phoneStatusBar, ViewGroup container, - StatusBarWindowManager statusBarWindowManager) { - mKeyguardViewMediator.registerStatusBar(phoneStatusBar, container, - statusBarWindowManager); - } - }; - private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() { private boolean mIsOccluded; diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardStatusBarBinder.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardStatusBarBinder.java deleted file mode 100644 index 04b6c29..0000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardStatusBarBinder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.keyguard; - -import com.android.systemui.statusbar.phone.PhoneStatusBar; -import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowManager; - -import android.os.Binder; -import android.view.ViewGroup; - -/** - * Communication interface from status bar to {@link com.android.systemui.keyguard.KeyguardService}. - */ -public abstract class KeyguardStatusBarBinder extends Binder { - - public abstract void registerStatusBar(PhoneStatusBar phoneStatusBar, ViewGroup container, - StatusBarWindowManager statusBarWindowManager); -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index e0a6e67..3326dee 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -60,6 +60,7 @@ import com.android.keyguard.MultiUserAvatarCache; import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.analytics.KeyguardAnalytics; import com.android.keyguard.analytics.Session; +import com.android.systemui.SystemUI; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarWindowManager; @@ -111,7 +112,7 @@ import static com.android.keyguard.analytics.KeyguardAnalytics.SessionTypeAdapte * directly to the keyguard UI is posted to a {@link android.os.Handler} to ensure it is taken on the UI * thread of the keyguard. */ -public class KeyguardViewMediator { +public class KeyguardViewMediator extends SystemUI { private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; final static boolean DEBUG = false; private static final boolean ENABLE_ANALYTICS = Build.IS_DEBUGGABLE; @@ -181,7 +182,6 @@ public class KeyguardViewMediator { /** The stream type that the lock sounds are tied to. */ private int mMasterStreamType; - private Context mContext; private AlarmManager mAlarmManager; private AudioManager mAudioManager; private StatusBarManager mStatusBarManager; @@ -211,7 +211,7 @@ public class KeyguardViewMediator { private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private final KeyguardAnalytics mKeyguardAnalytics; + private KeyguardAnalytics mKeyguardAnalytics; // these are protected by synchronized (this) @@ -284,7 +284,7 @@ public class KeyguardViewMediator { /** * The volume applied to the lock/unlock sounds. */ - private final float mLockSoundVolume; + private float mLockSoundVolume; /** * For managing external displays @@ -460,42 +460,34 @@ public class KeyguardViewMediator { mPM.userActivity(SystemClock.uptimeMillis(), false); } - /** - * Construct a KeyguardViewMediator - * @param context - * @param lockPatternUtils optional mock interface for LockPatternUtils - */ - public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils) { - mContext = context; - mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + private void setup() { + mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); mShowKeyguardWakeLock.setReferenceCounted(false); mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION)); - mKeyguardDisplayManager = new KeyguardDisplayManager(context); + mKeyguardDisplayManager = new KeyguardDisplayManager(mContext); - mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); - mUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); + mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); - mLockPatternUtils = lockPatternUtils != null - ? lockPatternUtils : new LockPatternUtils(mContext); + mLockPatternUtils = new LockPatternUtils(mContext); mLockPatternUtils.setCurrentUser(UserHandle.USER_OWNER); // Assume keyguard is showing (unless it's disabled) until we know for sure... mShowing = (mUpdateMonitor.isDeviceProvisioned() || mLockPatternUtils.isSecure()) && !mLockPatternUtils.isLockScreenDisabled(); - mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, mViewMediatorCallback, - lockPatternUtils); - WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); + mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, + mViewMediatorCallback, mLockPatternUtils); final ContentResolver cr = mContext.getContentResolver(); if (ENABLE_ANALYTICS && !LockPatternUtils.isSafeModeEnabled() && Settings.Secure.getInt(cr, KEYGUARD_ANALYTICS_SETTING, 0) == 1) { - mKeyguardAnalytics = new KeyguardAnalytics(context, new SessionTypeAdapter() { + mKeyguardAnalytics = new KeyguardAnalytics(mContext, new SessionTypeAdapter() { @Override public int getSessionType() { @@ -526,11 +518,17 @@ public class KeyguardViewMediator { if (soundPath == null || mUnlockSoundId == 0) { Log.w(TAG, "failed to load unlock sound from " + soundPath); } - int lockSoundDefaultAttenuation = context.getResources().getInteger( + int lockSoundDefaultAttenuation = mContext.getResources().getInteger( com.android.internal.R.integer.config_lockSoundVolumeDb); mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20); } + @Override + public void start() { + setup(); + putComponent(KeyguardViewMediator.class, this); + } + /** * Let us know that the system is ready after startup. */ 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 dd81c55..dcc6f37 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -16,14 +16,15 @@ package com.android.systemui.statusbar.phone; + import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT; import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.app.StatusBarManager.windowStateToString; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -35,11 +36,9 @@ import android.app.Notification; import android.app.PendingIntent; import android.app.StatusBarManager; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; @@ -67,7 +66,6 @@ import android.util.EventLog; import android.util.Log; import android.view.Display; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -75,28 +73,23 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewPropertyAnimator; import android.view.ViewStub; -import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; -import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.statusbar.StatusBarIcon; -import com.android.keyguard.KeyguardHostView; -import com.android.keyguard.KeyguardSimpleHostView; import com.android.systemui.DemoMode; import com.android.systemui.EventLogTags; import com.android.systemui.R; import com.android.systemui.SwipeHelper; -import com.android.systemui.keyguard.KeyguardService; -import com.android.systemui.keyguard.KeyguardStatusBarBinder; +import com.android.systemui.SystemUIApplication; +import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.GestureRecorder; @@ -104,7 +97,6 @@ import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.NotificationData.Entry; import com.android.systemui.statusbar.SignalClusterView; import com.android.systemui.statusbar.StatusBarIconView; - import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.DateView; @@ -114,7 +106,6 @@ import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.statusbar.policy.NotificationRowLayout; import com.android.systemui.statusbar.policy.OnSizeChangedListener; import com.android.systemui.statusbar.policy.RotationLockController; - import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; import java.io.FileDescriptor; @@ -279,7 +270,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { DisplayMetrics mDisplayMetrics = new DisplayMetrics(); - protected KeyguardStatusBarBinder mKeyguardService; // XXX: gesture research private final GestureRecorder mGestureRec = DEBUG_GESTURES ? new GestureRecorder("/sdcard/statusbar_gestures.dat") @@ -713,26 +703,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { } private void startKeyguard() { - - // Create the connection to KeyguardService. - Intent intent = new Intent(mContext, KeyguardService.class); - intent.setAction(KeyguardService.ACTION_STATUS_BAR_BIND); - if (!mContext.bindService(intent, new ServiceConnection() { - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mKeyguardService = (KeyguardStatusBarBinder) service; - mKeyguardService.registerStatusBar(PhoneStatusBar.this, mStatusBarWindow, - mStatusBarWindowManager); - } - - @Override - public void onServiceDisconnected(ComponentName name) { - if (DEBUG) Log.v(TAG, "Keyguard disconnected."); - mKeyguardService = null; - } - }, Context.BIND_AUTO_CREATE)) { - throw new RuntimeException("Couldn't bind status bar keyguard."); - } + getComponent(KeyguardViewMediator.class).registerStatusBar( + this, mStatusBarWindow, mStatusBarWindowManager); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 722a958..9ccd8e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -56,7 +56,6 @@ public class StatusBarKeyguardViewManager { private StatusBarWindowManager mStatusBarWindowManager; private boolean mScreenOn = false; - private boolean mShowOnRegister; public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils) { @@ -71,13 +70,6 @@ public class StatusBarKeyguardViewManager { mPhoneStatusBar = phoneStatusBar; mContainer = container; mStatusBarWindowManager = statusBarWindowManager; - if (mShowOnRegister) { - mShowOnRegister = false; - show(null); - if (mScreenOn) { - onScreenTurnedOn(null); - } - } } /** @@ -85,13 +77,9 @@ public class StatusBarKeyguardViewManager { * lazily. */ public void show(Bundle options) { - if (mStatusBarWindowManager != null) { - ensureView(); - mStatusBarWindowManager.setKeyguardShowing(true); - mKeyguardView.requestFocus(); - } else { - mShowOnRegister = true; - } + ensureView(); + mStatusBarWindowManager.setKeyguardShowing(true); + mKeyguardView.requestFocus(); } private void ensureView() { @@ -168,9 +156,7 @@ public class StatusBarKeyguardViewManager { } public void setNeedsInput(boolean needsInput) { - if (mStatusBarWindowManager != null) { - mStatusBarWindowManager.setKeyguardNeedsInput(needsInput); - } + mStatusBarWindowManager.setKeyguardNeedsInput(needsInput); } public void updateUserActivityTimeout() { @@ -190,24 +176,19 @@ public class StatusBarKeyguardViewManager { } public void setOccluded(boolean occluded) { - if (mStatusBarWindowManager != null) { - mStatusBarWindowManager.setKeyguardOccluded(occluded); - } + mStatusBarWindowManager.setKeyguardOccluded(occluded); } /** * Hides the keyguard view */ public void hide() { - if (mPhoneStatusBar != null) { - mStatusBarWindowManager.setKeyguardShowing(false); - if (mKeyguardView != null) { - mKeyguardView.cleanUp(); - mViewMediatorCallback.keyguardGone(); - } - removeView(); + mStatusBarWindowManager.setKeyguardShowing(false); + if (mKeyguardView != null) { + mKeyguardView.cleanUp(); + mViewMediatorCallback.keyguardGone(); } - mShowOnRegister = false; + removeView(); } /** diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 026d44e..62878e9 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -177,6 +177,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ private WindowState mKeyguardScrim; private boolean mKeyguardHidden; + private boolean mKeyguardDrawn; /* Table of Application Launch keys. Maps from key codes to intent categories. * @@ -4355,21 +4356,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void waitForKeyguard(final ScreenOnListener screenOnListener) { if (mKeyguardDelegate != null) { - if (screenOnListener != null) { - mKeyguardDelegate.onScreenTurnedOn(new KeyguardServiceDelegate.ShowListener() { - @Override - public void onShown(IBinder windowToken) { - waitForKeyguardWindowDrawn(windowToken, screenOnListener); - } - }); - return; - } else { - mKeyguardDelegate.onScreenTurnedOn(null); - } + mKeyguardDelegate.onScreenTurnedOn(new KeyguardServiceDelegate.ShowListener() { + @Override + public void onShown(IBinder windowToken) { + waitForKeyguardWindowDrawn(windowToken, screenOnListener); + } + }); } else { Slog.i(TAG, "No keyguard interface!"); + finishScreenTurningOn(screenOnListener); } - finishScreenTurningOn(screenOnListener); } private void waitForKeyguardWindowDrawn(IBinder windowToken, @@ -4382,6 +4378,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void sendResult(Bundle data) { Slog.i(TAG, "Lock screen displayed!"); finishScreenTurningOn(screenOnListener); + setKeyguardDrawn(); } })) { return; @@ -4395,6 +4392,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Slog.i(TAG, "No lock screen! windowToken=" + windowToken); finishScreenTurningOn(screenOnListener); + setKeyguardDrawn(); } private void finishScreenTurningOn(ScreenOnListener screenOnListener) { @@ -4475,6 +4473,23 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + private void setKeyguardDrawn() { + synchronized (mLock) { + mKeyguardDrawn = true; + } + try { + mWindowManager.enableScreenIfNeeded(); + } catch (RemoteException unhandled) { + } + } + + @Override + public boolean isKeyguardDrawnLw() { + synchronized (mLock) { + return mKeyguardDrawn; + } + } + void sendCloseSystemWindows() { sendCloseSystemWindows(mContext, null); } @@ -4758,6 +4773,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { synchronized (mLock) { mSystemBooted = true; } + waitForKeyguard(null); } ProgressDialog mBootMsgDialog = null; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index cb27110..05f58a7 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5290,6 +5290,13 @@ public class WindowManagerService extends IWindowManager.Stub performEnableScreen(); } + @Override + public void enableScreenIfNeeded() { + synchronized (mWindowMap) { + enableScreenIfNeededLocked(); + } + } + void enableScreenIfNeededLocked() { if (DEBUG_BOOT) { RuntimeException here = new RuntimeException("here"); @@ -5354,18 +5361,6 @@ public class WindowManagerService extends IWindowManager.Stub final int N = windows.size(); for (int i=0; i<N; i++) { WindowState w = windows.get(i); - if ((w.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { - // Only if there is a keyguard attached to the window manager - // will we consider ourselves as having a keyguard. If it - // isn't attached, we don't know if it wants to be shown or - // hidden. If it is attached, we will say we have a keyguard - // if the window doesn't want to be visible, because in that - // case it explicitly doesn't want to be shown so we should - // not delay turning the screen on for it. - boolean vis = w.mViewVisibility == View.VISIBLE - && w.mPolicyVisibility; - haveKeyguard = !vis; - } if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) { return; } @@ -5376,8 +5371,8 @@ public class WindowManagerService extends IWindowManager.Stub haveApp = true; } else if (w.mAttrs.type == TYPE_WALLPAPER) { haveWallpaper = true; - } else if ((w.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { - haveKeyguard = true; + } else if (w.mAttrs.type == TYPE_STATUS_BAR) { + haveKeyguard = mPolicy.isKeyguardDrawnLw(); } } } diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index 743a26c..e8c8d5d 100644 --- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -462,4 +462,8 @@ public class IWindowManagerImpl implements IWindowManager { // TODO Auto-generated method stub return false; } + + @Override + public void enableScreenIfNeeded() throws RemoteException { + } } |