summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-07-29 11:32:54 -0700
committerJohn Reck <jreck@google.com>2011-07-29 11:34:53 -0700
commit023124e33a36c31cee61b08020189c16ffaf8624 (patch)
treef70ecab758f4e614ae263999df1257196d21e84f /src/com/android/browser
parentd25c865122648a6098428c9161a1f3488a4aa9b4 (diff)
downloadpackages_apps_Browser-023124e33a36c31cee61b08020189c16ffaf8624.zip
packages_apps_Browser-023124e33a36c31cee61b08020189c16ffaf8624.tar.gz
packages_apps_Browser-023124e33a36c31cee61b08020189c16ffaf8624.tar.bz2
Get rid of the recovery dialog
Bug: 5081732 Change-Id: I6cbe0bdcd02735a21e785655df84896d8b79e8ce
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/CrashRecoveryHandler.java66
1 files changed, 16 insertions, 50 deletions
diff --git a/src/com/android/browser/CrashRecoveryHandler.java b/src/com/android/browser/CrashRecoveryHandler.java
index 319ff89..8cb5929 100644
--- a/src/com/android/browser/CrashRecoveryHandler.java
+++ b/src/com/android/browser/CrashRecoveryHandler.java
@@ -16,11 +16,7 @@
package com.android.browser;
-import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
-import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -49,7 +45,7 @@ public class CrashRecoveryHandler {
* we will automatically restore. If we then crash again within XX minutes,
* we will prompt instead of automatically restoring.
*/
- private static final long PROMPT_INTERVAL = 30 * 60 * 1000; // 30 minutes
+ private static final long PROMPT_INTERVAL = 5 * 60 * 1000; // 5 minutes
private static final int MSG_WRITE_STATE = 1;
private static final int MSG_CLEAR_STATE = 2;
@@ -63,7 +59,6 @@ public class CrashRecoveryHandler {
private Handler mBackgroundHandler;
private boolean mIsPreloading = false;
private boolean mDidPreload = false;
- private boolean mShouldPrompt = false;
private Bundle mRecoveryState = null;
public static CrashRecoveryHandler initialize(Controller controller) {
@@ -111,7 +106,6 @@ public class CrashRecoveryHandler {
break;
case MSG_PRELOAD_STATE:
mRecoveryState = loadCrashState();
- mShouldPrompt = shouldPrompt();
synchronized (CrashRecoveryHandler.this) {
mIsPreloading = false;
mDidPreload = true;
@@ -148,56 +142,32 @@ public class CrashRecoveryHandler {
public void clearState() {
mBackgroundHandler.sendEmptyMessage(MSG_CLEAR_STATE);
+ updateLastRecovered(0);
}
- public void promptToRecover(final Bundle state, final Intent intent) {
- new AlertDialog.Builder(mController.getActivity())
- .setTitle(R.string.recover_title)
- .setMessage(R.string.recover_prompt)
- .setIcon(R.mipmap.ic_launcher_browser)
- .setPositiveButton(R.string.recover_yes, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- updateLastRecovered();
- mController.doStart(state, intent);
- }
- })
- .setNegativeButton(R.string.recover_no, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- })
- .setOnCancelListener(new OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- clearState();
- mController.doStart(null, intent);
- }
- })
- .show();
- }
-
- private boolean shouldPrompt() {
+ private boolean shouldRestore() {
SharedPreferences prefs = mContext.getSharedPreferences(
RECOVERY_PREFERENCES, Context.MODE_PRIVATE);
long lastRecovered = prefs.getLong(KEY_LAST_RECOVERED, 0);
long timeSinceLastRecover = System.currentTimeMillis() - lastRecovered;
if (timeSinceLastRecover > PROMPT_INTERVAL) {
- return false;
+ return true;
}
- return true;
+ return false;
}
- private void updateLastRecovered() {
+ private void updateLastRecovered(long time) {
SharedPreferences prefs = mContext.getSharedPreferences(
RECOVERY_PREFERENCES, Context.MODE_PRIVATE);
prefs.edit()
- .putLong(KEY_LAST_RECOVERED, System.currentTimeMillis())
+ .putLong(KEY_LAST_RECOVERED, time)
.apply();
}
private Bundle loadCrashState() {
+ if (!shouldRestore()) {
+ return null;
+ }
Bundle state = null;
Parcel parcel = Parcel.obtain();
FileInputStream fin = null;
@@ -228,7 +198,10 @@ public class CrashRecoveryHandler {
} catch (IOException e) { }
}
}
- return state;
+ if (state != null && !state.isEmpty()) {
+ return state;
+ }
+ return null;
}
public void startRecovery(Intent intent) {
@@ -241,16 +214,9 @@ public class CrashRecoveryHandler {
}
if (!mDidPreload) {
mRecoveryState = loadCrashState();
- mShouldPrompt = shouldPrompt();
- }
- if (mRecoveryState != null && !mRecoveryState.isEmpty()) {
- if (mShouldPrompt) {
- promptToRecover(mRecoveryState, intent);
- return;
- } else {
- updateLastRecovered();
- }
}
+ updateLastRecovered(mRecoveryState != null
+ ? System.currentTimeMillis() : 0);
mController.doStart(mRecoveryState, intent);
mRecoveryState = null;
}