mirror of
https://github.com/LittleChest/AppCloneEnabler.git
synced 2026-05-07 06:54:48 +08:00
Compare commits
No commits in common. "main" and "v1.0" have entirely different histories.
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,7 +1,12 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|||||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
Double Tap To Wake
|
||||||
6
.idea/AndroidProjectSystem.xml
generated
Normal file
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/deploymentTargetSelector.xml
generated
Normal file
10
.idea/deploymentTargetSelector.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetSelector">
|
||||||
|
<selectionStates>
|
||||||
|
<SelectionState runConfigName="app">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
</SelectionState>
|
||||||
|
</selectionStates>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
19
.idea/gradle.xml
generated
Normal file
19
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/migrations.xml
generated
Normal file
10
.idea/migrations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/misc.xml
generated
Normal file
9
.idea/misc.xml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/runConfigurations.xml
generated
Normal file
17
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -8,10 +8,10 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "top.littlew.acer"
|
applicationId = "top.littlew.acer"
|
||||||
minSdk = 34
|
minSdk = 33
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 3
|
versionCode = 1
|
||||||
versionName = "1.2"
|
versionName = "1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xposeddescription"
|
android:name="xposeddescription"
|
||||||
android:value="Enable App Clone for all or custom user apps." />
|
android:value="Enable App Clone for all user apps." />
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xposedminversion"
|
android:name="xposedminversion"
|
||||||
android:value="93" />
|
android:value="93" />
|
||||||
|
|||||||
@ -2,20 +2,14 @@ package top.littlew.acer;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||||
import de.robv.android.xposed.XC_MethodHook;
|
import de.robv.android.xposed.XC_MethodHook;
|
||||||
@ -25,134 +19,169 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
|||||||
public class XposedInit implements IXposedHookLoadPackage {
|
public class XposedInit implements IXposedHookLoadPackage {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static Context mContext;
|
private static Context mContext;
|
||||||
private static List<String> cachedCloneableApps;
|
|
||||||
|
private static final int AVAILABLE = 0;
|
||||||
|
private static final int CLONED_APPS_SUMMARY_STRING_ID = 0x7f140736;
|
||||||
|
|
||||||
|
private static Class<?> UtilsClass;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
|
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
|
||||||
|
if (!lpparam.packageName.equals("com.android.settings")) {
|
||||||
if (lpparam.packageName.equals("com.android.settings")) {
|
return;
|
||||||
XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.settings.SettingsActivity", lpparam.classLoader), "onCreate", Bundle.class, new XC_MethodHook() {
|
|
||||||
@Override
|
|
||||||
protected void afterHookedMethod(MethodHookParam param) {
|
|
||||||
mContext = (Context) param.thisObject;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Class<?> clonedAppsPreferenceControllerClass = XposedHelpers.findClass("com.android.settings.applications.ClonedAppsPreferenceController", lpparam.classLoader);
|
|
||||||
|
|
||||||
XposedHelpers.findAndHookMethod(clonedAppsPreferenceControllerClass, "getAvailabilityStatus", new XC_MethodHook() {
|
|
||||||
@Override
|
|
||||||
protected void beforeHookedMethod(MethodHookParam param) {
|
|
||||||
param.setResult(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
XposedHelpers.findAndHookMethod(clonedAppsPreferenceControllerClass, "updateSummary", int.class, int.class, new XC_MethodHook() {
|
|
||||||
@SuppressLint({"QueryPermissionsNeeded", "DiscouragedApi"})
|
|
||||||
@Override
|
|
||||||
protected void beforeHookedMethod(MethodHookParam param) {
|
|
||||||
if (mContext == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PackageManager pm = mContext.getPackageManager();
|
|
||||||
|
|
||||||
List<String> cloneableApps = getCloneableApps();
|
|
||||||
|
|
||||||
List<PackageInfo> primaryInstalledPackagesAsUser = (List<PackageInfo>) XposedHelpers.callMethod(pm, "getInstalledPackagesAsUser", 0, XposedHelpers.callStaticMethod(UserHandle.class, "myUserId"));
|
|
||||||
|
|
||||||
List<String> primaryUserApps = primaryInstalledPackagesAsUser.stream().map(x -> x.packageName).toList();
|
|
||||||
|
|
||||||
int availableAppsCount = (int) cloneableApps.stream().filter(primaryUserApps::contains).count();
|
|
||||||
|
|
||||||
int clonedUserId = (int) XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.android.settings.Utils", lpparam.classLoader), "getCloneUserId", mContext);
|
|
||||||
int clonedAppsCount = 0;
|
|
||||||
|
|
||||||
if (!(clonedUserId == -1)) {
|
|
||||||
List<PackageInfo> cloneProfileInstalledPackagesAsUser = (List<PackageInfo>) XposedHelpers.callMethod(pm, "getInstalledPackagesAsUser", 0, clonedUserId);
|
|
||||||
|
|
||||||
List<String> cloneProfileApps = cloneProfileInstalledPackagesAsUser.stream().map(x -> x.packageName).toList();
|
|
||||||
|
|
||||||
clonedAppsCount = (int) cloneableApps.stream().filter(cloneProfileApps::contains).count();
|
|
||||||
}
|
|
||||||
|
|
||||||
Object mPreference = XposedHelpers.getObjectField(param.thisObject, "mPreference");
|
|
||||||
if (mPreference != null) {
|
|
||||||
XposedHelpers.callMethod(mPreference, "setSummary", String.format(mContext.getResources().getString(mContext.getResources().getIdentifier("cloned_apps_summary", "string", mContext.getPackageName())), clonedAppsCount, availableAppsCount - clonedAppsCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
param.setResult(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.settings.applications.AppStateClonedAppsBridge", lpparam.classLoader), "updateExtraInfo", XposedHelpers.findClass("com.android.settingslib.applications.ApplicationsState$AppEntry", lpparam.classLoader), String.class, int.class, new XC_MethodHook() {
|
|
||||||
@Override
|
|
||||||
protected void beforeHookedMethod(MethodHookParam param) {
|
|
||||||
XposedHelpers.setObjectField(param.thisObject, "mAllowedApps", getCloneableApps());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.settings.applications.manageapplications.ManageApplications", lpparam.classLoader), "updateOptionsMenu", new XC_MethodHook() {
|
|
||||||
@SuppressLint("DiscouragedApi")
|
|
||||||
@Override
|
|
||||||
protected void afterHookedMethod(MethodHookParam param) {
|
|
||||||
if (XposedHelpers.getObjectField(param.thisObject, "mListType").equals(17) && (int) XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.android.settings.Utils", lpparam.classLoader), "getCloneUserId", mContext) > 0) {
|
|
||||||
Menu mOptionsMenu = (Menu) XposedHelpers.getObjectField(param.thisObject, "mOptionsMenu");
|
|
||||||
if (mOptionsMenu != null) {
|
|
||||||
mOptionsMenu.findItem(mContext.getResources().getIdentifier("delete_all_app_clones", "id", mContext.getPackageName())).setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.launcher3.allapps.ActivityAllAppsContainerView$AdapterHolder", lpparam.classLoader), "setup", View.class, Predicate.class, new XC_MethodHook() {
|
|
||||||
@Override
|
|
||||||
protected void beforeHookedMethod(MethodHookParam param) {
|
|
||||||
if ((int) XposedHelpers.getObjectField(param.thisObject, "mType") == 0) {
|
|
||||||
Object allAppsContainerView = XposedHelpers.getObjectField(param.thisObject, "this$0");
|
|
||||||
|
|
||||||
Predicate workProfileMatcher = (Predicate) XposedHelpers.callMethod(XposedHelpers.getObjectField(allAppsContainerView, "mWorkManager"), "getItemInfoMatcher");
|
|
||||||
Predicate privateProfileMatcher = (Predicate) XposedHelpers.callMethod(XposedHelpers.getObjectField(allAppsContainerView, "mPrivateProfileManager"), "getItemInfoMatcher");
|
|
||||||
|
|
||||||
Predicate WorkOrPrivate = workProfileMatcher.or(privateProfileMatcher);
|
|
||||||
|
|
||||||
Predicate filter = WorkOrPrivate.negate();
|
|
||||||
|
|
||||||
param.args[1] = filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UtilsClass = XposedHelpers.findClass("com.android.settings.Utils", lpparam.classLoader);
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(
|
||||||
|
XposedHelpers.findClass("com.android.settings.SettingsActivity", lpparam.classLoader),
|
||||||
|
"onCreate",
|
||||||
|
Bundle.class,
|
||||||
|
new XC_MethodHook() {
|
||||||
|
@Override
|
||||||
|
protected void afterHookedMethod(MethodHookParam param) {
|
||||||
|
mContext = (Context) param.thisObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(XposedHelpers.findClass("android.os.Flags", lpparam.classLoader), "allowPrivateProfile", new XC_MethodHook() {
|
||||||
|
@Override
|
||||||
|
protected void beforeHookedMethod(MethodHookParam param) {
|
||||||
|
param.setResult(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Class<?> clonedAppsPreferenceControllerClass = XposedHelpers.findClass("com.android.settings.applications.ClonedAppsPreferenceController", lpparam.classLoader);
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(
|
||||||
|
clonedAppsPreferenceControllerClass,
|
||||||
|
"getAvailabilityStatus",
|
||||||
|
new XC_MethodHook() {
|
||||||
|
@Override
|
||||||
|
protected void beforeHookedMethod(MethodHookParam param) {
|
||||||
|
param.setResult(AVAILABLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(
|
||||||
|
clonedAppsPreferenceControllerClass,
|
||||||
|
"updatePreferenceSummary",
|
||||||
|
new XC_MethodHook() {
|
||||||
|
@Override
|
||||||
|
protected void beforeHookedMethod(MethodHookParam param) {
|
||||||
|
// Allowing native logic to calculate Summary.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(
|
||||||
|
clonedAppsPreferenceControllerClass,
|
||||||
|
"updateSummary",
|
||||||
|
int.class,
|
||||||
|
int.class,
|
||||||
|
new XC_MethodHook() {
|
||||||
|
@SuppressLint("QueryPermissionsNeeded")
|
||||||
|
@Override
|
||||||
|
protected void beforeHookedMethod(MethodHookParam param) {
|
||||||
|
if (mContext == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
|
||||||
|
List<String> primaryUserNonSystemAppPackages = new ArrayList<>();
|
||||||
|
for (PackageInfo pkgInfo : pm.getInstalledPackages(PackageManager.GET_ACTIVITIES)) {
|
||||||
|
if ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 &&
|
||||||
|
!pkgInfo.packageName.equals(lpparam.packageName)) {
|
||||||
|
primaryUserNonSystemAppPackages.add(pkgInfo.packageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentlyClonedCount = 0;
|
||||||
|
int cloneUserId = getCloneUserIDInternal();
|
||||||
|
if (cloneUserId > 0) {
|
||||||
|
@SuppressLint("PackageManagerGetInstalledPackagesAsUser")
|
||||||
|
List<PackageInfo> cloneUserPackages = (List<PackageInfo>) XposedHelpers.callMethod(pm, "getInstalledPackagesAsUser", PackageManager.GET_ACTIVITIES, cloneUserId);
|
||||||
|
|
||||||
|
for (PackageInfo clonedPkgInfo : cloneUserPackages) {
|
||||||
|
if ((clonedPkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 &&
|
||||||
|
primaryUserNonSystemAppPackages.contains(clonedPkgInfo.packageName)) {
|
||||||
|
currentlyClonedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object mPreference = XposedHelpers.getObjectField(param.thisObject, "mPreference");
|
||||||
|
if (mPreference != null) {
|
||||||
|
String newSummary = String.format(mContext.getResources().getString(CLONED_APPS_SUMMARY_STRING_ID), currentlyClonedCount, primaryUserNonSystemAppPackages.size());
|
||||||
|
XposedHelpers.callMethod(mPreference, "setSummary", newSummary);
|
||||||
|
}
|
||||||
|
param.setResult(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(
|
||||||
|
XposedHelpers.findClass("com.android.settings.applications.AppStateClonedAppsBridge", lpparam.classLoader),
|
||||||
|
"updateExtraInfo",
|
||||||
|
XposedHelpers.findClass("com.android.settingslib.applications.ApplicationsState$AppEntry", lpparam.classLoader),
|
||||||
|
String.class,
|
||||||
|
int.class,
|
||||||
|
new XC_MethodHook() {
|
||||||
|
@Override
|
||||||
|
protected void afterHookedMethod(MethodHookParam param) {
|
||||||
|
Object appEntry = param.args[0];
|
||||||
|
String pkg = (String) param.args[1];
|
||||||
|
ApplicationInfo appInfo = (ApplicationInfo) XposedHelpers.getObjectField(appEntry, "info");
|
||||||
|
|
||||||
|
int appEntryUserId = (int) XposedHelpers.callStaticMethod(UserHandle.class, "getUserId", appInfo.uid);
|
||||||
|
int cloneUserId = getCloneUserIDInternal();
|
||||||
|
|
||||||
|
Boolean shouldDisplay;
|
||||||
|
|
||||||
|
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
|
shouldDisplay = Boolean.FALSE;
|
||||||
|
} else {
|
||||||
|
List<String> cloneProfileNonSystemAppPackages = getStrings(cloneUserId);
|
||||||
|
|
||||||
|
if (appEntryUserId == cloneUserId) {
|
||||||
|
shouldDisplay = Boolean.TRUE;
|
||||||
|
} else if (appEntryUserId == (int) XposedHelpers.callStaticMethod(UserHandle.class, "myUserId")) {
|
||||||
|
if (!cloneProfileNonSystemAppPackages.contains(pkg)) {
|
||||||
|
shouldDisplay = Boolean.TRUE;
|
||||||
|
} else {
|
||||||
|
shouldDisplay = Boolean.FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldDisplay = Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XposedHelpers.setObjectField(appEntry, "extraInfo", shouldDisplay);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("QueryPermissionsNeeded")
|
private static List<String> getStrings(int cloneUserId) {
|
||||||
private List<String> getCloneableApps() {
|
List<String> cloneProfileNonSystemAppPackages = new ArrayList<>();
|
||||||
if (mContext == null) {
|
if (cloneUserId > 0 && mContext != null) {
|
||||||
return new ArrayList<>();
|
@SuppressLint("PackageManagerGetInstalledPackagesAsUser")
|
||||||
}
|
List<PackageInfo> installedClonedPackages = (List<PackageInfo>) XposedHelpers.callMethod(mContext.getPackageManager(), "getInstalledPackagesAsUser", PackageManager.GET_ACTIVITIES, cloneUserId);
|
||||||
|
if (installedClonedPackages != null) {
|
||||||
if (cachedCloneableApps != null) {
|
for (PackageInfo pInfo : installedClonedPackages) {
|
||||||
return cachedCloneableApps;
|
if ((pInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||||
}
|
cloneProfileNonSystemAppPackages.add(pInfo.packageName);
|
||||||
|
}
|
||||||
@SuppressLint("DiscouragedApi") List<String> cloneableApps = new ArrayList<>(Arrays.asList(mContext.getResources().getStringArray(mContext.getResources().getIdentifier("cloneable_apps", "array", "android"))));
|
|
||||||
|
|
||||||
SharedPreferences sharedPrefs = mContext.getSharedPreferences("cloneable_apps", Context.MODE_PRIVATE);
|
|
||||||
List<String> newCloneableApps = new ArrayList<>(sharedPrefs.getStringSet("cloneable_apps", new HashSet<>()));
|
|
||||||
|
|
||||||
cloneableApps.addAll(newCloneableApps);
|
|
||||||
|
|
||||||
if (cloneableApps.isEmpty()) {
|
|
||||||
List<PackageInfo> primaryInstalledPackagesAsUser = (List<PackageInfo>) XposedHelpers.callMethod(mContext.getPackageManager(), "getInstalledPackagesAsUser", 0, XposedHelpers.callStaticMethod(UserHandle.class, "myUserId"));
|
|
||||||
|
|
||||||
for (PackageInfo pkgInfo : primaryInstalledPackagesAsUser) {
|
|
||||||
if ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
|
||||||
cloneableApps.add(pkgInfo.packageName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cloneProfileNonSystemAppPackages;
|
||||||
|
}
|
||||||
|
|
||||||
cachedCloneableApps = cloneableApps;
|
private int getCloneUserIDInternal() {
|
||||||
return cachedCloneableApps;
|
if (UtilsClass == null || mContext == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return (int) XposedHelpers.callStaticMethod(UtilsClass, "getCloneUserId", mContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string-array name="xposed_scope">
|
<string-array name="xposed_scope">
|
||||||
<item>com.android.settings</item>
|
<item>com.android.settings</item>
|
||||||
<item>com.android.launcher3</item>
|
|
||||||
<item>com.google.android.apps.nexuslauncher</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.12.1"
|
agp = "8.12.0"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user