Apps cannot request to install certificates anymore on Android 11

Why need everything to be so hard?
This commit is contained in:
M66B 2020-07-06 11:59:51 +02:00
parent 19f1cb2587
commit 3ca25e0331
3 changed files with 10 additions and 2 deletions

View File

@ -52,6 +52,7 @@ import android.os.Handler;
import android.os.OperationCanceledException;
import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.provider.Settings;
import android.security.KeyChain;
import android.security.KeyChainException;
import android.text.Editable;
@ -1620,7 +1621,9 @@ public class FragmentCompose extends FragmentBase {
@Override
public void onNothingSelected() {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG);
final Intent intent = KeyChain.createInstallIntent();
final Intent intent = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R
? KeyChain.createInstallIntent()
: new Intent(Settings.ACTION_SECURITY_SETTINGS));
PackageManager pm = getContext().getPackageManager();
if (intent.resolveActivity(pm) != null) // package whitelisted
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {

View File

@ -54,6 +54,7 @@ import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintManager;
import android.provider.ContactsContract;
import android.provider.Settings;
import android.security.KeyChain;
import android.security.KeyChainException;
import android.text.SpannableString;
@ -5104,7 +5105,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override
public void onNothingSelected() {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG);
final Intent intent = KeyChain.createInstallIntent();
final Intent intent = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R
? KeyChain.createInstallIntent()
: new Intent(Settings.ACTION_SECURITY_SETTINGS));
PackageManager pm = getContext().getPackageManager();
if (intent.resolveActivity(pm) != null) // system whitelisted
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {

View File

@ -25,6 +25,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.security.KeyChain;
@ -212,6 +213,7 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
final Intent importKey = KeyChain.createInstallIntent();
btnImportKey.setEnabled(importKey.resolveActivity(pm) != null); // system whitelisted
btnImportKey.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? View.VISIBLE : View.GONE);
btnImportKey.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {