From d9bbd44bf31a09c013fadd9d5a0dfae65dc54a3d Mon Sep 17 00:00:00 2001 From: arunvoddu Date: Tue, 15 Nov 2022 08:39:26 +0000 Subject: [PATCH] HAL changes to PrimaryImei feature Bug: 184001777 Test: Build successfully Change-Id: I54c35d9bebd32180583241bfba4d2fd93f85381d --- .../hardware/radio/modem/IRadioModem.aidl | 4 ++ .../radio/modem/IRadioModemResponse.aidl | 4 ++ .../hardware/radio/modem/ImeiInfo.aidl | 45 +++++++++++++++ .../hardware/radio/modem/IRadioModem.aidl | 10 ++++ .../radio/modem/IRadioModemResponse.aidl | 19 +++++++ .../hardware/radio/modem/ImeiInfo.aidl | 55 +++++++++++++++++++ .../include/libradiocompat/RadioModem.h | 1 + .../libradiocompat/modem/RadioModem.cpp | 9 ++- radio/aidl/vts/radio_modem_response.cpp | 7 +++ radio/aidl/vts/radio_modem_test.cpp | 19 +++++++ radio/aidl/vts/radio_modem_utils.h | 4 ++ 11 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ImeiInfo.aidl create mode 100644 radio/aidl/android/hardware/radio/modem/ImeiInfo.aidl diff --git a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModem.aidl b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModem.aidl index 74dc39d99a..8546be789b 100644 --- a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModem.aidl +++ b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModem.aidl @@ -36,6 +36,9 @@ package android.hardware.radio.modem; interface IRadioModem { oneway void enableModem(in int serial, in boolean on); oneway void getBasebandVersion(in int serial); + /** + * @deprecated use getImei(int serial) + */ oneway void getDeviceIdentity(in int serial); oneway void getHardwareConfig(in int serial); oneway void getModemActivityInfo(in int serial); @@ -60,4 +63,5 @@ interface IRadioModem { oneway void setRadioCapability(in int serial, in android.hardware.radio.modem.RadioCapability rc); oneway void setRadioPower(in int serial, in boolean powerOn, in boolean forEmergencyCall, in boolean preferredForEmergencyCall); oneway void setResponseFunctions(in android.hardware.radio.modem.IRadioModemResponse radioModemResponse, in android.hardware.radio.modem.IRadioModemIndication radioModemIndication); + oneway void getImei(in int serial); } diff --git a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModemResponse.aidl b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModemResponse.aidl index af8bbe1282..5955439666 100644 --- a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModemResponse.aidl +++ b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/IRadioModemResponse.aidl @@ -37,6 +37,9 @@ interface IRadioModemResponse { oneway void acknowledgeRequest(in int serial); oneway void enableModemResponse(in android.hardware.radio.RadioResponseInfo info); oneway void getBasebandVersionResponse(in android.hardware.radio.RadioResponseInfo info, in String version); + /** + * @deprecated use getImeiResponse(RadioResponseInfo responseInfo, ImeiInfo imeiInfo) + */ oneway void getDeviceIdentityResponse(in android.hardware.radio.RadioResponseInfo info, in String imei, in String imeisv, in String esn, in String meid); oneway void getHardwareConfigResponse(in android.hardware.radio.RadioResponseInfo info, in android.hardware.radio.modem.HardwareConfig[] config); oneway void getModemActivityInfoResponse(in android.hardware.radio.RadioResponseInfo info, in android.hardware.radio.modem.ActivityStatsInfo activityInfo); @@ -59,4 +62,5 @@ interface IRadioModemResponse { oneway void sendDeviceStateResponse(in android.hardware.radio.RadioResponseInfo info); oneway void setRadioCapabilityResponse(in android.hardware.radio.RadioResponseInfo info, in android.hardware.radio.modem.RadioCapability rc); oneway void setRadioPowerResponse(in android.hardware.radio.RadioResponseInfo info); + oneway void getImeiResponse(in android.hardware.radio.RadioResponseInfo responseInfo, in @nullable android.hardware.radio.modem.ImeiInfo imeiInfo); } diff --git a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ImeiInfo.aidl b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ImeiInfo.aidl new file mode 100644 index 0000000000..dda706258b --- /dev/null +++ b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ImeiInfo.aidl @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.radio.modem; +@JavaDerive(toString=true) @VintfStability +parcelable ImeiInfo { + @Backing(type="int") @VintfStability + enum ImeiType { + PRIMARY = 1, + SECONDARY = 2, + } + ImeiType type; + String imei; + String svn; +} \ No newline at end of file diff --git a/radio/aidl/android/hardware/radio/modem/IRadioModem.aidl b/radio/aidl/android/hardware/radio/modem/IRadioModem.aidl index a5d98d3e25..2011c53e13 100644 --- a/radio/aidl/android/hardware/radio/modem/IRadioModem.aidl +++ b/radio/aidl/android/hardware/radio/modem/IRadioModem.aidl @@ -67,6 +67,7 @@ oneway interface IRadioModem { * @param serial Serial number of request. * * Response function is IRadioModemResponse.getDeviceIdentityResponse() + * @deprecated use getImei(int serial) */ void getDeviceIdentity(in int serial); @@ -235,4 +236,13 @@ oneway interface IRadioModem { */ void setResponseFunctions(in IRadioModemResponse radioModemResponse, in IRadioModemIndication radioModemIndication); + + /** + * Request the IMEI associated with the radio. + * + * @param serial : Serial number of request. + * + * Response function is IRadioModemResponse.getImeiResponse() + */ + void getImei(in int serial); } diff --git a/radio/aidl/android/hardware/radio/modem/IRadioModemResponse.aidl b/radio/aidl/android/hardware/radio/modem/IRadioModemResponse.aidl index eca31924fb..fd4bffb659 100644 --- a/radio/aidl/android/hardware/radio/modem/IRadioModemResponse.aidl +++ b/radio/aidl/android/hardware/radio/modem/IRadioModemResponse.aidl @@ -20,6 +20,7 @@ import android.hardware.radio.RadioResponseInfo; import android.hardware.radio.modem.ActivityStatsInfo; import android.hardware.radio.modem.HardwareConfig; import android.hardware.radio.modem.RadioCapability; +import android.hardware.radio.modem.ImeiInfo; /** * Interface declaring response functions to solicited radio requests for modem APIs. @@ -87,6 +88,8 @@ oneway interface IRadioModemResponse { * RadioError:NOT_PROVISIONED * RadioError:NO_RESOURCES * RadioError:CANCELLED + * RadioError:REQUEST_NOT_SUPPORTED + * @deprecated use getImeiResponse(RadioResponseInfo responseInfo, ImeiInfo imeiInfo) */ void getDeviceIdentityResponse(in RadioResponseInfo info, in String imei, in String imeisv, in String esn, in String meid); @@ -250,4 +253,20 @@ oneway interface IRadioModemResponse { * RadioError:NO_RF_CALIBRATION_INFO */ void setRadioPowerResponse(in RadioResponseInfo info); + + /** + * ImeiInfo to encapsulate the IMEI information from modem. When the return error code + * is {@code RadioError:NONE}, {@code imeiInfo} must be non-null, and a valid IMEITYPE, + * IMEI and SVN must be filled in {@code imeiInfo}. When the error code is not + * {@code RadioError:NONE}, {@code imeiInfo} must be {@code null}. + * + * @param responseInfo Response info struct containing response type, serial no. and error + * @param imeiInfo IMEI information + * + * Valid errors returned: + * RadioError:NONE + * RadioError:RADIO_NOT_AVAILABLE + * RadioError:MODEM_ERR + */ + void getImeiResponse(in RadioResponseInfo responseInfo, in @nullable ImeiInfo imeiInfo); } diff --git a/radio/aidl/android/hardware/radio/modem/ImeiInfo.aidl b/radio/aidl/android/hardware/radio/modem/ImeiInfo.aidl new file mode 100644 index 0000000000..2d25bb71c1 --- /dev/null +++ b/radio/aidl/android/hardware/radio/modem/ImeiInfo.aidl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.radio.modem; + +/** + * ImeiInfo to encapsulate the IMEI information from modem + */ + +@VintfStability +@JavaDerive(toString=true) +parcelable ImeiInfo { + + @VintfStability + @Backing(type="int") + /** + * ImeiType enum is used identify the IMEI as primary or secondary as mentioned in GSMA TS.37 + */ + enum ImeiType { + /** + * This is the primary IMEI of the device as mentioned in the GSMA TS.37. In a multi-SIM + * device the modem must set one IMEI with this type as mentioned in GSMA TS37_2.2_REQ_8. + * A single SIM with one IMEI must by default set that IMEI with this type. + */ + PRIMARY = 1, + /** This is not the primary IMEI of the device */ + SECONDARY = 2, + } + + /** Primary or secondary IMEI as mentioned in GSMA spec TS.37 */ + ImeiType type; + /** + * IMEI value, see 3gpp spec 23.003 section 6. Note: This primary IMEI mapping must be + * permanent throughout the lifetime of the device irrespective of the factory data reset, + * SIM activations or swaps. + */ + String imei; + /** + * IMEI software version, see 3gpp spec 23.003 section 6. + */ + String svn; +} \ No newline at end of file diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h index beb1fb0b49..54bedd8141 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h @@ -26,6 +26,7 @@ class RadioModem : public RadioCompatBase, ::ndk::ScopedAStatus enableModem(int32_t serial, bool on) override; ::ndk::ScopedAStatus getBasebandVersion(int32_t serial) override; ::ndk::ScopedAStatus getDeviceIdentity(int32_t serial) override; + ::ndk::ScopedAStatus getImei(int32_t serial) override; ::ndk::ScopedAStatus getHardwareConfig(int32_t serial) override; ::ndk::ScopedAStatus getModemActivityInfo(int32_t serial) override; ::ndk::ScopedAStatus getModemStackStatus(int32_t serial) override; diff --git a/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp b/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp index d28b94041b..f088b10b19 100644 --- a/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp +++ b/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp @@ -15,7 +15,7 @@ */ #include - +#include "commonStructs.h" #include "debug.h" #include "structs.h" @@ -49,6 +49,13 @@ ScopedAStatus RadioModem::getDeviceIdentity(int32_t serial) { return ok(); } +ScopedAStatus RadioModem::getImei(int32_t serial) { + LOG_CALL << serial; + LOG(ERROR) << " getImei is unsupported by HIDL HALs"; + respond()->getImeiResponse(notSupported(serial), {}); + return ok(); +} + ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) { LOG_CALL << serial; mHal1_5->getHardwareConfig(serial); diff --git a/radio/aidl/vts/radio_modem_response.cpp b/radio/aidl/vts/radio_modem_response.cpp index 20b44c5831..050b2c838f 100644 --- a/radio/aidl/vts/radio_modem_response.cpp +++ b/radio/aidl/vts/radio_modem_response.cpp @@ -46,6 +46,13 @@ ndk::ScopedAStatus RadioModemResponse::getDeviceIdentityResponse(const RadioResp return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus RadioModemResponse::getImeiResponse(const RadioResponseInfo& info, + const std::optional& /*imeiInfo*/) { + rspInfo = info; + parent_modem.notify(info.serial); + return ndk::ScopedAStatus::ok(); +} + ndk::ScopedAStatus RadioModemResponse::getHardwareConfigResponse( const RadioResponseInfo& info, const std::vector& /*config*/) { rspInfo = info; diff --git a/radio/aidl/vts/radio_modem_test.cpp b/radio/aidl/vts/radio_modem_test.cpp index f88da13af1..c00b238d8e 100644 --- a/radio/aidl/vts/radio_modem_test.cpp +++ b/radio/aidl/vts/radio_modem_test.cpp @@ -187,6 +187,25 @@ TEST_P(RadioModemTest, getDeviceIdentity) { LOG(DEBUG) << "getDeviceIdentity finished"; } +/* + * Test IRadioModem.getImei() for the response returned. + */ +TEST_P(RadioModemTest, getImei) { + LOG(DEBUG) << "getImei"; + serial = GetRandomSerialNumber(); + + radio_modem->getImei(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::EMPTY_RECORD})); + } + LOG(DEBUG) << "getImei finished"; +} + /* * Test IRadioModem.nvReadItem() for the response returned. */ diff --git a/radio/aidl/vts/radio_modem_utils.h b/radio/aidl/vts/radio_modem_utils.h index 49e1891212..d2f5a104bc 100644 --- a/radio/aidl/vts/radio_modem_utils.h +++ b/radio/aidl/vts/radio_modem_utils.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "radio_aidl_hal_utils.h" @@ -52,6 +53,9 @@ class RadioModemResponse : public BnRadioModemResponse { const std::string& esn, const std::string& meid) override; + virtual ndk::ScopedAStatus getImeiResponse(const RadioResponseInfo& info, + const std::optional& config) override; + virtual ndk::ScopedAStatus getHardwareConfigResponse( const RadioResponseInfo& info, const std::vector& config) override;