System UI
1.Introduction
1.0 注
梳理SystemUI - keyguard相关的代码执行流程,只做梳理,用于记录和输出md或pdf文档,然后基于pdf做分析和笔记,所以这里没有代码解析,只有大致的调用流程和重点方法的代码。欢迎纠错~
1.1 System UI
SystemUI: Android的系统界面,它包括了界面上方的状态栏status bar,下方的导航栏Navigation Bar,锁屏界面 Keyguard,电源界面PowerUI,近期任务界面Recent Task等。
1.2 代码路径
<source-code-path>/framework/base/packages/SystemUI
1.3 具体实现
- Status Bar 系统上方的状态栏
- Navigator Bar 系统下方的导航栏
- Keyguard 锁屏界面
- PowerUI 电源界面
- Recents Screen 近期任务界面
- VolumeUI 音量调节对话框
- Stack Divider 分屏功能调节器
- PipUI 画中画界面
- Screenshot 截屏界面
- RingtonePlayer 铃声播放器界面
- Settings Activity 系统设置中用到的一些界面,例如:NetworkOverLimitActivity,UsbDebuggingActivity等。
1.4 System UI 启动流程
framework/base/service/java/com/android/server/SystemServer.java : main() -> SystemServer().run();- run() -> startBootstrapServices()
-> startOtherServices() -> mActivityManagerService.systemReady -> startSystemUi() 在该方法中启动SystemUI - startSystemUi() ->
framework/base/packages/SystemUI/src/com/android/systemui/SystemUIService.java : onCreate() - onCreate() -> ((SystemUIApplication) getApplication()).startServicesIfNeeded()
- 读取service中预存的每个SystemUI相关类的反射,创建对应实例并启动相应的SystemUI进程
2. Keyguard
2.1 Keyguard
即Android 中处理锁屏(电源键按下、屏幕显示时间超时)、解锁(滑动、图案、指纹、声音、人脸、虹膜等)、锁屏下显示通知管理者。
2.2 KeyguardService的系统状态入口
void onStartedGoingToSleep(int pmSleepReason);
void onFinishedGoingToSleep(int pmSleepReason, boolean cameraGestureTriggered);
void onStartedWakingUp(int pmWakeReason, boolean cameraGestureTriggered);
void onFinishedWakingUp();
void onScreenTurningOn(IKeyguardDrawnCallback callback);
void onScreenTurnedOn();
void onScreenTurningOff();
void onScreenTurnedOff();
void onSystemReady();
void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
void onShortPowerPressedGoHome();
2.3 Keyguard启动 - onSystemReady
1.KeyguardService.onSystemReady()
public void onSystemReady() {
Trace.beginSection("KeyguardService.mBinder#onSystemReady");
checkPermission();
mKeyguardViewMediator.onSystemReady();
Trace.endSection();
}
2.KeyguardViewMediator.handleSystemReady()
private void handleSystemReady() {
synchronized (this) {
if (DEBUG) Log.d(TAG, "onSystemReady");
mSystemReady = true;
doKeyguardLocked(null);
mUpdateMonitor.registerCallback(mUpdateCallback);
}
maybeSendUserPresentBroadcast();
}
3.KeyguardViewMediator.doKeyguardLocked()
private void doKeyguardLocked(Bundle options) {
if (KeyguardUpdateMonitor.CORE_APPS_ONLY) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because booting to cryptkeeper");
return;
}
if (!mExternallyEnabled) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
mNeedToReshowWhenReenabled = true;
return;
}
if (mStatusBarKeyguardViewManager.isShowing()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
resetStateLocked();
return;
}
if (!mustNotUnlockCurrentUser()
|| !mUpdateMonitor.isDeviceProvisioned()) {
final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", false);
final boolean absent = SubscriptionManager.isValidSubscriptionId(
mUpdateMonitor.getNextSubIdForState(ABSENT));
final boolean disabled = SubscriptionManager.isValidSubscriptionId(
mUpdateMonitor.getNextSubIdForState(IccCardConstants.State.PERM_DISABLED));
final boolean lockedOrMissing = mUpdateMonitor.isSimPinSecure()
|| ((absent || disabled) && requireSim);
if (!lockedOrMissing && shouldWaitForProvisioning() && !mShowing) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned"
+ " and the sim is not locked or missing");
return;
}
boolean forceShow = options != null && options.getBoolean(OPTION_FORCE_SHOW, false);
if (mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser())
&& !lockedOrMissing && !forceShow && !mShowing) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
return;
}
if (mLockPatternUtils.checkVoldPassword(KeyguardUpdateMonitor.getCurrentUser())) {
if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted");
setShowingLocked(false);
hideLocked();
return;
}
}
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
showLocked(options);
}
4.KeyguardViewMediator.showLocked()
private void showLocked(Bundle options) {
Trace.beginSection("KeyguardViewMediator#showLocked aqcuiring mShowKeyguardWakeLock");
if (DEBUG) Log.d(TAG, "showLocked");
mShowKeyguardWakeLock.acquire();
Message msg = mHandler.obtainMessage(SHOW, options);
mHandler.sendMessage(msg);
Trace.endSection();
}
5.KeyguardViewMediator.handleMessage() -> handleShow()
private void handleShow(Bundle options) {
Trace.beginSection("KeyguardViewMediator#handleShow");
final int currentUser = KeyguardUpdateMonitor.getCurrentUser();
if (mLockPatternUtils.isSecure(currentUser)) {
mLockPatternUtils.getDevicePolicyManager().reportKeyguardSecured(currentUser);
}
synchronized (KeyguardViewMediator.this) {
if (!mSystemReady) {
if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready.");
return;
} else {
if (DEBUG) Log.d(TAG, "handleShow");
}
mHiding = false;
mWakeAndUnlocking = false;
setShowingLocked(true);
mStatusBarKeyguardViewManager.show(options);
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
adjustStatusBarLocked();
userActivity();
mUpdateMonitor.setKeyguardGoingAway(false );
mStatusBarWindowController.setKeyguardGoingAway(false );
mShowKeyguardWakeLock.release();
}
mKeyguardDisplayManager.show();
Trace.endSection();
}
6.StatusBarKeyguardViewManager.show()
public void show(Bundle options) {
mShowing = true;
mStatusBarWindowController.setKeyguardShowing(true);
mKeyguardMonitor.notifyKeyguardState(
mShowing, mKeyguardMonitor.isSecure(), mKeyguardMonitor.isOccluded());
reset(true );
StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
StatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN);
}
7.StatusBarKeyguardViewManager.reset()
public void reset(boolean hideBouncerWhenShowing) {
if (mShowing) {
if (mOccluded && !mDozing) {
mStatusBar.hideKeyguard();
if (hideBouncerWhenShowing || mBouncer.needsFullscreenBouncer()) {
hideBouncer(false );
}
} else {
showBouncerOrKeyguard(hideBouncerWhenShowing);
}
KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
updateStates();
}
}
UpdateMonitor.handleKeyguardReset
private void handleKeyguardReset() {
if (DEBUG) Log.d(TAG, "handleKeyguardReset");
updateBiometricListeningState();
mNeedsSlowUnlockTransition = resolveNeedsSlowUnlockTransition();
}
8.StatusBarKeyguardViewManager.showBouncerOrKeyguard()
protected void showBouncerOrKeyguard() {
if (mBouncer.needsFullscreenBouncer()) {
mPhoneStatusBar.hideKeyguard();
mBouncer.show(true );
} else {
mPhoneStatusBar.showKeyguard();
mBouncer.hide(false );
mBouncer.prepare();
}
}
9.Bouncer.needsFullscreenBouncer():
public boolean needsFullscreenBouncer() {
ensureView();
SecurityMode mode = mSecurityModel.getSecurityMode();
return mode == SecurityMode.SimPinPukMe1
|| mode == SecurityMode.SimPinPukMe2
|| mode == SecurityMode.SimPinPukMe3
|| mode == SecurityMode.SimPinPukMe4
|| mode == SecurityMode.AntiTheft
|| mode == SecurityMode.AlarmBoot;
}
10.KeyguardSecurityModel.getSecurityMode():
public SecurityMode getSecurityMode() {
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
SecurityMode mode = SecurityMode.None;
if (PowerOffAlarmManager.isAlarmBoot()) {
mode = SecurityMode.AlarmBoot;
} else {
for (int i = 0; i < KeyguardUtils.getNumOfPhone(); i++) {
if (isPinPukOrMeRequiredOfPhoneId(i)) {
if (0 == i) {
mode = SecurityMode.SimPinPukMe1;
} else if (1 == i) {
mode = SecurityMode.SimPinPukMe2;
} else if (2 == i) {
mode = SecurityMode.SimPinPukMe3;
} else if (3 == i) {
mode = SecurityMode.SimPinPukMe4;
}
break;
}
}
}
if (AntiTheftManager.isAntiTheftPriorToSecMode(mode)) {
Log.d("KeyguardSecurityModel", "should show AntiTheft!") ;
mode = SecurityMode.AntiTheft;
}
if (mode == SecurityMode.None) {
final int security = mLockPatternUtils.getActivePasswordQuality(
KeyguardUpdateMonitor.getCurrentUser());
switch (security) {
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
return SecurityMode.PIN;
case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
return SecurityMode.Password;
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
return SecurityMode.Pattern;
case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED:
return SecurityMode.None;
default:
throw new IllegalStateException("Unknown security quality:" + security);
}
}
Log.d(TAG, "getSecurityMode() - mode = " + mode);
return mode;
}
11.StatusBar.showKeyguard() / hideKeyguard()
public void showKeyguard() {
mStatusBarStateController.setKeyguardRequested(true);
mStatusBarStateController.setLeaveOpenOnKeyguardHide(false);
updateIsKeyguard();
mAssistManagerLazy.get().onLockscreenShown();
}
public boolean hideKeyguard() {
mStatusBarStateController.setKeyguardRequested(false);
return updateIsKeyguard();
}
12.StatusBar.updateIsKeyguard
boolean updateIsKeyguard() {
return updateIsKeyguard(false );
}
boolean updateIsKeyguard(boolean force) {
boolean wakeAndUnlocking = mBiometricUnlockController.getMode()
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
boolean keyguardForDozing = mDozeServiceHost.getDozingRequested()
&& (!mDeviceInteractive || isGoingToSleep() && (isScreenFullyOff() || mIsKeyguard));
boolean shouldBeKeyguard = (mStatusBarStateController.isKeyguardRequested()
|| keyguardForDozing) && !wakeAndUnlocking;
if (keyguardForDozing) {
updatePanelExpansionForKeyguard();
}
if (shouldBeKeyguard) {
if (mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
|| (isGoingToSleep()
&& mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_TURNING_OFF)) {
} else {
showKeyguardImpl();
}
} else {
return hideKeyguardImpl(force);
}
return false;
}
13.KeyguardDisplayManager.hide() / show()
public void show() {
if (!mShowing) {
if (DEBUG) Log.v(TAG, "show");
if (mMediaRouter != null) {
mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY,
mMediaRouterCallback, MediaRouter.CALLBACK_FLAG_PASSIVE_DISCOVERY);
} else {
Log.w(TAG, "MediaRouter not yet initialized");
}
updateDisplays(true );
}
mShowing = true;
}
public void hide() {
if (mShowing) {
if (DEBUG) Log.v(TAG, "hide");
if (mMediaRouter != null) {
mMediaRouter.removeCallback(mMediaRouterCallback);
}
updateDisplays(false );
}
mShowing = false;
}
14.KeyguardDisplayManager.updateDisplays
protected boolean updateDisplays(boolean showing) {
boolean changed = false;
if (showing) {
final Display[] displays = mDisplayService.getDisplays();
for (Display display : displays) {
int displayId = display.getDisplayId();
updateNavigationBarVisibility(displayId, false );
changed |= showPresentation(display);
}
} else {
changed = mPresentations.size() > 0;
for (int i = mPresentations.size() - 1; i >= 0; i--) {
int displayId = mPresentations.keyAt(i);
updateNavigationBarVisibility(displayId, true );
mPresentations.valueAt(i).dismiss();
}
mPresentations.clear();
}
return changed;
}
2.4 onStartGoingToSleep
1.KeyguardMediator.onStartedGoingToSleep
public void onStartedGoingToSleep(@WindowManagerPolicyConstants.OffReason int offReason) {
if (DEBUG) Log.d(TAG, "onStartedGoingToSleep(" + offReason + ")");
synchronized (this) {
mDeviceInteractive = false;
mPowerGestureIntercepted = false;
mGoingToSleep = true;
int currentUser = KeyguardUpdateMonitor.getCurrentUser();
final boolean lockImmediately =
mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
|| !mLockPatternUtils.isSecure(currentUser);
long timeout = getLockTimeout(KeyguardUpdateMonitor.getCurrentUser());
mLockLater = false;
if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled");
try {
mExitSecureCallback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
mExitSecureCallback = null;
if (!mExternallyEnabled) {
hideLocked();
}
} else if (mShowing) {
mPendingReset = true;
} else if (
(offReason == WindowManagerPolicyConstants.OFF_BECAUSE_OF_TIMEOUT
&& timeout > 0)
|| (offReason == WindowManagerPolicyConstants.OFF_BECAUSE_OF_USER
&& !lockImmediately)) {
doKeyguardLaterLocked(timeout);
mLockLater = true;
} else if (!mLockPatternUtils.isLockScreenDisabled(currentUser)) {
mPendingLock = true;
}
if (mPendingLock) {
playSounds(true);
}
}
mUpdateMonitor.dispatchStartedGoingToSleep(offReason);
mUpdateMonitor.dispatchKeyguardGoingAway(false);
notifyStartedGoingToSleep();
}
2.KeyguardViewMediator.hideLocked
private void hideLocked() {
Trace.beginSection("KeyguardViewMediator#hideLocked");
if (DEBUG) Log.d(TAG, "hideLocked");
Message msg = mHandler.obtainMessage(HIDE);
mHandler.sendMessage(msg);
Trace.endSection();
}
3.KeyguardViewMediator.handleHide
private void handleHide() {
Trace.beginSection("KeyguardViewMediator#handleHide");
if (mAodShowing) {
PowerManager pm = mContext.getSystemService(PowerManager.class);
pm.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
"com.android.systemui:BOUNCER_DOZING");
}
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleHide");
if (mustNotUnlockCurrentUser()) {
if (DEBUG) Log.d(TAG, "Split system user, quit unlocking.");
mKeyguardExitAnimationRunner = null;
return;
}
mHiding = true;
if (mShowing && !mOccluded) {
mKeyguardGoingAwayRunnable.run();
} else {
handleStartKeyguardExitAnimation(
SystemClock.uptimeMillis() + mHideAnimation.getStartOffset(),
mHideAnimation.getDuration(), null , null ,
null , null );
}
}
Trace.endSection();
}
4.KeyguardGoingAwayRunnable.run
public void run() {
Trace.beginSection("KeyguardViewMediator.mKeyGuardGoingAwayRunnable");
if (DEBUG) Log.d(TAG, "keyguardGoingAway");
mKeyguardViewControllerLazy.get().keyguardGoingAway();
int flags = 0;
if (mKeyguardViewControllerLazy.get().shouldDisableWindowAnimationsForUnlock()
|| (mWakeAndUnlocking && !mPulsing)
|| isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe()) {
flags |= WindowManagerPolicyConstants
.KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS;
}
if (mKeyguardViewControllerLazy.get().isGoingToNotificationShade()
|| (mWakeAndUnlocking && mPulsing)) {
flags |= WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
}
if (mKeyguardViewControllerLazy.get().isUnlockWithWallpaper()) {
flags |= KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
}
if (mKeyguardViewControllerLazy.get().shouldSubtleWindowAnimationsForUnlock()) {
flags |= WindowManagerPolicyConstants
.KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS;
}
mUpdateMonitor.setKeyguardGoingAway(true);
mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(true);
final int keyguardFlag = flags;
mUiBgExecutor.execute(() -> {
try {
ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag);
} catch (RemoteException e) {
Log.e(TAG, "Error while calling WindowManager", e);
}
});
Trace.endSection();
}
4.1 KeyguardController.keyguardGoingAway
void keyguardGoingAway(int flags) {
if (!mKeyguardShowing) {
return;
}
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "keyguardGoingAway");
mService.deferWindowLayout();
mKeyguardGoingAway = true;
try {
EventLogTags.writeWmSetKeyguardShown(
1 ,
mAodShowing ? 1 : 0,
1 ,
"keyguardGoingAway");
mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
TRANSIT_KEYGUARD_GOING_AWAY, convertTransitFlags(flags));
updateKeyguardSleepToken();
mRootWindowContainer.resumeFocusedTasksTopActivities();
mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
mRootWindowContainer.addStartingWindowsForVisibleActivities();
mWindowManager.executeAppTransition();
} finally {
mService.continueWindowLayout();
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
}
5.keyguardViewMediator.handleStartKeyguardExitAnimation
private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration,
RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers,
RemoteAnimationTarget[] nonApps, IRemoteAnimationFinishedCallback finishedCallback) {
Trace.beginSection("KeyguardViewMediator#handleStartKeyguardExitAnimation");
if (DEBUG) Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
+ " fadeoutDuration=" + fadeoutDuration);
synchronized (KeyguardViewMediator.this) {
if (!mHiding
&& !mSurfaceBehindRemoteAnimationRequested
&& !mKeyguardStateController.isFlingingToDismissKeyguardDuringSwipeGesture()) {
if (finishedCallback != null) {
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationFinished", e);
}
}
setShowingLocked(mShowing, true );
return;
}
mHiding = false;
IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner;
mKeyguardExitAnimationRunner = null;
if (mWakeAndUnlocking && mDrawnCallback != null) {
mKeyguardViewControllerLazy.get().getViewRootImpl().setReportNextDraw();
notifyDrawn(mDrawnCallback);
mDrawnCallback = null;
}
LatencyTracker.getInstance(mContext)
.onActionEnd(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation && runner != null
&& finishedCallback != null) {
IRemoteAnimationFinishedCallback callback =
new IRemoteAnimationFinishedCallback() {
@Override
public void onAnimationFinished() throws RemoteException {
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationFinished", e);
}
onKeyguardExitFinished();
mKeyguardViewControllerLazy.get().hide(0 ,
0 );
InteractionJankMonitor.getInstance()
.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
@Override
public IBinder asBinder() {
return finishedCallback.asBinder();
}
};
try {
InteractionJankMonitor.getInstance().begin(
createInteractionJankMonitorConf("RunRemoteAnimation"));
runner.onAnimationStart(WindowManager.TRANSIT_KEYGUARD_GOING_AWAY, apps,
wallpapers, nonApps, callback);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationStart", e);
}
} else if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
&& !mStatusBarStateController.leaveOpenOnKeyguardHide()
&& apps != null && apps.length > 0) {
mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback;
mSurfaceBehindRemoteAnimationRunning = true;
InteractionJankMonitor.getInstance().begin(
createInteractionJankMonitorConf("DismissPanel"));
mKeyguardUnlockAnimationControllerLazy.get().notifyStartKeyguardExitAnimation(
apps[0], startTime, mSurfaceBehindRemoteAnimationRequested);
} else {
InteractionJankMonitor.getInstance().begin(
createInteractionJankMonitorConf("RemoteAnimationDisabled"));
mKeyguardViewControllerLazy.get().hide(startTime, fadeoutDuration);
mContext.getMainExecutor().execute(() -> {
if (finishedCallback == null) {
InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
return;
}
final SyncRtSurfaceTransactionApplier applier =
new SyncRtSurfaceTransactionApplier(
mKeyguardViewControllerLazy.get().getViewRootImpl().getView());
final RemoteAnimationTarget primary = apps[0];
ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
anim.setDuration(400 );
anim.setInterpolator(Interpolators.LINEAR);
anim.addUpdateListener((ValueAnimator animation) -> {
SyncRtSurfaceTransactionApplier.SurfaceParams params =
new SyncRtSurfaceTransactionApplier.SurfaceParams.Builder(
primary.leash)
.withAlpha(animation.getAnimatedFraction())
.build();
applier.scheduleApply(params);
});
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
} finally {
InteractionJankMonitor.getInstance()
.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
}
@Override
public void onAnimationCancel(Animator animation) {
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
} finally {
InteractionJankMonitor.getInstance()
.cancel(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
}
});
anim.start();
});
onKeyguardExitFinished();
}
}
Trace.endSection();
}
6.KeyguardMediator.setShowingLocked
void setShowingLocked(boolean showing) {
setShowingLocked(showing, false );
}
private void setShowingLocked(boolean showing, boolean forceCallbacks) {
final boolean aodShowing = mDozing && !mWakeAndUnlocking;
final boolean notifyDefaultDisplayCallbacks = showing != mShowing
|| aodShowing != mAodShowing || forceCallbacks;
mShowing = showing;
mAodShowing = aodShowing;
if (notifyDefaultDisplayCallbacks) {
notifyDefaultDisplayCallbacks(showing);
updateActivityLockScreenState(showing, aodShowing);
}
}
7.IRemoteAnimationRunner.onAnimationStart
override fun onAnimationStart(
@WindowManager.TransitionOldType transit: Int,
apps: Array<out RemoteAnimationTarget>?,
wallpapers: Array<out RemoteAnimationTarget>?,
nonApps: Array<out RemoteAnimationTarget>?,
iCallback: IRemoteAnimationFinishedCallback?
) {
removeTimeout()
if (timedOut) {
iCallback?.invoke()
return
}
if (cancelled) {
return
}
context.mainExecutor.execute {
startAnimation(apps, nonApps, iCallback)
}
}
8.CarKeyguardViewController.hide
public void hide(long startTime, long fadeoutDuration) {
if (!mShowing) return;
mViewMediatorCallback.readyForKeyguardDone();
mShowing = false;
mKeyguardStateController.notifyKeyguardState(mShowing, false);
mBouncer.hide( true);
mCarSystemBarController.showAllNavigationButtons( true);
stop();
mKeyguardStateController.notifyKeyguardDoneFading();
mMainExecutor.execute(mViewMediatorCallback::keyguardGone);
notifyKeyguardUpdateMonitor();
}
KeyguardMediator.tryKeyguardDone
private void tryKeyguardDone() {
if (!mKeyguardDonePending && mHideAnimationRun && !mHideAnimationRunning) {
handleKeyguardDone();
} else if (!mHideAnimationRun) {
if (DEBUG) Log.d(TAG, "tryKeyguardDone: starting pre-hide animation");
mHideAnimationRun = true;
mHideAnimationRunning = true;
mKeyguardViewControllerLazy.get()
.startPreHideAnimation(mHideAnimationFinishedRunnable);
}
}
KeyguardLifeController(kt).updateListeningState
private fun updateListeningState() {
if (shouldListen != isListening) {
isListening = shouldListen
if (shouldListen) {
asyncSensorManager.requestTriggerSensor(listener, pickupSensor)
} else {
asyncSensorManager.cancelTriggerSensor(listener, pickupSensor)
}
}
}
9.KeyguardViewMediator.onKeyguardExitFinished
private void onKeyguardExitFinished() {
if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)) {
playSounds(false);
}
setShowingLocked(false);
mWakeAndUnlocking = false;
mDismissCallbackRegistry.notifyDismissSucceeded();
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
adjustStatusBarLocked();
sendUserPresentBroadcast();
}
2.5 onFinishedGoingToSleep
1. KeyguardViewMediator.onFinishedGoingToSleep
public void onFinishedGoingToSleep(
@WindowManagerPolicyConstants.OffReason int offReason, boolean cameraGestureTriggered) {
if (DEBUG) Log.d(TAG, "onFinishedGoingToSleep(" + offReason + ")");
synchronized (this) {
mDeviceInteractive = false;
mGoingToSleep = false;
mWakeAndUnlocking = false;
mAnimatingScreenOff = mDozeParameters.shouldControlUnlockedScreenOff();
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
notifyFinishedGoingToSleep();
if (cameraGestureTriggered) {
mContext.getSystemService(PowerManager.class).wakeUp(SystemClock.uptimeMillis(),
PowerManager.WAKE_REASON_CAMERA_LAUNCH,
"com.android.systemui:CAMERA_GESTURE_PREVENT_LOCK");
mPendingLock = false;
mPendingReset = false;
}
if (mPendingReset) {
resetStateLocked();
mPendingReset = false;
}
maybeHandlePendingLock();
if (!mLockLater && !cameraGestureTriggered) {
doKeyguardForChildProfilesLocked();
}
}
}
mUpdateMonitor.dispatchFinishedGoingToSleep(offReason);
}
private void notifyFinishedGoingToSleep() {
if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep");
mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP);
}
2.KeyguardViewMediator.handleNotifyFinishedGoingToSleep
private void handleNotifyFinishedGoingToSleep() {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyFinishedGoingToSleep");
mKeyguardViewControllerLazy.get().onFinishedGoingToSleep();
}
}
3.CarKeyguardViewController.onFinishedGoingToSleep
public void onFinishedGoingToSleep() {
if (mBouncer != null) {
mBouncer.onScreenTurnedOff();
}
}
4.KeyguardBouncer.onScreenTurnedOff
public void onScreenTurnedOff() {
if (mKeyguardViewController != null
&& mRoot != null && mRoot.getVisibility() == View.VISIBLE) {
mKeyguardViewController.onPause();
}
}
5.KeyguardHostViewController.onPause
public void onPause() {
if (DEBUG) {
Log.d(TAG, String.format("screen off, instance %s at %s",
Integer.toHexString(hashCode()), SystemClock.uptimeMillis()));
}
mKeyguardSecurityContainerController.showPrimarySecurityScreen(true);
mKeyguardSecurityContainerController.onPause();
mView.clearFocus();
}
6.KeyguardSecurityContainerController.showPrimarySecurityScreen / onPause
public void showPrimarySecurityScreen(boolean turningOff) {
SecurityMode securityMode = whitelistIpcs(() -> mSecurityModel.getSecurityMode(
KeyguardUpdateMonitor.getCurrentUser()));
if (DEBUG) Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
showSecurityScreen(securityMode);
}
public void onPause() {
mAdminSecondaryLockScreenController.hide();
if (mCurrentSecurityMode != SecurityMode.None) {
getCurrentSecurityController().onPause();
}
mView.onPause();
}
7.KeyguardUpdateMonitor.handleFinishedGoingToSleep
protected void handleFinishedGoingToSleep(int arg1) {
Assert.isMainThread();
mGoingToSleep = false;
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onFinishedGoingToSleep(arg1);
}
}
updateBiometricListeningState();
}
|