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
map Android UnifiedPush to DBus UnifiedPush
This commit is contained in:
@@ -133,11 +133,22 @@ public class Context extends Object {
|
||||
Security.addProvider(provider);
|
||||
|
||||
r.applyPackageQuirks(application_info.packageName);
|
||||
|
||||
for (PackageParser.Activity receiver : pkg.receivers) {
|
||||
for (PackageParser.ActivityIntentInfo intent : receiver.intents) {
|
||||
if (intent.matchAction("org.unifiedpush.android.connector.MESSAGE")) {
|
||||
nativeExportUnifiedPush(application_info.packageName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static native String native_get_apk_path();
|
||||
protected static native void native_updateConfig(Configuration config);
|
||||
private static native void nativeOpenFile(int fd);
|
||||
private static native void nativeExportUnifiedPush(String packageName);
|
||||
private static native void nativeRegisterUnifiedPush(String token, String application);
|
||||
|
||||
static Application createApplication(long native_window) throws Exception {
|
||||
Application application;
|
||||
@@ -502,6 +513,16 @@ public class Context extends Object {
|
||||
public void unregisterComponentCallbacks(ComponentCallbacks callbacks) {}
|
||||
|
||||
public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int dummy3) {
|
||||
if (intent.getComponent() == null) {
|
||||
for (PackageParser.Service s : pkg.services) {
|
||||
for (PackageParser.IntentInfo ii : s.intents) {
|
||||
if (ii.matchAction(intent.getAction())) {
|
||||
intent.setComponent(new ComponentName(pkg.packageName, s.className));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intent.getComponent() == null) {
|
||||
Slog.w(TAG, "Context.bindService: intent.getComponent() is null");
|
||||
return false;
|
||||
@@ -629,11 +650,27 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public void sendBroadcast(Intent intent) {
|
||||
if ("org.unifiedpush.android.distributor.REGISTER".equals(intent.getAction())) {
|
||||
nativeRegisterUnifiedPush(intent.getStringExtra("token"), intent.getStringExtra("application"));
|
||||
}
|
||||
for (IntentFilter filter : receiverMap.keySet()) {
|
||||
if (filter.matchAction(intent.getAction())) {
|
||||
receiverMap.get(filter).onReceive(this, intent);
|
||||
}
|
||||
}
|
||||
for (PackageParser.Activity receiver : pkg.receivers) {
|
||||
for (PackageParser.IntentInfo intentInfo : receiver.intents) {
|
||||
if (intentInfo.matchAction(intent.getAction())) {
|
||||
try {
|
||||
Class<? extends BroadcastReceiver> cls = Class.forName(receiver.className).asSubclass(BroadcastReceiver.class);
|
||||
BroadcastReceiver receiverInstance = cls.newInstance();
|
||||
receiverInstance.onReceive(this, intent);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stopService(Intent intent) throws ClassNotFoundException {
|
||||
|
||||
@@ -2318,6 +2318,11 @@ public class PackageManager {
|
||||
*/
|
||||
public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
|
||||
int flags) {
|
||||
if ("org.unifiedpush.android.distributor.REGISTER".equals(intent.getAction())) {
|
||||
ResolveInfo ri = new ResolveInfo();
|
||||
ri.activityInfo.exported = true;
|
||||
return Arrays.asList(ri);
|
||||
}
|
||||
return new ArrayList<ResolveInfo>();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ public class ResolveInfo {
|
||||
public ActivityInfo activityInfo = new ActivityInfo();
|
||||
public ServiceInfo serviceInfo = new ServiceInfo();
|
||||
public IntentFilter filter = new IntentFilter();
|
||||
public int priority = -500;
|
||||
|
||||
public static class DisplayNameComparator {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user