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
Try to start all external Services over DBus
No need to hardcode this only for Cloud Messaging
This commit is contained in:
@@ -176,9 +176,10 @@ JNIEXPORT void JNICALL Java_android_content_Context_nativeRegisterUnifiedPush(JN
|
||||
(*env)->ReleaseStringUTFChars(env, application_jstr, application);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_content_Context_nativeStartExternalService(JNIEnv *env, jclass this, jstring package_jstr, jobject intent)
|
||||
JNIEXPORT void JNICALL Java_android_content_Context_nativeStartExternalService(JNIEnv *env, jclass this, jobject intent)
|
||||
{
|
||||
GVariant *variant = intent_serialize(env, intent);
|
||||
jstring package_jstr = _GET_OBJ_FIELD(intent, "packageName", "Ljava/lang/String;");
|
||||
const char *package = (*env)->GetStringUTFChars(env, package_jstr, NULL);
|
||||
char *object_path = g_strdup_printf("/%s", package);
|
||||
g_strdelimit(object_path, ".", '/');
|
||||
|
||||
@@ -52,10 +52,10 @@ JNIEXPORT void JNICALL Java_android_content_Context_nativeRegisterUnifiedPush
|
||||
/*
|
||||
* Class: android_content_Context
|
||||
* Method: nativeStartExternalService
|
||||
* Signature: (Ljava/lang/String;Landroid/content/Intent;)V
|
||||
* Signature: (Landroid/content/Intent;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_Context_nativeStartExternalService
|
||||
(JNIEnv *, jclass, jstring, jobject);
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class Context extends Object {
|
||||
private static native void nativeOpenFile(int fd);
|
||||
private static native void nativeExportUnifiedPush(String packageName);
|
||||
private static native void nativeRegisterUnifiedPush(String token, String application);
|
||||
private static native void nativeStartExternalService(String packageName, Intent service);
|
||||
private static native void nativeStartExternalService(Intent service);
|
||||
|
||||
static Application createApplication(long native_window) throws Exception {
|
||||
Application application;
|
||||
@@ -482,12 +482,10 @@ public class Context extends Object {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intent.getAction() != null && intent.getAction().startsWith("com.google.android.c2dm")) {
|
||||
nativeStartExternalService("com.google.android.c2dm", intent);
|
||||
// Newer applications use a Messenger instead of a BroadcastReceiver for the return Intent.
|
||||
// Newer applications use a Messenger instead of a BroadcastReceiver for the GCM token return Intent.
|
||||
// To support new and old apps with a common interface, we wrap the Messenger in a BroadcastReceiver
|
||||
if ("com.google.android.c2dm.intent.REGISTER".equals(intent.getAction()) && intent.getParcelableExtra("google.messenger") instanceof Messenger) {
|
||||
final Messenger messenger = (Messenger)intent.getParcelableExtra("google.messenger");
|
||||
if (messenger != null) {
|
||||
receiverMap.put(new IntentFilter("com.google.android.c2dm.intent.REGISTRATION"), new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent resultIntent) {
|
||||
@@ -499,6 +497,9 @@ public class Context extends Object {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (intent.getPackage() != null && !intent.getPackage().equals(getPackageName())) {
|
||||
// External package. Try to start using DBus Action
|
||||
nativeStartExternalService(intent);
|
||||
return null;
|
||||
}
|
||||
if (component == null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ public class Intent implements Parcelable {
|
||||
private Uri data;
|
||||
private int flags;
|
||||
private String type;
|
||||
private String packageName;
|
||||
|
||||
public Intent() {}
|
||||
public Intent(Intent o) {
|
||||
@@ -63,7 +64,8 @@ public class Intent implements Parcelable {
|
||||
}
|
||||
|
||||
public Intent setPackage(String packageName) {
|
||||
return this; //??
|
||||
this.packageName = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Intent setType(String type) {
|
||||
@@ -328,7 +330,7 @@ public class Intent implements Parcelable {
|
||||
}
|
||||
|
||||
public String getPackage() {
|
||||
return component == null ? null : component.getPackageName();
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
|
||||
Reference in New Issue
Block a user