From 6ceef2d6a562e852aff0d51220be8e64853059c6 Mon Sep 17 00:00:00 2001 From: Daniel Bright Date: Fri, 20 Nov 2020 12:04:22 -0800 Subject: [PATCH] Add Radio Interface Capabilities * Introduces a set of capabilities specific for the radio interface that are determined by the vendor and are then surfaced through TelephonyManager. * There are no capabilities yet defined and will come later in S Test: Added cts, ran cts, and telephony tests Bug: 163085807 Change-Id: I56713e05cbd5200baa2a3bc79f7f4b0d580ad2a1 --- .../telephony/RadioInterfaceCapabilities.java | 53 +++++++++++++++++++ .../android/telephony/TelephonyManager.java | 35 ++++++++++++ .../internal/telephony/ITelephony.aidl | 8 +++ .../internal/telephony/RILConstants.java | 1 + 4 files changed, 97 insertions(+) create mode 100644 telephony/java/android/telephony/RadioInterfaceCapabilities.java diff --git a/telephony/java/android/telephony/RadioInterfaceCapabilities.java b/telephony/java/android/telephony/RadioInterfaceCapabilities.java new file mode 100644 index 0000000000000..7c7eb9fbbeb2c --- /dev/null +++ b/telephony/java/android/telephony/RadioInterfaceCapabilities.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020 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.telephony; + +import android.util.ArraySet; + +/** + * Contains the set of supported capabilities that the Radio Interface supports on this device. + * + * @hide + */ +public class RadioInterfaceCapabilities { + + private final ArraySet mSupportedCapabilities; + + + public RadioInterfaceCapabilities() { + mSupportedCapabilities = new ArraySet<>(); + } + + /** + * Marks a capability as supported + * + * @param capabilityName the name of the capability + */ + public void addSupportedCapability( + @TelephonyManager.RadioInterfaceCapability String capabilityName) { + mSupportedCapabilities.add(capabilityName); + } + + /** + * Whether the capability is supported + * + * @param capabilityName the name of the capability + */ + public boolean isSupported(String capabilityName) { + return mSupportedCapabilities.contains(capabilityName); + } +} diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ae2d1ad8d8dc3..73e4f9329b601 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -14209,4 +14209,39 @@ public class TelephonyManager { return Collections.emptyList(); } + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"RADIO_INTERFACE_CAPABILITY_"}, + value = {}) + public @interface RadioInterfaceCapability {} + + /** + * Whether the device supports a given capability on the radio interface. + * + * If the capability is not in the set of radio interface capabilities, false is returned. + * + * @param capability the name of the capability to check for + * @return the availability of the capability + * + * @hide + */ + public boolean isRadioInterfaceCapabilitySupported( + @NonNull @RadioInterfaceCapability String capability) { + try { + if (capability == null) return false; + + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isRadioInterfaceCapabilitySupported(capability); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + if (!isSystemProcess()) { + ex.rethrowAsRuntimeException(); + } + } + return false; + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 3e7defbbd5bdd..267d30cb32092 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2249,4 +2249,12 @@ interface ITelephony { * @return CarrierBandwidth with bandwidth of both primary and secondary carrier. */ CarrierBandwidth getCarrierBandwidth(int subId); + + /** + * Checks whether the device supports the given capability on the radio interface. + * + * @param capability the name of the capability + * @return the availability of the capability + */ + boolean isRadioInterfaceCapabilitySupported(String capability); } diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index a2361a7d34a17..4451314e76462 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -520,6 +520,7 @@ public interface RILConstants { int RIL_REQUEST_START_HANDOVER = 217; int RIL_REQUEST_CANCEL_HANDOVER = 218; int RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS = 219; + int RIL_REQUEST_GET_HAL_DEVICE_CAPABILITIES = 220; /* Responses begin */ int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;