summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-05-27 16:08:53 -0700
committerJohn Reck <jreck@google.com>2011-05-27 16:08:53 -0700
commitaed9c54d8e67bb683a5a415b3775525a3ac00508 (patch)
treee82411fbc093c966790e4cd70f04f2ccebcdef22 /src
parent9465f4db222d280118ecd9a45261a62389dda520 (diff)
downloadpackages_apps_Browser-aed9c54d8e67bb683a5a415b3775525a3ac00508.zip
packages_apps_Browser-aed9c54d8e67bb683a5a415b3775525a3ac00508.tar.gz
packages_apps_Browser-aed9c54d8e67bb683a5a415b3775525a3ac00508.tar.bz2
Prevent crashing in CrashRecoveryHandler
Catch Throwable instead of Exception Don't save screenshots for crash recovery Change-Id: I22c36dc644ae597c609880d2ced79436918d83a6
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/BrowserActivity.java4
-rw-r--r--src/com/android/browser/Controller.java4
-rw-r--r--src/com/android/browser/CrashRecoveryHandler.java5
-rw-r--r--src/com/android/browser/Tab.java12
-rw-r--r--src/com/android/browser/TabControl.java6
5 files changed, 19 insertions, 12 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 963f29f..dbcae2e 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -115,7 +115,7 @@ public class BrowserActivity extends Activity {
protected void onNewIntent(Intent intent) {
if (ACTION_RESTART.equals(intent.getAction())) {
Bundle outState = new Bundle();
- mController.onSaveInstanceState(outState);
+ mController.onSaveInstanceState(outState, true);
finish();
getApplicationContext().startActivity(
new Intent(getApplicationContext(), BrowserActivity.class)
@@ -166,7 +166,7 @@ public class BrowserActivity extends Activity {
if (LOGV_ENABLED) {
Log.v(LOGTAG, "BrowserActivity.onSaveInstanceState: this=" + this);
}
- mController.onSaveInstanceState(outState);
+ mController.onSaveInstanceState(outState, true);
}
@Override
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index e089f5d..1f5c8f0 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -616,7 +616,7 @@ public class Controller
mCrashRecoveryHandler.clearState();
}
- void onSaveInstanceState(Bundle outState) {
+ void onSaveInstanceState(Bundle outState, boolean saveImages) {
// the default implementation requires each view to have an id. As the
// browser handles the state itself and it doesn't use id for the views,
// don't call the default implementation. Otherwise it will trigger the
@@ -624,7 +624,7 @@ public class Controller
// focused view XXX has no id".
// Save all the tabs
- mTabControl.saveState(outState);
+ mTabControl.saveState(outState, saveImages);
// Save time so that we know how old incognito tabs (if any) are.
outState.putSerializable("lastActiveDate", Calendar.getInstance());
}
diff --git a/src/com/android/browser/CrashRecoveryHandler.java b/src/com/android/browser/CrashRecoveryHandler.java
index 9e98e76..60e39da 100644
--- a/src/com/android/browser/CrashRecoveryHandler.java
+++ b/src/com/android/browser/CrashRecoveryHandler.java
@@ -22,7 +22,6 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
-import android.os.Debug;
import android.os.Parcel;
import android.util.Log;
@@ -45,7 +44,7 @@ public class CrashRecoveryHandler {
public void backupState() {
final Bundle state = new Bundle();
- mController.onSaveInstanceState(state);
+ mController.onSaveInstanceState(state, false);
final Context context = mController.getActivity();
new Thread() {
@Override
@@ -57,7 +56,7 @@ public class CrashRecoveryHandler {
Context.MODE_PRIVATE);
fout.write(p.marshall());
fout.close();
- } catch (Exception e) {
+ } catch (Throwable e) {
Log.i(LOGTAG, "Failed to save persistent state", e);
} finally {
p.recycle();
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 4097334..98d209e 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1706,6 +1706,15 @@ class Tab {
return mSavedState;
}
+ Bundle getSavedState(boolean saveImages) {
+ if (saveImages && mScreenshot != null) {
+ Bundle b = new Bundle(mSavedState);
+ b.putParcelable(SCREENSHOT, mScreenshot);
+ return b;
+ }
+ return mSavedState;
+ }
+
/**
* Set the saved state.
*/
@@ -1739,9 +1748,6 @@ class Tab {
if (mParent != null) {
mSavedState.putLong(PARENTTAB, mParent.mId);
}
- if (mScreenshot != null) {
- mSavedState.putParcelable(SCREENSHOT, mScreenshot);
- }
mSavedState.putBoolean(USERAGENT,
mSettings.hasDesktopUseragent(getWebView()));
return true;
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 1fe9053..0aaf3d6 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -272,15 +272,17 @@ class TabControl {
* position sorted array of tab ids
* for each tab id, save the tab state
* @param outState
+ * @param saveImages
*/
- void saveState(Bundle outState) {
+ void saveState(Bundle outState, boolean saveImages) {
final int numTabs = getTabCount();
long[] ids = new long[numTabs];
int i = 0;
for (Tab tab : mTabs) {
ids[i++] = tab.getId();
if (tab.saveState()) {
- outState.putBundle(Long.toString(tab.getId()), tab.getSavedState());
+ outState.putBundle(Long.toString(tab.getId()),
+ tab.getSavedState(saveImages));
}
}
outState.putLongArray(POSITIONS, ids);