[core] Broadcast pkg changed to app (#1183)
This commit is contained in:
parent
5102b5c4f2
commit
daf3e8dbd6
|
|
@ -21,7 +21,10 @@
|
||||||
package org.lsposed.manager;
|
package org.lsposed.manager;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
@ -38,6 +41,7 @@ import org.lsposed.hiddenapibypass.HiddenApiBypass;
|
||||||
import org.lsposed.manager.repo.RepoLoader;
|
import org.lsposed.manager.repo.RepoLoader;
|
||||||
import org.lsposed.manager.ui.activity.CrashReportActivity;
|
import org.lsposed.manager.ui.activity.CrashReportActivity;
|
||||||
import org.lsposed.manager.util.DoHDNS;
|
import org.lsposed.manager.util.DoHDNS;
|
||||||
|
import org.lsposed.manager.util.ModuleUtil;
|
||||||
import org.lsposed.manager.util.theme.ThemeUtil;
|
import org.lsposed.manager.util.theme.ThemeUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
@ -136,7 +140,7 @@ public class App extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG && Process.isApplicationUid(Process.myUid())) {
|
||||||
setCrashReport();
|
setCrashReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,6 +158,17 @@ public class App extends Application {
|
||||||
DayNightDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme());
|
DayNightDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme());
|
||||||
LocaleDelegate.setDefaultLocale(getLocale());
|
LocaleDelegate.setDefaultLocale(getLocale());
|
||||||
|
|
||||||
|
registerReceiver(new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
int userId = intent.getIntExtra(Intent.EXTRA_USER, 0);
|
||||||
|
String packageName = intent.getStringExtra("android.intent.extra.PACKAGES");
|
||||||
|
if (packageName != null) {
|
||||||
|
ModuleUtil.getInstance().reloadSingleModule(packageName, userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new IntentFilter(Intent.ACTION_PACKAGE_CHANGED));
|
||||||
|
|
||||||
loadRemoteVersion();
|
loadRemoteVersion();
|
||||||
RepoLoader.getInstance().loadRemoteData();
|
RepoLoader.getInstance().loadRemoteData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ResultReceiver;
|
|
||||||
import android.os.SELinux;
|
import android.os.SELinux;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -60,7 +59,6 @@ import org.lsposed.lspd.util.FakeContext;
|
||||||
import org.lsposed.lspd.util.Utils;
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileDescriptor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
@ -241,6 +239,28 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void broadcastIntent(String modulePackageName, int moduleUserId) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_PACKAGE_CHANGED);
|
||||||
|
intent.addFlags(0x01000000); //Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND
|
||||||
|
intent.addFlags(0x00400000); //Intent.FLAG_RECEIVER_FROM_SHELL
|
||||||
|
intent.putExtra("android.intent.extra.PACKAGES", modulePackageName);
|
||||||
|
intent.putExtra(Intent.EXTRA_USER, moduleUserId);
|
||||||
|
intent.setPackage(BuildConfig.MANAGER_INJECTED_PKG_NAME);
|
||||||
|
try {
|
||||||
|
ActivityManagerService.broadcastIntentWithFeature(null, intent,
|
||||||
|
null, null, 0, null, null,
|
||||||
|
null, -1, null, true, false,
|
||||||
|
0);
|
||||||
|
intent.setPackage(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME);
|
||||||
|
ActivityManagerService.broadcastIntentWithFeature(null, intent,
|
||||||
|
null, null, 0, null, null,
|
||||||
|
null, -1, null, true, false,
|
||||||
|
0);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Log.e(TAG, "Broadcast to manager failed: ", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void createOrUpdateShortcut() {
|
public static void createOrUpdateShortcut() {
|
||||||
try {
|
try {
|
||||||
while (!UserService.isUserUnlocked(0)) {
|
while (!UserService.isUserUnlocked(0)) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -144,7 +143,10 @@ public class LSPosedService extends ILSPosedService.Stub {
|
||||||
boolean enabled = Arrays.asList(enabledModules).contains(moduleName);
|
boolean enabled = Arrays.asList(enabledModules).contains(moduleName);
|
||||||
boolean removed = intent.getAction().equals(Intent.ACTION_PACKAGE_FULLY_REMOVED) ||
|
boolean removed = intent.getAction().equals(Intent.ACTION_PACKAGE_FULLY_REMOVED) ||
|
||||||
intent.getAction().equals(Intent.ACTION_UID_REMOVED);
|
intent.getAction().equals(Intent.ACTION_UID_REMOVED);
|
||||||
LSPManagerService.showNotification(moduleName, userId, enabled || removed, systemModule);
|
if (!removed) {
|
||||||
|
LSPManagerService.showNotification(moduleName, userId, enabled, systemModule);
|
||||||
|
}
|
||||||
|
LSPManagerService.broadcastIntent(moduleName, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moduleName != null && ConfigManager.getInstance().isManager(moduleName) && userId == 0) {
|
if (moduleName != null && ConfigManager.getInstance().isManager(moduleName) && userId == 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue