summaryrefslogtreecommitdiff
path: root/telephony
diff options
context:
space:
mode:
authorNathan Harold <nharold@google.com>2020-02-20 14:46:13 -0800
committerJack Yu <jackyu@google.com>2020-09-23 21:47:00 -0700
commit42f5c3e326f3e2eb946dc18ffde7eadca1cf3878 (patch)
treef60e56328f6009bdc70db8a7728ba74b81cfa26c /telephony
parent4eec88d3d5e5fda38f3193c5ead2d709770836cc (diff)
Create Central Version of dataStateToString()
There are currently two slightly-different copies of dataStateToString(). -TelephonyManager#dataStateToString() -TelephonyRegistry#dataStateToString() The TelephonyRegistry version doesn't have a string for the DISCONNECTING state. In order to have a single copy that can be accessed from TelephonyRegistry (not mainline) and TelephonyManager (mainline), move both copies to TelephonyUtils. Bug: 149717408 Test: make; atest TelephonyRegistryTest Merged-In: I36945a8a432f7b4f0c449f7414996372e852b5b8 Change-Id: I36945a8a432f7b4f0c449f7414996372e852b5b8 (cherry picked from commit b640b1c62bdb90e81b8e21d89d658da4ba1c0f5e)
Diffstat (limited to 'telephony')
-rw-r--r--telephony/common/com/android/internal/telephony/util/TelephonyUtils.java21
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java17
2 files changed, 21 insertions, 17 deletions
diff --git a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
index 682697469af9..7736473feafb 100644
--- a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
+++ b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
@@ -15,6 +15,8 @@
*/
package com.android.internal.telephony.util;
+import static android.telephony.Annotation.DataState;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -26,6 +28,7 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.SystemProperties;
+import android.telephony.TelephonyManager;
import java.io.PrintWriter;
import java.util.Collections;
@@ -154,4 +157,22 @@ public final class TelephonyUtils {
} catch (InterruptedException ignored) {
}
}
+
+ /**
+ * Convert data state to string
+ *
+ * @return The data state in string format.
+ */
+ public static String dataStateToString(@DataState int state) {
+ switch (state) {
+ case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED";
+ case TelephonyManager.DATA_CONNECTING: return "CONNECTING";
+ case TelephonyManager.DATA_CONNECTED: return "CONNECTED";
+ case TelephonyManager.DATA_SUSPENDED: return "SUSPENDED";
+ case TelephonyManager.DATA_DISCONNECTING: return "DISCONNECTING";
+ case TelephonyManager.DATA_UNKNOWN: return "UNKNOWN";
+ }
+ // This is the error case. The well-defined value for UNKNOWN is -1.
+ return "UNKNOWN(" + state + ")";
+ }
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 4b5399e74abf..c7aaee1797c2 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -5499,23 +5499,6 @@ public class TelephonyManager {
}
}
- /**
- * Convert data state to string
- *
- * @return The data state in string format.
- * @hide
- */
- public static String dataStateToString(@DataState int state) {
- switch (state) {
- case DATA_DISCONNECTED: return "DISCONNECTED";
- case DATA_CONNECTING: return "CONNECTING";
- case DATA_CONNECTED: return "CONNECTED";
- case DATA_SUSPENDED: return "SUSPENDED";
- case DATA_DISCONNECTING: return "DISCONNECTING";
- }
- return "UNKNOWN(" + state + ")";
- }
-
/**
* @hide
*/