Skip to content

Commit 34c4fe5

Browse files
author
John Spurlock
committed
Fix remaining jank in secure add-widget transition.
Wait for activity to launch before dismissing the keyguard. Otherwise we see launcher/last activity waiting for the picker to start up. Also remove camera transition workaround obviated by: Iefee62061962625b622ff2cf9a307d9429c2ad54 Bug:7482560 Change-Id: I554ddffb7981488fa8a81933842b0c7730e775f3
1 parent cabcc59 commit 34c4fe5

File tree

6 files changed

+69
-41
lines changed

6 files changed

+69
-41
lines changed

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3899,7 +3899,7 @@ public boolean inKeyguardRestrictedKeyInputMode() {
38993899
}
39003900

39013901
public void dismissKeyguardLw() {
3902-
if (!mKeyguardMediator.isSecure()) {
3902+
if (mKeyguardMediator.isDismissable()) {
39033903
if (mKeyguardMediator.isShowing()) {
39043904
mHandler.post(new Runnable() {
39053905
public void run() {

policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,6 @@ private static View inflateGenericWidgetView(Context context) {
188188
return iv;
189189
}
190190

191-
@Override
192-
public void setPivotX(float pivotX) {
193-
// don't pivot me
194-
}
195-
196-
@Override
197-
public void setPivotY(float pivotY) {
198-
// don't pivot me
199-
}
200-
201191
public void render() {
202192
final Throwable[] thrown = new Throwable[1];
203193
final Bitmap[] offscreen = new Bitmap[1];

policy/src/com/android/internal/policy/impl/keyguard/KeyguardActivityLauncher.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import android.util.Log;
3636
import android.view.WindowManager;
3737

38+
import com.android.internal.policy.impl.keyguard.KeyguardSecurityCallback.OnDismissAction;
3839
import com.android.internal.widget.LockPatternUtils;
3940

4041
import java.util.List;
@@ -160,10 +161,8 @@ public void launchActivity(final Intent intent,
160161
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
161162
boolean isSecure = lockPatternUtils.isSecure();
162163
if (!isSecure || showsWhileLocked) {
163-
if (!isSecure) try {
164-
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
165-
} catch (RemoteException e) {
166-
Log.w(TAG, "can't dismiss keyguard on launch");
164+
if (!isSecure) {
165+
dismissKeyguardOnNextActivity();
167166
}
168167
try {
169168
if (DEBUG) Log.d(TAG, String.format("Starting activity for intent %s at %s",
@@ -176,16 +175,26 @@ public void launchActivity(final Intent intent,
176175
// Create a runnable to start the activity and ask the user to enter their
177176
// credentials.
178177
KeyguardSecurityCallback callback = getCallback();
179-
callback.setOnDismissRunnable(new Runnable() {
178+
callback.setOnDismissAction(new OnDismissAction() {
180179
@Override
181-
public void run() {
180+
public boolean onDismiss() {
181+
dismissKeyguardOnNextActivity();
182182
startActivityForCurrentUser(intent, animation, worker, onStarted);
183+
return true;
183184
}
184185
});
185186
callback.dismiss(false);
186187
}
187188
}
188189

190+
private void dismissKeyguardOnNextActivity() {
191+
try {
192+
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
193+
} catch (RemoteException e) {
194+
Log.w(TAG, "can't dismiss keyguard on launch");
195+
}
196+
}
197+
189198
private void startActivityForCurrentUser(final Intent intent, final Bundle options,
190199
Handler worker, final Runnable onStarted) {
191200
final UserHandle user = new UserHandle(UserHandle.USER_CURRENT);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import android.widget.RemoteViews.OnClickHandler;
5151

5252
import com.android.internal.R;
53+
import com.android.internal.policy.impl.keyguard.KeyguardSecurityCallback.OnDismissAction;
5354
import com.android.internal.policy.impl.keyguard.KeyguardSecurityModel.SecurityMode;
5455
import com.android.internal.widget.LockPatternUtils;
5556

@@ -79,7 +80,7 @@ public class KeyguardHostView extends KeyguardViewBase {
7980
private boolean mBootCompleted = false;
8081
private boolean mCheckAppWidgetConsistencyOnBootCompleted = false;
8182

82-
protected Runnable mLaunchRunnable;
83+
protected OnDismissAction mDismissAction;
8384

8485
protected int mFailedAttempts;
8586
private LockPatternUtils mLockPatternUtils;
@@ -364,8 +365,8 @@ public void showBackupSecurity() {
364365
}
365366

366367
@Override
367-
public void setOnDismissRunnable(Runnable runnable) {
368-
KeyguardHostView.this.setOnDismissRunnable(runnable);
368+
public void setOnDismissAction(OnDismissAction action) {
369+
KeyguardHostView.this.setOnDismissAction(action);
369370
}
370371

371372
};
@@ -569,12 +570,17 @@ private void showNextSecurityScreenOrFinish(boolean authenticated) {
569570

570571
// If there's a pending runnable because the user interacted with a widget
571572
// and we're leaving keyguard, then run it.
572-
if (mLaunchRunnable != null) {
573-
mLaunchRunnable.run();
574-
mLaunchRunnable = null;
573+
boolean deferKeyguardDone = false;
574+
if (mDismissAction != null) {
575+
deferKeyguardDone = mDismissAction.onDismiss();
576+
mDismissAction = null;
575577
}
576578
if (mViewMediatorCallback != null) {
577-
mViewMediatorCallback.keyguardDone(true);
579+
if (deferKeyguardDone) {
580+
mViewMediatorCallback.keyguardDonePending();
581+
} else {
582+
mViewMediatorCallback.keyguardDone(true);
583+
}
578584
}
579585
} else {
580586
mViewStateManager.showBouncer(true);
@@ -587,8 +593,8 @@ public boolean onClickHandler(final View view,
587593
final android.app.PendingIntent pendingIntent,
588594
final Intent fillInIntent) {
589595
if (pendingIntent.isActivity()) {
590-
setOnDismissRunnable(new Runnable() {
591-
public void run() {
596+
setOnDismissAction(new OnDismissAction() {
597+
public boolean onDismiss() {
592598
try {
593599
// TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
594600
Context context = view.getContext();
@@ -599,12 +605,13 @@ public void run() {
599605
pendingIntent.getIntentSender(), fillInIntent,
600606
Intent.FLAG_ACTIVITY_NEW_TASK,
601607
Intent.FLAG_ACTIVITY_NEW_TASK, 0, opts.toBundle());
602-
} catch (IntentSender.SendIntentException e) {
603-
android.util.Log.e(TAG, "Cannot send pending intent: ", e);
604-
} catch (Exception e) {
605-
android.util.Log.e(TAG, "Cannot send pending intent due to " +
606-
"unknown exception: ", e);
607-
}
608+
} catch (IntentSender.SendIntentException e) {
609+
android.util.Log.e(TAG, "Cannot send pending intent: ", e);
610+
} catch (Exception e) {
611+
android.util.Log.e(TAG, "Cannot send pending intent due to " +
612+
"unknown exception: ", e);
613+
}
614+
return false;
608615
}
609616
});
610617

@@ -633,7 +640,7 @@ public void showBackupSecurity() {
633640
}
634641

635642
@Override
636-
public void setOnDismissRunnable(Runnable runnable) {
643+
public void setOnDismissAction(OnDismissAction action) {
637644
}
638645

639646
@Override
@@ -668,11 +675,11 @@ public void reset() {
668675
}
669676

670677
/**
671-
* Sets a runnable to run when keyguard is dismissed
672-
* @param runnable
678+
* Sets an action to perform when keyguard is dismissed.
679+
* @param action
673680
*/
674-
protected void setOnDismissRunnable(Runnable runnable) {
675-
mLaunchRunnable = runnable;
681+
protected void setOnDismissAction(OnDismissAction action) {
682+
mDismissAction = action;
676683
}
677684

678685
private KeyguardSecurityView getSecurityView(SecurityMode securityMode) {
@@ -757,7 +764,7 @@ private void showSecurityScreen(SecurityMode securityMode) {
757764

758765
if (securityMode == SecurityMode.None) {
759766
// Discard current runnable if we're switching back to the selector view
760-
setOnDismissRunnable(null);
767+
setOnDismissAction(null);
761768
}
762769
mCurrentSecuritySelection = securityMode;
763770
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
public interface KeyguardSecurityCallback {
1919

20+
/*package*/ interface OnDismissAction {
21+
22+
/* returns true if the dismiss should be deferred */
23+
boolean onDismiss();
24+
}
25+
2026
/**
2127
* Dismiss the given security screen.
2228
* @param securityVerified true if the user correctly entered credentials for the given screen.
@@ -58,9 +64,9 @@ public interface KeyguardSecurityCallback {
5864
void showBackupSecurity();
5965

6066
/**
61-
* Sets a runnable to launch after the user successfully enters their credentials.
62-
* @param runnable
67+
* Sets an action to perform after the user successfully enters their credentials.
68+
* @param action
6369
*/
64-
void setOnDismissRunnable(Runnable runnable);
70+
void setOnDismissAction(OnDismissAction action);
6571

6672
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ public class KeyguardViewMediator {
235235
*/
236236
private boolean mWaitingUntilKeyguardVisible = false;
237237
private LockPatternUtils mLockPatternUtils;
238+
private boolean mKeyguardDonePending = false;
238239

239240
private SoundPool mLockSounds;
240241
private int mLockSoundId;
@@ -294,6 +295,11 @@ public interface ViewMediatorCallback {
294295
* has changed and needs to be reapplied to the window.
295296
*/
296297
void onUserActivityTimeoutChanged();
298+
299+
/**
300+
* Report that the keyguard is dismissable, pending the next keyguardDone call.
301+
*/
302+
void keyguardDonePending();
297303
}
298304

299305
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@@ -436,6 +442,11 @@ public void setNeedsInput(boolean needsInput) {
436442
public void onUserActivityTimeoutChanged() {
437443
mKeyguardViewManager.updateUserActivityTimeout();
438444
}
445+
446+
@Override
447+
public void keyguardDonePending() {
448+
mKeyguardDonePending = true;
449+
}
439450
};
440451

441452
public void wakeUp() {
@@ -1044,6 +1055,7 @@ public void onWakeMotionWhenKeyguardShowingTq() {
10441055
}
10451056

10461057
public void keyguardDone(boolean authenticated, boolean wakeup) {
1058+
mKeyguardDonePending = false;
10471059
synchronized (this) {
10481060
EventLog.writeEvent(70000, 2);
10491061
if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")");
@@ -1377,4 +1389,8 @@ private void handleNotifyScreenOn(KeyguardViewManager.ShowListener showListener)
13771389
}
13781390
}
13791391

1392+
public boolean isDismissable() {
1393+
return mKeyguardDonePending || !isSecure();
1394+
}
1395+
13801396
}

0 commit comments

Comments
 (0)