Added security provider debug info

pull/205/head
M66B 3 years ago
parent 03664f152d
commit b3a5d8cf87

@ -29,7 +29,9 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.security.KeyChain;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -48,6 +50,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import androidx.cardview.widget.CardView;
import androidx.lifecycle.Lifecycle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
@ -59,6 +62,8 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.Provider;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@ -87,7 +92,10 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
private Button btnImportKey;
private Button btnManageKeys;
private Button btnCa;
private CardView cardDebug;
private TextView tvKeySize;
private TextView tvProviders;
private OpenPgpServiceConnection pgpService;
private List<String> openPgpProvider = new ArrayList<>();
@ -128,7 +136,10 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
btnImportKey = view.findViewById(R.id.btnImportKey);
btnManageKeys = view.findViewById(R.id.btnManageKeys);
btnCa = view.findViewById(R.id.btnCa);
cardDebug = view.findViewById(R.id.cardDebug);
tvKeySize = view.findViewById(R.id.tvKeySize);
tvProviders = view.findViewById(R.id.tvProviders);
try {
openPgpProvider.clear();
@ -370,6 +381,9 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
// Initialize
FragmentDialogTheme.setBackground(getContext(), view, false);
boolean debug = prefs.getBoolean("debug", false);
cardDebug.setVisibility(debug || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
try {
int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES");
tvKeySize.setText(getString(R.string.title_advanced_aes_key_size, maxKeySize));
@ -377,6 +391,24 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
tvKeySize.setText(Log.formatThrowable(ex));
}
try {
int dp24 = Helper.dp2pixels(getContext(), 24);
SpannableStringBuilder ssb = new SpannableStringBuilder();
for (Provider p : Security.getProviders()) {
ssb.append(p.toString()).append('\n');
//for (Enumeration e = p.keys(); e.hasMoreElements(); ) {
// int start = ssb.length();
// ssb.append(e.nextElement().toString()).append('\n');
// ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
// ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), start, ssb.length(), 0);
//}
}
tvProviders.setText(ssb);
} catch (Throwable ex) {
tvProviders.setText(Log.formatThrowable(ex));
}
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;

@ -99,6 +99,8 @@ import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.nio.charset.StandardCharsets;
import java.security.Provider;
import java.security.Security;
import java.security.cert.CertPathValidatorException;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
@ -1817,6 +1819,9 @@ public class Log {
sb.append(String.format("Configuration: %s\r\n", config.toString()));
sb.append("\r\n");
for (Provider p : Security.getProviders())
sb.append(p).append("\r\n");
sb.append("\r\n");
try {
PackageInfo pi = context.getPackageManager()

@ -391,16 +391,61 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<eu.faircode.email.FixedTextView
android:id="@+id/tvKeySize"
android:layout_width="0dp"
<androidx.cardview.widget.CardView
android:id="@+id/cardDebug"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="3dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_aes_key_size"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:tag="debug"
app:cardBackgroundColor="?attr/colorCardBackground"
app:cardCornerRadius="6dp"
app:cardElevation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardSmine" />
app:layout_constraintTop_toBottomOf="@id/cardSmine">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="6dp"
android:paddingVertical="12dp">
<eu.faircode.email.FixedTextView
android:id="@+id/tvCaptionDebug"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/title_advanced_caption_debug"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvKeySize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="3dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_aes_key_size"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaptionDebug" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvProviders"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="3dp"
android:layout_marginTop="12dp"
android:text="Providers"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvKeySize" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

Loading…
Cancel
Save