@@ -95,36 +95,49 @@ class CarrierModer(private val context: Context) : Moder() {
9595}
9696
9797class SubscriptionModer (val subscriptionId : Int ) : Moder() {
98- fun updateCarrierConfig (key : String , value : Boolean ) {
99- Log .d(TAG , " Setting $key to $value " )
98+ private fun publishBundle (fn : (PersistableBundle ) -> Unit ) {
10099 val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
101100 val overrideBundle = PersistableBundle ()
102- overrideBundle.putBoolean(key, value )
101+ fn(overrideBundle )
103102 iCclInstance.overrideConfig(this .subscriptionId, overrideBundle, true )
104103 }
104+ fun updateCarrierConfig (key : String , value : Boolean ) {
105+ Log .d(TAG , " Setting $key to $value " )
106+ publishBundle { it.putBoolean(key, value) }
107+ }
105108
106109 fun updateCarrierConfig (key : String , value : String ) {
107110 Log .d(TAG , " Setting $key to $value " )
108- val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
109- val overrideBundle = PersistableBundle ()
110- overrideBundle.putString(key, value)
111- iCclInstance.overrideConfig(this .subscriptionId, overrideBundle, true )
111+ publishBundle { it.putString(key, value) }
112112 }
113113
114114 fun updateCarrierConfig (key : String , value : Int ) {
115115 Log .d(TAG , " Setting $key to $value " )
116- val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
117- val overrideBundle = PersistableBundle ()
118- overrideBundle.putInt(key, value)
119- iCclInstance.overrideConfig(this .subscriptionId, overrideBundle, true )
116+ publishBundle { it.putInt(key, value) }
117+ }
118+ fun updateCarrierConfig (key : String , value : Long ) {
119+ Log .d(TAG , " Setting $key to $value " )
120+ publishBundle { it.putLong(key, value) }
120121 }
121122
122123 fun updateCarrierConfig (key : String , value : IntArray ) {
123124 Log .d(TAG , " Setting $key to $value " )
124- val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
125- val overrideBundle = PersistableBundle ()
126- overrideBundle.putIntArray(key, value)
127- iCclInstance.overrideConfig(this .subscriptionId, overrideBundle, true )
125+ publishBundle { it.putIntArray(key, value) }
126+ }
127+
128+ fun updateCarrierConfig (key : String , value : BooleanArray ) {
129+ Log .d(TAG , " Setting $key to $value " )
130+ publishBundle { it.putBooleanArray(key, value) }
131+ }
132+
133+ fun updateCarrierConfig (key : String , value : Array <String >) {
134+ Log .d(TAG , " Setting $key to $value " )
135+ publishBundle { it.putStringArray(key, value) }
136+ }
137+
138+ fun updateCarrierConfig (key : String , value : LongArray ) {
139+ Log .d(TAG , " Setting $key to $value " )
140+ publishBundle { it.putLongArray(key, value) }
128141 }
129142
130143 fun clearCarrierConfig () {
@@ -138,7 +151,7 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
138151 telephony.resetIms(sub.getSlotIndex(this .subscriptionId))
139152 }
140153
141- private fun getStringValue (key : String ): String {
154+ fun getStringValue (key : String ): String {
142155 val subscriptionId = this .subscriptionId
143156 if (subscriptionId < 0 ) {
144157 return " "
@@ -149,7 +162,7 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
149162 return config.getString(key)
150163 }
151164
152- private fun getBooleanValue (key : String ): Boolean {
165+ fun getBooleanValue (key : String ): Boolean {
153166 val subscriptionId = this .subscriptionId
154167 if (subscriptionId < 0 ) {
155168 return false
@@ -160,7 +173,7 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
160173 return config.getBoolean(key)
161174 }
162175
163- private fun getIntValue (key : String ): Int {
176+ fun getIntValue (key : String ): Int {
164177 val subscriptionId = this .subscriptionId
165178 if (subscriptionId < 0 ) {
166179 return - 1
@@ -171,7 +184,29 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
171184 return config.getInt(key)
172185 }
173186
174- private fun getIntArrayValue (key : String ): IntArray {
187+ fun getLongValue (key : String ): Long {
188+ val subscriptionId = this .subscriptionId
189+ if (subscriptionId < 0 ) {
190+ return - 1
191+ }
192+ val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
193+
194+ val config = iCclInstance.getConfigForSubId(subscriptionId, iCclInstance.defaultCarrierServicePackageName)
195+ return config.getLong(key)
196+ }
197+
198+ fun getBooleanArrayValue (key : String ): BooleanArray {
199+ val subscriptionId = this .subscriptionId
200+ if (subscriptionId < 0 ) {
201+ return booleanArrayOf()
202+ }
203+ val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
204+
205+ val config = iCclInstance.getConfigForSubId(subscriptionId, iCclInstance.defaultCarrierServicePackageName)
206+ return config.getBooleanArray(key)
207+ }
208+
209+ fun getIntArrayValue (key : String ): IntArray {
175210 val subscriptionId = this .subscriptionId
176211 if (subscriptionId < 0 ) {
177212 return intArrayOf()
@@ -182,6 +217,27 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
182217 return config.getIntArray(key)
183218 }
184219
220+ fun getStringArrayValue (key : String ): Array <String > {
221+ val subscriptionId = this .subscriptionId
222+ if (subscriptionId < 0 ) {
223+ return arrayOf()
224+ }
225+ val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
226+
227+ val config = iCclInstance.getConfigForSubId(subscriptionId, iCclInstance.defaultCarrierServicePackageName)
228+ return config.getStringArray(key)
229+ }
230+ fun getValue (key : String ): Any? {
231+ val subscriptionId = this .subscriptionId
232+ if (subscriptionId < 0 ) {
233+ return null
234+ }
235+ val iCclInstance = this .loadCachedInterface { carrierConfigLoader }
236+
237+ val config = iCclInstance.getConfigForSubId(subscriptionId, iCclInstance.defaultCarrierServicePackageName)
238+ return config.get(key)
239+ }
240+
185241 val isVoLteConfigEnabled: Boolean
186242 get() = this .getBooleanValue(CarrierConfigManager .KEY_CARRIER_VOLTE_AVAILABLE_BOOL )
187243
0 commit comments