ACardEmulator: Added F-Droid build flavor with FOSS only

- avoid precompiled JARs for JCardSim
- use gradle's shadow plugin to relocate JCardSim's use of Bouncycastle
- removes JCardSim's Hello world applet
- use vJCRE to avoid importing Oracle's api_classic.jar

(We may use vJCRE as full replacement for JCardSim in the future, but
JCardSim is currently the choice with more features and support)
This commit is contained in:
Frank Morgner
2019-09-27 15:29:57 +02:00
parent e6a42efb6b
commit 1caff4f497
15 changed files with 160 additions and 77 deletions

5
.gitmodules vendored
View File

@@ -9,7 +9,7 @@
url = https://github.com/philipWendland/IsoApplet.git
[submodule "ACardEmulator/app/src/main/external/jcardsim"]
path = ACardEmulator/app/src/main/external/jcardsim
url = https://github.com/frankmorgner/jcardsim.git
url = https://github.com/licel/jcardsim
[submodule "ACardEmulator/app/src/main/external/MuscleApplet"]
path = ACardEmulator/app/src/main/external/MuscleApplet
url = https://github.com/martinpaljak/MuscleApplet.git
@@ -25,3 +25,6 @@
[submodule "ACardEmulator/app/src/main/external/PivApplet"]
path = ACardEmulator/app/src/main/external/PivApplet
url = https://github.com/frankmorgner/PivApplet
[submodule "ACardEmulator/app/src/main/external/vJCRE"]
path = ACardEmulator/app/src/main/external/vJCRE
url = https://github.com/martinpaljak/vJCRE

View File

@@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -8,38 +8,73 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SELECTED_BUILD_VARIANT" value="fullDebug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleFullDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileFullDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
<task>generateFullDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/full/debug;file://$MODULE_DIR$/build/generated/res/resValues/full/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output url="file://$MODULE_DIR$/build/intermediates/classes/full/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/full/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/full/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/full/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@@ -59,6 +94,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/vJCRE/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/jcardsim/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/GidsApplet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/IsoApplet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/PivApplet/src" isTestSource="false" />
@@ -85,7 +122,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
@@ -105,6 +141,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
@@ -119,9 +156,8 @@
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/sdk-v1.0.0.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-annotations:23.2.1@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:appcompat-v7:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.madgag.spongycastle:core:1.51.0.0@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-v4:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.journeyapps:zxing-android-embedded:3.2.0@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/jcardsim-3.0.4-SNAPSHOT-android.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.bouncycastle:bcprov-jdk14:1.49@jar" level="project" />
</component>
</module>

View File

@@ -1,4 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'com.github.johnrengelman.shadow'
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
task shadowJar(type: ShadowJar) {
configurations = [project.configurations.shadow]
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn shadowJar
}
android {
compileSdkVersion 23
@@ -16,25 +25,43 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "distribution"
productFlavors {
full {
dimension "distribution"
}
fdroid {
dimension "distribution"
applicationIdSuffix ".fdroid"
}
}
sourceSets {
main.java.srcDirs += 'src/main/external/vJCRE/src'
main.java.exclude('pro/javacard/vre/VJCREProvider*')
main.java.exclude('visa/*')
main.java.srcDirs += 'src/main/external/jcardsim/src/main/java'
main.java.exclude('**/APDUScriptTool.java')
main.java.exclude('**/JavaxSmartCardInterface.java')
main.java.exclude('**/CardTerminalSimulator.java')
main.java.exclude('**/JCSCard*.java')
main.java.exclude('**/JCSTerminal.java')
main.java.exclude('**/JCSFactory.java')
main.java.exclude('**/CardSimulator.java')
main.java.exclude('**/CAD.java')
main.java.exclude('**/CardTerminalSimulator.java')
main.java.exclude('com/licel/jcardsim/smartcardio/*')
main.java.exclude('com/licel/jcardsim/remote/*')
main.java.exclude('com/licel/jcardsim/utils/APDUScriptTool*')
main.java.exclude('com/licel/jcardsim/io/JavaxSmartCardInterface*')
main.java.exclude('com/licel/jcardsim/io/CAD*')
main.java.exclude('javacard/framework/service/CardRemoteObject*')
main.java.exclude('javacard/framework/service/RMIService*')
main.java.exclude('com/licel/jcardsim/utils/JavaCardApiProcessor*')
main.java.exclude('com/licel/jcardsim/framework/service/*')
main.java.exclude('com/licel/jcardsim/samples/*')
main.java.exclude('com/licel/jcardsim/crypto/*')
main.java.srcDirs += 'src/main/external/GidsApplet/src'
main.java.exclude('**/gidsAppletTests/*.java')
main.java.exclude('com/mysmartlogon/gidsAppletTests/*')
main.java.srcDirs += 'src/main/external/IsoApplet/src'
main.java.srcDirs += 'src/main/external/PivApplet/src'
main.java.srcDirs += 'src/main/external/android-scio/src/main'
main.java.srcDirs += 'src/main/external/ykneo-openpgp/applet/src'
main.java.srcDirs += 'src/main/external/ykneo-oath/applet/src'
}
shadowJar {
relocate 'org.bouncycastle', 'com.vsmartcard.acardemulator.org.bouncycastle'
}
}
android.applicationVariants.all { variant ->
@@ -59,12 +86,15 @@ android.applicationVariants.all { variant ->
}
dependencies {
shadow localGroovy()
shadow gradleApi()
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
compile 'com.google.zxing:core:3.2.1'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile files('libs/sdk-v1.0.0.jar')
compile 'org.bouncycastle:bcprov-jdk14:1.49'
fullCompile files('libs/sdk-v1.0.0.jar')
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2019 Frank Morgner
*
* This file is part of RemoteSmartCardReader.
*
* RemoteSmartCardReader is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* RemoteSmartCardReader is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* RemoteSmartCardReader. If not, see <http://www.gnu.org/licenses/>.
*/
package com.vsmartcard.acardemulator;
import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;
public class SmartcardProviderService extends IntentService {
public SmartcardProviderService () {
super("SmartcardProviderService");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
}
}

View File

@@ -175,4 +175,4 @@ public class MainActivity extends AppCompatActivity {
dialog.dismiss();
super.onPause();
}
}
}

View File

@@ -214,18 +214,22 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
});
Preference gear_nfc = findPreference("gear_nfc");
gear_nfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
String gearPackage = "com.samsung.android.gearoplugin";
try {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("market://details?id="+gearPackage)));
} catch (android.content.ActivityNotFoundException e) {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+gearPackage)));
final Preference gear_nfc = findPreference("gear_nfc");
if (BuildConfig.FLAVOR.equals("fdroid")) {
gear_nfc.setSummary("Samsung Gear integration is disabled in F-Droid");
} else {
gear_nfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
String gearPackage = "com.samsung.android.gearoplugin";
try {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("market://details?id="+gearPackage)));
} catch (android.content.ActivityNotFoundException e) {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+gearPackage)));
}
return true;
}
return true;
}
});
});
}
}
@Override
@@ -288,4 +292,4 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
// onResume gets called after this to handle the intent
setIntent(intent);
}
}
}

View File

@@ -6,7 +6,6 @@ import android.support.v4.content.LocalBroadcastManager;
import com.licel.jcardsim.base.Simulator;
import com.licel.jcardsim.base.SimulatorRuntime;
import com.licel.jcardsim.samples.HelloWorldApplet;
import com.licel.jcardsim.utils.AIDUtil;
import com.mysmartlogon.gidsApplet.GidsApplet;
import com.vsmartcard.acardemulator.R;
@@ -33,18 +32,6 @@ public class JCEmulator implements Emulator {
String aid, name, extra_install = "", extra_error = "";
simulator = new Simulator(new SimulatorRuntime());
if (activate_helloworld) {
name = context.getResources().getString(R.string.applet_helloworld);
aid = context.getResources().getString(R.string.aid_helloworld);
try {
simulator.installApplet(AIDUtil.create(aid), HelloWorldApplet.class);
extra_install += "\n" + name + " (AID: " + aid + ")";
} catch (Exception e) {
e.printStackTrace();
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
}
}
if (activate_openpgp) {
name = context.getResources().getString(R.string.applet_openpgp);
aid = context.getResources().getString(R.string.aid_openpgp);

View File

@@ -26,8 +26,6 @@
<string name="aid_pivapplet_truncated3">A00000030800</string>
<string name="aid_pivapplet_truncated4">A000000308</string>
<string name="applet_pivapplet">Alex Wilson\'s PIV Applet</string>
<string name="aid_helloworld">F000000001</string>
<string name="applet_helloworld">jCardSim Team\'s Hello World Applet</string>
<string name="aid_partial_openpgp">D27600012401</string>
<string name="aid_openpgp">D2760001240102000000000000010000</string>
<string name="applet_openpgp">Yubico\'s OpenPGP Applet</string>
@@ -36,7 +34,6 @@
<string name="startup_title">Tap To Emulate!</string>
<string name="startup_message">The following smart card applets are supported:\n
\n
<b>Hello World Applet</b> <small>(AID F000000001)</small>\n
<b>OpenPGP Applet</b> <small>(AID D2760001240102000000000000010000)</small>\n
<b>OATH Applet</b> <small>(AID A000000527210101)</small>\n
<b>PIV Applet</b> <small>(AID A00000030800001000)</small>\n

View File

@@ -4,10 +4,6 @@
android:description="@string/app_name"
android:requireDeviceUnlock="false">
<aid-group android:description="@string/applet_helloworld" android:category="other">
<aid-filter android:name="@string/aid_helloworld"/>
</aid-group>
<aid-group android:description="@string/applet_openpgp" android:category="other">
<aid-filter android:name="@string/aid_openpgp"/>
<aid-filter android:name="@string/aid_partial_openpgp"/>

View File

@@ -13,12 +13,6 @@
android:key="jc_settings"
>
<SwitchPreference
android:title="@string/applet_helloworld"
android:switchTextOn="@string/aid_helloworld"
android:key="activate_helloworld"
android:defaultValue="false"
/>
<SwitchPreference
android:title="@string/applet_openpgp"
android:switchTextOn="@string/aid_openpgp"
@@ -100,7 +94,7 @@
<Preference
android:title="Emulation with Gear's NFC"
android:summary="Samsung Gear needs to be installed for using the Gear's NFC emulation capabilities."
android:summary="Samsung Gear needs to be installed for using the Gear's NFC emulation capabilities. (Disabled on F-Droid)"
android:key="gear_nfc">
</Preference>

View File

@@ -6,6 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files