1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 08:36:19 +00:00
treble_evolution/patches/platform_frameworks_base/0017-Revert-Remove-unused-SystemProperties.set.patch
2024-04-24 15:13:17 +00:00

96 lines
3.0 KiB
Diff

From 475fcbf3767aec9b0426f97cbaefe8fbadba1222 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 21:24:12 +0800
Subject: [PATCH 17/51] Revert "Remove unused SystemProperties.set"
This reverts commit debb4616ef67f9ed5054eca51ec58592358ff55f.
* Needed for SPRD IMS
---
.../android/telephony/TelephonyManager.java | 69 +++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index f206987ddbf6..73c957c47892 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8152,6 +8152,75 @@ public class TelephonyManager {
}
}
+ /**
+ * Sets a per-phone telephony property with the value specified.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static void setTelephonyProperty(int phoneId, String property, String value) {
+ String propVal = "";
+ String p[] = null;
+ String prop = SystemProperties.get(property);
+
+ if (value == null) {
+ value = "";
+ }
+ value.replace(',', ' ');
+ if (prop != null) {
+ p = prop.split(",");
+ }
+
+ if (!SubscriptionManager.isValidPhoneId(phoneId)) {
+ Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " prop=" + prop);
+ return;
+ }
+
+ for (int i = 0; i < phoneId; i++) {
+ String str = "";
+ if ((p != null) && (i < p.length)) {
+ str = p[i];
+ }
+ propVal = propVal + str + ",";
+ }
+
+ propVal = propVal + value;
+ if (p != null) {
+ for (int i = phoneId + 1; i < p.length; i++) {
+ propVal = propVal + "," + p[i];
+ }
+ }
+
+ int propValLen = propVal.length();
+ try {
+ propValLen = propVal.getBytes("utf-8").length;
+ } catch (java.io.UnsupportedEncodingException e) {
+ Rlog.d(TAG, "setTelephonyProperty: utf-8 not supported");
+ }
+ if (propValLen > SystemProperties.PROP_VALUE_MAX) {
+ Rlog.d(TAG, "setTelephonyProperty: property too long phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " propVal=" + propVal);
+ return;
+ }
+
+ SystemProperties.set(property, propVal);
+ }
+
+ /**
+ * Sets a global telephony property with the value specified.
+ *
+ * @hide
+ */
+ public static void setTelephonyProperty(String property, String value) {
+ if (value == null) {
+ value = "";
+ }
+ Rlog.d(TAG, "setTelephonyProperty: success" + " property=" +
+ property + " value: " + value);
+ SystemProperties.set(property, value);
+ }
+
/**
* Inserts or updates a list property. Expands the list if its length is not enough.
*/
--
2.25.1