<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.drawelements.deqp"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:label="dEQP Tests"
+ package="com.drawelements.deqp"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:label="dEQP Tests"
android:icon="@drawable/deqp_app">
<activity android:name="com.drawelements.deqp.execserver.ExecServerActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="dEQP ExecServer"
android:launchMode="singleTask"
android:process=":execserverui"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
+ android:exported="true" />
<activity android:name="com.drawelements.deqp.execserver.ServiceStarter"
android:theme="@android:style/Theme.NoDisplay"
android:label="dEQP ExecServer Launcher"
</activity>
</application>
- <uses-sdk android:minSdkVersion="13"/>
- <uses-sdk android:targetSdkVersion="19"/>
- <uses-feature android:glEsVersion="0x00020000"/>
+ <uses-sdk android:minSdkVersion="13"/>
+ <uses-sdk android:targetSdkVersion="19"/>
+ <uses-feature android:glEsVersion="0x00020000"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
public class ExecServerActivity extends Activity {
- private static final String LOG_TAG = "dEQP/ExecServer";
- private static final int PORT = 50016;
-
- private TextView m_statusText;
+ private TextView m_statusText;
@Override
protected void onCreate (Bundle savedInstance) {
@Override
protected void onStart () {
super.onStart();
-
- try {
- Intent svc = new Intent(this, com.drawelements.deqp.execserver.ExecService.class);
- startService(svc);
- }
- catch (Exception e) {
- Log.e(LOG_TAG, "Service starter starting problem", e);
- m_statusText.setText("Failed to start ExecServer!");
- }
-
- // \todo [2013-05-07 pyry] Show IP address
- m_statusText.setText(String.format("Listening on port %d", PORT));
+ // \todo [2015-10-06 pyry] Connect to service, check status, offer option for killing it
+ m_statusText.setText("dEQP ExecServer is running");
}
@Override
import android.os.IBinder;
import com.drawelements.deqp.execserver.ExecServerActivity;
+import com.drawelements.deqp.testercore.Log;
import com.drawelements.deqp.R;
public class ExecService extends Service {
+
+ public static final String LOG_TAG = "dEQP";
+ public static final int DEFAULT_PORT = 50016;
+
+ private int m_curPort = -1;
+ private boolean m_isRunning = false;
+
static {
System.loadLibrary("deqp");
}
private final IBinder m_binder = new LocalBinder();
@Override
- public void onCreate () {
- onCreateNative();
- }
-
- @Override
public int onStartCommand (Intent intent, int flags, int startId) {
+ final int port = intent != null ? intent.getIntExtra("port", DEFAULT_PORT) : DEFAULT_PORT;
+
+ if (m_isRunning && (m_curPort != port)) {
+ Log.i(LOG_TAG, String.format("Port changed (old: %d, new: %d), killing old server", m_curPort, port));
+ stopServer();
+ m_isRunning = false;
+ }
+
+ if (!m_isRunning) {
+ startServer(port);
+
+ m_isRunning = true;
+ m_curPort = port;
+
+ Log.i(LOG_TAG, String.format("Listening on port %d", m_curPort));
+ }
+
// Intent to launch when notification is clicked.
Intent launchIntent = new Intent(this, ExecServerActivity.class);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@Override
public void onDestroy () {
- onDestroyNative();
+ if (m_isRunning) {
+ stopServer();
+ m_isRunning = false;
+ }
}
- private native void onCreateNative ();
- private native void onDestroyNative ();
+ private native void startServer (int port);
+ private native void stopServer ();
}
import android.app.Activity;
import android.os.Bundle;
import com.drawelements.deqp.testercore.Log;
+import com.drawelements.deqp.execserver.ExecService;
import android.content.Intent;
-public class ServiceStarter extends Activity
-{
- private static final String LOG_TAG = "dEQP/ServiceStarter";
+public class ServiceStarter extends Activity {
@Override
- public void onCreate(Bundle icicle)
- {
- super.onCreate(icicle);
+ public void onCreate(Bundle savedInstance) {
+ super.onCreate(savedInstance);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ final int port = getIntent().getIntExtra("port", ExecService.DEFAULT_PORT);
+
try {
- Intent svc = new Intent(this, com.drawelements.deqp.execserver.ExecService.class);
+ Intent svc = new Intent(this, ExecService.class);
+ svc.putExtra("port", port);
startService(svc);
}
catch (Exception e) {
- Log.e(LOG_TAG, "Service starter starting problem", e);
+ Log.e(ExecService.LOG_TAG, "Failed to start ExecService", e);
}
finish();
}
public class RemoteAPI {
- private static final String LOG_TAG = "dEQP/RemoteAPI";
+ private static final String LOG_TAG = "dEQP";
private Context m_context;
private String m_processName;
// ExecService
-ExecService::ExecService (JavaVM* vm, jobject context, deSocketFamily family, int port)
+ExecService::ExecService (JavaVM* vm, jobject context, int port, deSocketFamily family)
: m_process (vm, context)
, m_thread (vm, &m_process, family, port)
{
class ExecService
{
public:
- ExecService (JavaVM* vm, jobject context, deSocketFamily family = (deSocketFamily)DEFAULT_SOCKETFAMILY, int port = DEFAULT_PORT);
+ ExecService (JavaVM* vm, jobject context, int port, deSocketFamily family = (deSocketFamily)DEFAULT_SOCKETFAMILY);
~ExecService (void);
void start (void);
DE_BEGIN_EXTERN_C
-JNIEXPORT void JNICALL Java_com_drawelements_deqp_execserver_ExecService_onCreateNative (JNIEnv* env, jobject obj)
+JNIEXPORT void JNICALL Java_com_drawelements_deqp_execserver_ExecService_startServer (JNIEnv* env, jobject obj, jint port)
{
tcu::Android::ExecService* service = DE_NULL;
JavaVM* vm = DE_NULL;
env->GetJavaVM(&vm);
TCU_CHECK_INTERNAL(vm);
- service = new tcu::Android::ExecService(vm, obj);
+ service = new tcu::Android::ExecService(vm, obj, port);
service->start();
setExecService(env, obj, service);
{
logException(e);
delete service;
- tcu::die("ExecService.onCreateNative() failed");
+ tcu::die("ExecService.startServer() failed");
}
}
-JNIEXPORT void JNICALL Java_com_drawelements_deqp_execserver_ExecService_onDestroyNative (JNIEnv* env, jobject obj)
+JNIEXPORT void JNICALL Java_com_drawelements_deqp_execserver_ExecService_stopServer (JNIEnv* env, jobject obj)
{
try
{
catch (const std::exception& e)
{
logException(e);
- tcu::die("ExecService.onDestroyNative() failed");
+ tcu::die("ExecService.stopServer() failed");
}
}