Call update engine to apply payload

Calling update engine to apply payload provided from boot_otas and
reboot on success. Updating different dialogues for 4k prompt.

Test: m Settings && adb install -r $ANDROID_PRODUCT_OUT/system_ext/priv-app/Settings/Settings.apk
Test: make RunSettingsRoboTests ROBOTEST_FILTER=Enable16kPagesPreferenceControllerTest
Bug: 295573133
Change-Id: Iab90a2c2fae5f6aefce95b2306db91c7b056d9f7
This commit is contained in:
Pawan Wagh
2023-09-20 17:58:16 +00:00
parent 8996ca9768
commit 008842edeb
8 changed files with 347 additions and 15 deletions

View File

@@ -35,6 +35,7 @@ public class Enable16kPagesWarningDialog extends InstrumentedDialogFragment
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
public static final String TAG = "Enable16KDialog";
private static final String DIALOG_BUNDLE_KEY = "SHOW_16K_DIALOG";
private Enable16kbPagesDialogHost mHost;
@@ -42,17 +43,22 @@ public class Enable16kPagesWarningDialog extends InstrumentedDialogFragment
mHost = host;
}
/** Used to display warning dialog */
/** This method is used to show warning dialog to apply 16K update and reboot */
public static void show(
@NonNull Fragment hostFragment, @NonNull Enable16kbPagesDialogHost dialogHost) {
@NonNull Fragment hostFragment,
@NonNull Enable16kbPagesDialogHost dialogHost,
boolean enable16k) {
final FragmentManager manager = hostFragment.getActivity().getSupportFragmentManager();
Fragment existingFragment = manager.findFragmentByTag(TAG);
if (existingFragment == null) {
existingFragment = new Enable16kPagesWarningDialog();
existingFragment.setTargetFragment(hostFragment, 0 /* requestCode */);
}
if (existingFragment instanceof Enable16kPagesWarningDialog) {
Bundle bundle = new Bundle();
bundle.putBoolean(DIALOG_BUNDLE_KEY, enable16k);
existingFragment.setArguments(bundle);
existingFragment.setTargetFragment(hostFragment, 0 /* requestCode */);
((Enable16kPagesWarningDialog) existingFragment).setHost(dialogHost);
((Enable16kPagesWarningDialog) existingFragment).show(manager, TAG);
}
@@ -66,9 +72,17 @@ public class Enable16kPagesWarningDialog extends InstrumentedDialogFragment
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final Bundle bundle = getArguments();
boolean is16kDialog = bundle.getBoolean(DIALOG_BUNDLE_KEY);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.confirm_enable_16k_pages_title)
.setMessage(R.string.confirm_enable_16k_pages_text)
.setTitle(
is16kDialog
? R.string.confirm_enable_16k_pages_title
: R.string.confirm_enable_4k_pages_title)
.setMessage(
is16kDialog
? R.string.confirm_enable_16k_pages_text
: R.string.confirm_enable_4k_pages_text)
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create();