1 /* 2 * Copyright (C) 2018 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.settings.deviceinfo; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.os.storage.DiskInfo; 23 import android.os.storage.VolumeInfo; 24 import android.text.TextUtils; 25 import android.view.View; 26 27 import com.android.settings.R; 28 import com.android.settings.overlay.FeatureFactory; 29 30 public class StorageWizardFormatSlow extends StorageWizardBase { 31 private boolean mFormatPrivate; 32 33 @Override onCreate(Bundle savedInstanceState)34 protected void onCreate(Bundle savedInstanceState) { 35 super.onCreate(savedInstanceState); 36 if (mDisk == null) { 37 finish(); 38 return; 39 } 40 setContentView(R.layout.storage_wizard_generic); 41 42 mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false); 43 44 setHeaderText(R.string.storage_wizard_slow_v2_title, getDiskShortDescription()); 45 setBodyText(R.string.storage_wizard_slow_v2_body, getDiskDescription(), 46 getDiskShortDescription(), getDiskShortDescription(), 47 getDiskShortDescription()); 48 49 setBackButtonText(R.string.storage_wizard_slow_v2_start_over); 50 setNextButtonText(R.string.storage_wizard_slow_v2_continue); 51 52 // If benchmark wasn't actually slow, skip this warning 53 if (!getIntent().getBooleanExtra(EXTRA_FORMAT_SLOW, false)) { 54 onNavigateNext(null); 55 } 56 } 57 58 @Override onNavigateBack(View view)59 public void onNavigateBack(View view) { 60 FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().action(this, 61 SettingsEnums.ACTION_STORAGE_BENCHMARK_SLOW_ABORT); 62 63 final Intent intent = new Intent(this, StorageWizardInit.class); 64 startActivity(intent); 65 finishAffinity(); 66 } 67 68 @Override onNavigateNext(View view)69 public void onNavigateNext(View view) { 70 if (view != null) { 71 // User made an explicit choice to continue when slow 72 FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().action(this, 73 SettingsEnums.ACTION_STORAGE_BENCHMARK_SLOW_CONTINUE); 74 } else { 75 // User made an implicit choice to continue when fast 76 FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().action(this, 77 SettingsEnums.ACTION_STORAGE_BENCHMARK_FAST_CONTINUE); 78 } 79 80 final String forgetUuid = getIntent().getStringExtra(EXTRA_FORMAT_FORGET_UUID); 81 if (!TextUtils.isEmpty(forgetUuid)) { 82 mStorage.forgetVolume(forgetUuid); 83 } 84 85 final boolean offerMigrate; 86 if (mFormatPrivate) { 87 // Offer to migrate only if storage is currently internal 88 final VolumeInfo privateVol = getPackageManager() 89 .getPrimaryStorageCurrentVolume(); 90 offerMigrate = (privateVol != null 91 && VolumeInfo.ID_PRIVATE_INTERNAL.equals(privateVol.getId())); 92 } else { 93 offerMigrate = false; 94 } 95 96 if (offerMigrate) { 97 final Intent intent = new Intent(this, StorageWizardMigrateConfirm.class); 98 intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId()); 99 startActivity(intent); 100 } else { 101 final Intent intent = new Intent(this, StorageWizardReady.class); 102 intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId()); 103 startActivity(intent); 104 } 105 finishAffinity(); 106 } 107 } 108