]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: Fix crash when trying to "Restore" from a backup file without any categories.
authorpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 1 May 2009 13:55:41 +0000 (13:55 +0000)
committerpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 1 May 2009 13:55:41 +0000 (13:55 +0000)
git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2060 72b678ce-9140-0410-bee8-679b907dd61a

src/org/openintents/safe/Restore.java

index 4c8873c480acb4053a56dd773fa14e777282ad05..7246b38fad64780315b2c9a726989ddf01f0f0d0 100644 (file)
@@ -202,11 +202,14 @@ public class Restore extends Activity {
                                Toast.LENGTH_LONG).show();
                return false;
                }
-               CategoryEntry firstCatEntry=restoreDataSet.getCategories().get(0);
-               if (firstCatEntry==null) {
-                       Toast.makeText(Restore.this, getString(R.string.restore_error),
-                               Toast.LENGTH_LONG).show();
-                       return false;
+               CategoryEntry firstCatEntry= null;
+               if (restoreDataSet.getCategories().size() > 0) {
+                       firstCatEntry = restoreDataSet.getCategories().get(0);
+                       if (firstCatEntry==null) {
+                               Toast.makeText(Restore.this, getString(R.string.restore_error),
+                                       Toast.LENGTH_LONG).show();
+                               return false;
+                       }
                }
                CryptoHelper ch=new CryptoHelper();
                
@@ -243,19 +246,21 @@ public class Restore extends Activity {
                        return false;
                }
                
-               String firstCategory="";
-               try {
-                       firstCategory = ch.decrypt(firstCatEntry.name);
-               } catch (CryptoHelperException e) {
-                       Log.e(TAG,e.toString());
-               }
-               if (ch.getStatus() == false) {
-                       Toast.makeText(Restore.this, getString(R.string.restore_decrypt_error),
-                               Toast.LENGTH_LONG).show();
-                       return false;
+               if (firstCatEntry != null) {
+                       String firstCategory="";
+                       try {
+                               firstCategory = ch.decrypt(firstCatEntry.name);
+                       } catch (CryptoHelperException e) {
+                               Log.e(TAG,e.toString());
+                       }
+                       if (ch.getStatus() == false) {
+                               Toast.makeText(Restore.this, getString(R.string.restore_decrypt_error),
+                                       Toast.LENGTH_LONG).show();
+                               return false;
+                       }
+                       if (debug) Log.d(TAG,"firstCategory="+firstCategory);
                }
-               if (debug) Log.d(TAG,"firstCategory="+firstCategory);
-
+               
                dbHelper=new DBHelper(Restore.this);
 
                String msg=getString(R.string.restore_found,