summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2015-06-12 23:57:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-12 23:57:54 +0000
commit97d102d9e207f3379ef94929e239de848c784754 (patch)
tree14888523a4a74a253cf55f58f21fe67805cb7ba8
parentee5db351ac773f42d2fb2674545b82d1d1d0cdd5 (diff)
parent1d37d0f7fb3c66462432d33c6db51ef79e5e7c88 (diff)
downloadpackages_apps_Settings-97d102d9e207f3379ef94929e239de848c784754.zip
packages_apps_Settings-97d102d9e207f3379ef94929e239de848c784754.tar.gz
packages_apps_Settings-97d102d9e207f3379ef94929e239de848c784754.tar.bz2
Merge "Add simple null checks to StorageWizard*, also listen to..." into mnc-dev
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardBase.java22
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java6
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java6
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardInit.java6
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrate.java6
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java5
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java6
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java7
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java4
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardReady.java6
10 files changed, 59 insertions, 15 deletions
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index 31f7af4..294df95 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -20,8 +20,10 @@ import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.os.storage.DiskInfo;
+import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
@@ -63,6 +65,10 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
}
setTheme(R.style.SuwThemeMaterial_Light);
+
+ if (mDisk != null) {
+ mStorage.registerListener(mStorageListener);
+ }
}
@Override
@@ -82,6 +88,12 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
getBackButton().setVisibility(View.GONE);
}
+ @Override
+ protected void onDestroy() {
+ mStorage.unregisterListener(mStorageListener);
+ super.onDestroy();
+ }
+
protected NavigationBar getNavigationBar() {
return (NavigationBar) findViewById(R.id.suw_layout_navigation_bar);
}
@@ -142,4 +154,14 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
}
return null;
}
+
+ private final StorageEventListener mStorageListener = new StorageEventListener() {
+ @Override
+ public void onDiskDestroyed(DiskInfo disk) {
+ // We know mDisk != null.
+ if (mDisk.id.equals(disk.id)) {
+ finish();
+ }
+ }
+ };
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
index 33f2173..874dc2c 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -32,10 +32,12 @@ public class StorageWizardFormatConfirm extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mDisk == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_generic);
- Preconditions.checkNotNull(mDisk);
-
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
if (mFormatPrivate) {
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
index f1f4510..df2adfd 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
@@ -44,10 +44,12 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mDisk == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_progress);
- Preconditions.checkNotNull(mDisk);
-
mFormatPrivate = getIntent().getBooleanExtra(
StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
index 22a8008..61dfaaf 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardInit.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -34,10 +34,12 @@ public class StorageWizardInit extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mDisk == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_init);
- Preconditions.checkNotNull(mDisk);
-
setHeaderText(R.string.storage_wizard_init_title, mDisk.getDescription());
mRadioExternal = (RadioButton) findViewById(R.id.storage_wizard_init_external_title);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrate.java b/src/com/android/settings/deviceinfo/StorageWizardMigrate.java
index 7831a07..574408d 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrate.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrate.java
@@ -35,10 +35,12 @@ public class StorageWizardMigrate extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mDisk == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_migrate);
- Preconditions.checkNotNull(mDisk);
-
setHeaderText(R.string.storage_wizard_migrate_title, mDisk.getDescription());
setBodyText(R.string.memory_calculating_size);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
index daa76d7..ff74ea2 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
@@ -36,6 +36,11 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
mVolume = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
}
+ if (mVolume == null) {
+ finish();
+ return;
+ }
+
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
final String sourceDescrip = mStorage.getBestVolumeDescription(sourceVol);
final String targetDescrip = mStorage.getBestVolumeDescription(mVolume);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
index 70d93f8..4446c51 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
@@ -39,10 +39,12 @@ public class StorageWizardMigrateProgress extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mVolume == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_progress);
- Preconditions.checkNotNull(mVolume);
-
mMoveId = getIntent().getIntExtra(EXTRA_MOVE_ID, -1);
final String descrip = mStorage.getBestVolumeDescription(mVolume);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java
index 3a802a3..429b03c 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java
@@ -36,6 +36,10 @@ public class StorageWizardMoveConfirm extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mVolume == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_generic);
try {
@@ -45,9 +49,6 @@ public class StorageWizardMoveConfirm extends StorageWizardBase {
throw new RuntimeException(e);
}
- Preconditions.checkNotNull(mVolume);
- Preconditions.checkNotNull(mApp);
-
// Sanity check that target volume is candidate
Preconditions.checkState(
getPackageManager().getPackageCandidateVolumes(mApp).contains(mVolume));
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java b/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
index 86e623f..660f85c 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
@@ -36,6 +36,10 @@ public class StorageWizardMoveProgress extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mVolume == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_progress);
mMoveId = getIntent().getIntExtra(EXTRA_MOVE_ID, -1);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardReady.java b/src/com/android/settings/deviceinfo/StorageWizardReady.java
index 6d8846b..d6ea5e4 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardReady.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardReady.java
@@ -26,10 +26,12 @@ public class StorageWizardReady extends StorageWizardBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (mDisk == null) {
+ finish();
+ return;
+ }
setContentView(R.layout.storage_wizard_generic);
- Preconditions.checkNotNull(mDisk);
-
setHeaderText(R.string.storage_wizard_ready_title, mDisk.getDescription());
// TODO: handle mixed partition cases instead of just guessing based on