systemui shutdown dialog related
1. The systemui pull-down shutdown button
is found through the Android layout analysis tool
Button layout
base/packages/SystemUI/res-keyguard/layout/footer_actions.xml
button initialization and click event
frameworks/base/packages/SystemUI/src/com/android/systemui/qs/FooterActionsController.kt
private val powerMenuLite: View = view.findViewById(R.id.pm_lite)
...
powerMenuLite.setOnClickListener(onClickListener)
...
private val onClickListener = View.OnClickListener {
v ->
// Don't do anything if the tap looks suspicious.
if (!visible || falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
return@OnClickListener
}
if (v === settingsButtonContainer) {
if (!deviceProvisionedController.isCurrentUserSetup) {
// If user isn't setup just unlock the device and dump them back at SUW.
activityStarter.postQSRunnableDismissingKeyguard {
}
return@OnClickListener
}
metricsLogger.action(MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH)
startSettingsActivity()
} else if (v === powerMenuLite) {
uiEventLogger.log(GlobalActionsDialogLite.GlobalActionsEvent.GA_OPEN_QS)
globalActionsDialog?.showOrHideDialog(false, true, v)
}
}
GlobalActionsDialogLite
globalActionsDialog?.showOrHideDialog(false, true, v)
Here, locate the place where the button clicks to jump out of the shutdown dialog
2. GlobalActionsDialogLite
frameworks/base/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.javash
owOrHideDialog
public void showOrHideDialog(boolean keyguardShowing, boolean isDeviceProvisioned,
@Nullable View view) {
mKeyguardShowing = keyguardShowing;
mDeviceProvisioned = isDeviceProvisioned;
if (mDialog != null && mDialog.isShowing()) {
// In order to force global actions to hide on the same affordance press, we must
// register a call to onGlobalActionsShown() first to prevent the default actions
// menu from showing. This will be followed by a subsequent call to
// onGlobalActionsHidden() on dismiss()
mWindowManagerFuncs.onGlobalActionsShown();
mDialog.dismiss();
mDialog = null;
} else {
handleShow(view);
}
}
3. Click event
From the code point of view, this is an adapter adapter
public void onClickItem(int position) {
Action item = mAdapter.getItem(position);
if (!(item instanceof SilentModeTriStateAction)) {
if (mDialog != null) {
// don't dismiss the dialog if we're opening the power options menu
if (!(item instanceof PowerOptionsAction)) {
// Usually clicking an item shuts down the phone, locks, or starts an
// activity. We don't want to animate back into the power button when that
// happens, so we disable the dialog animation before dismissing.
mDialogLaunchAnimator.disableAllCurrentDialogsExitAnimations();
mDialog.dismiss();
}
} else {
Log.w(TAG, "Action clicked while mDialog is null.");
}
item.onPress();
}
}
4. item.onPress()
There are many internal classes in GlobalActionsDialogLite, which inherit and implement the onPress interface, corresponding to real click events.
The implementation class of the shutdown button is as follows
@VisibleForTesting
final class ShutDownAction extends SinglePressAction implements LongPressAction {
ShutDownAction() {
super(R.drawable.ic_lock_power_off,
R.string.global_action_power_off);
}
...
...
@Override
public void onPress() {
mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_PRESS);
// shutdown by making sure radio and power are handled accordingly.
mWindowManagerFuncs.shutdown();
}
}
5、GlobalActionsComponent
frameworks/base/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java
@Override
public void shutdown() {
/*Skip Monkey Test*/
if (ActivityManager.isUserAMonkey()) {
Log.d(TAG, "Cannot shut down during monkey test");
return;
}
/* @} */
try {
mBarService.shutdown();
} catch (RemoteException e) {
}
}
mBarService.shutdown();最终走到frameworks/base/services/core/java/com/android/server/statusbar/StatusBarManagerService.java