From 328472ebd8f9c139fef1ad859ed4f7b43b3f86c6 Mon Sep 17 00:00:00 2001 From: "dooyoung.hwang" Date: Thu, 21 May 2015 16:09:43 +0900 Subject: [PATCH] Patches for IKeyguardStateCallback 1. Also notify input is restricted or not when IKeyguardStateCallback callback is added. When first Keyguard is showing after boot, the mInputRestricted is not updated. So, inKeyguardRestrictedInputMode still returns false, although device is locked. 2. If mShowing remains false during setup time of KeyguardViewMediator, mInputRestricted is not updated. This is because updateInputRestrictedLocked is called only if showing value is changed during setup time. For this reason, when device is not provisioned, inKeyguardRestrictedInputMode returns false, and device does not restrict key. 3. If one of callbacks causes RemoteException, the other callbacks are not called. This is because catching RemoteException breaks for-loop. (cherry-picked from commit 516dad062580201d7a4ad6c112b23434385d5268) Change-Id: I0281405127bcc75285b908d01485da3ac9b40b52 Signed-off-by: Dooyoung Hwang --- .../keyguard/KeyguardViewMediator.java | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 74962ec093194..a53a7184713f3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -33,6 +33,7 @@ import android.content.pm.UserInfo; import android.media.AudioManager; import android.media.SoundPool; import android.os.Bundle; +import android.os.DeadObjectException; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -374,14 +375,17 @@ public class KeyguardViewMediator extends SystemUI { + ",state=" + simState + ")"); } - try { - int size = mKeyguardStateCallbacks.size(); - boolean simPinSecure = mUpdateMonitor.isSimPinSecure(); - for (int i = 0; i < size; i++) { + int size = mKeyguardStateCallbacks.size(); + boolean simPinSecure = mUpdateMonitor.isSimPinSecure(); + for (int i = size - 1; i >= 0; i--) { + try { mKeyguardStateCallbacks.get(i).onSimSecureStateChanged(simPinSecure); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to call onSimSecureStateChanged", e); + if (e instanceof DeadObjectException) { + mKeyguardStateCallbacks.remove(i); + } } - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onSimSecureStateChanged", e); } switch (simState) { @@ -544,6 +548,7 @@ public class KeyguardViewMediator extends SystemUI { // Assume keyguard is showing (unless it's disabled) until we know for sure... setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled( KeyguardUpdateMonitor.getCurrentUser())); + updateInputRestrictedLocked(); mTrustManager.reportKeyguardShowingChanged(); mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, @@ -925,13 +930,16 @@ public class KeyguardViewMediator extends SystemUI { boolean inputRestricted = isInputRestricted(); if (mInputRestricted != inputRestricted) { mInputRestricted = inputRestricted; - try { - int size = mKeyguardStateCallbacks.size(); - for (int i = 0; i < size; i++) { + int size = mKeyguardStateCallbacks.size(); + for (int i = size - 1; i >= 0; i--) { + try { mKeyguardStateCallbacks.get(i).onInputRestrictedStateChanged(inputRestricted); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to call onDeviceProvisioned", e); + if (e instanceof DeadObjectException) { + mKeyguardStateCallbacks.remove(i); + } } - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onDeviceProvisioned", e); } } } @@ -1530,13 +1538,16 @@ public class KeyguardViewMediator extends SystemUI { private void setShowingLocked(boolean showing) { if (showing != mShowing) { mShowing = showing; - try { - int size = mKeyguardStateCallbacks.size(); - for (int i = 0; i < size; i++) { + int size = mKeyguardStateCallbacks.size(); + for (int i = size - 1; i >= 0; i--) { + try { mKeyguardStateCallbacks.get(i).onShowingStateChanged(showing); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to call onShowingStateChanged", e); + if (e instanceof DeadObjectException) { + mKeyguardStateCallbacks.remove(i); + } } - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onShowingStateChanged", e); } updateInputRestrictedLocked(); mTrustManager.reportKeyguardShowingChanged(); @@ -1551,7 +1562,7 @@ public class KeyguardViewMediator extends SystemUI { callback.onShowingStateChanged(mShowing); callback.onInputRestrictedStateChanged(mInputRestricted); } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged", e); + Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e); } } }