Merge "Use SystemUI reboot UI for factory resets"

This commit is contained in:
Robert Horvath
2019-11-27 15:41:06 +00:00
committed by Android (Google) Code Review
3 changed files with 57 additions and 8 deletions

View File

@@ -32,6 +32,19 @@
android:layout_height="32sp"
android:text="@string/shutdown_progress"
android:textDirection="locale"
android:textSize="18sp"
android:textAppearance="?attr/textAppearanceMedium"
android:gravity="center"
android:layout_marginBottom="24dp"
android:visibility="gone"
android:fontFamily="@string/config_headlineFontFamily"/>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="32sp"
android:text="@string/shutdown_progress"
android:textDirection="locale"
android:textSize="24sp"
android:textAppearance="?attr/textAppearanceLarge"
android:gravity="center"

View File

@@ -17,9 +17,11 @@ package com.android.systemui.globalactions;
import static android.app.StatusBarManager.DISABLE2_GLOBAL_ACTIONS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.app.Dialog;
import android.app.KeyguardManager;
import android.content.Context;
import android.os.PowerManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -134,14 +136,22 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks,
int color = Utils.getColorAttrDefaultColor(mContext,
com.android.systemui.R.attr.wallpaperTextColor);
boolean onKeyguard = mContext.getSystemService(
KeyguardManager.class).isKeyguardLocked();
ProgressBar bar = d.findViewById(R.id.progress);
bar.getIndeterminateDrawable().setTint(color);
TextView message = d.findViewById(R.id.text1);
message.setTextColor(color);
if (isReboot) message.setText(R.string.reboot_to_reset_message);
TextView reasonView = d.findViewById(R.id.text1);
TextView messageView = d.findViewById(R.id.text2);
reasonView.setTextColor(color);
messageView.setTextColor(color);
messageView.setText(getRebootMessage(isReboot, reason));
String rebootReasonMessage = getReasonMessage(reason);
if (rebootReasonMessage != null) {
reasonView.setVisibility(View.VISIBLE);
reasonView.setText(rebootReasonMessage);
}
GradientColors colors = Dependency.get(SysuiColorExtractor.class).getNeutralColors();
background.setColor(colors.getMainColor(), false);
@@ -149,6 +159,30 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks,
d.show();
}
@StringRes
private int getRebootMessage(boolean isReboot, @Nullable String reason) {
if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {
return R.string.reboot_to_update_reboot;
} else if (reason != null && reason.equals(PowerManager.REBOOT_RECOVERY)) {
return R.string.reboot_to_reset_message;
} else if (isReboot) {
return R.string.reboot_to_reset_message;
} else {
return R.string.shutdown_progress;
}
}
@Nullable
private String getReasonMessage(@Nullable String reason) {
if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {
return mContext.getString(R.string.reboot_to_update_title);
} else if (reason != null && reason.equals(PowerManager.REBOOT_RECOVERY)) {
return mContext.getString(R.string.reboot_to_reset_title);
} else {
return null;
}
}
@Override
public void disable(int displayId, int state1, int state2, boolean animate) {
final boolean disabled = (state2 & DISABLE2_GLOBAL_ACTIONS) != 0;

View File

@@ -47,8 +47,8 @@ import android.util.TimingsTraceLog;
import android.view.WindowManager;
import com.android.internal.telephony.ITelephony;
import com.android.server.RescueParty;
import com.android.server.LocalServices;
import com.android.server.RescueParty;
import com.android.server.pm.PackageManagerService;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -307,7 +307,9 @@ public final class ShutdownThread extends Thread {
com.android.internal.R.string.reboot_to_update_reboot));
}
} else if (mReason != null && mReason.equals(PowerManager.REBOOT_RECOVERY)) {
if (RescueParty.isAttemptingFactoryReset()) {
if (showSysuiReboot()) {
return null;
} else if (RescueParty.isAttemptingFactoryReset()) {
// We're not actually doing a factory reset yet; we're rebooting
// to ask the user if they'd like to reset, so give them a less
// scary dialog message.