Nfc: Change return types for Nfc hal to specified type. am: 51068e0bd3 am: bec5eeba2c

am: c4908b5add

Change-Id: I8cfc53689fff8e526305d6e09a9675ff0e00c302
This commit is contained in:
Ruchi Kandoi
2016-11-29 01:42:10 +00:00
committed by android-build-merger
3 changed files with 49 additions and 39 deletions

View File

@@ -27,72 +27,80 @@ interface INfc {
* NCI initialization - ie accept CORE_RESET and subsequent commands through
* the write() call.
*
* If open() returns 0, the NCI stack will wait for a NfcEvent.OPEN_CPLT
* before continuing.
* If open() returns NfcStatus::OK, the NCI stack will wait for a
* NfcEvent.OPEN_CPLT before continuing.
*
* If open() returns any other value, the NCI stack will stop.
* If open() returns NfcStatus::FAILED, the NCI stack will stop.
*
*/
@entry
@callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"})
open(INfcClientCallback clientCallback) generates (int32_t retval);
open(INfcClientCallback clientCallback) generates (NfcStatus status);
/*
* Performs an NCI write.
*
* This method may queue writes and return immediately. The only
* requirement is that the writes are executed in order.
*
* @return number of bytes written to the NFCC
*/
@callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle",
"controlGranted"})
write(NfcData data) generates (int32_t retval);
write(NfcData data) generates (uint32_t retval);
/*
* coreInitialized() is called after the CORE_INIT_RSP is received from the NFCC.
* At this time, the HAL can do any chip-specific configuration.
* coreInitialized() is called after the CORE_INIT_RSP is received from the
* NFCC. At this time, the HAL can do any chip-specific configuration.
*
* If coreInitialized() returns 0, the NCI stack will wait for a NfcEvent.POST_INIT_CPLT
* before continuing.
* If coreInitialized() returns NfcStatus::OK, the NCI stack will wait for a
* NfcEvent.POST_INIT_CPLT before continuing.
*
* If coreInitialized() returns any other value, the NCI stack will continue
* immediately.
* If coreInitialized() returns NfcStatus::FAILED, the NCI stack will
* continue immediately.
*/
@callflow(next={"write", "prediscover", "close"})
coreInitialized(NfcData data) generates (int32_t retval);
coreInitialized(NfcData data) generates (NfcStatus status);
/*
* prediscover is called every time before starting RF discovery.
* It is a good place to do vendor-specific configuration that must be
* performed every time RF discovery is about to be started.
*
* If prediscover() returns 0, the NCI stack will wait for a NfcEvent.PREDISCOVER_CPLT
* before continuing.
* If prediscover() returns NfcStatus::OK, the NCI stack will wait for a
* NfcEvent.PREDISCOVER_CPLT before continuing.
*
* If prediscover() returns any other value, the NCI stack will start
* If prediscover() returns NfcStatus::FAILED, the NCI stack will start
* RF discovery immediately.
*/
@callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"})
prediscover() generates (int32_t retval);
prediscover() generates (NfcStatus status);
/*
* Close the NFC controller. Should free all resources.
*
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
*/
@exit
close() generates (int32_t retval);
close() generates (NfcStatus status);
/*
* Grant HAL the exclusive control to send NCI commands.
* Called in response to NfcEvent.REQUEST_CONTROL.
* Must only be called when there are no NCI commands pending.
* NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
*
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
*/
@callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"})
controlGranted() generates (int32_t retval);
controlGranted() generates (NfcStatus status);
/*
* Restart controller by power cyle;
* NfcEvent.OPEN_CPLT will notify when operation is complete.
*
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
*/
@callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"})
powerCycle() generates (int32_t retval);
powerCycle() generates (NfcStatus status);
};

View File

@@ -17,34 +17,36 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device) {
}
// Methods from ::android::hardware::nfc::V1_0::INfc follow.
::android::hardware::Return<int32_t> Nfc::open(const sp<INfcClientCallback>& clientCallback) {
::android::hardware::Return<NfcStatus> Nfc::open(const sp<INfcClientCallback>& clientCallback) {
mCallback = clientCallback;
return mDevice->open(mDevice, eventCallback, dataCallback);
int ret = mDevice->open(mDevice, eventCallback, dataCallback);
return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED;
}
::android::hardware::Return<int32_t> Nfc::write(const hidl_vec<uint8_t>& data) {
::android::hardware::Return<uint32_t> Nfc::write(const hidl_vec<uint8_t>& data) {
return mDevice->write(mDevice, data.size(), &data[0]);
}
::android::hardware::Return<int32_t> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) {
::android::hardware::Return<NfcStatus> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) {
hidl_vec<uint8_t> copy = data;
return mDevice->core_initialized(mDevice, &copy[0]);
int ret = mDevice->core_initialized(mDevice, &copy[0]);
return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED;
}
::android::hardware::Return<int32_t> Nfc::prediscover() {
return mDevice->pre_discover(mDevice);
::android::hardware::Return<NfcStatus> Nfc::prediscover() {
return mDevice->pre_discover(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
}
::android::hardware::Return<int32_t> Nfc::close() {
return mDevice->close(mDevice);
::android::hardware::Return<NfcStatus> Nfc::close() {
return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
}
::android::hardware::Return<int32_t> Nfc::controlGranted() {
return mDevice->control_granted(mDevice);
::android::hardware::Return<NfcStatus> Nfc::controlGranted() {
return mDevice->control_granted(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
}
::android::hardware::Return<int32_t> Nfc::powerCycle() {
return mDevice->power_cycle(mDevice);
::android::hardware::Return<NfcStatus> Nfc::powerCycle() {
return mDevice->power_cycle(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
}

View File

@@ -21,13 +21,13 @@ using ::android::sp;
struct Nfc : public INfc {
Nfc(nfc_nci_device_t* device);
::android::hardware::Return<int32_t> open(const sp<INfcClientCallback>& clientCallback) override;
::android::hardware::Return<int32_t> write(const hidl_vec<uint8_t>& data) override;
::android::hardware::Return<int32_t> coreInitialized(const hidl_vec<uint8_t>& data) override;
::android::hardware::Return<int32_t> prediscover() override;
::android::hardware::Return<int32_t> close() override;
::android::hardware::Return<int32_t> controlGranted() override;
::android::hardware::Return<int32_t> powerCycle() override;
::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override;
::android::hardware::Return<uint32_t> write(const hidl_vec<uint8_t>& data) override;
::android::hardware::Return<NfcStatus> coreInitialized(const hidl_vec<uint8_t>& data) override;
::android::hardware::Return<NfcStatus> prediscover() override;
::android::hardware::Return<NfcStatus> close() override;
::android::hardware::Return<NfcStatus> controlGranted() override;
::android::hardware::Return<NfcStatus> powerCycle() override;
static void eventCallback(uint8_t event, uint8_t status) {
if (mCallback != nullptr) {