aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaoma <haoma@google.com>2024-01-08 12:47:24 +0800
committerhaoma <haoma@google.com>2024-01-08 12:47:24 +0800
commitfb49c6fe937bf94c11f3bff2151a6e53b3bfec42 (patch)
tree925544b2947c1ad8bf86528ff0652cdef9c17949
parent66ee7893c2b3f09f35644c3d189f05e6830c125c (diff)
downloadmobly-bundled-snippets-fb49c6fe937bf94c11f3bff2151a6e53b3bfec42.tar.gz
Update format to comply w/ G3, and change var type back to Integer for String getLine1Number(@RpcDefault("0") Integer simSlot) and int getTelephonyCallState(@RpcDefault("0") Integer simSlot)
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
index b092254..1495bd0 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
@@ -42,16 +42,17 @@ public class TelephonySnippet implements Snippet {
@Rpc(
description =
- "Gets the line 1 phone number, or optionally get phone number for the " +
- "simSlot (slot# start from 0, only valid for API level > 32)")
- public String getLine1Number(@RpcDefault("0") int simSlot) {
+ "Gets the line 1 phone number, or optionally get phone number for the "
+ + "simSlot (slot# start from 0, only valid for API level > 32)")
+ public String getLine1Number(@RpcDefault("0") Integer simSlot) {
String thisNumber = "";
- if (Build.VERSION.SDK_INT < 33) {
+ if (Build.VERSION.SDK_INT < 33 || simSlot == null) {
thisNumber = mTelephonyManager.getLine1Number();
} else {
SubscriptionInfo mSubscriptionInfo =
- mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(simSlot);
+ mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(
+ simSlot.intValue());
if (mSubscriptionInfo != null) {
thisNumber =
mSubscriptionManager.getPhoneNumber(mSubscriptionInfo.getSubscriptionId());
@@ -68,23 +69,26 @@ public class TelephonySnippet implements Snippet {
@Rpc(
description =
- "Gets the call state for the default subscription or optionally get the call" +
- " state for the simSlot (slot# start from 0, only valid for API" +
- " level > 30). Call state values are 0: IDLE, 1: RINGING, 2: OFFHOOK")
- public int getTelephonyCallState(@RpcDefault("0") int simSlot) {
+ "Gets the call state for the default subscription or optionally get the call"
+ + " state for the simSlot (slot# start from 0, only valid for API"
+ + " level > 30). Call state values are 0: IDLE, 1: RINGING, 2: OFFHOOK")
+ public int getTelephonyCallState(@RpcDefault("0") Integer simSlot) {
int thisState = -1;
if (Build.VERSION.SDK_INT < 31) {
return mTelephonyManager.getCallState();
- } else {
+ } else if (simSlot != null) {
SubscriptionInfo mSubscriptionInfo =
- mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(simSlot);
+ mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(
+ simSlot.intValue());
if (mSubscriptionInfo != null) {
thisState =
mTelephonyManager
.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId())
.getCallStateForSubscription();
}
+ } else {
+ thisState = mTelephonyManager.getCallState();
}
return thisState;