From 0bacf4f46bc2ba465f81c352f394c12238e8ed14 Mon Sep 17 00:00:00 2001 From: Rambo Wang Date: Mon, 24 May 2021 12:57:49 -0700 Subject: [PATCH] Update javadoc of TM#getDataNetworkType to align with implementation Javadoc of TelephonyManager#getDataNetworkType says if the TelephonyManager object is not created with createForSubscriptionId, then applies to SubscriptionManager#getDefaultDataSubscriptionId(). But the actual implementation applies to SubscriptionManager#getActiveDataSubscriptionId() instead. While they are not always the same (e.g. when opptunistic network is active), the implementation is more accurate than the javadoc. Bug: 144803512 Test: make docs Change-Id: I7db32a9a99dd5d7f7c32b6b33f3d5f7bd09a0e02 --- telephony/java/android/telephony/TelephonyManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 1860ecb7c2747..26cd568d65306 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2932,7 +2932,12 @@ public class TelephonyManager { * currently in use on the device for data transmission. * * If this object has been created with {@link #createForSubscriptionId}, applies to the given - * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()} + * subId. Otherwise, applies to {@link SubscriptionManager#getActiveDataSubscriptionId()}. + * + * Note: Before {@link SubscriptionManager#getActiveDataSubscriptionId()} was introduced in API + * level 30, it was applied to {@link SubscriptionManager#getDefaultDataSubscriptionId()} which + * may be different now from {@link SubscriptionManager#getActiveDataSubscriptionId()}, e.g. + * when opportunistic network is providing cellular internet connection to the user. * *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).