}
PlatformResult NFCAdapter::IsActivatedHandlerForAID(
- const char* aid,
+ const std::string& type,
+ const std::string& aid,
bool* is_activated_handler) {
- AssertMsg(aid, "Poiner can not be null!");
AssertMsg(is_activated_handler, "Poiner can not be null!");
LoggerD("Entered");
- int ret = nfc_se_is_activated_handler_for_aid(aid, is_activated_handler);
+ nfc_se_type_e se_type;
+ PlatformResult result = NFCUtil::ToSecureElementType(type, &se_type);
+ if (!result.IsError()) {
+ return result;
+ }
+
+ int ret = nfc_se_is_activated_handler_for_aid(se_type,
+ aid.c_str(),
+ is_activated_handler);
if (NFC_ERROR_NONE != ret) {
LoggerE("IsActivatedHandlerForAID failed: %d", ret);
return NFCUtil::CodeToResult(ret,
}
PlatformResult NFCAdapter::IsActivatedHandlerForCategory(
- nfc_card_emulation_category_type_e category, bool* is_activated_handler) {
+ const std::string& type,
+ nfc_card_emulation_category_type_e category,
+ bool* is_activated_handler) {
AssertMsg(is_activated_handler, "Poiner can not be null!");
- LoggerD("Category: %d", category);
- int ret = nfc_se_is_activated_handler_for_category(category,
- is_activated_handler);
+ nfc_se_type_e se_type;
+ PlatformResult result = NFCUtil::ToSecureElementType(type, &se_type);
+ if (!result.IsError()) {
+ return result;
+ }
+
+ int ret = nfc_se_is_activated_handler_for_category(se_type,
+ category,
+ is_activated_handler);
if (NFC_ERROR_NONE != ret) {
LoggerE("IsActivatedHandlerForCategory failed: %d", ret);
return NFCUtil::CodeToResult(ret,
}
PlatformResult NFCAdapter::RegisterAID(
- const char* aid,
+ const std::string& type,
+ const std::string& aid,
nfc_card_emulation_category_type_e category) {
- AssertMsg(aid, "Poiner can not be null!");
- LoggerD("AID: %s, Category: %d", aid, category);
- int ret = nfc_se_register_aid(category, aid);
+ nfc_se_type_e se_type;
+ PlatformResult result = NFCUtil::ToSecureElementType(type, &se_type);
+ if (!result.IsError()) {
+ return result;
+ }
+
+ int ret = nfc_se_register_aid(se_type, category, aid.c_str());
if (NFC_ERROR_NONE != ret) {
LoggerE("RegisterAID failed: %d", ret);
return NFCUtil::CodeToResult(ret,
}
PlatformResult NFCAdapter::UnregisterAID(
- const char* aid,
+ const std::string& type,
+ const std::string& aid,
nfc_card_emulation_category_type_e category) {
- AssertMsg(aid, "Poiner can not be null!");
- LoggerD("AID: %s, Category: %d", aid, category);
- int ret = nfc_se_unregister_aid(category, aid);
+ nfc_se_type_e se_type;
+ PlatformResult result = NFCUtil::ToSecureElementType(type, &se_type);
+ if (!result.IsError()) {
+ return result;
+ }
+
+ int ret = nfc_se_unregister_aid(se_type, category, aid.c_str());
if (NFC_ERROR_NONE != ret) {
LoggerE("UnregisterAID failed: %d", ret);
return NFCUtil::CodeToResult(ret,
};
void NFCAdapter::GetAIDsForCategory(
+ const std::string& type,
nfc_card_emulation_category_type_e category,
const std::function<void(const AIDDataVector&)>& success_cb,
const std::function<void(const PlatformResult&)>& error_cb) {
- LoggerD("Category: %d", category);
+
+ nfc_se_type_e se_type;
+ PlatformResult result = NFCUtil::ToSecureElementType(type, &se_type);
+ if (!result.IsError()) {
+ error_cb(result);
+ return;
+ }
AIDDataVector aids{};
- int ret = nfc_se_foreach_registered_aids(category, SaveRow, &aids);
+ int ret = nfc_se_foreach_registered_aids(se_type, category, SaveRow, &aids);
if (NFC_ERROR_NONE != ret) {
LoggerE("GetAIDsForCategory failed: %d", ret);
error_cb(NFCUtil::CodeToResult(ret,
const UCharVector& apdu,
const std::function<void()>& success_cb,
const std::function<void(const common::PlatformResult&)>& error_cb);
- common::PlatformResult IsActivatedHandlerForAID(const char* aid,
+ common::PlatformResult IsActivatedHandlerForAID(const std::string& type,
+ const std::string& aid,
bool* is_activated_handler);
common::PlatformResult IsActivatedHandlerForCategory(
- nfc_card_emulation_category_type_e category, bool* is_activated_handler);
+ const std::string& type,
+ nfc_card_emulation_category_type_e category,
+ bool* is_activated_handler);
common::PlatformResult RegisterAID(
- const char* aid,
+ const std::string& type,
+ const std::string& aid,
nfc_card_emulation_category_type_e category);
common::PlatformResult UnregisterAID(
- const char* aid,
+ const std::string& type,
+ const std::string& aid,
nfc_card_emulation_category_type_e category);
void GetAIDsForCategory(
+ const std::string& type,
nfc_card_emulation_category_type_e category,
const std::function<void(const AIDDataVector&)>& success_cb,
const std::function<void(const common::PlatformResult&)>& error_cb);
native_.call('NFCAdapter_sendHostAPDUResponse', data, callback);
};
-NFCAdapter.prototype.isActivatedHandlerForAID = function(aid) {
+NFCAdapter.prototype.isActivatedHandlerForAID = function(type, aid) {
var args = validator_.validateArgs(arguments, [
+ {
+ name: 'type',
+ type: types_.ENUM,
+ values: type_.getValues(SecureElementType)
+ },
{name: 'aid', type: types_.STRING}
]);
- if (!arguments.length) {
+ if (arguments.length < 2) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var data = {
+ type: args.type,
aid: args.aid
};
return native_.getResultObject(result);
};
-NFCAdapter.prototype.isActivatedHandlerForCategory = function(category) {
- var args = validator_.validateArgs(arguments, [
- {name: 'category', type: types_.ENUM, values: Object.keys(CardEmulationCategoryType)}
- ]);
+NFCAdapter.prototype.isActivatedHandlerForCategory = function(type, category) {
+ var args = validator_.validateArgs(arguments, [{
+ name: 'type',
+ type: types_.ENUM,
+ values: type_.getValues(SecureElementType)
+ }, {
+ name: 'category',
+ type: types_.ENUM,
+ values: Object.keys(CardEmulationCategoryType)
+ }]);
- if (!arguments.length) {
+ if (arguments.length < 2) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var data = {
+ type: args.type,
category: args.category
};
return native_.getResultObject(result);
};
-NFCAdapter.prototype.registerAID = function(aid, category) {
- var args = validator_.validateArgs(arguments, [
- {name: 'aid', type: types_.STRING},
- {name: 'category', type: types_.ENUM, values: Object.keys(CardEmulationCategoryType)}
- ]);
-
- if (arguments.length < 2 || !type_.isString(arguments[0])) {
+NFCAdapter.prototype.registerAID = function(type, aid, category) {
+ var args = validator_.validateArgs(arguments, [{
+ name: 'type',
+ type: types_.ENUM,
+ values: type_.getValues(SecureElementType)
+ }, {
+ name: 'aid',
+ type: types_.STRING
+ }, {
+ name: 'category',
+ type: types_.ENUM,
+ values: Object.keys(CardEmulationCategoryType)
+ }]);
+
+ if (arguments.length < 3 || !type_.isString(arguments[0])) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var data = {
+ type: args.type,
aid: args.aid,
category: args.category
};
}
};
-NFCAdapter.prototype.unregisterAID = function(aid, category) {
+NFCAdapter.prototype.unregisterAID = function(type, aid, category) {
var args = validator_.validateArgs(arguments, [
+ {
+ name: 'type',
+ type: types_.ENUM,
+ values: type_.getValues(SecureElementType)
+ },
{name: 'aid', type: types_.STRING},
{name: 'category', type: types_.ENUM, values: Object.keys(CardEmulationCategoryType)}
]);
- if (arguments.length < 2 || !type_.isString(arguments[0])) {
+ if (arguments.length < 3 || !type_.isString(arguments[0])) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var data = {
+ type: args.type,
aid: args.aid,
category: args.category
};
});
}
-NFCAdapter.prototype.getAIDsForCategory = function(category, successCallback, errorCallback) {
- var args = validator_.validateArgs(arguments, [
- {name: 'category', type: types_.ENUM, values: Object.keys(CardEmulationCategoryType)},
- {name: 'successCallback', type: types_.FUNCTION},
- {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
- ]);
-
- if (arguments.length < 2) {
+NFCAdapter.prototype.getAIDsForCategory = function(type, category, successCallback, errorCallback) {
+ var args = validator_.validateArgs(arguments, [{
+ name: 'type',
+ type: types_.ENUM,
+ values: type_.getValues(SecureElementType)
+ }, {
+ name: 'category',
+ type: types_.ENUM,
+ values: Object.keys(CardEmulationCategoryType)
+ }, {
+ name: 'successCallback',
+ type: types_.FUNCTION
+ }, {
+ name: 'errorCallback',
+ type: types_.FUNCTION,
+ optional: true,
+ nullable: true
+ }]);
+
+ if (arguments.length < 3) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var data = {
+ type: args.type,
category: args.category
};
console.log('Current result: ' + result);
- var result_array = new Object();
+ var result_array = {};
for (var i in result.result) {
var current = result.result[i];
var keys = Object.keys(current);
void NFCInstance::IsActivatedHandlerForAID(const picojson::value& args,
picojson::object& out) {
LoggerD("Entered");
+ CHECK_EXIST(args, JSON_TYPE, out);
CHECK_EXIST(args, JSON_AID, out);
- const char* aid = args.get(JSON_AID).get<std::string>().c_str();
+ const std::string& aid = args.get(JSON_AID).get<std::string>();
bool is_activated_handler = false;
PlatformResult result = NFCAdapter::GetInstance()->IsActivatedHandlerForAID(
- aid, &is_activated_handler);
+ args.get(JSON_TYPE).get<std::string>(),
+ aid,
+ &is_activated_handler);
if (result.IsSuccess())
ReportSuccess(picojson::value(is_activated_handler), out);
else
void NFCInstance::IsActivatedHandlerForCategory(const picojson::value& args,
picojson::object& out) {
LoggerD("Entered");
+ CHECK_EXIST(args, JSON_TYPE, out);
CHECK_EXIST(args, JSON_CATEGORY, out);
nfc_card_emulation_category_type_e category =
bool is_activated_handler = false;
PlatformResult result =
- NFCAdapter::GetInstance()->IsActivatedHandlerForCategory(category,
+ NFCAdapter::GetInstance()->IsActivatedHandlerForCategory(
+ args.get(JSON_TYPE).get<std::string>(),
+ category,
&is_activated_handler);
if (result.IsSuccess())
ReportSuccess(picojson::value(is_activated_handler), out);
void NFCInstance::RegisterAID(const picojson::value& args,
picojson::object& out) {
LoggerD("Entered");
+ CHECK_EXIST(args, JSON_TYPE, out);
CHECK_EXIST(args, JSON_AID, out);
CHECK_EXIST(args, JSON_CATEGORY, out);
- const char* aid = args.get(JSON_AID).get<std::string>().c_str();
nfc_card_emulation_category_type_e category =
NFCUtil::StringToCategory(args.get(JSON_CATEGORY).get<std::string>());
- PlatformResult result = NFCAdapter::GetInstance()->RegisterAID(aid, category);
+ PlatformResult result = NFCAdapter::GetInstance()->RegisterAID(
+ args.get(JSON_TYPE).get<std::string>(),
+ args.get(JSON_AID).get<std::string>(),
+ category);
if (result.IsSuccess())
ReportSuccess(out);
else
void NFCInstance::UnregisterAID(const picojson::value& args,
picojson::object& out) {
LoggerD("Entered");
+ CHECK_EXIST(args, JSON_TYPE, out);
CHECK_EXIST(args, JSON_AID, out);
CHECK_EXIST(args, JSON_CATEGORY, out);
- const char* aid = args.get(JSON_AID).get<std::string>().c_str();
nfc_card_emulation_category_type_e category =
NFCUtil::StringToCategory(args.get(JSON_CATEGORY).get<std::string>());
PlatformResult result =
- NFCAdapter::GetInstance()->UnregisterAID(aid, category);
+ NFCAdapter::GetInstance()->UnregisterAID(
+ args.get(JSON_TYPE).get<std::string>(),
+ args.get(JSON_AID).get<std::string>(),
+ category);
if (result.IsSuccess())
ReportSuccess(out);
else
void NFCInstance::GetAIDsForCategory(const picojson::value& args,
picojson::object& out) {
LoggerD("Entered");
+ CHECK_EXIST(args, JSON_TYPE, out);
CHECK_EXIST(args, JSON_CATEGORY, out);
+ const std::string& type = args.get(JSON_TYPE).get<std::string>();
nfc_card_emulation_category_type_e required_category =
NFCUtil::StringToCategory(args.get(JSON_CATEGORY).get<std::string>());
const double& callback_id = args.get(JSON_CALLBACK_ID).get<double>();
common::TaskQueue::GetInstance().Async(
std::bind(&NFCAdapter::GetAIDsForCategory, NFCAdapter::GetInstance(),
- required_category, success_cb, error_cb));
+ type, required_category, success_cb, error_cb));
}
} // namespace nfc