-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use gradle 3.2.1 * Use gradle 4.10.2 * Cleanup - this is not needed * Cleanup * Cleanup * Leverage SystemClock * Cleanup * Separate the Application specific code * Extract library * Do not bleed out BouncyCastle into library API Also change the logging as we do not have the byte[]->hex method from spongycastle anymore
- Loading branch information
Showing
44 changed files
with
241 additions
and
199 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/im/status/hardwallet_lite_android/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
app/src/main/java/im/status/hardwallet_lite_android/app/MainActivity.java
This file was deleted.
Oops, something went wrong.
101 changes: 0 additions & 101 deletions
101
app/src/main/java/im/status/hardwallet_lite_android/io/CardManager.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
app/src/test/java/im/status/hardwallet_lite_android/ExampleUnitTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 1 addition & 4 deletions
5
app/src/main/AndroidManifest.xml → demo/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
demo/src/main/java/im/status/hardwallet_lite_android/app/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package im.status.hardwallet_lite_android.app; | ||
|
||
import android.nfc.NfcAdapter; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import im.status.hardwallet_lite_android.demo.R; | ||
import im.status.hardwallet_lite_android.io.APDUResponse; | ||
import im.status.hardwallet_lite_android.io.CardChannel; | ||
import im.status.hardwallet_lite_android.io.CardManager; | ||
import im.status.hardwallet_lite_android.io.OnCardConnectedListener; | ||
import im.status.hardwallet_lite_android.wallet.WalletAppletCommandSet; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = "MainActivity"; | ||
|
||
private NfcAdapter nfcAdapter; | ||
private CardManager cardManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
nfcAdapter = NfcAdapter.getDefaultAdapter(this); | ||
cardManager = new CardManager(); | ||
|
||
cardManager.setOnCardConnectedListener(new OnCardConnectedListener() { | ||
@Override | ||
public void onConnected(CardChannel cardChannel) { | ||
try { | ||
|
||
Log.i(TAG, "onCardConnected()"); | ||
|
||
// Applet-specific code | ||
WalletAppletCommandSet cmdSet = new WalletAppletCommandSet(cardChannel); | ||
|
||
// First thing to do is selecting the applet on the card. | ||
cmdSet.select().checkOK(); | ||
|
||
Log.i(TAG, "Applet is installed on the connected card."); | ||
|
||
// In real projects, the pairing key should be saved and used for all new sessions. | ||
cmdSet.autoPair("WalletAppletTest"); | ||
|
||
Log.i(TAG, "Pairing with card is done."); | ||
|
||
// Opening a Secure Channel is needed for all other applet commands | ||
cmdSet.autoOpenSecureChannel(); | ||
|
||
Log.i(TAG, "Secure channel opened."); | ||
|
||
// We send a GET STATUS command, which does not require PIN authentication | ||
APDUResponse resp = cmdSet.getStatus(WalletAppletCommandSet.GET_STATUS_P1_APPLICATION).checkOK(); | ||
|
||
Log.i(TAG, "Got status (response length=" + resp.getData().length + ")." ); | ||
|
||
// PIN authentication allows execution of privileged commands | ||
cmdSet.verifyPIN("000000").checkOK(); | ||
|
||
Log.i(TAG, "Pin Verified."); | ||
|
||
// Cleanup, in a real application you would not unpair and instead keep the pairing key for successive interactions. | ||
// We also remove all other pairings so that we do not fill all slots with failing runs. Again in real application | ||
// this would be a very bad idea to do. | ||
cmdSet.unpairOthers(); | ||
cmdSet.autoUnpair(); | ||
|
||
Log.i(TAG, "Unpaired."); | ||
|
||
} catch (Exception e) { | ||
Log.e(TAG, e.getMessage()); | ||
} | ||
|
||
} | ||
}); | ||
cardManager.start(); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
if (nfcAdapter != null) { | ||
nfcAdapter.enableReaderMode(this, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
if (nfcAdapter != null) { | ||
nfcAdapter.disableReaderMode(this); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#Tue Oct 23 10:14:17 CEST 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
task androidSourcesJar(type: Jar) { | ||
from android.sourceSets.main.java.source | ||
classifier = 'sources' | ||
} | ||
|
||
artifacts { | ||
archives androidSourcesJar | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation 'com.madgag.spongycastle:core:1.58.0.0' | ||
implementation 'com.madgag.spongycastle:prov:1.58.0.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Oops, something went wrong.