1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.managedprovisioning.provisioning; 18 19 import android.os.Bundle; 20 21 import androidx.annotation.VisibleForTesting; 22 23 import com.android.managedprovisioning.common.SettingsFacade; 24 import com.android.managedprovisioning.common.SetupGlifLayoutActivity; 25 import com.android.managedprovisioning.common.ThemeHelper; 26 import com.android.managedprovisioning.common.Utils; 27 28 /** 29 * An activity for telling the user they can abort set-up, reset the device. 30 * This activity is aimed to be repurposed for all the facrtory-resets in MP, in general 31 * but not for all provisioning failures as not every failure should imply factory-reset 32 */ 33 public class ResetDeviceActivity extends SetupGlifLayoutActivity { 34 ResetDeviceActivity()35 public ResetDeviceActivity() { 36 super(); 37 } 38 39 @VisibleForTesting ResetDeviceActivity( Utils utils, SettingsFacade settingsFacade, ThemeHelper themeHelper)40 public ResetDeviceActivity( 41 Utils utils, SettingsFacade settingsFacade, ThemeHelper themeHelper) { 42 super(utils, settingsFacade, themeHelper); 43 } 44 45 @Override onCreate(Bundle savedInstanceState)46 protected void onCreate(Bundle savedInstanceState) { 47 super.onCreate(savedInstanceState); 48 createBridge().initiateUi(this); 49 } 50 createBridge()51 protected ResetDeviceActivityBridge createBridge() { 52 return ResetDeviceActivityBridgeImpl.builder() 53 .setBridgeCallback(createBridgeCallback()) 54 .setInitializeLayoutParamsConsumer( 55 ResetDeviceActivity.this::initializeLayoutParams) 56 .build(); 57 } 58 createBridgeCallback()59 private ResetDeviceActivityBridgeCallback createBridgeCallback() { 60 return () -> { 61 getUtils().factoryReset(ResetDeviceActivity.this, 62 "User chose to abort setup."); 63 getTransitionHelper().finishActivity(ResetDeviceActivity.this); 64 }; 65 } 66 } 67