If user resumes APK after server shutdown, restart cmdthread.

Also make sure ANativeActivity_finish/DetachCurrentThread are called.
This commit is contained in:
michaelrgb
2018-01-02 11:30:30 +00:00
committed by Baldur Karlsson
parent b9be6a70e3
commit 89eb933be5
+16 -17
View File
@@ -356,18 +356,17 @@ vector<string> getRenderdoccmdArgs()
(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)
if(jsParam1) // Check if arg value found
{
string sub;
iss >> sub;
ret.push_back(sub);
ret.push_back("renderdoccmd");
const char *param1 = env->GetStringUTFChars(jsParam1, 0);
istringstream iss(param1);
while(iss)
{
string sub;
iss >> sub;
ret.push_back(sub);
}
}
android_state->activity->vm->DetachCurrentThread();
@@ -377,10 +376,8 @@ vector<string> getRenderdoccmdArgs()
void *cmdthread(void *)
{
vector<string> args = getRenderdoccmdArgs();
if(!args.size())
return NULL; // Nothing for APK to do.
renderdoccmd(GlobalEnvironment(), args);
if(args.size())
renderdoccmd(GlobalEnvironment(), args);
// activity is done and should be closed
ANativeActivity_finish(android_state->activity);
@@ -394,9 +391,11 @@ void handle_cmd(android_app *app, int32_t cmd)
{
case APP_CMD_INIT_WINDOW:
{
if(cmdthread_handle == 0)
pthread_create(&cmdthread_handle, NULL, cmdthread, NULL);
if(cmdthread_handle != 0)
// If user resumes APK after server shutdown, restart the thread.
pthread_join(cmdthread_handle, NULL);
pthread_create(&cmdthread_handle, NULL, cmdthread, NULL);
break;
}
case APP_CMD_WINDOW_REDRAW_NEEDED: