cmd/tailscale,android: bump gio version

Updates tailscale/tailscale#431 (fixes a resize crash)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/2/head
Elias Naur 5 years ago
parent eb6c345667
commit 4c1017a548

@ -5,12 +5,16 @@
package com.tailscale.ipn;
import android.app.Application;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.BroadcastReceiver;
import android.net.ConnectivityManager;
import android.view.View;
import android.os.Build;
import java.io.IOException;
@ -82,5 +86,14 @@ public class App extends Application {
return Build.MANUFACTURER + " " + Build.MODEL;
}
// Tracklifecycle adds a Peer fragment for tracking the Activity
// lifecycle.
static void trackLifecycle(View view) {
Activity act = (Activity)view.getContext();
FragmentTransaction ft = act.getFragmentManager().beginTransaction();
ft.add(new Peer(), "Peer");
ft.commitNow();
}
private static native void onConnectivityChanged(boolean connected);
}

@ -378,9 +378,7 @@ func (a *App) runUI() error {
if err != nil {
return err
}
// Register an Android Fragment instance for lifecycle tracking
// of our Activity.
w.RegisterFragment("com.tailscale.ipn.Peer")
a.trackLifecycle(w)
var ops op.Ops
state := new(clientState)
var peer jni.Object
@ -448,6 +446,23 @@ func (a *App) runUI() error {
}
}
// trackLifecycle registers an Android Fragment instance for lifecycle
// tracking of our Activity.
func (a *App) trackLifecycle(w *app.Window) {
go func() {
w.Do(func(view uintptr) {
err := jni.Do(a.jvm, func(env jni.Env) error {
cls := jni.GetObjectClass(env, a.appCtx)
trackLifecycle := jni.GetStaticMethodID(env, cls, "trackLifecycle", "(Landroid/view/View;)V")
return jni.CallStaticVoidMethod(env, cls, trackLifecycle, jni.Value(view))
})
if err != nil {
fatalErr(err)
}
})
}()
}
func (a *App) updateState(javaPeer jni.Object, state *clientState) {
if javaPeer != 0 && state.browseURL != "" {
a.browseToURL(javaPeer, state.browseURL)
@ -560,5 +575,6 @@ func (a *App) callVoidMethod(obj jni.Object, name, sig string, args ...jni.Value
}
func fatalErr(err error) {
log.Print(err)
// TODO: expose in UI.
log.Printf("fatal error: %v", err)
}

@ -3,7 +3,7 @@ module tailscale.com/tailscale-android
go 1.14
require (
gioui.org v0.0.0-20200611133933-6d5fbcba3f21
gioui.org v0.0.0-20200613154758-8688ed95c255
gioui.org/cmd v0.0.0-20200530141830-d2c67cdf8039
github.com/tailscale/wireguard-go v0.0.0-20200515231107-62868271d710
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3

@ -1,8 +1,8 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200530124200-1377bea3cdc5/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200611133933-6d5fbcba3f21 h1:VFB+0QxUPABMgEarfyJeHQvUNc++9TASnDVXcFgxLcA=
gioui.org v0.0.0-20200611133933-6d5fbcba3f21/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200613154758-8688ed95c255 h1:f4jG6oVrLsPZ0zsGpmUVyNfvdZIx7T+JQ0a4Y2EhvY4=
gioui.org v0.0.0-20200613154758-8688ed95c255/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org/cmd v0.0.0-20200530141830-d2c67cdf8039 h1:mO1CTk+PwcDQGMXpN1JJiFflYBvwqSQ6+3Gvp64IKHo=
gioui.org/cmd v0.0.0-20200530141830-d2c67cdf8039/go.mod h1:B1g+HOceSj7g3S4Yao3skwInTpcK978KANys5YuapMc=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

@ -61,7 +61,6 @@ func Do(vm JVM, f func(env Env) error) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var env *C.JNIEnv
var detach bool
if res := C._jni_GetEnv(vm.jvm, &env, C.JNI_VERSION_1_6); res != C.JNI_OK {
if res != C.JNI_EDETACHED {
panic(fmt.Errorf("JNI GetEnv failed with error %d", res))
@ -69,14 +68,9 @@ func Do(vm JVM, f func(env Env) error) error {
if C._jni_AttachCurrentThread(vm.jvm, &env, nil) != C.JNI_OK {
panic(errors.New("runInJVM: AttachCurrentThread failed"))
}
detach = true
defer C._jni_DetachCurrentThread(vm.jvm)
}
if detach {
defer func() {
C._jni_DetachCurrentThread(vm.jvm)
}()
}
return f(Env{env})
}

Loading…
Cancel
Save