mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Merge pull request #339 from michaelrgb/master
RenderDocCmd.apk arguments, plus Internet permissions to use sockets.
This commit is contained in:
@@ -1,26 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.renderdoc.renderdoccmd" android:versionCode="1" android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="9"/>
|
||||
|
||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
||||
<uses-sdk android:minSdkVersion="9"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<application android:label="RenderDocCmd" android:hasCode="true">
|
||||
<activity android:name=".Loader" android:label="RenderDocCmdLoader" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
<application android:label="RenderDocCmd" android:hasCode="true">
|
||||
|
||||
<activity android:name=".Loader" android:label="RenderDocCmdLoader" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
<!-- Our activity is the built-in NativeActivity framework class.
|
||||
This will take care of integrating with our NDK code. -->
|
||||
<activity android:name="android.app.NativeActivity" android:label="RenderDocCmd" android:configChanges="orientation|keyboardHidden">
|
||||
<!-- Tell NativeActivity the name of or .so -->
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
<activity android:name="android.app.NativeActivity" android:label="RenderDocCmd" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
||||
|
||||
@@ -39,6 +39,8 @@ extern "C" {
|
||||
#define LOGCAT_TAG "renderdoc"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::istringstream;
|
||||
|
||||
struct android_app *android_state;
|
||||
|
||||
@@ -70,28 +72,57 @@ void DisplayRendererPreview(ReplayRenderer *renderer, TextureDisplay &displayCfg
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the renderdoccmd arguments passed via am start
|
||||
// Examples: am start ... -e renderdoccmd "remoteserver"
|
||||
// -e renderdoccmd "replay /sdcard/capture.rdc"
|
||||
vector<string> getRenderdoccmdArgs()
|
||||
{
|
||||
JNIEnv *env;
|
||||
android_state->activity->vm->AttachCurrentThread(&env, 0);
|
||||
|
||||
jobject me = android_state->activity->clazz;
|
||||
|
||||
jclass acl = env->GetObjectClass(me); // class pointer of NativeActivity
|
||||
jmethodID giid = env->GetMethodID(acl, "getIntent", "()Landroid/content/Intent;");
|
||||
jobject intent = env->CallObjectMethod(me, giid); // Got our intent
|
||||
|
||||
jclass icl = env->GetObjectClass(intent); // class pointer of Intent
|
||||
jmethodID gseid =
|
||||
env->GetMethodID(icl, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
|
||||
jstring jsParam1 =
|
||||
(jstring)env->CallObjectMethod(intent, gseid, env->NewStringUTF("renderdoccmd"));
|
||||
|
||||
vector<string> ret;
|
||||
if(!jsParam1)
|
||||
return ret; // No arg value found
|
||||
|
||||
ret.push_back("renderdoccmd");
|
||||
|
||||
const char *param1 = env->GetStringUTFChars(jsParam1, 0);
|
||||
istringstream iss(param1);
|
||||
while(iss)
|
||||
{
|
||||
string sub;
|
||||
iss >> sub;
|
||||
ret.push_back(sub);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void handle_cmd(android_app *app, int32_t cmd)
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case APP_CMD_INIT_WINDOW:
|
||||
{
|
||||
// The window is being shown, get it ready.
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG,
|
||||
"APP_CMD_INIT_WINDOW: android_state->window: %p", android_state->window);
|
||||
|
||||
const char *argv[] = {
|
||||
"renderdoccmd", "replay", "/sdcard/capture.rdc",
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
renderdoccmd(argc, (char **)argv);
|
||||
vector<string> args = getRenderdoccmdArgs();
|
||||
if(!args.size())
|
||||
break; // Nothing for APK to do.
|
||||
renderdoccmd(args);
|
||||
break;
|
||||
}
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
// The window is being hidden or closed, clean it up.
|
||||
// DeleteVulkan();
|
||||
break;
|
||||
case APP_CMD_TERM_WINDOW: break;
|
||||
default: __android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG, "event not handled: %d", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user