diff options
author | Jim Miller <jaggies@google.com> | 2013-10-16 18:15:46 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2013-10-17 16:40:13 -0700 |
commit | 174236381bfb7c49994667905a6fc6e1b8356a38 (patch) | |
tree | 9ae312c83bbf99225b6529b7b489a0a0fd6e6886 | |
parent | fc7e2d76a573b86e2630008bacaff966928c1652 (diff) | |
download | base-174236381bfb7c49994667905a6fc6e1b8356a38.tar.gz |
Fix issue where keyguard adds widgets before the system is ready
While under heavy system load, keyguard was able to create widgets before
before ActivityManagerService was ready. The result was a race
between keyguard adding widgets and ActivityManagerService being
ready to send broadcasts.
This fix provides keyguard with an additional signal to know when
the system is booted and widgets are safe to load.
Fixes bug b/11217169
Change-Id: I7a714d65b068678f961e52bdde4e1c20f9c287f0
7 files changed, 33 insertions, 6 deletions
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl index 45a38be8aee4..63ff5a074108 100644 --- a/core/java/com/android/internal/policy/IKeyguardService.aidl +++ b/core/java/com/android/internal/policy/IKeyguardService.aidl @@ -43,4 +43,5 @@ interface IKeyguardService { oneway void showAssistant(); oneway void dispatch(in MotionEvent event); oneway void launchCamera(); + oneway void onBootCompleted(); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java index d7c5fe2f0c16..36b2446c6b68 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java @@ -141,6 +141,10 @@ public class KeyguardService extends Service { checkPermission(); mKeyguardViewMediator.launchCamera(); } + public void onBootCompleted() { + checkPermission(); + mKeyguardViewMediator.onBootCompleted(); + } }; } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 45cd3d4bcd2a..520cea32b013 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -635,15 +635,14 @@ public class KeyguardUpdateMonitor { * PhoneWindowManager in this case. */ protected void dispatchBootCompleted() { - if (!mBootCompleted) { - mHandler.sendEmptyMessage(MSG_BOOT_COMPLETED); - } + mHandler.sendEmptyMessage(MSG_BOOT_COMPLETED); } /** * Handle {@link #MSG_BOOT_COMPLETED} */ protected void handleBootCompleted() { + if (mBootCompleted) return; mBootCompleted = true; mAudioManager = new AudioManager(mContext); mAudioManager.registerRemoteControlDisplay(mRemoteControlDisplay); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java index a37a3a440a7f..b92ae905b028 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java @@ -530,9 +530,6 @@ public class KeyguardViewMediator { mSystemReady = true; mUpdateMonitor.registerCallback(mUpdateCallback); - // Send boot completed message if it hasn't already been sent. - mUpdateMonitor.dispatchBootCompleted(); - // Suppress biometric unlock right after boot until things have settled if it is the // selected security method, otherwise unsuppress it. It must be unsuppressed if it is // not the selected security method for the following reason: if the user starts @@ -1366,4 +1363,8 @@ public class KeyguardViewMediator { Message msg = mHandler.obtainMessage(LAUNCH_CAMERA); mHandler.sendMessage(msg); } + + public void onBootCompleted() { + mUpdateMonitor.dispatchBootCompleted(); + } } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 1c43014e54c8..816672f7787c 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -4668,6 +4668,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void systemBooted() { + if (mKeyguardDelegate != null) { + mKeyguardDelegate.onBootCompleted(); + } synchronized (mLock) { mSystemBooted = true; } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java index 56a282b60577..bf22e2f79085 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java @@ -52,6 +52,7 @@ public class KeyguardServiceDelegate { public int offReason; public int currentUser; public boolean screenIsOn; + public boolean bootCompleted; }; public interface ShowListener { @@ -117,6 +118,9 @@ public class KeyguardServiceDelegate { // This is used to hide the scrim once keyguard displays. mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(null)); } + if (mKeyguardState.bootCompleted) { + mKeyguardService.onBootCompleted(); + } } @Override @@ -305,4 +309,11 @@ public class KeyguardServiceDelegate { }); } + public void onBootCompleted() { + if (mKeyguardService != null) { + mKeyguardService.onBootCompleted(); + } + mKeyguardState.bootCompleted = true; + } + } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java index 83be1a801b88..9fb2a504a265 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java @@ -180,6 +180,14 @@ public class KeyguardServiceWrapper implements IKeyguardService { } } + public void onBootCompleted() { + try { + mService.onBootCompleted(); + } catch (RemoteException e) { + Slog.w(TAG , "Remote Exception", e); + } + } + public void showAssistant() { // Not used by PhoneWindowManager } |