Use of Relinker to avoid all the UnsatisfiedLinkError piling up
This commit is contained in:
parent
db69cb7613
commit
5b87aff021
5 changed files with 61 additions and 31 deletions
|
@ -6,7 +6,7 @@ model {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "org.ab.x48"
|
||||
minSdkVersion.apiLevel 8
|
||||
minSdkVersion.apiLevel 9
|
||||
targetSdkVersion.apiLevel 24
|
||||
}
|
||||
|
||||
|
@ -23,3 +23,6 @@ model {
|
|||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compile 'com.getkeepsafe.relinker:relinker:1.2.2'
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.ab.x48" android:installLocation="auto" android:versionCode="67" android:versionName="1.67">
|
||||
package="org.ab.x48" android:installLocation="auto" android:versionCode="69" android:versionName="1.69">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".X48"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -118,7 +118,6 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
audiobuf = new short [44100]; // 1s worth
|
||||
track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, 16384, AudioTrack.MODE_STREAM);
|
||||
annImages = new Bitmap [6];
|
||||
updateContrast();
|
||||
matrixScreen = new Matrix();
|
||||
matrixBack= new Matrix();
|
||||
annImages [0] = BitmapFactory.decodeResource(x48.getResources(), R.drawable.ann01);
|
||||
|
|
|
@ -16,6 +16,9 @@ import android.content.SharedPreferences;
|
|||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
@ -23,6 +26,8 @@ import android.view.MenuItem;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
|
||||
import com.getkeepsafe.relinker.ReLinker;
|
||||
|
||||
public class X48 extends Activity {
|
||||
|
||||
private HPView mainView;
|
||||
|
@ -38,26 +43,57 @@ public class X48 extends Activity {
|
|||
|
||||
private static EmulatorThread thread;
|
||||
private static Timer SIGALRM;
|
||||
|
||||
private static boolean errorLib;
|
||||
private Handler mHandler;
|
||||
|
||||
// http://www.hpcalc.org/hp48/pc/emulators/gxrom-r.zip
|
||||
|
||||
private ReLinker.Logger logcatLogger = new ReLinker.Logger() {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
Log.d("ReLinker", message);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (errorLib) {
|
||||
showDialog(DIALOG_LIB_KO);
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.i("x48", "starting activity");
|
||||
boolean firstLaunch = !AssetUtil.copyAsset(this, getResources().getAssets(), false);
|
||||
|
||||
readyToGo() ;
|
||||
if (!AssetUtil.isFilesReady(this)) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||
setContentView(R.layout.main);
|
||||
mainView = (HPView) findViewById(R.id.hpview);
|
||||
|
||||
mHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message inputMessage) {
|
||||
if (inputMessage.what == 1) {
|
||||
readyToGo();
|
||||
if (!AssetUtil.isFilesReady(X48.this)) {
|
||||
showDialog(DIALOG_ROM_KO);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
showDialog(DIALOG_LIB_KO);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ReLinker.recursively().log(logcatLogger).loadLibrary(X48.this, "droid48", new ReLinker.LoadListener() {
|
||||
|
||||
@Override
|
||||
public void success() {
|
||||
mHandler.obtainMessage(1).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(Throwable t) {
|
||||
mHandler.obtainMessage(0).sendToTarget();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/9996333/openoptionsmenu-function-not-working-in-ics
|
||||
|
@ -83,16 +119,13 @@ public class X48 extends Activity {
|
|||
public void readyToGo() {
|
||||
hp48s = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("hp48s", false);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||
setContentView(R.layout.main);
|
||||
mainView = (HPView) findViewById(R.id.hpview);
|
||||
|
||||
checkPrefs();
|
||||
|
||||
thread = new EmulatorThread(this);
|
||||
thread.start();
|
||||
mainView.resume();
|
||||
mainView.updateContrast();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,13 +205,6 @@ public class X48 extends Activity {
|
|||
mainView.emulatorReady();
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("droid48");
|
||||
} catch (java.lang.UnsatisfiedLinkError e) {
|
||||
errorLib = true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
@ -191,6 +217,7 @@ public class X48 extends Activity {
|
|||
SIGALRM.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (thread != null)
|
||||
SIGALRM();
|
||||
}
|
||||
}, 0, 20);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle-experimental:0.8.3'
|
||||
|
|
Loading…
Reference in a new issue