Skip to content

Commit

Permalink
feat: allow usage of non-MIUI package installers
Browse files Browse the repository at this point in the history
  • Loading branch information
updateing committed Jan 16, 2023
1 parent 35450bb commit 9fe83db
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void handleLoadPackage(final LoadPackageParam lpparam) {
if (mPrefs.getBoolean("controls_fingerprintscreen")) Controls.FingerprintScreenOnHook(lpparam);
if (mPrefs.getBoolean("controls_fingerprintwake")) Controls.NoFingerprintWakeHook(lpparam);
if (mPrefs.getBoolean("various_disableapp")) Various.AppsDisableServiceHook(lpparam);
if (mPrefs.getBoolean("various_anyinstaller")) Various.AnyPackageInstallerHook(lpparam);
if (mPrefs.getStringAsInt("system_allrotations2", 1) > 1) System.AllRotationsHook(lpparam);
if (mPrefs.getStringAsInt("system_nolightuponcharges", 1) > 1) System.NoLightUpOnChargeHook(lpparam);
if (mPrefs.getStringAsInt("system_autogroupnotif", 1) > 1) System.AutoGroupNotificationsHook(lpparam);
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/name/mikanoshi/customiuizer/mods/Various.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.ContentObserver;
Expand Down Expand Up @@ -1038,6 +1039,15 @@ protected void before(MethodHookParam param) throws Throwable {
});
}

public static void AnyPackageInstallerHook(LoadPackageParam lpparam) {
Helpers.findAndHookMethod("com.android.server.pm.PackageManagerServiceImpl", lpparam.classLoader, "hookChooseBestActivity", Intent.class, String.class, long.class, List.class, int.class, ResolveInfo.class, new MethodHook() {
@Override
protected void before(final MethodHookParam param) throws Throwable {
param.setResult(param.args[5]);
}
});
}

public static void GboardPaddingHook() {
Helpers.findAndHookMethod(findClass("android.os.SystemProperties", null), "get", String.class, new MethodHook() {
@Override
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1137,4 +1137,6 @@
<string name="system_cc_enable_style_switch_title">开启控制中心样式切换</string>
<string name="system_cc_disable_bluetooth_restrict_title">禁用蓝牙临时关闭态</string>
<string name="system_cc_collapse_after_clicked_title">单击开关后自动收起</string>
<string name="various_anyinstaller_title">允许使用非MIUI的软件包安装器</string>
<string name="various_anyinstaller_sum">去除软件包安装intent中的安装器包名过滤条件。</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,4 +1177,6 @@
<string name="system_cc_enable_style_switch_title">Enable CC style switch</string>
<string name="system_cc_disable_bluetooth_restrict_title">Disable disconnect bluetooth until tomorrow</string>
<string name="system_cc_collapse_after_clicked_title">Collapse after touch</string>
<string name="various_anyinstaller_title">Allow non-MIUI package installers</string>
<string name="various_anyinstaller_sum">Remove the filter about package installer name on such intents.</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/prefs_various.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
android:summary="@string/various_installappinfo_summ"
android:defaultValue="false" />

<name.mikanoshi.customiuizer.prefs.CheckBoxPreferenceEx
android:key="pref_key_various_anyinstaller"
android:title="@string/various_anyinstaller_title"
android:summary="@string/various_anyinstaller_sum"
android:defaultValue="false" />

<name.mikanoshi.customiuizer.prefs.CheckBoxPreferenceEx
android:key="pref_key_various_disable_access_devicelogs"
android:title="@string/various_disable_access_devicelogs_title"
Expand Down

0 comments on commit 9fe83db

Please sign in to comment.