-
Notifications
You must be signed in to change notification settings - Fork 36
/
0018-TelephonyManager-bring-back-getNetworkClass.patch
84 lines (79 loc) · 3.1 KB
/
0018-TelephonyManager-bring-back-getNetworkClass.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From f500eec93a1e40744ed6eb4806ab617bc4e6417c Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 13:46:15 +0800
Subject: [PATCH 18/46] TelephonyManager: bring back getNetworkClass()
This partially reverts commit c058cac051ab083dc7fb7ea6aa85699110b2e9bf.
* Needed by Spreadtrum IMS
---
.../android/telephony/TelephonyManager.java | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 551b73a1706f..62bd70374c96 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3204,6 +3204,64 @@ public class TelephonyManager {
}
}
+ /**
+ * Network Class Definitions.
+ * Do not change this order, it is used for sorting during emergency calling in
+ * {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies
+ * should be added after the current definitions.
+ */
+ /** Unknown network class. {@hide} */
+ public static final int NETWORK_CLASS_UNKNOWN = 0;
+ /** Class of broadly defined "2G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_2_G = 1;
+ /** Class of broadly defined "3G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_3_G = 2;
+ /** Class of broadly defined "4G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_4_G = 3;
+ /** Class of broadly defined "5G" networks. {@hide} */
+ public static final int NETWORK_CLASS_5_G = 4;
+
+ /**
+ * Return general class of network type, such as "3G" or "4G". In cases
+ * where classification is contentious, this method is conservative.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static int getNetworkClass(int networkType) {
+ switch (networkType) {
+ case NETWORK_TYPE_GPRS:
+ case NETWORK_TYPE_GSM:
+ case NETWORK_TYPE_EDGE:
+ case NETWORK_TYPE_CDMA:
+ case NETWORK_TYPE_1xRTT:
+ case NETWORK_TYPE_IDEN:
+ return NETWORK_CLASS_2_G;
+ case NETWORK_TYPE_UMTS:
+ case NETWORK_TYPE_EVDO_0:
+ case NETWORK_TYPE_EVDO_A:
+ case NETWORK_TYPE_HSDPA:
+ case NETWORK_TYPE_HSUPA:
+ case NETWORK_TYPE_HSPA:
+ case NETWORK_TYPE_EVDO_B:
+ case NETWORK_TYPE_EHRPD:
+ case NETWORK_TYPE_HSPAP:
+ case NETWORK_TYPE_TD_SCDMA:
+ return NETWORK_CLASS_3_G;
+ case NETWORK_TYPE_LTE:
+ case NETWORK_TYPE_IWLAN:
+ case NETWORK_TYPE_LTE_CA:
+ return NETWORK_CLASS_4_G;
+ case NETWORK_TYPE_NR:
+ return NETWORK_CLASS_5_G;
+ default:
+ return NETWORK_CLASS_UNKNOWN;
+ }
+ }
+
/**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
--
2.34.1