Revert "ipa: hal: Control Version 1.1"
This reverts commit deaec666b404493f32d6d7301d90230c028c2e58.
Change-Id: Ie0a6803ddf12cf2dfe19700819a72f4fbbb14e93
diff --git a/hal/Android.bp b/hal/Android.bp
index 1c52dcd..f7559b2 100644
--- a/hal/Android.bp
+++ b/hal/Android.bp
@@ -22,7 +22,6 @@
"libhardware",
"android.hardware.tetheroffload.config@1.0",
"android.hardware.tetheroffload.control@1.0",
- "android.hardware.tetheroffload.control@1.1",
],
export_include_dirs: ["inc"],
vendor: true,
diff --git a/hal/inc/CtUpdateAmbassador.h b/hal/inc/CtUpdateAmbassador.h
index ef4c5ee..d4890f3 100644
--- a/hal/inc/CtUpdateAmbassador.h
+++ b/hal/inc/CtUpdateAmbassador.h
@@ -32,12 +32,13 @@
#include <hidl/HidlTransportSupport.h>
/* HIDL Includes */
-#include <android/hardware/tetheroffload/control/1.1/ITetheringOffloadCallback.h>
+#include <android/hardware/tetheroffload/control/1.0/ITetheringOffloadCallback.h>
/* Internal Includes */
#include "IOffloadManager.h"
/* Namespace pollution avoidance */
+using ::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback;
using ::android::hardware::tetheroffload::control::V1_0::NetworkProtocol;
using HALIpAddrPortPair = ::android::hardware::tetheroffload::control::V1_0::IPv4AddrPortPair;
using HALNatTimeoutUpdate = ::android::hardware::tetheroffload::control::V1_0::NatTimeoutUpdate;
@@ -49,13 +50,13 @@
class CtUpdateAmbassador : public IOffloadManager::ConntrackTimeoutUpdater {
public:
- CtUpdateAmbassador(const ::android::sp<::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback>& /* cb */);
+ CtUpdateAmbassador(const ::android::sp<ITetheringOffloadCallback>& /* cb */);
/* ------------------- CONNTRACK TIMEOUT UPDATER ------------------------ */
void updateTimeout(IpaNatTimeoutUpdate /* update */);
private:
static bool translate(IpaNatTimeoutUpdate /* in */, HALNatTimeoutUpdate& /* out */);
static bool translate(IpaIpAddrPortPair /* in */, HALIpAddrPortPair& /* out */);
static bool L4ToNetwork(IpaL4Protocol /* in */, NetworkProtocol& /* out */);
- const ::android::sp<::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback>& mFramework;
+ const ::android::sp<ITetheringOffloadCallback>& mFramework;
}; /* CtUpdateAmbassador */
#endif /* _CT_UPDATE_AMBASSADOR_H_ */
\ No newline at end of file
diff --git a/hal/inc/HAL.h b/hal/inc/HAL.h
index cbabb1b..92ec135 100644
--- a/hal/inc/HAL.h
+++ b/hal/inc/HAL.h
@@ -31,7 +31,7 @@
/* HIDL Includes */
#include <android/hardware/tetheroffload/config/1.0/IOffloadConfig.h>
-#include <android/hardware/tetheroffload/control/1.1/IOffloadControl.h>
+#include <android/hardware/tetheroffload/control/1.0/IOffloadControl.h>
#include <hidl/HidlTransportSupport.h>
/* External Includes */
@@ -59,11 +59,10 @@
using ::std::string;
using ::std::vector;
-using namespace android::hardware::tetheroffload::control;
-using ::android::sp;
using ::android::hardware::tetheroffload::config::V1_0::IOffloadConfig;
-using ::android::hardware::tetheroffload::control::V1_1::IOffloadControl;
-using ::android::hardware::tetheroffload::control::V1_1::ITetheringOffloadCallback;
+using ::android::hardware::tetheroffload::control::V1_0::IOffloadControl;
+
+using ::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback;
#define KERNEL_PAGE 4096
@@ -132,9 +131,9 @@
const hidl_handle& /* fd2 */,
setHandles_cb /* hidl_cb */);
- /* IOffloadControl 1.0 */
+ /* IOffloadControl */
Return<void> initOffload(
- const ::android::sp<::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback>& /* cb */,
+ const ::android::sp<ITetheringOffloadCallback>& /* cb */,
initOffload_cb /* hidl_cb */);
Return<void> stopOffload(
stopOffload_cb /* hidl_cb */);
@@ -162,12 +161,6 @@
const hidl_string& /* iface */,
const hidl_string& /* prefix */,
removeDownstream_cb /* hidl_cb */);
- /* IOffloadControl 1.1 */
- Return<void> setDataWarningAndLimit(
- const hidl_string& /* upstream */,
- uint64_t /* warningBytes */,
- uint64_t /* limitBytes */,
- setDataWarningAndLimit_cb /* hidl_cb */);
private:
typedef struct BoolResult {
@@ -200,8 +193,7 @@
hidl_handle mHandle1;
hidl_handle mHandle2;
LocalLogBuffer mLogs;
- android::sp<V1_0::ITetheringOffloadCallback> mCb;
- android::sp<V1_1::ITetheringOffloadCallback> mCb_1_1;
+ ::android::sp<ITetheringOffloadCallback> mCb;
IpaEventRelay *mCbIpa;
CtUpdateAmbassador *mCbCt;
}; /* HAL */
diff --git a/hal/inc/IOffloadManager.h b/hal/inc/IOffloadManager.h
index 14edffd..6a357b3 100644
--- a/hal/inc/IOffloadManager.h
+++ b/hal/inc/IOffloadManager.h
@@ -120,12 +120,6 @@
* tether interface pairs when this callback is called.
*/
virtual void onLimitReached(){}
- /**
- * Called when the warning set via setQuota has expired. It is expected
- * that limit has not been reached yet.
- *
- */
- virtual void onWarningReached(){}
}; /* IpaEventListener */
/**
@@ -333,34 +327,6 @@
*/
virtual RET setQuota(const char* /* upstream */, uint64_t /* limit */) = 0;
/**
- * This api replaces setQuota.
- *
- * Instruct hardware to stop forwarding traffic and send a callback after
- * warning/limit bytes have been transferred in either direction on this upstream
- * interface.
- *
- * Note that when one of the quota bytes is reached, the other one is still considered valid
- * unless this method is called again with the same interface.
- *
- * @param upstream Upstream interface name that the limit should apply to
- * @param warningBytes The quota of warning, defined as the number of bytes, starting from
- * zero and counting from now.
- * @param limitBytes The quota of limit, defined as the number of bytes, starting from zero
- * and counting from now.
- *
- * @return SUCCESS If the limit was successfully applied
- * SUCCESS_OPTIMIZED If the limit was sufficiently high to be
- * interpreted as "no quota".
- * FAIL_HARDWARE If the limit was rejected by the hardware
- * FAIL_UNSUPPORTED If metering is not supported on this interface
- * FAIL_TRY_AGAIN If this upstream has not been previously
- * configured to allow offload
- * (via setUpstreamParameters)
- */
- virtual RET setQuotaWarning(const char* /* upstream */,
- uint64_t /* warningBytes */,
- uint64_t /* limitBytes */) = 0;
- /**
* Query for statistics counters in hardware.
*
* This returns an aggregate of all hardware accelerated traffic which
diff --git a/hal/inc/IpaEventRelay.h b/hal/inc/IpaEventRelay.h
index a426b79..4541510 100644
--- a/hal/inc/IpaEventRelay.h
+++ b/hal/inc/IpaEventRelay.h
@@ -32,32 +32,24 @@
#include <hidl/HidlTransportSupport.h>
/* HIDL Includes */
-#include <android/hardware/tetheroffload/control/1.1/ITetheringOffloadCallback.h>
+#include <android/hardware/tetheroffload/control/1.0/ITetheringOffloadCallback.h>
/* Internal Includes */
#include "IOffloadManager.h"
/* Namespace pollution avoidance */
-using namespace android::hardware::tetheroffload::control;
-using ::android::hardware::tetheroffload::control::V1_1::OffloadCallbackEvent;
+using ::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback;
+
class IpaEventRelay : public IOffloadManager::IpaEventListener {
public:
- IpaEventRelay(const ::android::sp<V1_0::ITetheringOffloadCallback>& /* 1.0 cb */,
- const ::android::sp<V1_1::ITetheringOffloadCallback>& /* 1.1 cb */);
+ IpaEventRelay(const ::android::sp<ITetheringOffloadCallback>& /* cb */);
/* ----------------------- IPA EVENT LISTENER --------------------------- */
void onOffloadStarted();
void onOffloadStopped(StoppedReason /* reason */);
void onOffloadSupportAvailable();
void onLimitReached();
- void onWarningReached();
private:
- const ::android::sp<V1_0::ITetheringOffloadCallback>& mFramework;
- const ::android::sp<V1_1::ITetheringOffloadCallback>& mFramework_1_1;
-
- static const int V1_0 = 0;
- static const int V1_1 = 1;
-
- void sendEvent(OffloadCallbackEvent, int /* version */);
+ const ::android::sp<ITetheringOffloadCallback>& mFramework;
}; /* IpaEventRelay */
#endif /* _IPA_EVENT_RELAY_H_ */
\ No newline at end of file
diff --git a/hal/src/CtUpdateAmbassador.cpp b/hal/src/CtUpdateAmbassador.cpp
index 2ae10f8..eba6b93 100644
--- a/hal/src/CtUpdateAmbassador.cpp
+++ b/hal/src/CtUpdateAmbassador.cpp
@@ -36,7 +36,7 @@
#include <cutils/log.h>
/* HIDL Includes */
-#include <android/hardware/tetheroffload/control/1.1/ITetheringOffloadCallback.h>
+#include <android/hardware/tetheroffload/control/1.0/ITetheringOffloadCallback.h>
/* Internal Includes */
#include "CtUpdateAmbassador.h"
diff --git a/hal/src/HAL.cpp b/hal/src/HAL.cpp
index a0f3120..f18767a 100644
--- a/hal/src/HAL.cpp
+++ b/hal/src/HAL.cpp
@@ -60,6 +60,7 @@
using ::std::map;
using ::std::vector;
+
/* ------------------------------ PUBLIC ------------------------------------ */
Return<::android::sp<HAL>> HAL::makeIPAHAL(int version, IOffloadManager* mgr) {
android::hardware::ProcessState::initWithMmapSize((size_t)(2 * KERNEL_PAGE));
@@ -81,7 +82,6 @@
HAL::HAL(IOffloadManager* mgr) : mLogs("HAL Function Calls", 50) {
mIPA = mgr;
mCb.clear();
- mCb_1_1.clear();
mCbIpa = nullptr;
mCbCt = nullptr;
} /* HAL */
@@ -180,7 +180,7 @@
void HAL::registerIpaCb() {
if (isInitialized() && mCbIpa == nullptr) {
LocalLogBuffer::FunctionLog fl("registerEventListener");
- mCbIpa = new IpaEventRelay(mCb, mCb_1_1);
+ mCbIpa = new IpaEventRelay(mCb);
mIPA->registerEventListener(mCbIpa);
mLogs.addLog(fl);
} else {
@@ -193,8 +193,6 @@
void HAL::registerCtCb() {
if (isInitialized() && mCbCt == nullptr) {
LocalLogBuffer::FunctionLog fl("registerCtTimeoutUpdater");
- // We can allways use the 1.0 callback here since it is always guarenteed to
- // be non-nullptr if any version is created.
mCbCt = new CtUpdateAmbassador(mCb);
mIPA->registerCtTimeoutUpdater(mCbCt);
mLogs.addLog(fl);
@@ -248,7 +246,6 @@
} /* clearHandles */
bool HAL::isInitialized() {
- // Only have to check 1.0 Callback since it will always be created.
return mCb.get() != nullptr;
} /* isInitialized */
@@ -331,7 +328,7 @@
/* -------------------------- IOffloadControl ------------------------------- */
Return<void> HAL::initOffload
(
- const ::android::sp<V1_0::ITetheringOffloadCallback>& cb,
+ const ::android::sp<ITetheringOffloadCallback>& cb,
initOffload_cb hidl_cb
) {
LocalLogBuffer::FunctionLog fl(__func__);
@@ -344,21 +341,12 @@
} else {
/* Should storing the CB be a function? */
mCb = cb;
- mCb_1_1 = V1_1::ITetheringOffloadCallback::castFrom(cb).withDefault(nullptr);
- // As long as 1 callback version is supported we are fine.
- if (mCb == nullptr && mCb_1_1 == nullptr) {
- BoolResult res = makeInputCheckFailure("callbacks are nullptr");
- hidl_cb(res.success, res.errMsg);
- fl.setResult(res.success, res.errMsg);
- mLogs.addLog(fl);
- } else {
registerEventListeners();
BoolResult res = ipaResultToBoolResult(RET::SUCCESS);
hidl_cb(res.success, res.errMsg);
fl.setResult(res.success, res.errMsg);
mLogs.addLog(fl);
}
- }
return Void();
} /* initOffload */
@@ -377,7 +365,6 @@
} else {
/* Should removing the CB be a function? */
mCb.clear();
- mCb_1_1.clear();
unregisterEventListeners();
RET ipaReturn = mIPA->stopAllOffload();
@@ -425,7 +412,7 @@
memset(&res,0,sizeof(BoolResult));
if (!isInitialized()) {
- res = makeInputCheckFailure("Not initialized");
+ BoolResult res = makeInputCheckFailure("Not initialized");
} else if(prefixesStr.size() < 1) {
res = ipaResultToBoolResult(RET::FAIL_INPUT_CHECK);
} else if (!parser.add(prefixesStr)) {
@@ -574,7 +561,7 @@
PrefixParser prefixParser;
if (!isInitialized()) {
- BoolResult res = makeInputCheckFailure("Not initialized (addDownstream)");
+ BoolResult res = makeInputCheckFailure("Not initialized (setUpstreamParameters)");
hidl_cb(res.success, res.errMsg);
fl.setResult(res.success, res.errMsg);
}
@@ -608,7 +595,7 @@
PrefixParser prefixParser;
if (!isInitialized()) {
- BoolResult res = makeInputCheckFailure("Not initialized (removeDownstream)");
+ BoolResult res = makeInputCheckFailure("Not initialized (setUpstreamParameters)");
hidl_cb(res.success, res.errMsg);
fl.setResult(res.success, res.errMsg);
}
@@ -628,34 +615,3 @@
mLogs.addLog(fl);
return Void();
} /* removeDownstream */
-
-Return<void> HAL::setDataWarningAndLimit
-(
- const hidl_string& upstream,
- uint64_t warningBytes,
- uint64_t limitBytes,
- setDataWarningAndLimit_cb hidl_cb
-) {
- LocalLogBuffer::FunctionLog fl(__func__);
- fl.addArg("upstream", upstream);
- fl.addArg("warningBytes", warningBytes);
- fl.addArg("limitBytes", limitBytes);
-
- // Can only be called from HAL 1.1 so no check here is needed.
- if (!isInitialized()) {
- BoolResult res = makeInputCheckFailure("Not initialized (setDataWarningAndLimit)");
- hidl_cb(res.success, res.errMsg);
- fl.setResult(res.success, res.errMsg);
- } else {
- RET ipaReturn = mIPA->setQuotaWarning(upstream.c_str(), limitBytes, warningBytes);
- if(ipaReturn == RET::FAIL_TRY_AGAIN) {
- ipaReturn = RET::SUCCESS;
- }
- BoolResult res = ipaResultToBoolResult(ipaReturn);
- hidl_cb(res.success, res.errMsg);
- fl.setResult(res.success, res.errMsg);
- }
-
- mLogs.addLog(fl);
- return Void();
-} /* setDataWarningAndLimit */
diff --git a/hal/src/IpaEventRelay.cpp b/hal/src/IpaEventRelay.cpp
index f0cbd21..137092f 100644
--- a/hal/src/IpaEventRelay.cpp
+++ b/hal/src/IpaEventRelay.cpp
@@ -29,48 +29,28 @@
#define LOG_TAG "IPAHALService/IpaEventRelay"
/* External Includes */
#include <cutils/log.h>
-//#include <hidl/Status.h> //TODO: Might be easier to return Status
/* HIDL Includes */
-#include <android/hardware/tetheroffload/control/1.1/ITetheringOffloadCallback.h>
+#include <android/hardware/tetheroffload/control/1.0/ITetheringOffloadCallback.h>
/* Internal Includes */
#include "IpaEventRelay.h"
/* Namespace pollution avoidance */
-using ::android::hardware::Return;
-// using ::android::hardware::Status;
-using ::android::hardware::tetheroffload::control::V1_1::ITetheringOffloadCallback;
+using ::android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback;
+using ::android::hardware::tetheroffload::control::V1_0::OffloadCallbackEvent;
IpaEventRelay::IpaEventRelay(
- const ::android::sp<V1_0::ITetheringOffloadCallback>& cb,
- const ::android::sp<V1_1::ITetheringOffloadCallback>& cb_1_1) : mFramework(cb), mFramework_1_1(cb_1_1) {
+ const ::android::sp<ITetheringOffloadCallback>& cb) : mFramework(cb) {
} /* IpaEventRelay */
-using OnEventVersion = std::function<Return<void>()>;
-void IpaEventRelay::sendEvent(OffloadCallbackEvent event, int version) {
- // Events need to be sent for the version passed in and all versions defined after that.
- // This ensures all new versions get the correct events, but vrsion where events where not
- // defined do not.
- std::vector<OnEventVersion> getVersion = {
- { [&]() -> Return<void> { return mFramework->onEvent(
- (::android::hardware::tetheroffload::control::V1_0::OffloadCallbackEvent) event); }},
- { [&]() -> Return<void> { return mFramework_1_1->onEvent_1_1(event); }}
- };
-
- for (int i = version; i < getVersion.size(); i++) {
- OnEventVersion func = getVersion[i];
- auto ret = func();
- if (!ret.isOk()) {
- ALOGE("Triggering onEvent CallbackV1_%d failed.", i);
- }
- }
-}
-
void IpaEventRelay::onOffloadStarted() {
ALOGI("onOffloadStarted()");
- sendEvent(OffloadCallbackEvent::OFFLOAD_STARTED, V1_0);
+ auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STARTED);
+ if (!ret.isOk()) {
+ ALOGE("Triggering OffloadStarted Callback failed.");
+ }
} /* onOffloadStarted */
void IpaEventRelay::onOffloadStopped(StoppedReason reason) {
@@ -83,10 +63,16 @@
*/
}
else if ( reason == StoppedReason::ERROR ) {
- sendEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_ERROR, V1_0);
+ auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_ERROR);
+ if (!ret.isOk()) {
+ ALOGE("Triggering OffloadStopped Callback failed.");
+ }
}
else if ( reason == StoppedReason::UNSUPPORTED ) {
- sendEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_UNSUPPORTED, V1_0);
+ auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_UNSUPPORTED);
+ if (!ret.isOk()) {
+ ALOGE("Triggering OffloadStopped Callback failed.");
+ }
}
else {
ALOGE("Unknown stopped reason(%d)", reason);
@@ -95,16 +81,16 @@
void IpaEventRelay::onOffloadSupportAvailable() {
ALOGI("onOffloadSupportAvailable()");
- sendEvent(OffloadCallbackEvent::OFFLOAD_SUPPORT_AVAILABLE, V1_0);
+ auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_SUPPORT_AVAILABLE);
+ if (!ret.isOk()) {
+ ALOGE("Triggering OffloadSupportAvailable Callback failed.");
+ }
} /* onOffloadSupportAvailable */
void IpaEventRelay::onLimitReached() {
ALOGI("onLimitReached()");
- sendEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_LIMIT_REACHED, V1_0);
+ auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_LIMIT_REACHED);
+ if (!ret.isOk()) {
+ ALOGE("Triggering LimitReached Callback failed.");
+ }
} /* onLimitReached */
-
-/** V1_1 API's **/
-void IpaEventRelay::onWarningReached() {
- ALOGI("onWarningReached()");
- sendEvent(OffloadCallbackEvent::OFFLOAD_WARNING_REACHED, V1_1);
-} /* onWarningReached */