cmd/tailsca,java/comt/tailscale/ipn: don't require an Activity for Google sign-out

The GoogleSignIn.getClient has a version that only needs a Context, not an Activity.

Updates tailscale/tailscale#670

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/3/head
Elias Naur 4 years ago
parent a0a33e92c4
commit 3089ad8347

@ -27,6 +27,11 @@ import java.security.GeneralSecurityException;
import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKey;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import org.gioui.Gio;
public class App extends Application {
@ -85,6 +90,13 @@ public class App extends Application {
);
}
void googleSignOut() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.build();
GoogleSignInClient client = GoogleSignIn.getClient(this, gso);
client.signOut();
}
void setTileStatus(boolean wantRunning) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
return;

@ -58,13 +58,6 @@ public class Peer extends Fragment {
super.onDestroy();
}
public void googleSignOut() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.build();
GoogleSignInClient client = GoogleSignIn.getClient(getActivity(), gso);
client.signOut();
}
public void googleSignIn(String serverOAuthID) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(serverOAuthID)

@ -670,7 +670,7 @@ func (a *App) processUIEvents(w *app.Window, events []UIEvent, peer jni.Object,
a.store.WriteString(loginMethodPrefKey, loginMethodWeb)
requestBackend(e)
case LogoutEvent:
a.signOut(peer)
a.signOut()
requestBackend(e)
case ConnectEvent:
requestBackend(e)
@ -686,12 +686,9 @@ func (a *App) processUIEvents(w *app.Window, events []UIEvent, peer jni.Object,
}
}
func (a *App) signOut(peer jni.Object) {
if peer == 0 {
return
}
func (a *App) signOut() {
err := jni.Do(a.jvm, func(env jni.Env) error {
return a.callVoidMethod(peer, "googleSignOut", "()V")
return a.callVoidMethod(a.appCtx, "googleSignOut", "()V")
})
if err != nil {
fatalErr(err)

Loading…
Cancel
Save