From 318471896dafc1a392ab8a4404ae3ef743bdf010 Mon Sep 17 00:00:00 2001 From: Sooraj Sasindran Date: Tue, 9 Jul 2019 15:12:28 -0700 Subject: [PATCH] Send error if ONS is not available Send error for data switch api if ONS is not available Bug: 136294842 Test: regression test Change-Id: If844939c0936729e4487b6e4f75cd58d28195718 --- .../android/telephony/TelephonyManager.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 758cd286ac1b6..6f60d334974d4 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -10788,7 +10788,6 @@ public class TelephonyManager { * @param callback Callback will be triggered once it succeeds or failed. * See {@link TelephonyManager.SetOpportunisticSubscriptionResult} * for more details. Pass null if don't care about the result. - * */ public void setPreferredOpportunisticDataSubscription(int subId, boolean needValidation, @Nullable @CallbackExecutor Executor executor, @Nullable Consumer callback) { @@ -10796,6 +10795,12 @@ public class TelephonyManager { try { IOns iOpportunisticNetworkService = getIOns(); if (iOpportunisticNetworkService == null) { + if (executor == null || callback == null) { + return; + } + Binder.withCleanCallingIdentity(() -> executor.execute(() -> { + callback.accept(SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); + })); return; } ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() { @@ -10877,9 +10882,16 @@ public class TelephonyManager { if (executor == null || callback == null) { return; } - Binder.withCleanCallingIdentity(() -> executor.execute(() -> { - callback.accept(UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); - })); + if (iOpportunisticNetworkService == null) { + /* Todo passing unknown due to lack of good error codes */ + Binder.withCleanCallingIdentity(() -> executor.execute(() -> { + callback.accept(UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE); + })); + } else { + Binder.withCleanCallingIdentity(() -> executor.execute(() -> { + callback.accept(UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + })); + } return; } IUpdateAvailableNetworksCallback callbackStub =