Radio Keepalive HAL

This adds support for offloading of keepalive packets
to the radio for reduced power consumption.

Bug: 33277538
Test: none
Change-Id: I8e8a841e25f18afeae07f70024c698efa58263e2
This commit is contained in:
Nathan Harold 2017-05-24 19:42:40 -07:00
parent 37e00854d9
commit 4e2541ecc6
5 changed files with 244 additions and 1 deletions

View file

@ -93,6 +93,82 @@ $(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveRequest)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveRequest.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveRequest
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveStatus)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveStatusCode)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveStatusCode.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveStatusCode
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveType)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveType.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveType
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (NetworkScanRequest)
#
@ -275,6 +351,8 @@ GEN := $(intermediates)/android/hardware/radio/V1_1/IRadioResponse.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IRadioResponse.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
@ -380,6 +458,82 @@ $(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveRequest)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveRequest.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveRequest
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveStatus)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveStatusCode)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveStatusCode.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveStatusCode
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (KeepaliveType)
#
GEN := $(intermediates)/android/hardware/radio/V1_1/KeepaliveType.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
android.hardware.radio@1.1::types.KeepaliveType
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (NetworkScanRequest)
#
@ -562,6 +716,8 @@ GEN := $(intermediates)/android/hardware/radio/V1_1/IRadioResponse.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IRadioResponse.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \

View file

@ -89,4 +89,24 @@ interface IRadio extends @1.0::IRadio {
* Response function is IRadioResponse.stopNetworkScanResponse()
*/
oneway stopNetworkScan(int32_t serial);
/**
* Start a Keepalive session (for IPsec)
*
* @param serial Serial number of request.
* @param keepalive A request structure containing all necessary info to describe a keepalive
*
* Response function is IRadioResponse.startKeepaliveResponse()
*/
oneway startKeepalive(int32_t serial, KeepaliveRequest keepalive);
/**
* Stop an ongoing Keepalive session (for IPsec)
*
* @param serial Serial number of request.
* @param sessionHandle The handle that was provided by IRadioResponse.startKeepaliveResponse
*
* Response function is IRadioResponse.stopKeepaliveResponse()
*/
oneway stopKeepalive(int32_t serial, int32_t sessionHandle);
};

View file

@ -39,4 +39,15 @@ interface IRadioIndication extends @1.0::IRadioIndication{
* @param result Network scan result as NetworkScanResult defined in types.hal
*/
oneway networkScanResult(RadioIndicationType type, NetworkScanResult result);
};
/**
* Indicates a status update for a particular Keepalive session. This must include
* a handle for a previous session and should include a status update regarding the
* state of a keepalive. Unsolicited keepalive status reports should never be
* PENDING as unsolicited status should only be sent when known.
*
* @param type Type of radio indication
* @param status Status information for a Keepalive session
*/
oneway keepaliveStatus(RadioIndicationType type, KeepaliveStatus status);
};

View file

@ -71,4 +71,26 @@ interface IRadioResponse extends @1.0::IRadioResponse {
* RadioError:MODEM_ERR
*/
oneway stopNetworkScanResponse(RadioResponseInfo info);
/**
* @param info Response info struct containing response type, serial no. and error
* @param status Status object containing a new handle and a current status. The
* status returned here may be PENDING to indicate that the radio has not yet
* processed the keepalive request.
*
* Valid errors returned:
* RadioError:NONE
* RadioError:NO_RESOURCES
* RadioError:INVALID_ARGUMENTS
*/
oneway startKeepaliveResponse(RadioResponseInfo info, KeepaliveStatus status);
/**
* @param info Response info struct containing response type, serial no. and error
*
* Valid errors returned:
* RadioError:NONE
* RadioError:INVALID_ARGUMENTS
*/
oneway stopKeepaliveResponse(RadioResponseInfo info);
};

View file

@ -132,6 +132,19 @@ enum ScanStatus : int32_t {
COMPLETE = 2, // The result contains the last part of the scan results
};
enum KeepaliveType : int32_t {
NATT_IPV4 = 0, // Keepalive specified by RFC 3948 Sec. 2.3 using IPv4
NATT_IPV6 = 1, // Keepalive specified by RFC 3948 Sec. 2.3 using IPv6
};
enum KeepaliveStatusCode : int32_t {
ACTIVE, // Keepalive is currently active
INACTIVE, // Keepalive is inactive, which indicates an error
PENDING, // Requested keepalive has not yet been processed by
// the modem. Only allowed in a RESPONSE message to
// a REQUEST
};
struct RadioAccessSpecifier {
RadioAccessNetworks radioAccessNetwork; // The type of network to scan
vec<GeranBands> geranBands; // Valid only if radioAccessNetwork = GERAN
@ -182,3 +195,24 @@ struct ImsiEncryptionInfo {
// identity.
int64_t expirationTime; // date-time in UTC when the key will expire.
};
struct KeepaliveRequest {
KeepaliveType type; // The format of the keepalive packet
vec<uint8_t> sourceAddress; // source address with type = family, in network
// byte order
int32_t sourcePort; // source port if relevant for the given type
// INT_MAX: 0x7FFFFFFF denotes that the field is unused
vec<uint8_t> destinationAddress; // destination address with type = family, in network
// byte order
int32_t destinationPort; // destination if relevant for the given type
// INT_MAX: 0x7FFFFFFF denotes that the field is unused
int32_t maxKeepaliveIntervalMillis; // the max interval between packets, in milliseconds
int32_t cid; // Context ID, returned in setupDataCallResponse
// that uniquely identifies the data call to which
// this keepalive must applied
};
struct KeepaliveStatus {
int32_t sessionHandle; // the sessionHandle provided by the api
KeepaliveStatusCode code; // status for the given keepalive
};