[core] Fix detection of newly installed manager
This commit is contained in:
parent
c9117285c7
commit
43e878aabe
|
|
@ -216,6 +216,8 @@ public class ConfigManager {
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
managerUid = info.applicationInfo.uid;
|
managerUid = info.applicationInfo.uid;
|
||||||
manager = info.packageName;
|
manager = info.packageName;
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "manager is not installed");
|
||||||
}
|
}
|
||||||
} catch (RemoteException ignored) {
|
} catch (RemoteException ignored) {
|
||||||
}
|
}
|
||||||
|
|
@ -558,8 +560,8 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManager(String module_pkg_name) {
|
public boolean isManager(String packageName) {
|
||||||
return module_pkg_name.equals(manager);
|
return packageName.equals(manager) || packageName.equals(DEFAULT_MANAGER_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManager(int uid) {
|
public boolean isManager(int uid) {
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ public class LSPosedService extends ILSPosedService.Stub {
|
||||||
Log.e(TAG, "Package name is null");
|
Log.e(TAG, "Package name is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "New installed: " + packageName);
|
||||||
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||||
int userId = intent.getIntExtra(Intent.EXTRA_USER, -1);
|
int userId = intent.getIntExtra(Intent.EXTRA_USER, -1);
|
||||||
boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
||||||
|
|
@ -103,7 +104,9 @@ public class LSPosedService extends ILSPosedService.Stub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED) && uid > 0 && ConfigManager.getInstance().isManager(packageName)) {
|
if (!intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED) && uid > 0 && ConfigManager.getInstance().isManager(packageName)) {
|
||||||
|
Log.d(TAG, "Manager updated");
|
||||||
try {
|
try {
|
||||||
|
ConfigManager.getInstance().updateManager();
|
||||||
ConfigManager.grantManagerPermission();
|
ConfigManager.grantManagerPermission();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import android.content.pm.ServiceInfo;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -38,6 +39,7 @@ import io.github.lsposed.lspd.Application;
|
||||||
import io.github.lsposed.lspd.utils.ParceledListSlice;
|
import io.github.lsposed.lspd.utils.ParceledListSlice;
|
||||||
|
|
||||||
import static android.content.pm.ServiceInfo.FLAG_ISOLATED_PROCESS;
|
import static android.content.pm.ServiceInfo.FLAG_ISOLATED_PROCESS;
|
||||||
|
import static io.github.lsposed.lspd.service.ServiceManager.TAG;
|
||||||
|
|
||||||
public class PackageService {
|
public class PackageService {
|
||||||
private static IPackageManager pm = null;
|
private static IPackageManager pm = null;
|
||||||
|
|
@ -46,6 +48,20 @@ public class PackageService {
|
||||||
public static IPackageManager getPackageManager() {
|
public static IPackageManager getPackageManager() {
|
||||||
if (binder == null && pm == null) {
|
if (binder == null && pm == null) {
|
||||||
binder = ServiceManager.getService("package");
|
binder = ServiceManager.getService("package");
|
||||||
|
if (binder == null) return null;
|
||||||
|
try {
|
||||||
|
binder.linkToDeath(new IBinder.DeathRecipient() {
|
||||||
|
@Override
|
||||||
|
public void binderDied() {
|
||||||
|
Log.w(TAG, "pm is dead");
|
||||||
|
binder.unlinkToDeath(this, 0);
|
||||||
|
binder = null;
|
||||||
|
pm = null;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
}
|
||||||
pm = IPackageManager.Stub.asInterface(binder);
|
pm = IPackageManager.Stub.asInterface(binder);
|
||||||
}
|
}
|
||||||
return pm;
|
return pm;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue