mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Only require C2D_MESSAGE permission when defined
This commit is contained in:
parent
9e0ee103a1
commit
f94d140dea
@ -23,6 +23,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PermissionInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -468,6 +469,15 @@ public class McsService extends Service implements Handler.Callback {
|
|||||||
intent.putExtra(appData.key, appData.value);
|
intent.putExtra(appData.key, appData.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String receiverPermission;
|
||||||
|
try {
|
||||||
|
String name = msg.category + ".permission.C2D_MESSAGE";
|
||||||
|
getPackageManager().getPermissionInfo(name, 0);
|
||||||
|
receiverPermission = name;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
receiverPermission = null;
|
||||||
|
}
|
||||||
|
|
||||||
List<ResolveInfo> infos = getPackageManager().queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER);
|
List<ResolveInfo> infos = getPackageManager().queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER);
|
||||||
if (infos == null || infos.isEmpty()) {
|
if (infos == null || infos.isEmpty()) {
|
||||||
logd("No target for message, wut?");
|
logd("No target for message, wut?");
|
||||||
@ -476,7 +486,7 @@ public class McsService extends Service implements Handler.Callback {
|
|||||||
logd("Target: " + resolveInfo);
|
logd("Target: " + resolveInfo);
|
||||||
Intent targetIntent = new Intent(intent);
|
Intent targetIntent = new Intent(intent);
|
||||||
targetIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
|
targetIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
|
||||||
sendOrderedBroadcast(targetIntent, msg.category + ".permission.C2D_MESSAGE");
|
sendOrderedBroadcast(targetIntent, receiverPermission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user