From ab72e3a3d2adceacdf10c035e3abc46a658776b7 Mon Sep 17 00:00:00 2001 From: Ian Field Date: Thu, 26 Jan 2017 21:09:16 +0000 Subject: [PATCH] Add built-in crypto algorithm list --- app/build.gradle | 32 +++++++++---------- .../uk/co/ianfield/devstat/MainActivity.java | 11 +++++-- .../uk/co/ianfield/devstat/StatHelper.java | 23 +++++++++++++ app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8ea2c03..51a5d73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,8 +3,8 @@ apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'me.tatarka.retrolambda' android { - compileSdkVersion 24 - buildToolsVersion '24.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -13,10 +13,10 @@ android { defaultConfig { minSdkVersion 9 - targetSdkVersion 24 + targetSdkVersion 25 applicationId 'uk.co.ianfield.devstat' - versionCode 14 - versionName '2.2.1' + versionCode 15 + versionName '2.3.0' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } signingConfigs { @@ -41,13 +41,13 @@ android { } dependencies { - compile 'com.android.support:support-v4:24.2.1' - compile 'com.android.support:appcompat-v7:24.2.1' - compile 'com.android.support:recyclerview-v7:24.2.1' - compile 'com.android.support:design:24.2.1' + compile 'com.android.support:support-v4:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:recyclerview-v7:25.1.0' + compile 'com.android.support:design:25.1.0' - compile 'com.jakewharton:butterknife:8.2.1' - apt 'com.jakewharton:butterknife-compiler:8.2.1' + compile 'com.jakewharton:butterknife:8.5.1' + apt 'com.jakewharton:butterknife-compiler:8.5.1' provided 'javax.annotation:jsr250-api:1.0' compile 'com.google.dagger:dagger:2.0.2' @@ -60,11 +60,11 @@ dependencies { androidTestCompile 'junit:junit:4.12' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' - androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1' - androidTestCompile 'com.android.support:support-annotations:24.2.1' - androidTestCompile 'com.android.support.test:runner:0.4.1' - androidTestCompile 'com.android.support.test:rules:0.4.1' + androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' + androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' + androidTestCompile 'com.android.support:support-annotations:25.1.0' + androidTestCompile 'com.android.support.test:runner:0.5' + androidTestCompile 'com.android.support.test:rules:0.5' // Set this dependency if you want to use Hamcrest matching androidTestCompile 'org.hamcrest:hamcrest-library:1.3' } diff --git a/app/src/main/java/uk/co/ianfield/devstat/MainActivity.java b/app/src/main/java/uk/co/ianfield/devstat/MainActivity.java index 5a6c8ca..c7c5caf 100644 --- a/app/src/main/java/uk/co/ianfield/devstat/MainActivity.java +++ b/app/src/main/java/uk/co/ianfield/devstat/MainActivity.java @@ -34,6 +34,7 @@ public class MainActivity extends AppCompatActivity { private ArrayList screenStats; private ArrayList softwareStats; private ArrayList featureStats; + private ArrayList cryptoStats; @Override protected void onCreate(Bundle savedInstanceState) { @@ -82,12 +83,18 @@ protected void onCreate(Bundle savedInstanceState) { // Features (some will dupe for now) featureStats = helper.getFeatureList(); + cryptoStats = helper.getCryptoList(); + // This could probably be done better ArrayList> statGroups = new ArrayList<>(); - statGroups.addAll(Arrays.asList(screenStats, softwareStats, hardwareStats, featureStats)); + statGroups.addAll( + Arrays.asList(screenStats, softwareStats, hardwareStats, featureStats, cryptoStats) + ); viewPager.setAdapter(new InformationPagerAdapter(getSupportFragmentManager(), this, - new int[]{R.string.title_screen_metrics, R.string.title_software, R.string.title_hardware, R.string.title_features}, + new int[]{R.string.title_screen_metrics, R.string.title_software, R.string.title_hardware, + R.string.title_features, R.string.title_crypto + }, statGroups)); tabLayout.setupWithViewPager(viewPager); diff --git a/app/src/main/java/uk/co/ianfield/devstat/StatHelper.java b/app/src/main/java/uk/co/ianfield/devstat/StatHelper.java index 96fd06e..0845b45 100644 --- a/app/src/main/java/uk/co/ianfield/devstat/StatHelper.java +++ b/app/src/main/java/uk/co/ianfield/devstat/StatHelper.java @@ -15,10 +15,13 @@ import android.util.DisplayMetrics; import android.util.Log; +import java.security.Provider; +import java.security.Security; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; +import java.util.Set; import uk.co.ianfield.devstat.model.StatItem; @@ -283,6 +286,26 @@ private boolean isTelephonyEnabled() { return (tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY); } + ArrayList getCryptoList() { + ArrayList cryptoList = new ArrayList<>(); + + for (Provider provider : Security.getProviders()) { + StatItem item = new StatItem(); + item.setTitle(provider.getName()); + String info = ""; + + Set services = provider.getServices(); + for (Provider.Service service : services) { + info += service.getAlgorithm() + "\n"; + } + info = info.substring(0, info.length() - 2); + item.setInfo(info); + cryptoList.add(item); + } + + return cryptoList; + } + public enum Hardware { MANUFACTURER, MODEL, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3732853..d79e900 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,5 +62,6 @@ Online Processors Copied to clipboard! + Crypto diff --git a/build.gradle b/build.gradle index 25c8ede..ab7f36a 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.3' + classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath 'me.tatarka:gradle-retrolambda:3.3.0'