From 1276af44e97de5b56f67481ec9d0b0e110974b34 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Mon, 20 Jan 2020 13:48:36 -0800 Subject: Add setSystemSelectionChannels API Add setSystemSelectionChannels as a SystemApi, connecting to the identically-named HAL method. Fixes: 144595103 Test: manual through the testapp, atest TelephonyManagerTest Change-Id: I52ff09258af772e272937dd137813d0d63c50cb5 Merged-In: I52ff09258af772e272937dd137813d0d63c50cb5 --- api/system-current.txt | 1 + api/test-current.txt | 1 + .../java/android/telephony/TelephonyManager.java | 47 ++++++++++++++++++++++ .../internal/telephony/IBooleanConsumer.aidl | 23 +++++++++++ .../com/android/internal/telephony/ITelephony.aidl | 5 +++ .../android/internal/telephony/RILConstants.java | 1 + 6 files changed, 78 insertions(+) create mode 100644 telephony/java/com/android/internal/telephony/IBooleanConsumer.aidl diff --git a/api/system-current.txt b/api/system-current.txt index f0e167edaa39..b04384c23e2c 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9435,6 +9435,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadioPower(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer); method @Deprecated public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios(); diff --git a/api/test-current.txt b/api/test-current.txt index d0c13724b363..8da35e972426 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3248,6 +3248,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile(); method @Deprecated public void setCarrierTestOverride(String, String, String, String, String, String, String); method public void setCarrierTestOverride(String, String, String, String, String, String, String, String, String); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer); method @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String); field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 76b914555f89..f877395b524a 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -95,6 +95,7 @@ import android.util.Pair; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.CellNetworkScanResult; +import com.android.internal.telephony.IBooleanConsumer; import com.android.internal.telephony.INumberVerificationCallback; import com.android.internal.telephony.IOns; import com.android.internal.telephony.IPhoneSubInfo; @@ -118,6 +119,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.Executor; import java.util.function.Consumer; @@ -12429,6 +12431,51 @@ public class TelephonyManager { return true; } + /** + * Specify which bands modem's background scan must act on. + * If {@code specifiers} is non-empty, the scan will be restricted to the bands specified. + * Otherwise, it scans all bands. + * + * For example, CBRS is only on LTE band 48. By specifying this band, + * modem saves more power. + * + * @param specifiers which bands to scan. + * @param executor The executor to execute the callback on + * @param callback The callback that gets invoked when the radio responds to the request. Called + * with {@code true} if the request succeeded, {@code false} otherwise. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public void setSystemSelectionChannels(@NonNull List specifiers, + @Nullable @CallbackExecutor Executor executor, + @Nullable Consumer callback) { + Objects.requireNonNull(specifiers, "Specifiers must not be null."); + if (callback != null) { + Objects.requireNonNull(executor, "Executor must not be null when" + + " the callback is nonnull"); + } + + IBooleanConsumer aidlConsumer = callback == null ? null : new IBooleanConsumer.Stub() { + @Override + public void accept(boolean result) { + executor.execute(() -> callback.accept(result)); + } + }; + + try { + ITelephony service = getITelephony(); + if (service != null) { + service.setSystemSelectionChannels(specifiers, getSubId(), aidlConsumer); + } + } catch (RemoteException ex) { + if (!isSystemProcess()) { + ex.rethrowAsRuntimeException(); + } + } + } + /** * Verifies whether the input MCC/MNC and MVNO correspond to the current carrier. * diff --git a/telephony/java/com/android/internal/telephony/IBooleanConsumer.aidl b/telephony/java/com/android/internal/telephony/IBooleanConsumer.aidl new file mode 100644 index 000000000000..eb5bedabf15f --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IBooleanConsumer.aidl @@ -0,0 +1,23 @@ +/* + * 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 com.android.internal.telephony; + +// Copies consumer pattern for an operation that requires a boolean result from another process to +// finish. +oneway interface IBooleanConsumer { + void accept(boolean result); +} \ No newline at end of file diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d8339c8deefa..19207aae5268 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -42,6 +42,7 @@ import android.telephony.NetworkScanRequest; import android.telephony.PhoneCapability; import android.telephony.PhoneNumberRange; import android.telephony.RadioAccessFamily; +import android.telephony.RadioAccessSpecifier; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.TelephonyHistogram; @@ -56,6 +57,7 @@ import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.aidl.IImsRegistrationCallback; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.telephony.CellNetworkScanResult; +import com.android.internal.telephony.IBooleanConsumer; import com.android.internal.telephony.IIntegerConsumer; import com.android.internal.telephony.INumberVerificationCallback; import com.android.internal.telephony.OperatorInfo; @@ -2201,6 +2203,9 @@ interface ITelephony { boolean isApnMetered(int apnType, int subId); + oneway void setSystemSelectionChannels(in List specifiers, + int subId, IBooleanConsumer resultCallback); + boolean isMvnoMatched(int subId, int mvnoType, String mvnoMatchData); /** diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 0e0a22eecd28..53ad70a07563 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -491,6 +491,7 @@ public interface RILConstants { int RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG = 207; int RIL_REQUEST_ENABLE_UICC_APPLICATIONS = 208; int RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT = 209; + int RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS = 210; /* Responses begin */ int RIL_RESPONSE_ACKNOWLEDGEMENT = 800; -- cgit v1.2.3-59-g8ed1b From 6c219c886b1c9e1cd92cf20733f840615b1f2bcf Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Thu, 27 Feb 2020 19:12:36 -0800 Subject: Split setSystemSelectionChannels Split method into two parts, one that takes a callback/executor and one that doesn't. Fixes: 148866746 Test: atest TelephonyManagerTest#testSetSystemSelectionChannels Change-Id: Ic5a130e5806b4516caa1a8510214eaf9b2b43b03 Merged-In: Ic5a130e5806b4516caa1a8510214eaf9b2b43b03 --- api/system-current.txt | 3 ++- api/test-current.txt | 3 ++- .../java/android/telephony/TelephonyManager.java | 30 +++++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index b04384c23e2c..a14569e9d4ae 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9435,7 +9435,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadioPower(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int); - method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List); method @Deprecated public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios(); diff --git a/api/test-current.txt b/api/test-current.txt index 8da35e972426..eba52bb6c6e8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3248,7 +3248,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile(); method @Deprecated public void setCarrierTestOverride(String, String, String, String, String, String, String); method public void setCarrierTestOverride(String, String, String, String, String, String, String, String, String); - method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List); method @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String); field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index f877395b524a..293bf094b21d 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -12449,14 +12449,32 @@ public class TelephonyManager { @TestApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull List specifiers, - @Nullable @CallbackExecutor Executor executor, - @Nullable Consumer callback) { + @NonNull @CallbackExecutor Executor executor, + @NonNull Consumer callback) { Objects.requireNonNull(specifiers, "Specifiers must not be null."); - if (callback != null) { - Objects.requireNonNull(executor, "Executor must not be null when" - + " the callback is nonnull"); - } + Objects.requireNonNull(executor, "Executor must not be null."); + Objects.requireNonNull(callback, "Callback must not be null."); + setSystemSelectionChannelsInternal(specifiers, executor, callback); + } + + /** + * Same as {@link #setSystemSelectionChannels(List, Executor, Consumer)}, but to be + * used when the caller does not need feedback on the results of the operation. + * @param specifiers which bands to scan. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public void setSystemSelectionChannels(@NonNull List specifiers) { + Objects.requireNonNull(specifiers, "Specifiers must not be null."); + setSystemSelectionChannelsInternal(specifiers, null, null); + } + + private void setSystemSelectionChannelsInternal(@NonNull List specifiers, + @Nullable @CallbackExecutor Executor executor, + @Nullable Consumer callback) { IBooleanConsumer aidlConsumer = callback == null ? null : new IBooleanConsumer.Stub() { @Override public void accept(boolean result) { -- cgit v1.2.3-59-g8ed1b