Checkin before logging in if needed, force checkin after login

Fixes crash under certain conditions when creating account, might fix Play Store
This commit is contained in:
mar-v-in 2015-10-05 16:26:29 +02:00
parent 501866bb7d
commit 2657d740e7
1 changed files with 31 additions and 7 deletions

View File

@ -161,14 +161,27 @@ public class LoginActivity extends AssistantActivity {
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (LastCheckinInfo.read(this).androidId == 0) {
try {
CheckinManager.checkin(this, false);
} catch (IOException e) {
Log.d(TAG, "Checkin failed", e);
showError(R.string.auth_general_error_desc);
}
new Thread(new Runnable() {
@Override
public void run() {
Runnable next;
next = checkin(false) ? new Runnable() {
@Override
public void run() {
loadLoginPage();
}
} : new Runnable() {
@Override
public void run() {
showError(R.string.auth_general_error_desc);
}
};
LoginActivity.this.runOnUiThread(next);
}
}).start();
} else {
loadLoginPage();
}
loadLoginPage();
} else {
showError(R.string.no_network_error_desc);
}
@ -267,6 +280,7 @@ public class LoginActivity extends AssistantActivity {
public void onResponse(AuthResponse response) {
authManager.storeResponse(response);
PeopleManager.loadUserInfo(LoginActivity.this, account);
checkin(true);
finish();
}
@ -277,6 +291,16 @@ public class LoginActivity extends AssistantActivity {
});
}
private boolean checkin(boolean force) {
try {
CheckinManager.checkin(LoginActivity.this, force);
return true;
} catch (IOException e) {
Log.w(TAG, "Checkin failed", e);
}
return false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KEYCODE_BACK) && webView.canGoBack() && (webView.getVisibility() == VISIBLE)) {