Fix notification intent for Android 14 DP2 (#2435)

This commit is contained in:
LoveSy 2023-03-09 17:30:53 +08:00 committed by GitHub
parent 7087c6f752
commit af1223e4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -142,6 +142,7 @@ public class LSPNotificationManager {
static void notifyStatusNotification() {
var intent = new Intent(openManagerAction);
intent.setPackage("android");
var context = new FakeContext();
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
var notification = new Notification.Builder(context, STATUS_CHANNEL_ID)
@ -180,6 +181,7 @@ public class LSPNotificationManager {
private static PendingIntent getModuleIntent(String modulePackageName, int moduleUserId) {
var intent = new Intent(openManagerAction);
intent.setPackage("android");
intent.setData(new Uri.Builder().scheme("module").encodedAuthority(modulePackageName + ":" + moduleUserId).build());
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
return PendingIntent.getBroadcast(new FakeContext(), 3, intent, flags);
@ -187,6 +189,7 @@ public class LSPNotificationManager {
private static PendingIntent getModuleScopeIntent(String modulePackageName, int moduleUserId, String scopePackageName, String action, IXposedScopeCallback callback) {
var intent = new Intent(moduleScope);
intent.setPackage("android");
intent.setData(new Uri.Builder().scheme("module").encodedAuthority(modulePackageName + ":" + moduleUserId).encodedPath(scopePackageName).appendQueryParameter("action", action).build());
var extras = new Bundle();
extras.putBinder("callback", callback.asBinder());

View File

@ -28,6 +28,7 @@ import static org.lsposed.lspd.service.ServiceManager.getExecutorService;
import android.app.IApplicationThread;
import android.app.IUidObserver;
import android.content.Context;
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.IntentFilter;
@ -328,7 +329,7 @@ public class LSPosedService extends ILSPosedService.Stub {
};
try {
for (var filter : filters) {
ActivityManagerService.registerReceiver("android", null, receiver, filter, requiredPermission, userId, 0);
ActivityManagerService.registerReceiver("android", null, receiver, filter, requiredPermission, userId, Context.RECEIVER_NOT_EXPORTED);
}
} catch (RemoteException e) {
Log.e(TAG, "register receiver", e);
@ -401,10 +402,9 @@ public class LSPosedService extends ILSPosedService.Stub {
private void registerModuleScopeReceiver() {
var intentFilter = new IntentFilter(LSPNotificationManager.moduleScope);
var moduleFilter = new IntentFilter(intentFilter);
moduleFilter.addDataScheme("module");
intentFilter.addDataScheme("module");
registerReceiver(List.of(intentFilter, moduleFilter), "android.permission.BRICK", 0, this::dispatchModuleScope);
registerReceiver(List.of(intentFilter), "android.permission.BRICK", 0, this::dispatchModuleScope);
Log.d(TAG, "registered module scope receiver");
}