Merge branch 'GearS2'

This commit is contained in:
Frank Morgner
2017-01-15 20:42:15 +01:00
33 changed files with 1633 additions and 99 deletions

10
.gitignore vendored
View File

@@ -84,3 +84,13 @@ local.properties
/virtualsmartcard/lib
/virtualsmartcard/win32/BixVReader/Release
/virtualsmartcard/win32/Release
ACardEmulator/build
build/
crash-info/
.sign/
.sdk_delta.info
.rds_delta
*.apk
keystore.properties

View File

@@ -32,12 +32,14 @@
<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/r/androidTest/debug" isTestSource="true" generated="true" />
<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$/src/debug/res" type="java-resource" />
@@ -87,12 +89,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<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/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.2.1/jars" />
@@ -101,39 +99,32 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.journeyapps/zxing-android-embedded/3.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.2.1" level="project" />
<orderEntry type="library" exported="" name="sdk-v1.0.0" level="project" />
<orderEntry type="library" exported="" name="design-23.2.1" level="project" />
<orderEntry type="library" exported="" name="jcardsim-3.0.4-SNAPSHOT-android" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="core-3.2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.2.1" level="project" />
<orderEntry type="library" exported="" name="accessory-v2.3.2" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="zxing-android-embedded-3.2.0" level="project" />
<orderEntry type="library" exported="" name="accessory-v2.3.2" level="project" />
<orderEntry type="library" exported="" name="jcardsim-3.0.4-SNAPSHOT-android" level="project" />
<orderEntry type="library" exported="" name="design-23.2.1" level="project" />
<orderEntry type="library" exported="" name="core-3.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.2.1" level="project" />
<orderEntry type="library" exported="" name="core-1.51.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.1" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.2.1" level="project" />
</component>
</module>

View File

@@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.vsmartcard.acardemulator"
minSdkVersion 19
@@ -49,12 +48,12 @@ android.applicationVariants.all { variant ->
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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 group: 'com.madgag.spongycastle', name: 'core', version: '1.51.0.0'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile files('libs/sdk-v1.0.0.jar')
}

Binary file not shown.

Binary file not shown.

View File

@@ -7,6 +7,13 @@
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@@ -37,7 +44,7 @@
</intent-filter>
</activity>
<service android:name=".EmulatorService"
<service android:name=".EmulatorHostApduService"
android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
@@ -47,6 +54,24 @@
<meta-data android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="@xml/aid_list"/>
</service>
<service android:name=".SmartcardProviderService" />
<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
</intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
</intent-filter>
</receiver>
<meta-data
android:name="AccessoryServicesLocation"
android:value="/res/xml/accessoryservices.xml" />
<meta-data
android:name="GearAppType"
android:value="tpk" />
</application>
</manifest>

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2015 Frank Morgner
*
* This file is part of ACardEmulator.
*
* ACardEmulator 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.
*
* ACardEmulator 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
* ACardEmulator. If not, see <http://www.gnu.org/licenses/>.
*/
package com.vsmartcard.acardemulator;
import android.content.Intent;
import android.nfc.cardemulation.HostApduService;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.vsmartcard.acardemulator.emulators.EmulatorSingleton;
public class EmulatorHostApduService extends HostApduService {
@Override
public void onCreate() {
super.onCreate();
EmulatorSingleton.createEmulator(this);
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public byte[] processCommandApdu(byte[] capdu, Bundle extras) {
return EmulatorSingleton.process(this, capdu);
}
@Override
public void onDeactivated(int reason) {
Intent i = new Intent(EmulatorSingleton.TAG);
Log.d("", "End transaction");
switch (reason) {
case DEACTIVATION_LINK_LOSS:
i.putExtra(EmulatorSingleton.EXTRA_DESELECT, "link lost");
EmulatorSingleton.deactivate();
break;
case DEACTIVATION_DESELECTED:
EmulatorSingleton.deactivate();
break;
}
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
}
}

View File

@@ -41,6 +41,8 @@ import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.vsmartcard.acardemulator.emulators.EmulatorSingleton;
public class MainActivity extends AppCompatActivity {
@@ -48,12 +50,12 @@ public class MainActivity extends AppCompatActivity {
private BroadcastReceiver bReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(EmulatorService.TAG)) {
String capdu = intent.getStringExtra(EmulatorService.EXTRA_CAPDU);
String rapdu = intent.getStringExtra(EmulatorService.EXTRA_RAPDU);
String error = intent.getStringExtra(EmulatorService.EXTRA_ERROR);
String deselect = intent.getStringExtra(EmulatorService.EXTRA_DESELECT);
String install = intent.getStringExtra(EmulatorService.EXTRA_INSTALL);
if (intent.getAction().equals(EmulatorSingleton.TAG)) {
String capdu = intent.getStringExtra(EmulatorSingleton.EXTRA_CAPDU);
String rapdu = intent.getStringExtra(EmulatorSingleton.EXTRA_RAPDU);
String error = intent.getStringExtra(EmulatorSingleton.EXTRA_ERROR);
String deselect = intent.getStringExtra(EmulatorSingleton.EXTRA_DESELECT);
String install = intent.getStringExtra(EmulatorSingleton.EXTRA_INSTALL);
if (install != null)
textViewVPCDStatus.append(getResources().getString(R.string.status_install) + ":" + install + "\n");
if (capdu != null)
@@ -102,7 +104,7 @@ public class MainActivity extends AppCompatActivity {
if (emulator != getString(R.string.vicc)) {
Snackbar.make(view, "Scheduled re-installation of all applets...", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
EmulatorService.destroySimulator(getApplicationContext());
EmulatorSingleton.destroyEmulator();
}
}
});
@@ -116,8 +118,11 @@ public class MainActivity extends AppCompatActivity {
LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(EmulatorService.TAG);
intentFilter.addAction(EmulatorSingleton.TAG);
bManager.registerReceiver(bReceiver, intentFilter);
Intent serviceIntent = new Intent(this.getApplicationContext(), SmartcardProviderService.class);
startService(serviceIntent);
}
@Override

View File

@@ -200,6 +200,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return true;
}
});
bindPreferenceSummaryToValue(findPreference("nfc"));
}
@Override

View File

@@ -0,0 +1,220 @@
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* * Neither the name of Samsung Electronics Co., Ltd. nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.vsmartcard.acardemulator;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.accessory.SA;
import com.samsung.android.sdk.accessory.SAAgent;
import com.samsung.android.sdk.accessory.SAAuthenticationToken;
import com.samsung.android.sdk.accessory.SAPeerAgent;
import com.samsung.android.sdk.accessory.SASocket;
import com.vsmartcard.acardemulator.emulators.EmulatorSingleton;
import java.io.IOException;
public class SmartcardProviderService extends SAAgent {
private static final String TAG = "ACardEmulator";
private static final int ACCESSORY_CHANNEL_ID = 104;
private static final Class<ServiceConnection> SASOCKET_CLASS = ServiceConnection.class;
private final IBinder mBinder = new LocalBinder();
private ServiceConnection mConnectionHandler = null;
Handler mHandler = new Handler();
public SmartcardProviderService() {
super(TAG, SASOCKET_CLASS);
}
@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
EmulatorSingleton.createEmulator(this);
} catch (SsdkUnsupportedException e) {
// try to handle SsdkUnsupportedException
if (processUnsupportedException(e)) {
EmulatorSingleton.createEmulator(this);
return;
}
} catch (Exception e1) {
e1.printStackTrace();
/*
* Your application can not use Samsung Accessory SDK. Your application should work smoothly
* without using this SDK, or you may want to notify user and close your application gracefully
* (release resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
}
findPeerAgents();
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
@Override
protected void onFindPeerAgentsResponse(SAPeerAgent[] peerAgents, int result) {
switch (result) {
case PEER_AGENT_FOUND:
break;
case FINDPEER_SERVICE_NOT_FOUND:
break;
case FINDPEER_DEVICE_NOT_CONNECTED:
break;
default:
break;
}
Log.d(TAG, "onFindPeerAgentResponse : result =" + result);
}
@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
//TODO: Check for keys and everything
acceptServiceConnectionRequest(peerAgent);
}
}
@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
if (result == SAAgent.CONNECTION_SUCCESS) {
if (socket != null) {
mConnectionHandler = (ServiceConnection) socket;
Toast.makeText(getBaseContext(), "connection established", Toast.LENGTH_SHORT).show();
}
} else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
Log.e(TAG, "onServiceConnectionResponse, CONNECTION_ALREADY_EXIST");
}
}
@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
/*
* The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
* version of accessory device. Please refer to another sample application for Security.
*/
}
@Override
protected void onError(SAPeerAgent peerAgent, String errorMessage, int errorCode) {
super.onError(peerAgent, errorMessage, errorCode);
}
private boolean processUnsupportedException(SsdkUnsupportedException e) {
e.printStackTrace();
int errType = e.getType();
if (errType == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED
|| errType == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) {
/*
* Your application can not use Samsung Accessory SDK. You application should work smoothly
* without using this SDK, or you may want to notify user and close your app gracefully (release
* resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
} else if (errType == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) {
Log.e(TAG, "You need to install Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) {
Log.e(TAG, "You need to update Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
Log.e(TAG, "We recommend that you update your Samsung Accessory SDK before using this application.");
return false;
}
return true;
}
public class LocalBinder extends Binder {
public SmartcardProviderService getService() {
return SmartcardProviderService.this;
}
}
public class ServiceConnection extends SASocket {
public ServiceConnection() {
super(ServiceConnection.class.getName());
}
@Override
public void onError(int channelId, String errorMessage, int errorCode) {
}
@Override
public void onReceive(int channelId, byte[] data) {
if (mConnectionHandler == null) {
return;
}
final byte[] sendResponse;
if (data[0] == 'd') {
// APDU is sent
byte[] newData = new byte[data.length - 1];
System.arraycopy(data, 1, newData, 0, data.length - 1);
byte[] response = EmulatorSingleton.process(getApplicationContext(), newData);
sendResponse = new byte[response.length + 1];
sendResponse[0] = 'd';
System.arraycopy(response, 0, sendResponse, 1, response.length);
} else if (data[0] == 'a') {
// request for aids
String[] aidList = EmulatorSingleton.getRegisteredAids(getApplicationContext());
String aidListJoined = TextUtils.join(",", aidList);
sendResponse = new byte[aidListJoined.length() + 1];
sendResponse[0] = 'a';
byte[] aids = aidListJoined.getBytes();
System.arraycopy(aids, 0, sendResponse, 1, aids.length);
} else {
Log.e(TAG, "unknown message from consumer: " + new String(data));
return;
}
new Thread(new Runnable() {
public void run() {
try {
mConnectionHandler.send(ACCESSORY_CHANNEL_ID, sendResponse);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
@Override
protected void onServiceConnectionLost(int reason) {
mConnectionHandler = null;
EmulatorSingleton.deactivate();
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), "connection lost", Toast.LENGTH_SHORT).show();
}
});
}
}
}

View File

@@ -17,28 +17,31 @@
* ACardEmulator. If not, see <http://www.gnu.org/licenses/>.
*/
package com.vsmartcard.acardemulator;
package com.vsmartcard.acardemulator.emulators;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.nfc.cardemulation.HostApduService;
import android.os.Bundle;
import android.os.StrictMode;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.nfc.NfcAdapter;
import android.nfc.cardemulation.CardEmulation;
import android.preference.PreferenceManager;
import android.support.annotation.XmlRes;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.vsmartcard.acardemulator.R;
import com.vsmartcard.acardemulator.Util;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import com.vsmartcard.acardemulator.emulators.Emulator;
import com.vsmartcard.acardemulator.emulators.JCEmulator;
import com.vsmartcard.acardemulator.emulators.VICCEmulator;
public class EmulatorService extends HostApduService {
import java.util.ArrayList;
import java.util.List;
public class EmulatorSingleton {
public static final String TAG = "com.vsmartcard.acardemulator.EmulatorService";
public static final String EXTRA_CAPDU = "MSG_CAPDU";
public static final String EXTRA_RAPDU = "MSG_RAPDU";
@@ -49,22 +52,35 @@ public class EmulatorService extends HostApduService {
private static Emulator emulator = null;
private static boolean do_destroy = false;
@Override
public void onCreate () {
super.onCreate();
private static void destroyEmulatorIfRequested(Context context) {
if (do_destroy) {
emulator.destroy();
emulator = null;
do_destroy = false;
Intent i = new Intent(TAG);
i.putExtra(EXTRA_DESELECT, "Uninstalled all applets.");
LocalBroadcastManager.getInstance(context).sendBroadcast(i);
}
}
public static void destroyEmulator() {
do_destroy = true;
}
public static void createEmulator(Context context) {
// force reloading applets if requested
do_destroy();
destroyEmulatorIfRequested(context);
if (emulator == null) {
Log.d("", "Begin transaction");
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(context);
String str_emulator = SP.getString("emulator", "");
if (str_emulator.equals(getString(R.string.vicc))) {
if (str_emulator.equals(context.getString(R.string.vicc))) {
emulator = new VICCEmulator(
SP.getString("hostname", VICCEmulator.DEFAULT_HOSTNAME),
Integer.parseInt(SP.getString("port", Integer.toString(VICCEmulator.DEFAULT_PORT))));
} else {
emulator = new JCEmulator(this,
emulator = new JCEmulator(context,
SP.getBoolean("activate_helloworld", false),
SP.getBoolean("activate_openpgp", false),
SP.getBoolean("activate_oath", false),
@@ -74,55 +90,45 @@ public class EmulatorService extends HostApduService {
}
}
public static void destroySimulator(Context context) {
do_destroy = true;
}
private void do_destroy() {
if (do_destroy) {
emulator.destroy();
emulator = null;
do_destroy = false;
Intent i = new Intent(TAG);
i.putExtra(EXTRA_DESELECT, "Uninstalled all applets.");
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
}
}
@Override
public void onDestroy() {
do_destroy();
super.onDestroy();
}
@Override
public byte[] processCommandApdu(byte[] capdu, Bundle extras) {
public static byte[] process(Context context, byte[] capdu) {
byte[] rapdu = emulator.process(capdu);
Intent i = new Intent(TAG);
i.putExtra(EXTRA_CAPDU, Util.byteArrayToHexString(capdu));
if (rapdu != null)
i.putExtra(EXTRA_RAPDU, Util.byteArrayToHexString(rapdu));
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
LocalBroadcastManager.getInstance(context).sendBroadcast(i);
return rapdu;
}
@Override
public void onDeactivated(int reason) {
Intent i = new Intent(TAG);
public static String[] getRegisteredAids(Context context) {
List<String> aidList = new ArrayList<>();
XmlResourceParser aidXmlParser = context.getResources().getXml(R.xml.aid_list);
Log.d("", "End transaction");
switch (reason) {
case DEACTIVATION_LINK_LOSS:
i.putExtra(EXTRA_DESELECT, "link lost");
emulator.deactivate();
break;
case DEACTIVATION_DESELECTED:
emulator.deactivate();
break;
try {
while (aidXmlParser.getEventType() != XmlPullParser.END_DOCUMENT) {
if (aidXmlParser.getEventType() == XmlPullParser.START_TAG) {
if (aidXmlParser.getName().equals("aid-filter")) {
int aid = aidXmlParser.getAttributeResourceValue(0, -1);
if (aid != -1) {
aidList.add(context.getResources().getString(aid));
}
}
}
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
aidXmlParser.next();
}
aidXmlParser.close();
} catch (XmlPullParserException | IOException e) {
Log.e(TAG.substring(0, 23), "Couldn't parse aid xml list.");
}
return aidList.toArray(new String[0]);
}
public static void deactivate() {
emulator.deactivate();
}
}

View File

@@ -9,7 +9,6 @@ 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.EmulatorService;
import com.vsmartcard.acardemulator.R;
import com.vsmartcard.acardemulator.Util;
@@ -100,11 +99,11 @@ public class JCEmulator implements Emulator {
}
}
Intent i = new Intent(EmulatorService.TAG);
Intent i = new Intent(EmulatorSingleton.TAG);
if (!extra_error.isEmpty())
i.putExtra(EmulatorService.EXTRA_ERROR, extra_error);
i.putExtra(EmulatorSingleton.EXTRA_ERROR, extra_error);
if (!extra_install.isEmpty())
i.putExtra(EmulatorService.EXTRA_INSTALL, extra_install);
i.putExtra(EmulatorSingleton.EXTRA_INSTALL, extra_install);
LocalBroadcastManager.getInstance(context).sendBroadcast(i);
}

View File

@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.vsmartcard.smartcardemulator.MainActivity">
tools:context="com.vsmartcard.acardemulator.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"

View File

@@ -44,6 +44,14 @@
</string-array>
<string name="jcardsim">Builtin Java Card Simulator</string>
<string name="vicc">Remote Virtual Smart Card</string>
<string-array name="strNFC">
<item>@string/nfc</item>
<item>@string/gear</item>
</string-array>
<string name="nfc">Builtin NFC</string>
<string name="gear">Samsung Accessory</string>
<string name="vicc_config_info">If you choose the virtual smart card (VICC) as emulator, you need to start the it on your computer with the `--reversed` flag and configure the connection parameters here accordingly.</string>
<string name="hint_vicc_port">VICC Port</string>
<string name="hint_vicc_hostname">VICC Hostname</string>

View File

@@ -0,0 +1,51 @@
<!DOCTYPE resources [
<!ELEMENT resources (application)>
<!ELEMENT application (serviceProfile)+>
<!ATTLIST application name CDATA #REQUIRED>
<!ELEMENT serviceProfile (supportedTransports, serviceChannel+) >
<!ATTLIST application xmlns:android CDATA #IMPLIED>
<!ATTLIST serviceProfile xmlns:android CDATA #IMPLIED>
<!ATTLIST serviceProfile serviceImpl CDATA #REQUIRED>
<!ATTLIST serviceProfile role (PROVIDER | CONSUMER | provider | consumer) #REQUIRED>
<!ATTLIST serviceProfile name CDATA #REQUIRED>
<!ATTLIST serviceProfile id CDATA #REQUIRED>
<!ATTLIST serviceProfile version CDATA #REQUIRED>
<!ATTLIST serviceProfile serviceLimit (ANY | ONE_ACCESSORY | ONE_PEERAGENT | any | one_accessory | one_peeragent) #IMPLIED>
<!ATTLIST serviceProfile serviceTimeout CDATA #IMPLIED>
<!ELEMENT supportedTransports (transport)+>
<!ATTLIST supportedTransports xmlns:android CDATA #IMPLIED>
<!ELEMENT transport EMPTY>
<!ATTLIST transport xmlns:android CDATA #IMPLIED>
<!ATTLIST transport type (TRANSPORT_WIFI | TRANSPORT_BT | TRANSPORT_BLE | TRANSPORT_USB |
transport_wifi | transport_bt | transport_ble | transport_usb) #REQUIRED>
<!ELEMENT serviceChannel EMPTY>
<!ATTLIST serviceChannel xmlns:android CDATA #IMPLIED>
<!ATTLIST serviceChannel id CDATA #REQUIRED>
<!ATTLIST serviceChannel dataRate (LOW | HIGH | low | high) #REQUIRED>
<!ATTLIST serviceChannel priority (LOW | MEDIUM | HIGH | low | medium | high) #REQUIRED>
<!ATTLIST serviceChannel reliability (ENABLE | DISABLE | enable | disable ) #REQUIRED>
]>
<resources>
<application name="VirtualSmartCardReader" >
<serviceProfile
id="/com/vsmcartcard"
name="VirtualSmartCardReaderProvider"
role="provider"
serviceImpl="com.vsmartcard.acardemulator.SmartcardProviderService"
version="1.0"
serviceLimit="ANY"
serviceTimeout="10">
<supportedTransports>
<transport type="TRANSPORT_BT" />
<transport type="TRANSPORT_WIFI" />
</supportedTransports>
<serviceChannel
id="104"
dataRate="low"
priority="high"
reliability= "enable"/>
</serviceProfile>
</application>
</resources>

View File

@@ -81,4 +81,11 @@
</PreferenceCategory>
<ListPreference
android:key="nfc"
android:title="NFC communication hardware"
android:defaultValue="@string/nfc"
android:entries="@array/strNFC"
android:entryValues="@array/strNFC" />
</PreferenceScreen>

View File

@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@@ -1,6 +1,6 @@
#Thu May 12 09:46:58 CEST 2016
#Tue Oct 04 22:11:09 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

460
TCardEmulator/.cproject Normal file
View File

@@ -0,0 +1,460 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1329109068">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1329109068" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.tizen.nativecore.NativeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="com.vsmartcard.tcardemulator" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1329109068" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
<folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1329109068." name="/" resourcePath="">
<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1756955423" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1425984353" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/TCardEmulator}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1787680921" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.1781797598" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
<tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.992648229" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1129520531" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.2010611735" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1018206821" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1405252491" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="wearable-2.3.1-device.core_llvm34.armel.core.app"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.946474805" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-manager&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/../wearable-2.3.1-device.core/usr/include/sap_client&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.342405019" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
<listOptionValue builtIn="false" value="-mthumb"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.1591385432" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.1872608313" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
<listOptionValue builtIn="false" value="samsung-sap"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.975801712" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.136102720" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.88517044" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1660527581" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.785296696" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.560394667" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="wearable-2.3.1-device.core_llvm34.armel.core.app"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1539152499" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-manager&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/../wearable-2.3.1-device.core/usr/include/sap_client&quot;"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.658636378" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
<listOptionValue builtIn="false" value="-mthumb"/>
</option>
<option id="gnu.c.compiler.option.include.paths.1290677103" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks.core.559620149" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
<listOptionValue builtIn="false" value="samsung-sap"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1649884941" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.631588111" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.274416099" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.26915008" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1831689991" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1614788795" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
<listOptionValue builtIn="false" value="-pie -lpthread "/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
<listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
<listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
<listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/../wearable-2.3.1-device.core/usr/lib&quot;"/>
<listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
</option>
<option id="gnu.cpp.link.option.paths.936736444" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1272058736" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool command="arm-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.548583527" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1033719303" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="org.tizen.nativecore.tool.fnmapgen.1575192993" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
<tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1839833566" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
<tool id="org.tizen.nativecore.tool.ast.1190183162" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
<tool id="org.tizen.nativecore.tool.ast.cpp.1999988221" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.1461814311" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
<tool id="org.tizen.nativecore.tool.sbi.po.compiler.531213072" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
<tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1113764296" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.release.1757677484">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1757677484" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.tizen.nativecore.NativeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="com.vsmartcard.tcardemulator" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1757677484" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release">
<folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.1757677484." name="/" resourcePath="">
<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.589413647" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.251744671" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder buildPath="${workspace_loc:/TCardEmulator}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1951900405" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.2072693820" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
<tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1078127376" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.508218667" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.default" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1054111679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.178297827" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.898708869" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="wearable-2.3.1-emulator.core_llvm34.i386.core.app"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.758147050" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-manager&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/../wearable-2.3.1-emulator.core/usr/include/sap_client&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1770251882" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.1632378439" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.739969600" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
<listOptionValue builtIn="false" value="samsung-sap"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1974288354" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1627185536" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.839760477" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.default" id="sbi.gnu.c.compiler.option.debugging.level.core.1452382994" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1405555431" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1453291800" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="wearable-2.3.1-emulator.core_llvm34.i386.core.app"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1757524318" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-manager&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/../wearable-2.3.1-emulator.core/usr/include/sap_client&quot;"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.306921511" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option>
<option id="gnu.c.compiler.option.include.paths.2076085071" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks.core.733344345" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
<listOptionValue builtIn="false" value="samsung-sap"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2137682856" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1895617564" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.417969963" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.45803718" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1705005837" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1487027321" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
<listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
<listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
<listOptionValue builtIn="false" value="-pie -lpthread "/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
<listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
<listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
<listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/../wearable-2.3.1-emulator.core/usr/lib&quot;"/>
<listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
</option>
<option id="gnu.cpp.link.option.paths.1763248614" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.441140653" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.267643016" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1669348827" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="org.tizen.nativecore.tool.fnmapgen.1204270433" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
<tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1190612639" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
<tool id="org.tizen.nativecore.tool.ast.332380071" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
<tool id="org.tizen.nativecore.tool.ast.cpp.145826372" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.548341821" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
<tool id="org.tizen.nativecore.tool.sbi.po.compiler.331671546" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
<tool id="org.tizen.nativecore.tool.sbi.edc.compiler.608912392" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="TCardEmulator.org.tizen.nativecore.target.sbi.gcc45.app.1121012633" name="Tizen Native Application" projectType="org.tizen.nativecore.target.sbi.gcc45.app"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.debug.1329109068">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.1757677484">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/TCardEmulator"/>
</configuration>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/TCardEmulator"/>
</configuration>
</storageModule>
</cproject>

4
TCardEmulator/.exportMap Normal file
View File

@@ -0,0 +1,4 @@
{
global: main;
local: *;
};

2
TCardEmulator/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/Debug
/SA_Report

52
TCardEmulator/.project Normal file
View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TCardEmulator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.tizen.nativecore.apichecker.apicheckerbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.tizen.nativecore.apichecker.apicheckernature</nature>
</natures>
<filteredResources>
<filter>
<id>1464204018079</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
</matcher>
</filter>
<filter>
<id>1464204018094</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-project_def.prop</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

12
TCardEmulator/.tproject Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tproject xmlns="http://www.tizen.org/tproject">
<platforms>
<platform>
<name>wearable-2.3.1</name>
</platform>
</platforms>
<package>
<blacklist/>
<resFallback autoGen="true"/>
</package>
</tproject>

View File

@@ -0,0 +1,11 @@
#ifndef __sap_H__
#define __sap_H__
#include <nfc.h>
void send_apdu_response(nfc_se_h handle, unsigned char *resp, unsigned int resp_len);
void install_aids(void *buffer, unsigned int buffer_size);
extern gboolean agent_connected;
#endif /* __tcardemulator_H__ */

View File

@@ -0,0 +1,21 @@
#ifndef __tcardemulator_H__
#define __tcardemulator_H__
#define LOG_TAG "tcardemulator"
#if !defined(PACKAGE)
#define PACKAGE "com.vsmartcard.tcardemulator"
#endif
#include <stddef.h>
#include <glib.h>
#include <nfc.h>
#include <glib.h>
void initialize_sap();
gboolean find_peers();
gboolean request_service_connection(void);
gboolean terminate_service_connection(void);
gboolean send_data(nfc_se_h nfc_handle, char* prefix, unsigned int prefix_len, void *message, unsigned int message_len);
#endif /* __tcardemulator_H__ */

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<application name="VirtualSmartCardReader">
<serviceProfile id="/com/vsmcartcard" name="VirtualSmartCardReaderConsumer"
role="consumer" version="1.0">
<supportedTransports>
<transport type="TRANSPORT_BT" />
<transport type="TRANSPORT_WIFI" />
</supportedTransports>
<serviceChannel id="104" dataRate="low" priority="high"
reliability="enable">
</serviceChannel>
</serviceProfile>
</application>
</resources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<application name="com.vsmartcard.tcardemulator">
<wallet>
<aid-group category="other">
<aid aid="A000000397425446590201" se_type="hce" unlock="false"
power="sleep" />
<aid aid="A0000003974254465902" se_type="hce" unlock="false"
power="sleep" />
<aid aid="A00000039742544659" se_type="hce" unlock="false" power="sleep" />
</aid-group>
<aid-group category="other">
<aid aid="F000000001" se_type="hce" unlock="false" power="sleep" />
</aid-group>
<aid-group category="other">
<aid aid="D27600012401" se_type="hce" unlock="false" power="sleep" />
<aid aid="D2760001240102000000000000010000" se_type="hce" unlock="false"
power="sleep" />
</aid-group>
<aid-group category="other">
<aid aid="A000000527210101" se_type="hce" unlock="false" power="sleep" />
</aid-group>
</wallet>
</application>

372
TCardEmulator/src/sap.c Normal file
View File

@@ -0,0 +1,372 @@
#include "tcardemulator.h"
#include "sap_app.h"
#include <dlog.h>
#include <unistd.h>
#include <stdlib.h>
#include <nfc.h>
#include <sap.h>
#include <glib.h>
#define ACCESSORY_PROFILE_ID "/com/vsmcartcard"
#define ACCESSORY_CHANNELID 104
typedef struct priv {
sap_agent_h agent;
sap_socket_h socket;
sap_peer_agent_h peer_agent;
nfc_se_h nfc_handle;
} priv_s;
gboolean agent_created = FALSE;
gboolean agent_connected = FALSE;
static priv_s priv_data = { 0 };
void on_peer_agent_updated(sap_peer_agent_h peer_agent,
sap_peer_agent_status_e peer_status,
sap_peer_agent_found_result_e result,
void *user_data) {
switch (result) {
case SAP_PEER_AGENT_FOUND_RESULT_DEVICE_NOT_CONNECTED:
dlog_print(DLOG_INFO, LOG_TAG, "device is not connected");
break;
case SAP_PEER_AGENT_FOUND_RESULT_FOUND:
if (peer_status == SAP_PEER_AGENT_STATUS_AVAILABLE) {
priv_data.peer_agent = peer_agent;
dlog_print(DLOG_INFO, LOG_TAG, "requesting service connection");
request_service_connection();
} else {
dlog_print(DLOG_INFO, LOG_TAG, "peer agent removed");
sap_peer_agent_destroy(peer_agent);
}
break;
case SAP_PEER_AGENT_FOUND_RESULT_SERVICE_NOT_FOUND:
dlog_print(DLOG_INFO, LOG_TAG, "service not found");
break;
case SAP_PEER_AGENT_FOUND_RESULT_TIMEDOUT:
dlog_print(DLOG_INFO, LOG_TAG, "peer agent find timed out");
break;
case SAP_PEER_AGENT_FOUND_RESULT_INTERNAL_ERROR:
dlog_print(DLOG_INFO, LOG_TAG, "peer agent find search failed");
break;
}
}
static void on_service_connection_terminated(sap_peer_agent_h peer_agent,
sap_socket_h socket,
sap_service_connection_result_e result,
void *user_data) {
switch (result) {
case SAP_CONNECTION_TERMINATED_REASON_PEER_DISCONNECTED:
dlog_print(DLOG_INFO, LOG_TAG, "disconnected because peer lost");
break;
case SAP_CONNECTION_TERMINATED_REASON_DEVICE_DETACHED:
dlog_print(DLOG_INFO, LOG_TAG, "disconnected because device is detached");
break;
default:
// fall through
case SAP_CONNECTION_TERMINATED_REASON_UNKNOWN:
dlog_print(DLOG_INFO, LOG_TAG, "disconnected because of unknown reason");
break;
}
sap_socket_destroy(priv_data.socket);
priv_data.socket = NULL;
agent_connected = FALSE;
}
static void on_data_recieved(sap_socket_h socket,
unsigned short int channel_id,
unsigned int payload_length,
void *buffer,
void *user_data) {
dlog_print(DLOG_INFO, LOG_TAG, "received data: %p, len:%d", buffer, payload_length);
char* string_buffer = (char*) buffer;
if (string_buffer[0] == 'a') {
install_aids(buffer + sizeof(char), payload_length - 1);
} else if (string_buffer[0] == 'd') {
send_apdu_response(priv_data.nfc_handle, buffer + sizeof(char), payload_length - 1);
}
}
gboolean send_data(nfc_se_h nfc_handle, char* prefix, unsigned int prefix_len, void *message, unsigned int message_len) {
gboolean result;
if (nfc_handle != NULL) {
priv_data.nfc_handle = nfc_handle;
}
void *final_message = malloc(prefix_len + message_len);
memcpy(final_message, prefix, prefix_len);
memcpy(final_message + prefix_len * sizeof(char), message, message_len);
result = sap_socket_send_data(priv_data.socket,
ACCESSORY_CHANNELID, prefix_len + message_len, final_message);
if (result != SAP_RESULT_SUCCESS) {
dlog_print(DLOG_INFO, LOG_TAG, "couldn't send sap message: %d", result);
}
free(final_message);
return result;
}
gboolean request_installed_aids() {
return send_data(NULL, "a", 1, "", 0);
}
static void on_service_connection_created(sap_peer_agent_h peer_agent,
sap_socket_h socket,
sap_service_connection_result_e result,
void *user_data) {
switch (result) {
case SAP_CONNECTION_SUCCESS:
dlog_print(DLOG_INFO, LOG_TAG, "peer agent connection is successful, pa :%u", peer_agent);
sap_peer_agent_set_service_connection_terminated_cb(priv_data.peer_agent,
on_service_connection_terminated,
NULL);
sap_socket_set_data_received_cb(socket, on_data_recieved, peer_agent);
priv_data.socket = socket;
agent_connected = TRUE;
request_installed_aids();
break;
case SAP_CONNECTION_ALREADY_EXIST:
dlog_print(DLOG_INFO, LOG_TAG, "connection already exists");
priv_data.socket = socket;
agent_connected = TRUE;
break;
case SAP_CONNECTION_FAILURE_DEVICE_UNREACHABLE:
dlog_print(DLOG_INFO, LOG_TAG, "device is not unreachable");
break;
case SAP_CONNECTION_FAILURE_INVALID_PEERAGENT:
dlog_print(DLOG_INFO, LOG_TAG, "invalid peer agent");
break;
case SAP_CONNECTION_FAILURE_NETWORK:
dlog_print(DLOG_INFO, LOG_TAG, "network failure");
break;
case SAP_CONNECTION_FAILURE_PEERAGENT_NO_RESPONSE:
dlog_print(DLOG_INFO, LOG_TAG, "peer agent is no response");
break;
case SAP_CONNECTION_FAILURE_PEERAGENT_REJECTED:
dlog_print(DLOG_INFO, LOG_TAG, "peer agent is rejected");
break;
case SAP_CONNECTION_FAILURE_UNKNOWN:
dlog_print(DLOG_INFO, LOG_TAG, "unknown error");
break;
}
}
static gboolean _create_service_connection(gpointer user_data) {
struct priv *priv = NULL;
sap_result_e result = SAP_RESULT_FAILURE;
priv = (struct priv *)user_data;
result = sap_agent_request_service_connection(priv->agent,
priv->peer_agent,
on_service_connection_created,
NULL);
if (result == SAP_RESULT_SUCCESS) {
dlog_print(DLOG_DEBUG, LOG_TAG, "req service conn call succeeded");
} else {
dlog_print(DLOG_ERROR, LOG_TAG, "req service conn call is failed (%d)", result);
}
return FALSE;
}
gboolean request_service_connection(void) {
g_idle_add(_create_service_connection, &priv_data);
return TRUE;
}
static gboolean _terminate_service_connection(gpointer user_data) {
struct priv *priv = NULL;
sap_result_e result = SAP_RESULT_FAILURE;
priv = (struct priv *)user_data;
if (priv->socket)
result = sap_peer_agent_terminate_service_connection(priv->peer_agent);
else {
return FALSE;
}
if (result == SAP_RESULT_SUCCESS) {
dlog_print(DLOG_DEBUG, LOG_TAG, "terminate service conn call succeeded");
priv->socket = NULL;
agent_connected = FALSE;
} else {
dlog_print(DLOG_ERROR, LOG_TAG, "terminate service conn call is failed (%d)", result);
}
return FALSE;
}
gboolean terminate_service_connection(void)
{
g_idle_add(_terminate_service_connection, &priv_data);
return TRUE;
}
static gboolean _find_peer_agent(gpointer user_data)
{
struct priv *priv = NULL;
sap_result_e result = SAP_RESULT_FAILURE;
priv = (struct priv *)user_data;
result = sap_agent_find_peer_agent(priv->agent, on_peer_agent_updated, NULL);
if (result == SAP_RESULT_SUCCESS) {
dlog_print(DLOG_DEBUG, LOG_TAG, "find peer call succeeded");
} else {
dlog_print(DLOG_ERROR, LOG_TAG, "find peer call failed (%d)", result);
}
return FALSE;
}
gboolean find_peers()
{
g_idle_add(_find_peer_agent, &priv_data);
dlog_print(DLOG_DEBUG, LOG_TAG, "find peer called");
return TRUE;
}
static void on_agent_initialized(sap_agent_h agent,
sap_agent_initialized_result_e result,
void *user_data)
{
switch (result) {
case SAP_AGENT_INITIALIZED_RESULT_SUCCESS:
dlog_print(DLOG_INFO, LOG_TAG, "agent is initialized");
priv_data.agent = agent;
agent_created = TRUE;
break;
case SAP_AGENT_INITIALIZED_RESULT_DUPLICATED:
dlog_print(DLOG_INFO, LOG_TAG, "duplicate registration");
break;
case SAP_AGENT_INITIALIZED_RESULT_INVALID_ARGUMENTS:
dlog_print(DLOG_INFO, LOG_TAG, "invalid arguments");
break;
case SAP_AGENT_INITIALIZED_RESULT_INTERNAL_ERROR:
dlog_print(DLOG_INFO, LOG_TAG, "internal sap error");
break;
default:
dlog_print(DLOG_INFO, LOG_TAG, "unknown status (%d)", result);
break;
}
}
static void on_device_status_changed(sap_device_status_e status, sap_transport_type_e transport_type,
void *user_data)
{
switch (transport_type) {
case SAP_TRANSPORT_TYPE_BT:
dlog_print(DLOG_INFO, LOG_TAG, "connectivity type(%d): bt", transport_type);
break;
case SAP_TRANSPORT_TYPE_BLE:
dlog_print(DLOG_INFO, LOG_TAG, "connectivity type(%d): ble", transport_type);
break;
case SAP_TRANSPORT_TYPE_TCP:
dlog_print(DLOG_INFO, LOG_TAG, "connectivity type(%d): tcp/ip", transport_type);
break;
case SAP_TRANSPORT_TYPE_USB:
dlog_print(DLOG_INFO, LOG_TAG, "connectivity type(%d): usb", transport_type);
break;
case SAP_TRANSPORT_TYPE_MOBILE:
dlog_print(DLOG_INFO, LOG_TAG, "connectivity type(%d): mobile", transport_type);
break;
default:
dlog_print(DLOG_INFO, LOG_TAG, "unknown connectivity type (%d)", transport_type);
break;
}
switch (status) {
case SAP_DEVICE_STATUS_DETACHED:
if (priv_data.peer_agent) {
sap_socket_destroy(priv_data.socket);
priv_data.socket = NULL;
sap_peer_agent_destroy(priv_data.peer_agent);
priv_data.peer_agent = NULL;
agent_connected = FALSE;
}
break;
case SAP_DEVICE_STATUS_ATTACHED:
if (agent_created) {
g_idle_add(_find_peer_agent, &priv_data);
}
break;
default:
dlog_print(DLOG_INFO, LOG_TAG, "unknown status (%d)", status);
break;
}
}
gboolean agent_initialize()
{
int result = 0, i = 1;
gboolean agent_initialized = TRUE;
do {
if (i > 100) {
agent_initialized = FALSE;
break;
}
result = sap_agent_initialize(priv_data.agent,
ACCESSORY_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER,
on_agent_initialized, NULL);
dlog_print(DLOG_DEBUG, LOG_TAG, "sap_agent_initialize >>> %d", result);
i++;
} while (result != SAP_RESULT_SUCCESS);
return agent_initialized;
}
void initialize_sap()
{
sap_agent_h agent = NULL;
sap_agent_create(&agent);
if (agent == NULL)
dlog_print(DLOG_ERROR, LOG_TAG, "ERROR in creating agent");
else
dlog_print(DLOG_INFO, LOG_TAG, "SUCCESSFULLY create sap agent");
priv_data.agent = agent;
sap_set_device_status_changed_cb(on_device_status_changed, NULL);
agent_initialize();
}

View File

@@ -0,0 +1,159 @@
#include "tcardemulator.h"
#include "sap_app.h"
#include <service_app.h>
#include <nfc.h>
#include <dlog.h>
#include <unistd.h>
#include <stdlib.h>
#include <glib.h>
typedef struct appdata {
} appdata_s;
static void hce_event_cb(nfc_se_h handle, nfc_hce_event_type_e event, unsigned char *apdu, unsigned int apdu_len, void *user_data) {
switch (event) {
case NFC_HCE_EVENT_DEACTIVATED:
dlog_print(DLOG_DEBUG, LOG_TAG, "received NFC_HCE_EVENT_DEACTIVATED event on NFC handle %d", handle);
break;
case NFC_HCE_EVENT_ACTIVATED:
dlog_print(DLOG_DEBUG, LOG_TAG, "received NFC_HCE_EVENT_ACTIVATED event on NFC handle %d", handle);
if (!agent_connected) {
find_peers();
}
break;
case NFC_HCE_EVENT_APDU_RECEIVED:
dlog_print(DLOG_DEBUG, LOG_TAG, "received NFC_HCE_EVENT_APDU_RECEIVED event on NFC handle %d", handle);
if (agent_connected) {
send_data(handle, "d", 1, apdu, apdu_len);
} else {
dlog_print(DLOG_INFO, LOG_TAG, "couldn't send message on SAP channel because agent is not connected");
}
break;
default:
dlog_print(DLOG_DEBUG, LOG_TAG, "received unknown event on NFC handle %d", handle);
break;
}
}
void register_aid(gpointer data) {
int result = nfc_se_register_aid(NFC_SE_TYPE_HCE, NFC_CARD_EMULATION_CATEGORY_OTHER, data);
if (result != NFC_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_register_aid for aid %s failed: %d", data, result);
} else {
dlog_print(DLOG_DEBUG, LOG_TAG, "nfc_se_register_aid for aid %s succeeded.", data);
}
}
void install_aids(void *buffer, unsigned int buffer_size) {
gchar aid_string[buffer_size + 1];
g_strlcpy(aid_string, (gchar *)buffer, buffer_size + 1);
gchar **aid_buffer = g_strsplit(aid_string, ",", 0);
int i;
int aid_len = g_strv_length(aid_buffer);
for (i = 0; i < aid_len; i++) {
register_aid((gpointer)aid_buffer[i]);
}
g_strfreev(aid_buffer);
}
void send_apdu_response(nfc_se_h handle, unsigned char *resp, unsigned int resp_len) {
dlog_print(DLOG_DEBUG, LOG_TAG, "sending data to nfc handle: %d", handle);
int result = nfc_hce_send_apdu_response(handle, resp, resp_len);
if (result != NFC_ERROR_NONE) {
dlog_print(DLOG_DEBUG, LOG_TAG, "error sending data to nfc handle %d: ", handle);
}
}
bool service_app_create(void *data) {
int ret = NFC_ERROR_NONE;
bool r = false;
nfc_se_card_emulation_mode_type_e ce_type;
ret = nfc_manager_initialize();
if (ret != NFC_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_initialize failed : %d", ret);
goto err;
}
ret = nfc_se_get_card_emulation_mode(&ce_type);
if (ret != NFC_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_get_card_emulation_mode failed : %d", ret);
goto err;
}
if (ce_type == NFC_SE_CARD_EMULATION_MODE_OFF) {
nfc_se_enable_card_emulation();
if (ret != NFC_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_enable_card_emulation failed : %d", ret);
goto err;
}
}
ret = nfc_manager_set_hce_event_cb(hce_event_cb, NULL);
if (ret != NFC_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_set_hce_event_cb failed : %d", ret);
goto err;
} else {
dlog_print(DLOG_DEBUG, LOG_TAG, "nfc_manager_set_hce_event_cb succeeded");
}
initialize_sap();
find_peers();
r = true;
err:
return r;
}
void service_app_terminate(void *data) {
int ret = NFC_ERROR_NONE;
nfc_manager_unset_hce_event_cb();
ret = nfc_manager_deinitialize();
if (ret != NFC_ERROR_NONE)
{
dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_deinitialize failed : %d", ret);
}
terminate_service_connection();
return;
}
void service_app_control(app_control_h app_control, void *data) {
return;
}
void service_app_low_memory(void *data) {
service_app_terminate(&data);
return;
}
void service_app_low_battery(void *data) {
service_app_terminate(&data);
return;
}
int main(int argc, char* argv[]) {
appdata_s ad = {};
service_app_event_callback_s event_callback;
event_callback.create = service_app_create;
event_callback.terminate = service_app_terminate;
event_callback.app_control = service_app_control;
event_callback.low_memory = service_app_low_memory;
event_callback.low_battery = service_app_low_battery;
return svc_app_main(argc, argv, &event_callback, &ad);
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1" package="com.vsmartcard.tcardemulator" version="1.0.0">
<profile name="wearable"/>
<service-application appid="com.vsmartcard.tcardemulator" exec="com.vsmartcard.tcardemulator" multiple="false" nodisplay="false" taskmanage="false" type="capp">
<label>Smart Card Emulator</label>
<icon>ic_launcher.png</icon>
<metadata key="http://tizen.org/metadata/nfc_cardemulation" value="/shared/res/wallet.xml"/>
<metadata key="accessory-services-location" value="/res/accessoryservices.xml"/>
</service-application>
<privileges>
<privilege>http://developer.samsung.com/tizen/privilege/accessoryprotocol</privilege>
<privilege>http://tizen.org/privilege/nfc.cardemulation</privilege>
</privileges>
<feature name="http://tizen.org/feature/network.nfc.card_emulation.hce">true</feature>
</manifest>