Bug 1140830 - Don't try to use a null JSONObject in SiteIdentity.update() r=rnewman

This patch avoids a crash in ART on HTC One M8 devices, where a (deliberate?) NPE was used for init.
This commit is contained in:
James Willcox 2015-03-09 22:37:17 -07:00
Родитель 753efaddd0
Коммит f09b7427dc
2 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -119,22 +119,26 @@ public class SiteIdentity {
}
public SiteIdentity() {
resetIdentityData();
mMixedMode = MixedMode.UNKNOWN;
mTrackingMode = TrackingMode.UNKNOWN;
reset();
}
private void resetIdentityData() {
public void reset() {
mSecurityMode = SecurityMode.UNKNOWN;
mHost = null;
mOwner = null;
mSupplemental = null;
mVerifier = null;
mEncrypted = null;
mMixedMode = MixedMode.UNKNOWN;
mTrackingMode = TrackingMode.UNKNOWN;
}
void update(JSONObject identityData) {
if (identityData == null) {
reset();
return;
}
try {
JSONObject mode = identityData.getJSONObject("mode");
@ -153,7 +157,7 @@ public class SiteIdentity {
try {
mSecurityMode = SecurityMode.fromString(mode.getString("identity"));
} catch (Exception e) {
resetIdentityData();
reset();
return;
}
@ -164,10 +168,10 @@ public class SiteIdentity {
mVerifier = identityData.getString("verifier");
mEncrypted = identityData.getString("encrypted");
} catch (Exception e) {
resetIdentityData();
reset();
}
} catch (Exception e) {
resetIdentityData();
reset();
mMixedMode = MixedMode.UNKNOWN;
mTrackingMode = TrackingMode.UNKNOWN;
}

Просмотреть файл

@ -612,7 +612,7 @@ public class Tab {
setHasFeeds(false);
setHasOpenSearch(false);
updateIdentityData(null);
mSiteIdentity.reset();
setZoomConstraints(new ZoomConstraints(true));
setHasTouchListeners(false);
setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
@ -629,7 +629,7 @@ public class Tab {
void handleDocumentStart(boolean restoring, String url) {
setLoadProgress(LOAD_PROGRESS_START);
setState((!restoring && shouldShowProgress(url)) ? STATE_LOADING : STATE_SUCCESS);
updateIdentityData(null);
mSiteIdentity.reset();
}
void handleDocumentStop(boolean success) {