Auth: Return result from login activity (#2227)
Fixes the problem that when logging in to Google Maps for the first time, it still stays on the login page after logging in.
This commit is contained in:
parent
c9ae0f6f4e
commit
235622d79c
1 changed files with 26 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
|
|||
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
import android.accounts.AccountManager;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
|
@ -95,6 +96,7 @@ public class LoginActivity extends AssistantActivity {
|
|||
private WebView webView;
|
||||
private String accountType;
|
||||
private AccountManager accountManager;
|
||||
private AccountAuthenticatorResponse response;
|
||||
private InputMethodManager inputMethodManager;
|
||||
private ViewGroup authContent;
|
||||
private int state = 0;
|
||||
|
|
@ -137,6 +139,12 @@ public class LoginActivity extends AssistantActivity {
|
|||
closeWeb(true);
|
||||
}
|
||||
});
|
||||
if(getIntent().hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)){
|
||||
Object tempObject = getIntent().getExtras().get("accountAuthenticatorResponse");
|
||||
if (tempObject instanceof AccountAuthenticatorResponse) {
|
||||
response = (AccountAuthenticatorResponse) tempObject;
|
||||
}
|
||||
}
|
||||
if (getIntent().hasExtra(EXTRA_TOKEN)) {
|
||||
if (getIntent().hasExtra(EXTRA_EMAIL)) {
|
||||
AccountManager accountManager = AccountManager.get(this);
|
||||
|
|
@ -190,6 +198,14 @@ public class LoginActivity extends AssistantActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if(response != null){
|
||||
response.onError(AccountManager.ERROR_CODE_CANCELED, "Canceled");
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setTitle(R.string.just_a_sec);
|
||||
setSpoofButtonText(null);
|
||||
|
|
@ -332,7 +348,15 @@ public class LoginActivity extends AssistantActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void returnSuccessResponse(Account account){
|
||||
if(response != null){
|
||||
Bundle bd = new Bundle();
|
||||
bd.putString(AccountManager.KEY_ACCOUNT_NAME,account.name);
|
||||
bd.putBoolean("new_account_created",false);
|
||||
bd.putString(AccountManager.KEY_ACCOUNT_TYPE,accountType);
|
||||
response.onResult(bd);
|
||||
}
|
||||
}
|
||||
private void retrieveGmsToken(final Account account) {
|
||||
final AuthManager authManager = new AuthManager(this, account.name, GMS_PACKAGE_NAME, "ac2dm");
|
||||
authManager.setPermitted(true);
|
||||
|
|
@ -357,6 +381,7 @@ public class LoginActivity extends AssistantActivity {
|
|||
accountManager.setAccountVisibility(account, PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE, VISIBILITY_USER_MANAGED_VISIBLE);
|
||||
}
|
||||
checkin(true);
|
||||
returnSuccessResponse(account);
|
||||
finish();
|
||||
}
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue