1. 程式人生 > >Android O 格式化SD卡時沒有移動資料頁面

Android O 格式化SD卡時沒有移動資料頁面

  • vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
 public class StorageWizardFormatProgress extends StorageWizardBase {
                     storage.partitionPrivate(activity.mDisk.getId());
                     publishProgress(40);
 
-                    final VolumeInfo privateVol = activity.findFirstVolume(VolumeInfo.TYPE_PRIVATE);
+                  //add
+                    //final VolumeInfo privateVol = activity.findFirstVolume(VolumeInfo.TYPE_PRIVATE);
+                    VolumeInfo privatePreVol = null;
+                    privatePreVol = activity.findFirstVolume(VolumeInfo.TYPE_PRIVATE);
+                    for(int i = 10;i > 0;i--){
+                        if(privatePreVol != null){
+                            break;
+                        }else{
+                            try{
+                                Thread.sleep(1000);
+                                privatePreVol = activity.findFirstVolume(VolumeInfo.TYPE_PRIVATE);
+                            }catch(Exception e){
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                    final VolumeInfo privateVol = privatePreVol;
+                  //end
                     mPrivateBench = storage.benchmark(privateVol.getId());
                     mPrivateBench /= 1000000;