You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
FLAG_ACTIVITY_CLEAR_TOP: create Activity if it doesn't already exist
When originally implementing this flag, we forgot to handle cases where the Activity does not exist.
This commit is contained in:
@@ -201,10 +201,11 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeStartActivity(JNIEnv *env
|
|||||||
activity_start(env, activity);
|
activity_start(env, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity(JNIEnv *env, jclass class, jclass activity_class, jobject intent)
|
JNIEXPORT jboolean JNICALL Java_android_app_Activity_nativeResumeActivity(JNIEnv *env, jclass class, jclass activity_class, jobject intent)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
GList *activities_to_close = NULL;
|
GList *activities_to_close = NULL;
|
||||||
|
jboolean found = JNI_FALSE;
|
||||||
for (l = activity_backlog; l != NULL; l = l->next) {
|
for (l = activity_backlog; l != NULL; l = l->next) {
|
||||||
if ((*env)->IsSameObject(env, activity_class, _CLASS(l->data))) {
|
if ((*env)->IsSameObject(env, activity_class, _CLASS(l->data))) {
|
||||||
if (l != activity_backlog) {
|
if (l != activity_backlog) {
|
||||||
@@ -218,6 +219,7 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity(JNIEnv *en
|
|||||||
(*env)->CallVoidMethod(env, l->data, handle_cache.activity.onNewIntent, intent);
|
(*env)->CallVoidMethod(env, l->data, handle_cache.activity.onNewIntent, intent);
|
||||||
if((*env)->ExceptionCheck(env))
|
if((*env)->ExceptionCheck(env))
|
||||||
(*env)->ExceptionDescribe(env);
|
(*env)->ExceptionDescribe(env);
|
||||||
|
found = JNI_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,6 +230,8 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity(JNIEnv *en
|
|||||||
_UNREF(l->data);
|
_UNREF(l->data);
|
||||||
}
|
}
|
||||||
g_list_free(activities_to_close);
|
g_list_free(activities_to_close);
|
||||||
|
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeOpenURI(JNIEnv *env, jclass class, jstring uriString)
|
JNIEXPORT void JNICALL Java_android_app_Activity_nativeOpenURI(JNIEnv *env, jclass class, jstring uriString)
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeStartActivity
|
|||||||
/*
|
/*
|
||||||
* Class: android_app_Activity
|
* Class: android_app_Activity
|
||||||
* Method: nativeResumeActivity
|
* Method: nativeResumeActivity
|
||||||
* Signature: (Ljava/lang/Class;Landroid/content/Intent;)V
|
* Signature: (Ljava/lang/Class;Landroid/content/Intent;)Z
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity
|
JNIEXPORT jboolean JNICALL Java_android_app_Activity_nativeResumeActivity
|
||||||
(JNIEnv *, jclass, jclass, jobject);
|
(JNIEnv *, jclass, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback, La
|
|||||||
|
|
||||||
private native void nativeFinish(long native_window);
|
private native void nativeFinish(long native_window);
|
||||||
public static native void nativeStartActivity(Activity activity);
|
public static native void nativeStartActivity(Activity activity);
|
||||||
public static native void nativeResumeActivity(Class<? extends Activity> activityClass, Intent intent);
|
public static native boolean nativeResumeActivity(Class<? extends Activity> activityClass, Intent intent);
|
||||||
public static native void nativeOpenURI(String uri);
|
public static native void nativeOpenURI(String uri);
|
||||||
public native void nativeFileChooser(int action, String type, String title, int requestCode);
|
public native void nativeFileChooser(int action, String type, String title, int requestCode);
|
||||||
public void reportFullyDrawn() {}
|
public void reportFullyDrawn() {}
|
||||||
|
|||||||
@@ -663,11 +663,12 @@ public class Context extends Object {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if ((intent_.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0 && intent_.getComponent() != null) {
|
if ((intent_.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0 && intent_.getComponent() != null) {
|
||||||
Activity.nativeResumeActivity(Class.forName(intent_.getComponent().getClassName()).asSubclass(Activity.class), intent_);
|
boolean found = Activity.nativeResumeActivity(Class.forName(intent_.getComponent().getClassName()).asSubclass(Activity.class), intent_);
|
||||||
} else {
|
if (found)
|
||||||
Activity activity = Activity.internalCreateActivity(className_, this_application.native_window, intent_);
|
return;
|
||||||
Activity.nativeStartActivity(activity);
|
|
||||||
}
|
}
|
||||||
|
Activity activity = Activity.internalCreateActivity(className_, this_application.native_window, intent_);
|
||||||
|
Activity.nativeStartActivity(activity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user