[core] Workaround for lenovo (motorola) app clone (#1458)
Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
0e192b00a3
commit
86a20f7eef
|
|
@ -39,6 +39,7 @@ import android.content.pm.VersionedPackage;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Parcel;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
|
@ -132,7 +133,8 @@ public class PackageService {
|
||||||
IPackageManager pm = getPackageManager();
|
IPackageManager pm = getPackageManager();
|
||||||
if (pm == null) return ParceledListSlice.emptyList();
|
if (pm == null) return ParceledListSlice.emptyList();
|
||||||
for (var user : UserService.getUsers()) {
|
for (var user : UserService.getUsers()) {
|
||||||
res.addAll(pm.getInstalledPackages(flags, user.id).getList());
|
// in case duplicate pkginfo in one user
|
||||||
|
res.addAll(pm.getInstalledPackages(flags, user.id).getList().parallelStream().distinct().collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
if (filterNoProcess) {
|
if (filterNoProcess) {
|
||||||
return new ParceledListSlice<>(res.parallelStream().filter(packageInfo -> {
|
return new ParceledListSlice<>(res.parallelStream().filter(packageInfo -> {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -72,6 +74,19 @@ public class UserService {
|
||||||
users = um.getUsers(true, true, true);
|
users = um.getUsers(true, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Utils.isLENOVO) { // lenovo hides user [900, 910) for app cloning
|
||||||
|
var gotUsers = new boolean[10];
|
||||||
|
for (var user : users) {
|
||||||
|
var residual = user.id - 900;
|
||||||
|
if (residual >= 0 && residual < 10) gotUsers[residual] = true;
|
||||||
|
}
|
||||||
|
for (int i = 900; i <= 909; i++) {
|
||||||
|
var user = um.getUserInfo(i);
|
||||||
|
if (user != null && !gotUsers[i - 900]) {
|
||||||
|
users.add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public class Utils {
|
||||||
|
|
||||||
public static final String LOG_TAG = "LSPosed";
|
public static final String LOG_TAG = "LSPosed";
|
||||||
public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
|
public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
|
||||||
|
public static final boolean isLENOVO = !TextUtils.isEmpty(SystemProperties.get("ro.lenovo.region"));
|
||||||
|
|
||||||
public static void logD(Object msg) {
|
public static void logD(Object msg) {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public interface IUserManager extends IInterface {
|
||||||
List<UserInfo> getUsers(boolean excludePartial, boolean excludeDying, boolean excludePreCreated)
|
List<UserInfo> getUsers(boolean excludePartial, boolean excludeDying, boolean excludePreCreated)
|
||||||
throws RemoteException;
|
throws RemoteException;
|
||||||
|
|
||||||
|
UserInfo getUserInfo(int userHandle);
|
||||||
|
|
||||||
UserInfo getProfileParent(int userId) throws RemoteException;
|
UserInfo getProfileParent(int userId) throws RemoteException;
|
||||||
|
|
||||||
boolean isUserUnlockingOrUnlocked(int userId) throws RemoteException;
|
boolean isUserUnlockingOrUnlocked(int userId) throws RemoteException;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue