Merge pull request #1237 from reicast/lk/android-studio
Android: Background service (Part 1)
|
@ -51,7 +51,7 @@ script:
|
|||
before_deploy:
|
||||
- cd ../../
|
||||
- mkdir -p artifacts/$GIT_BUILD/
|
||||
- cp shell/android-studio/app/build/outputs/apk/debug/app-debug.apk artifacts/$GIT_BUILD/reicast-android-debug-$GIT_HASH.apk
|
||||
- cp shell/android-studio/reicast/build/outputs/apk/debug/reicast-debug.apk artifacts/$GIT_BUILD/reicast-android-debug-$GIT_HASH.apk
|
||||
deploy:
|
||||
provider: s3
|
||||
access_key_id: AKIAJR5J3OHAQUP5BHHQ
|
||||
|
|
|
@ -85,16 +85,16 @@ play {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:25.4.0'
|
||||
compile 'com.android.support:appcompat-v7:25.4.0'
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.1.2'
|
||||
compile 'org.bouncycastle:bcprov-jdk16:1.46'
|
||||
compile 'commons-io:commons-io:2.6'
|
||||
compile 'org.apache.commons:commons-lang3:3.7'
|
||||
compile ('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
implementation 'com.android.support:support-v4:25.4.0'
|
||||
implementation 'com.android.support:appcompat-v7:25.4.0'
|
||||
implementation 'com.android.support:design:25.4.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
|
||||
implementation 'org.bouncycastle:bcprov-jdk16:1.46'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'org.apache.commons:commons-lang3:3.7'
|
||||
implementation ('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude module: 'junit'
|
||||
}
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_SERVICE" />
|
||||
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
|
@ -121,6 +122,12 @@
|
|||
android:configChanges="orientation|navigation|screenSize|screenLayout|uiMode|keyboard|keyboardHidden"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
|
||||
|
||||
<service
|
||||
android:name=".emu.EmuService"
|
||||
android:configChanges="orientation"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1 @@
|
|||
9891979f2c0e9e9e8a8975e16aea9b4e943bd3aa
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
@ -1,6 +1,9 @@
|
|||
package com.reicast.emulator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
|
@ -19,6 +22,7 @@ import android.view.WindowManager;
|
|||
import android.widget.PopupWindow;
|
||||
|
||||
import com.reicast.emulator.config.Config;
|
||||
import com.reicast.emulator.emu.EmuService;
|
||||
import com.reicast.emulator.emu.GL2JNIView;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
import com.reicast.emulator.emu.OnScreenMenu;
|
||||
|
@ -35,6 +39,7 @@ import java.util.HashMap;
|
|||
import tv.ouya.console.api.OuyaController;
|
||||
|
||||
public class GL2JNIActivity extends Activity {
|
||||
private Intent serviceIntent;
|
||||
public GL2JNIView mView;
|
||||
OnScreenMenu menu;
|
||||
public MainPopup popUp;
|
||||
|
@ -56,6 +61,11 @@ public class GL2JNIActivity extends Activity {
|
|||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
||||
}
|
||||
//serviceIntent = new Intent(this, EmuService.class);
|
||||
//serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND);
|
||||
//serviceIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
//startService(serviceIntent);
|
||||
|
||||
Emulator app = (Emulator)getApplicationContext();
|
||||
app.getConfigurationPrefs(prefs);
|
||||
menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
|
||||
|
@ -536,6 +546,22 @@ public class GL2JNIActivity extends Activity {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean serviceRunning(Class<?> javaclass) {
|
||||
ActivityManager manager = (ActivityManager)
|
||||
getSystemService(Context.ACTIVITY_SERVICE);
|
||||
try {
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (javaclass.getName().equals(
|
||||
service.service.getClassName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
@ -546,15 +572,18 @@ public class GL2JNIActivity extends Activity {
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
//if (serviceRunning(EmuService.class))
|
||||
// stopService(serviceIntent);
|
||||
mView.onDestroy();
|
||||
JNIdc.terminate();
|
||||
moga.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
// TODO Auto-generated method stub
|
||||
JNIdc.stop();
|
||||
mView.onStop();
|
||||
super.onStop();
|
||||
// mView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -573,14 +573,15 @@ public class GL2JNINative extends NativeActivity {
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mView.onDestroy();
|
||||
JNIdc.terminate();
|
||||
moga.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
JNIdc.stop();
|
||||
mView.onStop();
|
||||
super.onStop();
|
||||
// mView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -76,16 +76,21 @@ public class EditVJoyActivity extends Activity {
|
|||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
mView.onStop();
|
||||
super.onStop();
|
||||
// mView.onStop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mView.onDestroy();
|
||||
}
|
||||
|
||||
PopupWindow createVJoyPopup() {
|
||||
final PopupWindow popUp = new PopupWindow(this);
|
|
@ -153,7 +153,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
}
|
||||
try {
|
||||
mLogcatProc = Runtime.getRuntime().exec(
|
||||
new String[] { "logcat", "-d", "AndroidRuntime:E *:S" });
|
||||
new String[] { "logcat", "-ds", "AndroidRuntime:E" });
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
mLogcatProc.getInputStream()));
|
||||
String line;
|
||||
|
@ -187,7 +187,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
mLogcatProc = null;
|
||||
reader = null;
|
||||
mLogcatProc = Runtime.getRuntime().exec(
|
||||
new String[] { "logcat", "-d", "reicast:V *:S" });
|
||||
new String[] { "logcat", "-ds", "reicast:V" });
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
mLogcatProc.getInputStream()));
|
||||
log.append(separator);
|
||||
|
@ -203,7 +203,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
mLogcatProc = null;
|
||||
reader = null;
|
||||
mLogcatProc = Runtime.getRuntime().exec(
|
||||
new String[] { "logcat", "-d", "GL2JNIView:E *:S" });
|
||||
new String[] { "logcat", "-ds", "GL2JNIView:E" });
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
mLogcatProc.getInputStream()));
|
||||
log.append(separator);
|
|
@ -0,0 +1,48 @@
|
|||
package com.reicast.emulator.emu;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.reicast.emulator.R;
|
||||
|
||||
public class EmuService extends Service {
|
||||
|
||||
private final static int FOREGROUND_ID = 999;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (intent != null && intent.getAction() != null
|
||||
&& intent.getAction().equals("com.reicast.emulator.KYS")) {
|
||||
stopSelf();
|
||||
} else {
|
||||
Intent intentService = new Intent(this, EmuService.class);
|
||||
intentService.setAction("com.reicast.emulator.KYS");
|
||||
PendingIntent pendingIntent = PendingIntent.getService(this,
|
||||
(int) System.currentTimeMillis(), intentService,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setTicker(getString(R.string.service_ticker))
|
||||
.setContentTitle(getString(R.string.service_title))
|
||||
.setContentText(getString(R.string.service_content))
|
||||
.setContentIntent(pendingIntent);
|
||||
startForeground(FOREGROUND_ID, builder.build());
|
||||
return START_STICKY_COMPATIBILITY;
|
||||
}
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
stopForeground(true);
|
||||
}
|
||||
}
|
|
@ -655,7 +655,7 @@ public class GL2JNIView extends GLSurfaceView
|
|||
long used=pos-Player.getPlaybackHeadPosition();
|
||||
long avail=size-used;
|
||||
|
||||
//Log.i("AUD", "u: " + used + " a: " + avail);
|
||||
//Log.i("audcfg", "u: " + used + " a: " + avail);
|
||||
if (avail<newdata)
|
||||
return 0;
|
||||
}
|
||||
|
@ -693,7 +693,18 @@ public class GL2JNIView extends GLSurfaceView
|
|||
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
// public void onStop() {
|
||||
// // TODO Auto-generated method stub
|
||||
// System.exit(0);
|
||||
// try {
|
||||
// ethd.join();
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
System.exit(0);
|
||||
try {
|
|
@ -95,16 +95,19 @@ public class GLCFactory14 {
|
|||
glAPIToTry = EGL14.EGL_OPENGL_ES2_BIT;
|
||||
} else {
|
||||
renderableType = EGL14.EGL_OPENGL_ES2_BIT;
|
||||
// If this API does not work, try ES next.
|
||||
glAPIToTry = EGL14.EGL_OPENGL_ES_API;
|
||||
// If this API does not work, is a potato.
|
||||
glAPIToTry = EGL10.EGL_NONE;
|
||||
}
|
||||
|
||||
// This EGL config specification is used to specify 2.0 rendering.
|
||||
// We use a minimum size of 4 bits for red/green/blue, but will
|
||||
// perform actual matching in chooseConfig() below.
|
||||
configSpec = new int[] {
|
||||
EGL14.EGL_RED_SIZE, 4,
|
||||
EGL14.EGL_GREEN_SIZE, 4,
|
||||
EGL14.EGL_BLUE_SIZE, 4,
|
||||
EGL14.EGL_RENDERABLE_TYPE, renderableType,
|
||||
EGL14.EGL_DEPTH_SIZE, 24,
|
||||
EGL14.EGL_DEPTH_SIZE, 16,
|
||||
EGL14.EGL_NONE
|
||||
};
|
||||
|
||||
|
@ -115,7 +118,7 @@ public class GLCFactory14 {
|
|||
}
|
||||
}
|
||||
|
||||
} while (glAPIToTry != EGL14.EGL_OPENGL_ES_API && mValue[0]<=0);
|
||||
} while (glAPIToTry != EGL10.EGL_NONE && mValue[0]<=0);
|
||||
|
||||
if (mValue[0]<=0) {
|
||||
throw new IllegalArgumentException("No configs match configSpec");
|
|
@ -8,7 +8,7 @@ public final class JNIdc
|
|||
public static native void config(String dirName);
|
||||
public static native void init(String fileName);
|
||||
public static native void run(Object track);
|
||||
public static native void stop();
|
||||
public static native void terminate();
|
||||
|
||||
public static native int send(int cmd, int opt);
|
||||
public static native int data(int cmd, byte[] data);
|
|
@ -69,6 +69,7 @@ LOCAL_PRELINK_MODULE := false
|
|||
|
||||
LOCAL_MODULE := dc
|
||||
LOCAL_DISABLE_FORMAT_STRING_CHECKS=true
|
||||
LOCAL_SHORT_COMMANDS := true
|
||||
LOCAL_ASFLAGS := -fPIC -fvisibility=hidden
|
||||
LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz
|
||||
#-Wl,-Map,./res/raw/syms.mp3
|
|
@ -25,7 +25,7 @@ extern "C"
|
|||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_config(JNIEnv *env,jobject obj,jstring dirName) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_init(JNIEnv *env,jobject obj,jstring fileName) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_run(JNIEnv *env,jobject obj,jobject emu_thread) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_stop(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_terminate(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobject obj,jint id, jint v) __attribute__((visibility("default")));
|
||||
JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_data(JNIEnv *env,jobject obj,jint id, jbyteArray d) __attribute__((visibility("default")));
|
||||
|
@ -368,7 +368,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupVmu(JNIEnv *env,
|
|||
//jpix=env->NewByteArray(1536);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_stop(JNIEnv *env,jobject obj)
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_terminate(JNIEnv *env,jobject obj)
|
||||
{
|
||||
dc_term();
|
||||
}
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |