StorageWizardMigrateConfirm.java revision 6a0082b483eb487c44dec5e8855cf0e1ab92020b
1/* 2 * Copyright (C) 2015 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 17package com.android.settings.deviceinfo; 18 19import static com.android.settings.deviceinfo.StorageSettings.TAG; 20 21import android.content.Intent; 22import android.content.pm.PackageManager; 23import android.os.Bundle; 24import android.os.storage.VolumeInfo; 25import android.util.Log; 26 27import com.android.settings.R; 28 29public class StorageWizardMigrateConfirm extends StorageWizardBase { 30 private MigrateEstimateTask mEstimate; 31 32 @Override 33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setContentView(R.layout.storage_wizard_generic); 36 37 // When called with just disk, find the first private volume 38 if (mVolume == null) { 39 mVolume = findFirstVolume(VolumeInfo.TYPE_PRIVATE); 40 } 41 42 final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume(); 43 if (sourceVol == null || mVolume == null) { 44 Log.d(TAG, "Missing either source or target volume"); 45 finish(); 46 return; 47 } 48 49 final String sourceDescrip = mStorage.getBestVolumeDescription(sourceVol); 50 final String targetDescrip = mStorage.getBestVolumeDescription(mVolume); 51 52 setIllustrationInternal(true); 53 setHeaderText(R.string.storage_wizard_migrate_confirm_title, targetDescrip); 54 setBodyText(R.string.memory_calculating_size); 55 setSecondaryBodyText(R.string.storage_wizard_migrate_details, targetDescrip); 56 57 mEstimate = new MigrateEstimateTask(this) { 58 @Override 59 public void onPostExecute(String size, String time) { 60 setBodyText(R.string.storage_wizard_migrate_confirm_body, time, size, 61 sourceDescrip); 62 } 63 }; 64 65 mEstimate.copyFrom(getIntent()); 66 mEstimate.execute(); 67 68 getNextButton().setText(R.string.storage_wizard_migrate_confirm_next); 69 } 70 71 @Override 72 public void onNavigateNext() { 73 final int moveId = getPackageManager().movePrimaryStorage(mVolume); 74 75 final Intent intent = new Intent(this, StorageWizardMigrateProgress.class); 76 intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); 77 intent.putExtra(PackageManager.EXTRA_MOVE_ID, moveId); 78 startActivity(intent); 79 finishAffinity(); 80 } 81} 82