summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/TabControl.java
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-07-13 15:18:25 -0700
committerMichael Kolb <kolby@google.com>2011-07-13 15:55:53 -0700
commit3ae7f74a64fd1dc101910f1b14f315b34d1f1274 (patch)
tree7c14c3f720a790ec07499f613dfae48e9b018b00 /src/com/android/browser/TabControl.java
parent308b301d37295044c5beac52c5b1a8de0853304f (diff)
downloadandroid_packages_apps_Gello-3ae7f74a64fd1dc101910f1b14f315b34d1f1274.tar.gz
android_packages_apps_Gello-3ae7f74a64fd1dc101910f1b14f315b34d1f1274.tar.bz2
android_packages_apps_Gello-3ae7f74a64fd1dc101910f1b14f315b34d1f1274.zip
fix restore bug
Bug: 5023284 only save tab id's if the tab state can be saved this prevents trying to restore tabs that didn't get saved Change-Id: I9ca8a3f71c4cb9029718492fbd5447e782524869
Diffstat (limited to 'src/com/android/browser/TabControl.java')
-rw-r--r--src/com/android/browser/TabControl.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 5f3995ff..1be2016a 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -297,10 +297,12 @@ class TabControl {
long[] ids = new long[numTabs];
int i = 0;
for (Tab tab : mTabs) {
- ids[i++] = tab.getId();
if (tab.saveState()) {
+ ids[i++] = tab.getId();
outState.putBundle(Long.toString(tab.getId()),
tab.getSavedState(saveImages));
+ } else {
+ ids[i++] = -1;
}
}
if (!outState.isEmpty()) {
@@ -327,13 +329,12 @@ class TabControl {
}
final long oldcurrent = inState.getLong(CURRENT);
long current = -1;
- if (restoreIncognitoTabs ||
- !inState.getBundle(Long.toString(oldcurrent)).getBoolean(Tab.INCOGNITO)) {
+ if (restoreIncognitoTabs || (hasState(oldcurrent, inState) && !isIncognito(oldcurrent, inState))) {
current = oldcurrent;
} else {
// pick first non incognito tab
for (long id : ids) {
- if (!inState.getBundle(Long.toString(id)).getBoolean(Tab.INCOGNITO)) {
+ if (hasState(id, inState) && !isIncognito(id, inState)) {
current = id;
break;
}
@@ -342,6 +343,20 @@ class TabControl {
return current;
}
+ private boolean hasState(long id, Bundle state) {
+ if (id == -1) return false;
+ Bundle tab = state.getBundle(Long.toString(id));
+ return ((tab != null) && !tab.isEmpty());
+ }
+
+ private boolean isIncognito(long id, Bundle state) {
+ Bundle tabstate = state.getBundle(Long.toString(id));
+ if ((tabstate != null) && !tabstate.isEmpty()) {
+ return tabstate.getBoolean(Tab.INCOGNITO);
+ }
+ return false;
+ }
+
/**
* Restore the state of all the tabs.
* @param currentId The tab id to restore.