From bd4babf8f82ad8079a1a87c5099d27d9ec00d4f8 Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Tue, 14 Nov 2023 11:16:19 +0600 Subject: [PATCH] [Installer] Allow installing system apps with a different signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The “Install only” button is enabled for system apps when the signatures are different. This is useful for only those who have disabled signature verification using methods such as CorePatch. Signed-off-by: Muntashir Al-Islam --- .../apk/installer/InstallerDialogHelper.java | 5 +++-- .../installer/PackageInstallerActivity.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/InstallerDialogHelper.java b/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/InstallerDialogHelper.java index ef86e9c1b84..7797732eb81 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/InstallerDialogHelper.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/InstallerDialogHelper.java @@ -189,12 +189,13 @@ public void showDowngradeReinstallWarning(CharSequence msg, public void showSignatureMismatchReinstallWarning(CharSequence msg, @NonNull OnClickButtonsListener onClickButtonsListener, - @NonNull View.OnClickListener installOnlyButtonListener) { + @NonNull View.OnClickListener installOnlyButtonListener, + boolean isSystem) { // Buttons mNeutralBtn.setVisibility(View.VISIBLE); mNeutralBtn.setText(R.string.only_install); mNeutralBtn.setOnClickListener(installOnlyButtonListener); - mPositiveBtn.setVisibility(View.VISIBLE); + mPositiveBtn.setVisibility(isSystem ? View.GONE : View.VISIBLE); mPositiveBtn.setText(R.string.yes); mPositiveBtn.setOnClickListener(v -> onClickButtonsListener.triggerInstall()); mNegativeBtn.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerActivity.java b/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerActivity.java index 3bc497c46f9..bdc26b07b45 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerActivity.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerActivity.java @@ -444,21 +444,21 @@ public void triggerCancel() { } // Signature is different ApplicationInfo info = mModel.getInstalledPackageInfo().applicationInfo; // Installed package info is never null here. - if (ApplicationInfoCompat.isSystemApp(info)) { + boolean isSystem = ApplicationInfoCompat.isSystemApp(info); + SpannableStringBuilder builder = new SpannableStringBuilder(); + if (isSystem) { // Cannot reinstall a system app with a different signature - showInstallationFinishedDialog(mModel.getPackageName(), - getString(R.string.app_signing_signature_mismatch_for_system_apps), null, false); - return; + builder.append(getString(R.string.app_signing_signature_mismatch_for_system_apps)); + } else { + // Offer user to uninstall and then install the app again + builder.append(getString(R.string.do_you_want_to_uninstall_and_install)).append(" ") + .append(UIUtils.getItalicString(getString(R.string.app_data_will_be_lost))); } - // Offer user to uninstall and then install the app again - SpannableStringBuilder builder = new SpannableStringBuilder() - .append(getString(R.string.do_you_want_to_uninstall_and_install)).append(" ") - .append(UIUtils.getItalicString(getString(R.string.app_data_will_be_lost))) - .append("\n\n"); + builder.append("\n\n"); int start = builder.length(); builder.append(getText(R.string.app_signing_install_without_data_loss)); builder.setSpan(new RelativeSizeSpan(0.8f), start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - mDialogHelper.showSignatureMismatchReinstallWarning(builder, reinstallListener, v -> install()); + mDialogHelper.showSignatureMismatchReinstallWarning(builder, reinstallListener, v -> install(), isSystem); } @Override