Sync up to v212

This commit is contained in:
Andy CrossGate Yan
2020-02-27 14:07:15 +00:00
parent 5a4c7737ee
commit 9fe4d8ccf3
9 changed files with 767 additions and 6 deletions

View File

@@ -0,0 +1,74 @@
From 03cfb2b7b10a4ff6040521bb974de6f1566ce0a0 Mon Sep 17 00:00:00 2001
From: Michael Cheah <michael@cheah.xyz>
Date: Sat, 11 Jan 2020 13:19:04 +0800
Subject: [PATCH 2/2] Fix operatorNumeric parsing in CellInfoUtil & support old
mnc format
---
.../network/telephony/CellInfoUtil.java | 26 ++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.java b/src/com/android/settings/network/telephony/CellInfoUtil.java
index def81a10c6..6e6586a4cb 100644
--- a/src/com/android/settings/network/telephony/CellInfoUtil.java
+++ b/src/com/android/settings/network/telephony/CellInfoUtil.java
@@ -16,6 +16,7 @@
package com.android.settings.network.telephony;
+import android.os.SystemProperties;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
@@ -34,6 +35,8 @@ import android.util.Log;
import com.android.internal.telephony.OperatorInfo;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -125,6 +128,16 @@ public final class CellInfoUtil {
Log.e(TAG, "Invalid CellInfo type");
oi = new OperatorInfo("", "", "");
}
+
+ // Fix manual network selection with old modem
+ // https://github.com/LineageOS/android_hardware_ril/commit/e3d006fa722c02fc26acdfcaa43a3f3a1378eba9
+ if (SystemProperties.getBoolean("persist.sys.phh.radio.use_old_mnc_format", false)
+ && !TextUtils.isEmpty(oi.getOperatorNumeric())) {
+ oi = new OperatorInfo(
+ oi.getOperatorAlphaLong(),
+ oi.getOperatorAlphaShort(),
+ oi.getOperatorNumeric() + "+");
+ }
return oi;
}
@@ -135,12 +148,19 @@ public final class CellInfoUtil {
* we only want to wrap the operator info and PLMN to a CellInfo object.
*/
public static CellInfo convertOperatorInfoToCellInfo(OperatorInfo operatorInfo) {
+ Pattern p = Pattern.compile("^([0-9]{5,6}).*");
String operatorNumeric = operatorInfo.getOperatorNumeric();
String mcc = null;
String mnc = null;
- if (operatorNumeric != null && operatorNumeric.matches("^[0-9]{5,6}$")) {
- mcc = operatorNumeric.substring(0, 3);
- mnc = operatorNumeric.substring(3);
+ Log.d(TAG, "operatorNumeric: " + operatorNumeric);
+ if (operatorNumeric != null) {
+ Matcher m = p.matcher(operatorNumeric);
+ if (m.matches()) {
+ mcc = m.group(1).substring(0, 3);
+ mnc = m.group(1).substring(3);
+ } else {
+ Log.e(TAG, "Failed to parse operatorNumeric!");
+ }
}
CellIdentityGsm cig = new CellIdentityGsm(
Integer.MAX_VALUE /* lac */,
--
2.17.1