Skip to content

Commit

Permalink
[Installer] Allow installing system apps with a different signature
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MuntashirAkon committed Nov 14, 2023
1 parent 3fc7e6b commit bd4babf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bd4babf

Please sign in to comment.