mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind/java: reenable asset access.
This is done by moving app.Context to internal/mobileinit, introducing mobileinit.SetCurrentContext and, making bind/java depend on it. TODO: check gomobile bind's proguard rule - context lookup was implemented through reflection on android.app.AppGlobals class. Change-Id: Ieb6ad503eeef8c2c1c5836a21c667938c5a701a2 Reviewed-on: https://go-review.googlesource.com/12279 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
committed by
Hyang-Ah Hana Kim
parent
c6888a7bae
commit
136fa9bbbb
@@ -4,6 +4,8 @@
|
||||
|
||||
package go;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
@@ -24,6 +26,16 @@ public class Seq {
|
||||
Log.w("GoSeq", "LoadJNI class not found");
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO(hyangah): check proguard rule.
|
||||
Application appl = (Application)Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null, (Object[]) null);
|
||||
Context ctx = appl.getApplicationContext();
|
||||
setContext(ctx);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.w("GoSeq", "Global context not found:" + e);
|
||||
}
|
||||
|
||||
initSeq();
|
||||
new Thread("GoSeq") {
|
||||
public void run() { Seq.receive(); }
|
||||
@@ -37,6 +49,8 @@ public class Seq {
|
||||
ensure(64);
|
||||
}
|
||||
|
||||
static native void setContext(Context ctx);
|
||||
|
||||
// Ensure that at least size bytes can be written to the Seq.
|
||||
// Any existing data in the buffer is preserved.
|
||||
public native void ensure(int size);
|
||||
|
||||
Reference in New Issue
Block a user