blob: b0a46538e12c20080c860e248a4b7d4abb371747 [file] [log] [blame]
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001/*
Jonathan Basseri6465afd2015-02-25 13:05:57 -08002 * Copyright (c) 2015, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Jonathan Basseri6465afd2015-02-25 13:05:57 -080017package com.android.phone;
18
Jonathan Basseri65273c82017-07-25 15:08:42 -070019import static android.service.carrier.CarrierService.ICarrierServiceWrapper.KEY_CONFIG_BUNDLE;
20import static android.service.carrier.CarrierService.ICarrierServiceWrapper.RESULT_ERROR;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080021
Jonathan Basseri11f89572015-05-05 11:57:39 -070022import android.annotation.NonNull;
Torbjorn Eklund723527a2019-02-13 11:16:25 +010023import android.annotation.Nullable;
Hunter Knepshielde601f432020-02-19 10:16:04 -080024import android.app.AppOpsManager;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080025import android.content.BroadcastReceiver;
26import android.content.ComponentName;
27import android.content.Context;
28import android.content.Intent;
29import android.content.IntentFilter;
30import android.content.ServiceConnection;
Jonathan Basseri7697cae2015-07-06 15:49:23 -070031import android.content.SharedPreferences;
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -070032import android.content.pm.PackageInfo;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070033import android.content.pm.PackageManager;
Junda Liu43d723a2015-05-12 17:23:45 -070034import android.os.Binder;
Jonathan Basseri7697cae2015-07-06 15:49:23 -070035import android.os.Build;
Jonathan Basseri65273c82017-07-25 15:08:42 -070036import android.os.Bundle;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080037import android.os.Handler;
38import android.os.IBinder;
Rambo Wang7e3bc122021-03-23 09:24:38 -070039import android.os.Looper;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080040import android.os.Message;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070041import android.os.PersistableBundle;
Hunter Knepshielde601f432020-02-19 10:16:04 -080042import android.os.Process;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080043import android.os.RemoteException;
Jonathan Basseri65273c82017-07-25 15:08:42 -070044import android.os.ResultReceiver;
Meng Wang97a6a462020-01-23 16:22:16 -080045import android.os.UserHandle;
Jonathan Basseri7697cae2015-07-06 15:49:23 -070046import android.preference.PreferenceManager;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080047import android.service.carrier.CarrierIdentifier;
Zach Johnson36d7aab2015-05-22 15:43:00 -070048import android.service.carrier.CarrierService;
49import android.service.carrier.ICarrierService;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080050import android.telephony.CarrierConfigManager;
51import android.telephony.SubscriptionManager;
Peter Wangc035ce42020-01-08 21:00:22 -080052import android.telephony.TelephonyFrameworkInitializer;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080053import android.telephony.TelephonyManager;
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -080054import android.text.TextUtils;
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -080055import android.util.ArraySet;
chen xudb04c292019-03-26 17:01:15 -070056import android.util.LocalLog;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080057import android.util.Log;
58
Rambo Wang7e3bc122021-03-23 09:24:38 -070059import com.android.internal.annotations.VisibleForTesting;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080060import com.android.internal.telephony.ICarrierConfigLoader;
61import com.android.internal.telephony.IccCardConstants;
62import com.android.internal.telephony.Phone;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080063import com.android.internal.telephony.PhoneFactory;
Nathan Harold48ac0972019-03-13 22:33:01 -070064import com.android.internal.telephony.SubscriptionInfoUpdater;
Jeff Davidsona8e4e242018-03-15 17:16:18 -070065import com.android.internal.telephony.TelephonyPermissions;
Meng Wanga320b942019-11-25 11:21:26 -080066import com.android.internal.telephony.util.ArrayUtils;
shuoq26a3a4c2016-12-16 11:06:48 -080067import com.android.internal.util.IndentingPrintWriter;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080068
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -070069import java.io.File;
Junda Liu43d723a2015-05-12 17:23:45 -070070import java.io.FileDescriptor;
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -070071import java.io.FileInputStream;
72import java.io.FileNotFoundException;
73import java.io.FileOutputStream;
Jonathan Basseri1f743c92015-05-15 00:19:46 -070074import java.io.FilenameFilter;
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -070075import java.io.IOException;
Junda Liu43d723a2015-05-12 17:23:45 -070076import java.io.PrintWriter;
shuoq26a3a4c2016-12-16 11:06:48 -080077import java.util.ArrayList;
78import java.util.Arrays;
79import java.util.Collections;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080080import java.util.List;
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -080081import java.util.Set;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080082
83/**
84 * CarrierConfigLoader binds to privileged carrier apps to fetch carrier config overlays.
Jonathan Basseri6465afd2015-02-25 13:05:57 -080085 */
Jonathan Basseri6465afd2015-02-25 13:05:57 -080086public class CarrierConfigLoader extends ICarrierConfigLoader.Stub {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -070087 private static final String LOG_TAG = "CarrierConfigLoader";
Meng Wang33ad2bc2017-03-16 20:21:20 -070088
89 // Package name for platform carrier config app, bundled with system image.
90 private final String mPlatformCarrierConfigPackage;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080091
92 /** The singleton instance. */
93 private static CarrierConfigLoader sInstance;
94 // The context for phone app, passed from PhoneGlobals.
95 private Context mContext;
96 // Carrier configs from default app, indexed by phoneID.
Jonathan Basseric31f1f32015-05-12 10:13:03 -070097 private PersistableBundle[] mConfigFromDefaultApp;
Jonathan Basseri6465afd2015-02-25 13:05:57 -080098 // Carrier configs from privileged carrier config app, indexed by phoneID.
Jonathan Basseric31f1f32015-05-12 10:13:03 -070099 private PersistableBundle[] mConfigFromCarrierApp;
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100100 // Persistent Carrier configs that are provided via the override test API, indexed by phone ID.
101 private PersistableBundle[] mPersistentOverrideConfigs;
Hall Liu506724b2018-10-22 18:16:14 -0700102 // Carrier configs that are provided via the override test API, indexed by phone ID.
103 private PersistableBundle[] mOverrideConfigs;
Jayachandran C645ec612020-01-10 10:30:25 -0800104 // Carrier configs to override code default when there is no SIM inserted
105 private PersistableBundle mNoSimConfig;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800106 // Service connection for binding to config app.
Zach Johnson36d7aab2015-05-22 15:43:00 -0700107 private CarrierServiceConnection[] mServiceConnection;
Jayachandran C645ec612020-01-10 10:30:25 -0800108 // Service connection for binding to carrier config app for no SIM config.
109 private CarrierServiceConnection[] mServiceConnectionForNoSimConfig;
Sarah Chin807d5c62020-03-30 17:21:09 -0700110 // Whether we have sent config change broadcast for each phone id.
Junda Liu03aad762017-07-21 13:32:17 -0700111 private boolean[] mHasSentConfigChange;
Sarah Chin807d5c62020-03-30 17:21:09 -0700112 // Whether the broadcast was sent from EVENT_SYSTEM_UNLOCKED, to track rebroadcasts
113 private boolean[] mFromSystemUnlocked;
Nathan Harold48ac0972019-03-13 22:33:01 -0700114 // SubscriptionInfoUpdater
115 private final SubscriptionInfoUpdater mSubscriptionInfoUpdater;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800116
Nanxi Chen3d670502016-03-17 16:32:09 -0700117 // Broadcast receiver for Boot intents, register intent filter in construtor.
118 private final BroadcastReceiver mBootReceiver = new ConfigLoaderBroadcastReceiver();
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800119 // Broadcast receiver for SIM and pkg intents, register intent filter in constructor.
Nanxi Chen3d670502016-03-17 16:32:09 -0700120 private final BroadcastReceiver mPackageReceiver = new ConfigLoaderBroadcastReceiver();
Jack Yu67663de2019-10-17 15:19:48 -0700121 private final LocalLog mCarrierConfigLoadingLog = new LocalLog(100);
chen xudb04c292019-03-26 17:01:15 -0700122
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800123
124 // Message codes; see mHandler below.
125 // Request from SubscriptionInfoUpdater when SIM becomes absent or error.
126 private static final int EVENT_CLEAR_CONFIG = 0;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800127 // Has connected to default app.
128 private static final int EVENT_CONNECTED_TO_DEFAULT = 3;
129 // Has connected to carrier app.
130 private static final int EVENT_CONNECTED_TO_CARRIER = 4;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700131 // Config has been loaded from default app (or cache).
132 private static final int EVENT_FETCH_DEFAULT_DONE = 5;
133 // Config has been loaded from carrier app (or cache).
134 private static final int EVENT_FETCH_CARRIER_DONE = 6;
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700135 // Attempt to fetch from default app or read from XML.
Jonathan Basseri65273c82017-07-25 15:08:42 -0700136 private static final int EVENT_DO_FETCH_DEFAULT = 7;
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700137 // Attempt to fetch from carrier app or read from XML.
Jonathan Basseri65273c82017-07-25 15:08:42 -0700138 private static final int EVENT_DO_FETCH_CARRIER = 8;
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700139 // A package has been installed, uninstalled, or updated.
140 private static final int EVENT_PACKAGE_CHANGED = 9;
Jonathan Basseri930701e2015-06-11 20:56:43 -0700141 // Bind timed out for the default app.
142 private static final int EVENT_BIND_DEFAULT_TIMEOUT = 10;
143 // Bind timed out for a carrier app.
144 private static final int EVENT_BIND_CARRIER_TIMEOUT = 11;
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700145 // Check if the system fingerprint has changed.
146 private static final int EVENT_CHECK_SYSTEM_UPDATE = 12;
Nanxi Chen3d670502016-03-17 16:32:09 -0700147 // Rerun carrier config binding after system is unlocked.
148 private static final int EVENT_SYSTEM_UNLOCKED = 13;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700149 // Fetching config timed out from the default app.
150 private static final int EVENT_FETCH_DEFAULT_TIMEOUT = 14;
151 // Fetching config timed out from a carrier app.
152 private static final int EVENT_FETCH_CARRIER_TIMEOUT = 15;
Nathan Harold48ac0972019-03-13 22:33:01 -0700153 // SubscriptionInfoUpdater has finished updating the sub for the carrier config.
154 private static final int EVENT_SUBSCRIPTION_INFO_UPDATED = 16;
Malcolm Chen5ea18532019-10-24 19:55:44 -0700155 // Multi-SIM config changed.
156 private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 17;
Jayachandran C645ec612020-01-10 10:30:25 -0800157 // Attempt to fetch from default app or read from XML for no SIM case.
158 private static final int EVENT_DO_FETCH_DEFAULT_FOR_NO_SIM_CONFIG = 18;
159 // No SIM config has been loaded from default app (or cache).
160 private static final int EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE = 19;
161 // Has connected to default app for no SIM config.
162 private static final int EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG = 20;
163 // Bind timed out for the default app when trying to fetch no SIM config.
164 private static final int EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT = 21;
165 // Fetching config timed out from the default app for no SIM config.
166 private static final int EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT = 22;
Rambo Wangab13e3e2021-04-08 15:01:06 -0700167 // NOTE: any new EVENT_* values must be added to method eventToString().
Jonathan Basseri930701e2015-06-11 20:56:43 -0700168
Junda Liu6cb45002016-03-22 17:18:20 -0700169 private static final int BIND_TIMEOUT_MILLIS = 30000;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800170
Meng Wang0f6b2ea2020-01-06 18:31:16 -0800171 // Keys used for saving and restoring config bundle from file.
172 private static final String KEY_VERSION = "__carrier_config_package_version__";
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800173
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100174 private static final String OVERRIDE_PACKAGE_ADDITION = "-override";
175
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700176 // SharedPreferences key for last known build fingerprint.
177 private static final String KEY_FINGERPRINT = "build_fingerprint";
178
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -0800179 // Argument for #dump that indicates we should also call the default and specified carrier
180 // service's #dump method. In multi-SIM devices, it's possible that carrier A is on SIM 1 and
181 // carrier B is on SIM 2, in which case we should not dump carrier B's service when carrier A
182 // requested the dump.
183 private static final String DUMP_ARG_REQUESTING_PACKAGE = "--requesting-package";
184
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800185 // Handler to process various events.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700186 //
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700187 // For each phoneId, the event sequence should be:
Jonathan Basseri65273c82017-07-25 15:08:42 -0700188 // fetch default, connected to default, fetch default (async), fetch default done,
189 // fetch carrier, connected to carrier, fetch carrier (async), fetch carrier done.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700190 //
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700191 // If there is a saved config file for either the default app or the carrier app, we skip
192 // binding to the app and go straight from fetch to loaded.
193 //
194 // At any time, at most one connection is active. If events are not in this order, previous
195 // connection will be unbound, so only latest event takes effect.
196 //
197 // We broadcast ACTION_CARRIER_CONFIG_CHANGED after:
198 // 1. loading from carrier app (even if read from a file)
199 // 2. loading from default app if there is no carrier app (even if read from a file)
200 // 3. clearing config (e.g. due to sim removal)
201 // 4. encountering bind or IPC error
Jonathan Basseri65273c82017-07-25 15:08:42 -0700202 private class ConfigHandler extends Handler {
Rambo Wang7e3bc122021-03-23 09:24:38 -0700203 ConfigHandler(@NonNull Looper looper) {
204 super(looper);
205 }
206
Jonathan Basseri65273c82017-07-25 15:08:42 -0700207 @Override
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800208 public void handleMessage(Message msg) {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700209 final int phoneId = msg.arg1;
Rambo Wangab13e3e2021-04-08 15:01:06 -0700210 logdWithLocalLog("mHandler: " + eventToString(msg.what) + " phoneId: " + phoneId);
Malcolm Chen5ea18532019-10-24 19:55:44 -0700211 if (!SubscriptionManager.isValidPhoneId(phoneId)
212 && msg.what != EVENT_MULTI_SIM_CONFIG_CHANGED) {
213 return;
214 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800215 switch (msg.what) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800216 case EVENT_CLEAR_CONFIG: {
Malcolm Chen5ea18532019-10-24 19:55:44 -0700217 clearConfigForPhone(phoneId, true);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800218 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700219 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700220
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800221 case EVENT_SYSTEM_UNLOCKED: {
Malcolm Chen5ea18532019-10-24 19:55:44 -0700222 for (int i = 0; i < TelephonyManager.from(mContext).getActiveModemCount();
223 ++i) {
Sarah Chin807d5c62020-03-30 17:21:09 -0700224 // When the user unlocks the device, send the broadcast again (with a
225 // rebroadcast extra) if we have sent it before unlock. This will avoid
226 // trying to load the carrier config when the SIM is still loading when the
227 // unlock happens.
Junda Liu03aad762017-07-21 13:32:17 -0700228 if (mHasSentConfigChange[i]) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800229 logdWithLocalLog("System unlocked");
Sarah Chin807d5c62020-03-30 17:21:09 -0700230 mFromSystemUnlocked[i] = true;
Junda Liu03aad762017-07-21 13:32:17 -0700231 updateConfigForPhoneId(i);
232 }
Nanxi Chen3d670502016-03-17 16:32:09 -0700233 }
234 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700235 }
Nanxi Chen3d670502016-03-17 16:32:09 -0700236
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800237 case EVENT_PACKAGE_CHANGED: {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700238 final String carrierPackageName = (String) msg.obj;
239 // Only update if there are cached config removed to avoid updating config for
240 // unrelated packages.
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700241 if (clearCachedConfigForPackage(carrierPackageName)) {
Malcolm Chen5ea18532019-10-24 19:55:44 -0700242 int numPhones = TelephonyManager.from(mContext).getActiveModemCount();
Junda Liu8a8a53a2015-05-15 16:19:57 -0700243 for (int i = 0; i < numPhones; ++i) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800244 logdWithLocalLog("Package changed: " + carrierPackageName
Jack Yu67663de2019-10-17 15:19:48 -0700245 + ", phone=" + i);
Junda Liu8a8a53a2015-05-15 16:19:57 -0700246 updateConfigForPhoneId(i);
247 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700248 }
249 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700250 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700251
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800252 case EVENT_DO_FETCH_DEFAULT: {
Rambo Wang9bc7d362021-03-09 09:10:58 -0800253 // Clear in-memory cache for carrier app config, so when carrier app gets
254 // uninstalled, no stale config is left.
255 if (mConfigFromCarrierApp[phoneId] != null
256 && getCarrierPackageForPhoneId(phoneId) == null) {
257 mConfigFromCarrierApp[phoneId] = null;
258 }
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100259 // Restore persistent override values.
260 PersistableBundle config = restoreConfigFromXml(
261 mPlatformCarrierConfigPackage, OVERRIDE_PACKAGE_ADDITION, phoneId);
262 if (config != null) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800263 logd("Loaded persistent override config from XML. package="
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100264 + mPlatformCarrierConfigPackage
265 + " phoneId=" + phoneId);
266 mPersistentOverrideConfigs[phoneId] = config;
267 }
268
269 config = restoreConfigFromXml(mPlatformCarrierConfigPackage, "", phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700270 if (config != null) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800271 logd(
Jonathan Basseri65273c82017-07-25 15:08:42 -0700272 "Loaded config from XML. package="
273 + mPlatformCarrierConfigPackage
274 + " phoneId="
275 + phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700276 mConfigFromDefaultApp[phoneId] = config;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700277 Message newMsg = obtainMessage(EVENT_FETCH_DEFAULT_DONE, phoneId, -1);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700278 newMsg.getData().putBoolean("loaded_from_xml", true);
279 mHandler.sendMessage(newMsg);
280 } else {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700281 // No cached config, so fetch it from the default app.
282 if (bindToConfigPackage(
283 mPlatformCarrierConfigPackage,
284 phoneId,
285 EVENT_CONNECTED_TO_DEFAULT)) {
286 sendMessageDelayed(
Rambo Wang610fdf62021-03-08 21:37:11 -0800287 obtainMessage(EVENT_BIND_DEFAULT_TIMEOUT, phoneId, -1 /*arg2*/,
288 getMessageToken(phoneId)),
Jonathan Basseri930701e2015-06-11 20:56:43 -0700289 BIND_TIMEOUT_MILLIS);
290 } else {
Nathan Harold1122e3d2021-01-22 15:45:24 -0800291 // Put a stub bundle in place so that the rest of the logic continues
292 // smoothly.
Rambo Wang42026112021-04-07 20:57:28 +0000293 mConfigFromDefaultApp[phoneId] = new PersistableBundle();
Jonathan Basseri65273c82017-07-25 15:08:42 -0700294 // Send broadcast if bind fails.
Nathan Harold48ac0972019-03-13 22:33:01 -0700295 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700296 // TODO: We *must* call unbindService even if bindService returns false.
297 // (And possibly if SecurityException was thrown.)
chen xudb04c292019-03-26 17:01:15 -0700298 loge("binding to default app: "
299 + mPlatformCarrierConfigPackage + " fails");
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700300 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800301 }
302 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700303 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800304
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800305 case EVENT_CONNECTED_TO_DEFAULT: {
Rambo Wang610fdf62021-03-08 21:37:11 -0800306 removeMessages(EVENT_BIND_DEFAULT_TIMEOUT, getMessageToken(phoneId));
Jonathan Basseri65273c82017-07-25 15:08:42 -0700307 final CarrierServiceConnection conn = (CarrierServiceConnection) msg.obj;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800308 // If new service connection has been created, unbind.
309 if (mServiceConnection[phoneId] != conn || conn.service == null) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700310 unbindIfBound(mContext, conn);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800311 break;
312 }
chen xu02581692018-11-11 19:03:44 -0800313 final CarrierIdentifier carrierId = getCarrierIdentifierForPhoneId(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700314 // ResultReceiver callback will execute in this Handler's thread.
315 final ResultReceiver resultReceiver =
316 new ResultReceiver(this) {
317 @Override
318 public void onReceiveResult(int resultCode, Bundle resultData) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700319 unbindIfBound(mContext, conn);
Rambo Wanga9d27a52021-04-09 16:17:33 -0700320 removeMessages(EVENT_FETCH_DEFAULT_TIMEOUT,
321 getMessageToken(phoneId));
Jonathan Basseri65273c82017-07-25 15:08:42 -0700322 // If new service connection has been created, this is stale.
323 if (mServiceConnection[phoneId] != conn) {
324 loge("Received response for stale request.");
325 return;
326 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700327 if (resultCode == RESULT_ERROR || resultData == null) {
328 // On error, abort config fetching.
329 loge("Failed to get carrier config");
Nathan Harold48ac0972019-03-13 22:33:01 -0700330 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700331 return;
332 }
333 PersistableBundle config =
334 resultData.getParcelable(KEY_CONFIG_BUNDLE);
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100335 saveConfigToXml(mPlatformCarrierConfigPackage, "", phoneId,
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800336 carrierId, config);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700337 mConfigFromDefaultApp[phoneId] = config;
338 sendMessage(
339 obtainMessage(
340 EVENT_FETCH_DEFAULT_DONE, phoneId, -1));
341 }
342 };
343 // Now fetch the config asynchronously from the ICarrierService.
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800344 try {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700345 ICarrierService carrierService =
346 ICarrierService.Stub.asInterface(conn.service);
347 carrierService.getCarrierConfig(carrierId, resultReceiver);
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800348 logdWithLocalLog("Fetch config for default app: "
chen xudb04c292019-03-26 17:01:15 -0700349 + mPlatformCarrierConfigPackage
350 + " carrierid: " + carrierId.toString());
Jonathan Basseri65273c82017-07-25 15:08:42 -0700351 } catch (RemoteException e) {
chen xudb04c292019-03-26 17:01:15 -0700352 loge("Failed to get carrier config from default app: " +
353 mPlatformCarrierConfigPackage + " err: " + e.toString());
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700354 unbindIfBound(mContext, conn);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700355 break; // So we don't set a timeout.
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800356 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700357 sendMessageDelayed(
Rambo Wang610fdf62021-03-08 21:37:11 -0800358 obtainMessage(EVENT_FETCH_DEFAULT_TIMEOUT, phoneId, -1 /*arg2*/,
359 getMessageToken(phoneId)),
Jonathan Basseri65273c82017-07-25 15:08:42 -0700360 BIND_TIMEOUT_MILLIS);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800361 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700362 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800363
Jonathan Basseri930701e2015-06-11 20:56:43 -0700364 case EVENT_BIND_DEFAULT_TIMEOUT:
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800365 case EVENT_FETCH_DEFAULT_TIMEOUT: {
366 loge("Bind/fetch time out from " + mPlatformCarrierConfigPackage);
Rambo Wang610fdf62021-03-08 21:37:11 -0800367 removeMessages(EVENT_FETCH_DEFAULT_TIMEOUT, getMessageToken(phoneId));
chen xuf60b3162019-05-01 21:31:05 -0700368 // If we attempted to bind to the app, but the service connection is null due to
369 // the race condition that clear config event happens before bind/fetch complete
370 // then config was cleared while we were waiting and we should not continue.
371 if (mServiceConnection[phoneId] != null) {
372 // If a ResponseReceiver callback is in the queue when this happens, we will
373 // unbind twice and throw an exception.
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700374 unbindIfBound(mContext, mServiceConnection[phoneId]);
chen xuf60b3162019-05-01 21:31:05 -0700375 broadcastConfigChangedIntent(phoneId);
376 }
Nathan Harold1122e3d2021-01-22 15:45:24 -0800377 // Put a stub bundle in place so that the rest of the logic continues smoothly.
Rambo Wang42026112021-04-07 20:57:28 +0000378 mConfigFromDefaultApp[phoneId] = new PersistableBundle();
Nathan Harold48ac0972019-03-13 22:33:01 -0700379 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri930701e2015-06-11 20:56:43 -0700380 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700381 }
Jonathan Basseri930701e2015-06-11 20:56:43 -0700382
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800383 case EVENT_FETCH_DEFAULT_DONE: {
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700384 // If we attempted to bind to the app, but the service connection is null, then
385 // config was cleared while we were waiting and we should not continue.
386 if (!msg.getData().getBoolean("loaded_from_xml", false)
387 && mServiceConnection[phoneId] == null) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800388 break;
389 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700390 final String carrierPackageName = getCarrierPackageForPhoneId(phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700391 if (carrierPackageName != null) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800392 logd("Found carrier config app: " + carrierPackageName);
Jordan Liu38a614c2019-03-20 15:01:17 -0700393 sendMessage(obtainMessage(EVENT_DO_FETCH_CARRIER, phoneId, -1));
Jonathan Basserib919e932015-05-27 16:53:08 +0000394 } else {
Nathan Harold48ac0972019-03-13 22:33:01 -0700395 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri4ae2e7c2015-05-15 00:19:46 -0700396 }
397 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700398 }
Jonathan Basseri4ae2e7c2015-05-15 00:19:46 -0700399
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800400 case EVENT_DO_FETCH_CARRIER: {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700401 final String carrierPackageName = getCarrierPackageForPhoneId(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700402 final PersistableBundle config =
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100403 restoreConfigFromXml(carrierPackageName, "", phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700404 if (config != null) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800405 logd(
Jonathan Basseri65273c82017-07-25 15:08:42 -0700406 "Loaded config from XML. package="
407 + carrierPackageName
408 + " phoneId="
409 + phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700410 mConfigFromCarrierApp[phoneId] = config;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700411 Message newMsg = obtainMessage(EVENT_FETCH_CARRIER_DONE, phoneId, -1);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700412 newMsg.getData().putBoolean("loaded_from_xml", true);
413 sendMessage(newMsg);
414 } else {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700415 // No cached config, so fetch it from a carrier app.
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800416 if (carrierPackageName != null && bindToConfigPackage(carrierPackageName,
417 phoneId, EVENT_CONNECTED_TO_CARRIER)) {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700418 sendMessageDelayed(
Rambo Wang610fdf62021-03-08 21:37:11 -0800419 obtainMessage(EVENT_BIND_CARRIER_TIMEOUT, phoneId, -1 /*arg2*/,
420 getMessageToken(phoneId)),
Jonathan Basseri930701e2015-06-11 20:56:43 -0700421 BIND_TIMEOUT_MILLIS);
422 } else {
Nathan Harold1122e3d2021-01-22 15:45:24 -0800423 // Put a stub bundle in place so that the rest of the logic continues
424 // smoothly.
Rambo Wang42026112021-04-07 20:57:28 +0000425 mConfigFromCarrierApp[phoneId] = new PersistableBundle();
Jonathan Basseri65273c82017-07-25 15:08:42 -0700426 // Send broadcast if bind fails.
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700427 broadcastConfigChangedIntent(phoneId);
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800428 loge("Bind to carrier app: " + carrierPackageName + " fails");
Nathan Harold48ac0972019-03-13 22:33:01 -0700429 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700430 }
431 }
432 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700433 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700434
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800435 case EVENT_CONNECTED_TO_CARRIER: {
Rambo Wang610fdf62021-03-08 21:37:11 -0800436 removeMessages(EVENT_BIND_CARRIER_TIMEOUT, getMessageToken(phoneId));
Jonathan Basseri65273c82017-07-25 15:08:42 -0700437 final CarrierServiceConnection conn = (CarrierServiceConnection) msg.obj;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800438 // If new service connection has been created, unbind.
Jonathan Basseri65273c82017-07-25 15:08:42 -0700439 if (mServiceConnection[phoneId] != conn || conn.service == null) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700440 unbindIfBound(mContext, conn);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800441 break;
442 }
chen xu02581692018-11-11 19:03:44 -0800443 final CarrierIdentifier carrierId = getCarrierIdentifierForPhoneId(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700444 // ResultReceiver callback will execute in this Handler's thread.
445 final ResultReceiver resultReceiver =
446 new ResultReceiver(this) {
447 @Override
448 public void onReceiveResult(int resultCode, Bundle resultData) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700449 unbindIfBound(mContext, conn);
Rambo Wanga9d27a52021-04-09 16:17:33 -0700450 removeMessages(EVENT_FETCH_CARRIER_TIMEOUT,
451 getMessageToken(phoneId));
Jonathan Basseri65273c82017-07-25 15:08:42 -0700452 // If new service connection has been created, this is stale.
453 if (mServiceConnection[phoneId] != conn) {
454 loge("Received response for stale request.");
455 return;
456 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700457 if (resultCode == RESULT_ERROR || resultData == null) {
458 // On error, abort config fetching.
chen xudb04c292019-03-26 17:01:15 -0700459 loge("Failed to get carrier config from carrier app: "
460 + getCarrierPackageForPhoneId(phoneId));
Jonathan Basseri65273c82017-07-25 15:08:42 -0700461 broadcastConfigChangedIntent(phoneId);
Nathan Harold48ac0972019-03-13 22:33:01 -0700462 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700463 return;
464 }
465 PersistableBundle config =
466 resultData.getParcelable(KEY_CONFIG_BUNDLE);
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100467 saveConfigToXml(getCarrierPackageForPhoneId(phoneId), "",
468 phoneId, carrierId, config);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700469 mConfigFromCarrierApp[phoneId] = config;
470 sendMessage(
471 obtainMessage(
472 EVENT_FETCH_CARRIER_DONE, phoneId, -1));
473 }
474 };
475 // Now fetch the config asynchronously from the ICarrierService.
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800476 try {
Jonathan Basseri65273c82017-07-25 15:08:42 -0700477 ICarrierService carrierService =
478 ICarrierService.Stub.asInterface(conn.service);
479 carrierService.getCarrierConfig(carrierId, resultReceiver);
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800480 logdWithLocalLog("Fetch config for carrier app: "
chen xudb04c292019-03-26 17:01:15 -0700481 + getCarrierPackageForPhoneId(phoneId)
482 + " carrierid: " + carrierId.toString());
Jonathan Basseri65273c82017-07-25 15:08:42 -0700483 } catch (RemoteException e) {
484 loge("Failed to get carrier config: " + e.toString());
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700485 unbindIfBound(mContext, conn);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700486 break; // So we don't set a timeout.
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800487 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700488 sendMessageDelayed(
Rambo Wang610fdf62021-03-08 21:37:11 -0800489 obtainMessage(EVENT_FETCH_CARRIER_TIMEOUT, phoneId, -1 /*arg2*/,
490 getMessageToken(phoneId)),
Jonathan Basseri65273c82017-07-25 15:08:42 -0700491 BIND_TIMEOUT_MILLIS);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800492 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700493 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800494
Jonathan Basseri930701e2015-06-11 20:56:43 -0700495 case EVENT_BIND_CARRIER_TIMEOUT:
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800496 case EVENT_FETCH_CARRIER_TIMEOUT: {
Nathan Harold1122e3d2021-01-22 15:45:24 -0800497 loge("Bind/fetch from carrier app timeout, package="
498 + getCarrierPackageForPhoneId(phoneId));
Rambo Wang610fdf62021-03-08 21:37:11 -0800499 removeMessages(EVENT_FETCH_CARRIER_TIMEOUT, getMessageToken(phoneId));
chen xuf60b3162019-05-01 21:31:05 -0700500 // If we attempted to bind to the app, but the service connection is null due to
501 // the race condition that clear config event happens before bind/fetch complete
502 // then config was cleared while we were waiting and we should not continue.
503 if (mServiceConnection[phoneId] != null) {
504 // If a ResponseReceiver callback is in the queue when this happens, we will
505 // unbind twice and throw an exception.
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700506 unbindIfBound(mContext, mServiceConnection[phoneId]);
chen xuf60b3162019-05-01 21:31:05 -0700507 broadcastConfigChangedIntent(phoneId);
508 }
Nathan Harold1122e3d2021-01-22 15:45:24 -0800509 // Put a stub bundle in place so that the rest of the logic continues smoothly.
Rambo Wang42026112021-04-07 20:57:28 +0000510 mConfigFromCarrierApp[phoneId] = new PersistableBundle();
Nathan Harold48ac0972019-03-13 22:33:01 -0700511 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri930701e2015-06-11 20:56:43 -0700512 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700513 }
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800514 case EVENT_FETCH_CARRIER_DONE: {
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700515 // If we attempted to bind to the app, but the service connection is null, then
516 // config was cleared while we were waiting and we should not continue.
517 if (!msg.getData().getBoolean("loaded_from_xml", false)
518 && mServiceConnection[phoneId] == null) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800519 break;
520 }
Nathan Harold48ac0972019-03-13 22:33:01 -0700521 notifySubscriptionInfoUpdater(phoneId);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800522 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700523 }
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700524
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800525 case EVENT_CHECK_SYSTEM_UPDATE: {
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700526 SharedPreferences sharedPrefs =
527 PreferenceManager.getDefaultSharedPreferences(mContext);
528 final String lastFingerprint = sharedPrefs.getString(KEY_FINGERPRINT, null);
529 if (!Build.FINGERPRINT.equals(lastFingerprint)) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800530 logd(
Jonathan Basseri65273c82017-07-25 15:08:42 -0700531 "Build fingerprint changed. old: "
532 + lastFingerprint
533 + " new: "
534 + Build.FINGERPRINT);
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700535 clearCachedConfigForPackage(null);
Jonathan Basseri65273c82017-07-25 15:08:42 -0700536 sharedPrefs
537 .edit()
538 .putString(KEY_FINGERPRINT, Build.FINGERPRINT)
539 .apply();
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700540 }
541 break;
Jonathan Basseri65273c82017-07-25 15:08:42 -0700542 }
Nathan Harold48ac0972019-03-13 22:33:01 -0700543
544 case EVENT_SUBSCRIPTION_INFO_UPDATED:
545 broadcastConfigChangedIntent(phoneId);
546 break;
Malcolm Chen5ea18532019-10-24 19:55:44 -0700547 case EVENT_MULTI_SIM_CONFIG_CHANGED:
548 onMultiSimConfigChanged();
549 break;
Jayachandran C645ec612020-01-10 10:30:25 -0800550
551 case EVENT_DO_FETCH_DEFAULT_FOR_NO_SIM_CONFIG: {
552 PersistableBundle config =
553 restoreNoSimConfigFromXml(mPlatformCarrierConfigPackage);
554
555 if (config != null) {
556 logd("Loaded no SIM config from XML. package="
557 + mPlatformCarrierConfigPackage);
558 mNoSimConfig = config;
559 sendMessage(
560 obtainMessage(
561 EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE,
562 phoneId, -1));
563 } else {
564 // No cached config, so fetch it from the default app.
565 if (bindToConfigPackage(
566 mPlatformCarrierConfigPackage,
567 phoneId,
568 EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG)) {
569 sendMessageDelayed(
570 obtainMessage(
571 EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT,
572 phoneId, -1), BIND_TIMEOUT_MILLIS);
573 } else {
574 broadcastConfigChangedIntent(phoneId, false);
575 // TODO: We *must* call unbindService even if bindService returns false.
576 // (And possibly if SecurityException was thrown.)
577 loge("binding to default app to fetch no SIM config: "
578 + mPlatformCarrierConfigPackage + " fails");
579 }
580 }
581 break;
582 }
583
584 case EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE: {
585 broadcastConfigChangedIntent(phoneId, false);
586 break;
587 }
588
589 case EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT:
590 case EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT: {
591 loge("Bind/fetch time out for no SIM config from "
592 + mPlatformCarrierConfigPackage);
593 removeMessages(EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT);
594 // If we attempted to bind to the app, but the service connection is null due to
595 // the race condition that clear config event happens before bind/fetch complete
596 // then config was cleared while we were waiting and we should not continue.
597 if (mServiceConnectionForNoSimConfig[phoneId] != null) {
598 // If a ResponseReceiver callback is in the queue when this happens, we will
599 // unbind twice and throw an exception.
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700600 unbindIfBound(mContext, mServiceConnectionForNoSimConfig[phoneId]);
Jayachandran C645ec612020-01-10 10:30:25 -0800601 }
602 broadcastConfigChangedIntent(phoneId, false);
603 break;
604 }
605
606 case EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG: {
607 removeMessages(EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT);
608 final CarrierServiceConnection conn = (CarrierServiceConnection) msg.obj;
609 // If new service connection has been created, unbind.
610 if (mServiceConnectionForNoSimConfig[phoneId] != conn || conn.service == null) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700611 unbindIfBound(mContext, conn);
Jayachandran C645ec612020-01-10 10:30:25 -0800612 break;
613 }
614
615 // ResultReceiver callback will execute in this Handler's thread.
616 final ResultReceiver resultReceiver =
617 new ResultReceiver(this) {
618 @Override
619 public void onReceiveResult(int resultCode, Bundle resultData) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700620 unbindIfBound(mContext, conn);
Jayachandran C645ec612020-01-10 10:30:25 -0800621 // If new service connection has been created, this is stale.
622 if (mServiceConnectionForNoSimConfig[phoneId] != conn) {
623 loge("Received response for stale request.");
624 return;
625 }
626 removeMessages(EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT);
627 if (resultCode == RESULT_ERROR || resultData == null) {
628 // On error, abort config fetching.
629 loge("Failed to get no SIM carrier config");
630 return;
631 }
632 PersistableBundle config =
633 resultData.getParcelable(KEY_CONFIG_BUNDLE);
634 saveNoSimConfigToXml(mPlatformCarrierConfigPackage, config);
635 mNoSimConfig = config;
636 sendMessage(
637 obtainMessage(
638 EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE,
639 phoneId, -1));
640 }
641 };
642 // Now fetch the config asynchronously from the ICarrierService.
643 try {
644 ICarrierService carrierService =
645 ICarrierService.Stub.asInterface(conn.service);
646 carrierService.getCarrierConfig(null, resultReceiver);
647 logdWithLocalLog("Fetch no sim config from default app: "
648 + mPlatformCarrierConfigPackage);
649 } catch (RemoteException e) {
650 loge("Failed to get no sim carrier config from default app: " +
651 mPlatformCarrierConfigPackage + " err: " + e.toString());
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700652 unbindIfBound(mContext, conn);
Jayachandran C645ec612020-01-10 10:30:25 -0800653 break; // So we don't set a timeout.
654 }
655 sendMessageDelayed(
656 obtainMessage(
657 EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT,
658 phoneId, -1), BIND_TIMEOUT_MILLIS);
659 break;
660 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800661 }
662 }
Jonathan Basseri65273c82017-07-25 15:08:42 -0700663 }
664
665 private final Handler mHandler;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800666
667 /**
668 * Constructs a CarrierConfigLoader, registers it as a service, and registers a broadcast
669 * receiver for relevant events.
670 */
Rambo Wang7e3bc122021-03-23 09:24:38 -0700671 @VisibleForTesting
672 /* package */ CarrierConfigLoader(Context context,
673 SubscriptionInfoUpdater subscriptionInfoUpdater, @NonNull Looper looper) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800674 mContext = context;
Meng Wang33ad2bc2017-03-16 20:21:20 -0700675 mPlatformCarrierConfigPackage =
676 mContext.getString(R.string.platform_carrier_config_package);
Rambo Wang7e3bc122021-03-23 09:24:38 -0700677 mHandler = new ConfigHandler(looper);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800678
Nanxi Chen3d670502016-03-17 16:32:09 -0700679 IntentFilter bootFilter = new IntentFilter();
680 bootFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
681 context.registerReceiver(mBootReceiver, bootFilter);
682
Junda Liu8a8a53a2015-05-15 16:19:57 -0700683 // Register for package updates. Update app or uninstall app update will have all 3 intents,
684 // in the order or removed, added, replaced, all with extra_replace set to true.
685 IntentFilter pkgFilter = new IntentFilter();
686 pkgFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
687 pkgFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
688 pkgFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
689 pkgFilter.addDataScheme("package");
Jordan Liu5ca24762019-07-10 12:51:09 -0700690 context.registerReceiver(mPackageReceiver, pkgFilter);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800691
Malcolm Chen978dda52019-10-08 18:15:25 -0700692 int numPhones = TelephonyManager.from(context).getSupportedModemCount();
Jonathan Basseric31f1f32015-05-12 10:13:03 -0700693 mConfigFromDefaultApp = new PersistableBundle[numPhones];
694 mConfigFromCarrierApp = new PersistableBundle[numPhones];
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100695 mPersistentOverrideConfigs = new PersistableBundle[numPhones];
Hall Liu506724b2018-10-22 18:16:14 -0700696 mOverrideConfigs = new PersistableBundle[numPhones];
Rambo Wang42026112021-04-07 20:57:28 +0000697 mNoSimConfig = new PersistableBundle();
Zach Johnson36d7aab2015-05-22 15:43:00 -0700698 mServiceConnection = new CarrierServiceConnection[numPhones];
Junda Liu03aad762017-07-21 13:32:17 -0700699 mHasSentConfigChange = new boolean[numPhones];
Sarah Chin807d5c62020-03-30 17:21:09 -0700700 mFromSystemUnlocked = new boolean[numPhones];
Jayachandran C645ec612020-01-10 10:30:25 -0800701 mServiceConnectionForNoSimConfig = new CarrierServiceConnection[numPhones];
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800702 logd("CarrierConfigLoader has started");
Rambo Wang7e3bc122021-03-23 09:24:38 -0700703 mSubscriptionInfoUpdater = subscriptionInfoUpdater;
Jonathan Basseri7697cae2015-07-06 15:49:23 -0700704 mHandler.sendEmptyMessage(EVENT_CHECK_SYSTEM_UPDATE);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800705 }
706
707 /**
708 * Initialize the singleton CarrierConfigLoader instance.
709 *
710 * This is only done once, at startup, from {@link com.android.phone.PhoneApp#onCreate}.
711 */
Rambo Wang7e3bc122021-03-23 09:24:38 -0700712 /* package */ static CarrierConfigLoader init(Context context) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800713 synchronized (CarrierConfigLoader.class) {
714 if (sInstance == null) {
Rambo Wang7e3bc122021-03-23 09:24:38 -0700715 sInstance = new CarrierConfigLoader(context,
716 PhoneFactory.getSubscriptionInfoUpdater(), Looper.myLooper());
Brad Ebingerfa6575f2021-05-04 00:29:50 +0000717 // Make this service available through ServiceManager.
718 TelephonyFrameworkInitializer.getTelephonyServiceManager()
719 .getCarrierConfigServiceRegisterer().register(sInstance);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800720 } else {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700721 Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800722 }
723 return sInstance;
724 }
725 }
726
Rambo Wang7e3bc122021-03-23 09:24:38 -0700727 @VisibleForTesting
728 /* package */ void clearConfigForPhone(int phoneId, boolean fetchNoSimConfig) {
Malcolm Chen5ea18532019-10-24 19:55:44 -0700729 /* Ignore clear configuration request if device is being shutdown. */
730 Phone phone = PhoneFactory.getPhone(phoneId);
731 if (phone != null) {
732 if (phone.isShuttingDown()) {
733 return;
734 }
735 }
736
737 mConfigFromDefaultApp[phoneId] = null;
738 mConfigFromCarrierApp[phoneId] = null;
739 mServiceConnection[phoneId] = null;
740 mHasSentConfigChange[phoneId] = false;
741
Jayachandran C645ec612020-01-10 10:30:25 -0800742 if (fetchNoSimConfig) {
743 // To fetch no SIM config
744 mHandler.sendMessage(
745 mHandler.obtainMessage(
746 EVENT_DO_FETCH_DEFAULT_FOR_NO_SIM_CONFIG, phoneId, -1));
747 }
Malcolm Chen5ea18532019-10-24 19:55:44 -0700748 }
749
Nathan Harold48ac0972019-03-13 22:33:01 -0700750 private void notifySubscriptionInfoUpdater(int phoneId) {
751 String configPackagename;
752 PersistableBundle configToSend;
753 int carrierId = getSpecificCarrierIdForPhoneId(phoneId);
754 // Prefer the carrier privileged carrier app, but if there is not one, use the platform
755 // default carrier app.
756 if (mConfigFromCarrierApp[phoneId] != null) {
757 configPackagename = getCarrierPackageForPhoneId(phoneId);
758 configToSend = mConfigFromCarrierApp[phoneId];
759 } else {
760 configPackagename = mPlatformCarrierConfigPackage;
761 configToSend = mConfigFromDefaultApp[phoneId];
762 }
Nazanin Bakhshi6fcc3342019-09-18 17:54:01 -0700763
Malcolm Chenefafd1c2020-02-20 13:27:08 -0800764 if (configToSend == null) {
Rambo Wang42026112021-04-07 20:57:28 +0000765 configToSend = new PersistableBundle();
Malcolm Chenefafd1c2020-02-20 13:27:08 -0800766 }
767
Nazanin Bakhshi6fcc3342019-09-18 17:54:01 -0700768 // mOverrideConfigs is for testing. And it will override current configs.
769 PersistableBundle config = mOverrideConfigs[phoneId];
770 if (config != null) {
Torbjorn Eklund1050cb02018-11-16 14:05:38 +0100771 configToSend = new PersistableBundle(configToSend);
Nazanin Bakhshi6fcc3342019-09-18 17:54:01 -0700772 configToSend.putAll(config);
773 }
774
Nathan Harold48ac0972019-03-13 22:33:01 -0700775 mSubscriptionInfoUpdater.updateSubscriptionByCarrierConfigAndNotifyComplete(
776 phoneId, configPackagename, configToSend,
777 mHandler.obtainMessage(EVENT_SUBSCRIPTION_INFO_UPDATED, phoneId, -1));
778 }
779
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800780 private void broadcastConfigChangedIntent(int phoneId) {
Amit Mahajanf8088ab2018-03-02 15:24:07 -0800781 broadcastConfigChangedIntent(phoneId, true);
782 }
783
784 private void broadcastConfigChangedIntent(int phoneId, boolean addSubIdExtra) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800785 Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
Christopher Tate38f55eb2017-02-14 14:43:49 -0800786 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
chen xuf9db49f2019-03-31 23:04:42 -0700787 Intent.FLAG_RECEIVER_FOREGROUND);
Qiongcheng Luoe7de61b2018-08-06 10:20:09 +0800788 if (addSubIdExtra) {
789 int simApplicationState = TelephonyManager.SIM_STATE_UNKNOWN;
790 int[] subIds = SubscriptionManager.getSubId(phoneId);
791 if (!ArrayUtils.isEmpty(subIds)) {
792 TelephonyManager telMgr = TelephonyManager.from(mContext)
793 .createForSubscriptionId(subIds[0]);
794 simApplicationState = telMgr.getSimApplicationState();
795 }
Malcolm Chenf7635ec2020-04-15 15:45:00 -0700796 logd("Broadcast CARRIER_CONFIG_CHANGED for phone " + phoneId
797 + " simApplicationState " + simApplicationState);
Qiongcheng Luoe7de61b2018-08-06 10:20:09 +0800798 // Include subId/carrier id extra only if SIM records are loaded
799 if (simApplicationState != TelephonyManager.SIM_STATE_UNKNOWN
800 && simApplicationState != TelephonyManager.SIM_STATE_NOT_READY) {
801 SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
802 intent.putExtra(TelephonyManager.EXTRA_SPECIFIC_CARRIER_ID,
803 getSpecificCarrierIdForPhoneId(phoneId));
804 intent.putExtra(TelephonyManager.EXTRA_CARRIER_ID, getCarrierIdForPhoneId(phoneId));
805 }
Amit Mahajanf8088ab2018-03-02 15:24:07 -0800806 }
Amit Mahajanb33bcda2018-01-24 12:56:44 -0800807 intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, phoneId);
Sarah Chin807d5c62020-03-30 17:21:09 -0700808 intent.putExtra(CarrierConfigManager.EXTRA_REBROADCAST_ON_UNLOCK,
809 mFromSystemUnlocked[phoneId]);
Meng Wang97a6a462020-01-23 16:22:16 -0800810 mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
Jack Yue9e95be2020-03-22 10:56:06 -0700811 int[] subIds = SubscriptionManager.getSubId(phoneId);
812 if (subIds != null && subIds.length > 0) {
813 logd("Broadcast CARRIER_CONFIG_CHANGED for phone " + phoneId + ", subId=" + subIds[0]);
814 } else {
815 logd("Broadcast CARRIER_CONFIG_CHANGED for phone " + phoneId);
816 }
Junda Liu03aad762017-07-21 13:32:17 -0700817 mHasSentConfigChange[phoneId] = true;
Sarah Chin807d5c62020-03-30 17:21:09 -0700818 mFromSystemUnlocked[phoneId] = false;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800819 }
820
821 /** Binds to the default or carrier config app. */
822 private boolean bindToConfigPackage(String pkgName, int phoneId, int eventId) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800823 logdWithLocalLog("Binding to " + pkgName + " for phone " + phoneId);
Zach Johnsonfca8a8d2015-06-19 18:21:37 -0700824 Intent carrierService = new Intent(CarrierService.CARRIER_SERVICE_INTERFACE);
Zach Johnson36d7aab2015-05-22 15:43:00 -0700825 carrierService.setPackage(pkgName);
Jayachandran C645ec612020-01-10 10:30:25 -0800826 CarrierServiceConnection serviceConnection = new CarrierServiceConnection(
827 phoneId, pkgName, eventId);
828 if (eventId == EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG) {
829 mServiceConnectionForNoSimConfig[phoneId] = serviceConnection;
830 } else {
831 mServiceConnection[phoneId] = serviceConnection;
832 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800833 try {
Jayachandran C645ec612020-01-10 10:30:25 -0800834 if (mContext.bindService(carrierService, serviceConnection,
Jordan Liu178430d2020-02-10 14:32:15 -0800835 Context.BIND_AUTO_CREATE)) {
Rambo Wangdba4ccd2021-09-17 13:18:35 -0700836 serviceConnection.isBound = true;
Jordan Liu178430d2020-02-10 14:32:15 -0800837 return true;
838 } else {
839 return false;
840 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800841 } catch (SecurityException ex) {
842 return false;
843 }
844 }
845
Rambo Wang7e3bc122021-03-23 09:24:38 -0700846 @VisibleForTesting
847 /* package */ CarrierIdentifier getCarrierIdentifierForPhoneId(int phoneId) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800848 String mcc = "";
849 String mnc = "";
850 String imsi = "";
851 String gid1 = "";
852 String gid2 = "";
853 String spn = TelephonyManager.from(mContext).getSimOperatorNameForPhone(phoneId);
854 String simOperator = TelephonyManager.from(mContext).getSimOperatorNumericForPhone(phoneId);
chen xu02581692018-11-11 19:03:44 -0800855 int carrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
chen xua31f22b2019-03-06 15:28:50 -0800856 int specificCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
Jonathan Basseri1fa437c2015-04-20 11:08:18 -0700857 // A valid simOperator should be 5 or 6 digits, depending on the length of the MNC.
858 if (simOperator != null && simOperator.length() >= 3) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800859 mcc = simOperator.substring(0, 3);
860 mnc = simOperator.substring(3);
861 }
862 Phone phone = PhoneFactory.getPhone(phoneId);
863 if (phone != null) {
864 imsi = phone.getSubscriberId();
865 gid1 = phone.getGroupIdLevel1();
Junda Liu73183532015-05-14 13:55:40 -0700866 gid2 = phone.getGroupIdLevel2();
chen xu02581692018-11-11 19:03:44 -0800867 carrierId = phone.getCarrierId();
chen xua31f22b2019-03-06 15:28:50 -0800868 specificCarrierId = phone.getSpecificCarrierId();
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800869 }
chen xua31f22b2019-03-06 15:28:50 -0800870 return new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2, carrierId, specificCarrierId);
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800871 }
872
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700873 /** Returns the package name of a priveleged carrier app, or null if there is none. */
Nathan Harold1122e3d2021-01-22 15:45:24 -0800874 @Nullable
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700875 private String getCarrierPackageForPhoneId(int phoneId) {
876 List<String> carrierPackageNames = TelephonyManager.from(mContext)
877 .getCarrierPackageNamesForIntentAndPhone(
Zach Johnsonfca8a8d2015-06-19 18:21:37 -0700878 new Intent(CarrierService.CARRIER_SERVICE_INTERFACE), phoneId);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700879 if (carrierPackageNames != null && carrierPackageNames.size() > 0) {
880 return carrierPackageNames.get(0);
881 } else {
882 return null;
883 }
884 }
885
886 private String getIccIdForPhoneId(int phoneId) {
887 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
888 return null;
889 }
890 Phone phone = PhoneFactory.getPhone(phoneId);
891 if (phone == null) {
892 return null;
893 }
894 return phone.getIccSerialNumber();
895 }
896
chen xu02581692018-11-11 19:03:44 -0800897 /**
chen xua31f22b2019-03-06 15:28:50 -0800898 * Get the sim specific carrier id {@link TelephonyManager#getSimSpecificCarrierId()}
chen xu02581692018-11-11 19:03:44 -0800899 */
chen xua31f22b2019-03-06 15:28:50 -0800900 private int getSpecificCarrierIdForPhoneId(int phoneId) {
Naina Nalluri86fc7b02018-08-03 10:38:30 -0700901 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
chen xu02581692018-11-11 19:03:44 -0800902 return TelephonyManager.UNKNOWN_CARRIER_ID;
Naina Nalluri86fc7b02018-08-03 10:38:30 -0700903 }
904 Phone phone = PhoneFactory.getPhone(phoneId);
905 if (phone == null) {
chen xu02581692018-11-11 19:03:44 -0800906 return TelephonyManager.UNKNOWN_CARRIER_ID;
Naina Nalluri86fc7b02018-08-03 10:38:30 -0700907 }
chen xua31f22b2019-03-06 15:28:50 -0800908 return phone.getSpecificCarrierId();
chen xu02581692018-11-11 19:03:44 -0800909 }
910
911 /**
912 * Get the sim carrier id {@link TelephonyManager#getSimCarrierId() }
913 */
914 private int getCarrierIdForPhoneId(int phoneId) {
915 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
916 return TelephonyManager.UNKNOWN_CARRIER_ID;
Naina Nalluri86fc7b02018-08-03 10:38:30 -0700917 }
chen xu02581692018-11-11 19:03:44 -0800918 Phone phone = PhoneFactory.getPhone(phoneId);
919 if (phone == null) {
920 return TelephonyManager.UNKNOWN_CARRIER_ID;
921 }
922 return phone.getCarrierId();
Naina Nalluri86fc7b02018-08-03 10:38:30 -0700923 }
924
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700925 /**
926 * Writes a bundle to an XML file.
927 *
chen xu02581692018-11-11 19:03:44 -0800928 * The bundle will be written to a file named after the package name, ICCID and
chen xua31f22b2019-03-06 15:28:50 -0800929 * specific carrier id {@link TelephonyManager#getSimSpecificCarrierId()}. the same carrier
chen xu02581692018-11-11 19:03:44 -0800930 * should have a single copy of XML file named after carrier id. However, it's still possible
931 * that platform doesn't recognize the current sim carrier, we will use iccid + carrierid as
932 * the canonical file name. carrierid can also handle the cases SIM OTA resolves to different
933 * carrier while iccid remains the same.
934 *
935 * The file can be restored later with {@link @restoreConfigFromXml}. The XML output will
936 * include the bundle and the current version of the specified package.
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700937 *
938 * In case of errors or invalid input, no file will be written.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700939 *
Jayachandran C645ec612020-01-10 10:30:25 -0800940 * @param packageName the name of the package from which we fetched this bundle.
941 * @param extraString An extra string to be used in the XML file name.
942 * @param phoneId the phone ID.
943 * @param carrierId contains all carrier-identifying information.
944 * @param config the bundle to be written. Null will be treated as an empty bundle.
945 * @param isNoSimConfig whether this is invoked for noSimConfig or not.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700946 */
Torbjorn Eklund723527a2019-02-13 11:16:25 +0100947 private void saveConfigToXml(String packageName, @NonNull String extraString, int phoneId,
Jayachandran C645ec612020-01-10 10:30:25 -0800948 CarrierIdentifier carrierId, PersistableBundle config, boolean isNoSimConfig) {
949 if (packageName == null) {
950 loge("Cannot save config with null packageName");
Yuchen Dongc15afed2018-04-26 17:05:22 +0800951 return;
952 }
953
Jayachandran C645ec612020-01-10 10:30:25 -0800954 String fileName;
955 if (isNoSimConfig) {
956 fileName = getFilenameForNoSimConfig(packageName);
957 } else {
958 if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
959 != TelephonyManager.SIM_STATE_LOADED) {
960 loge("Skip save config because SIM records are not loaded.");
961 return;
962 }
963
964 final String iccid = getIccIdForPhoneId(phoneId);
965 final int cid = carrierId.getSpecificCarrierId();
966 if (iccid == null) {
967 loge("Cannot save config with null iccid.");
968 return;
969 }
970 fileName = getFilenameForConfig(packageName, extraString, iccid, cid);
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700971 }
Jayachandran C645ec612020-01-10 10:30:25 -0800972
Junda Liu02596502016-11-15 13:46:43 -0800973 // b/32668103 Only save to file if config isn't empty.
974 // In case of failure, not caching an empty bundle will
975 // try loading config again on next power on or sim loaded.
976 // Downside is for genuinely empty bundle, will bind and load
977 // on every power on.
978 if (config == null || config.isEmpty()) {
979 return;
Jonathan Basseri1f743c92015-05-15 00:19:46 -0700980 }
981
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700982 final String version = getPackageVersion(packageName);
983 if (version == null) {
984 loge("Failed to get package version for: " + packageName);
985 return;
986 }
987
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800988 logdWithLocalLog(
989 "Save config to xml, packagename: " + packageName + " phoneId: " + phoneId);
chen xudb04c292019-03-26 17:01:15 -0700990
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700991 FileOutputStream outFile = null;
992 try {
Jayachandran C645ec612020-01-10 10:30:25 -0800993 outFile = new FileOutputStream(new File(mContext.getFilesDir(), fileName));
Meng Wang0f6b2ea2020-01-06 18:31:16 -0800994 config.putString(KEY_VERSION, version);
995 config.writeToStream(outFile);
996 outFile.flush();
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700997 outFile.close();
Hunter Knepshield9f091fc2020-01-28 17:41:43 -0800998 } catch (IOException e) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -0700999 loge(e.toString());
1000 }
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001001 }
1002
Rambo Wang7e3bc122021-03-23 09:24:38 -07001003 @VisibleForTesting
1004 /* package */ void saveConfigToXml(String packageName, @NonNull String extraString, int phoneId,
Jayachandran C645ec612020-01-10 10:30:25 -08001005 CarrierIdentifier carrierId, PersistableBundle config) {
1006 saveConfigToXml(packageName, extraString, phoneId, carrierId, config, false);
1007 }
1008
Rambo Wang7e3bc122021-03-23 09:24:38 -07001009 @VisibleForTesting
1010 /* package */ void saveNoSimConfigToXml(String packageName, PersistableBundle config) {
Jayachandran C645ec612020-01-10 10:30:25 -08001011 saveConfigToXml(packageName, "", -1, null, config, true);
1012 }
1013
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001014 /**
1015 * Reads a bundle from an XML file.
1016 *
1017 * This restores a bundle that was written with {@link #saveConfigToXml}. This returns the saved
Yuchen Dongc15afed2018-04-26 17:05:22 +08001018 * config bundle for the given package and phone ID.
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001019 *
1020 * In case of errors, or if the saved config is from a different package version than the
1021 * current version, then null will be returned.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001022 *
Jayachandran C645ec612020-01-10 10:30:25 -08001023 * @param packageName the name of the package from which we fetched this bundle.
1024 * @param extraString An extra string to be used in the XML file name.
1025 * @param phoneId the phone ID.
1026 * @param isNoSimConfig whether this is invoked for noSimConfig or not.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001027 * @return the bundle from the XML file. Returns null if there is no saved config, the saved
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001028 * version does not match, or reading config fails.
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001029 */
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001030 private PersistableBundle restoreConfigFromXml(String packageName, @NonNull String extraString,
Jayachandran C645ec612020-01-10 10:30:25 -08001031 int phoneId, boolean isNoSimConfig) {
1032 if (packageName == null) {
1033 loge("Cannot restore config with null packageName");
1034 }
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001035 final String version = getPackageVersion(packageName);
1036 if (version == null) {
1037 loge("Failed to get package version for: " + packageName);
1038 return null;
1039 }
Yuchen Dongc15afed2018-04-26 17:05:22 +08001040
Jayachandran C645ec612020-01-10 10:30:25 -08001041 String fileName;
1042 if (isNoSimConfig) {
1043 fileName = getFilenameForNoSimConfig(packageName);
1044 } else {
1045 if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
1046 != TelephonyManager.SIM_STATE_LOADED) {
1047 loge("Skip restore config because SIM records are not loaded.");
1048 return null;
1049 }
1050
1051 final String iccid = getIccIdForPhoneId(phoneId);
1052 final int cid = getSpecificCarrierIdForPhoneId(phoneId);
1053 if (iccid == null) {
1054 loge("Cannot restore config with null iccid.");
1055 return null;
1056 }
1057 fileName = getFilenameForConfig(packageName, extraString, iccid, cid);
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001058 }
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001059
1060 PersistableBundle restoredBundle = null;
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001061 File file = null;
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001062 FileInputStream inFile = null;
1063 try {
Jayachandran C645ec612020-01-10 10:30:25 -08001064 file = new File(mContext.getFilesDir(),fileName);
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001065 inFile = new FileInputStream(file);
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001066
Meng Wang0f6b2ea2020-01-06 18:31:16 -08001067 restoredBundle = PersistableBundle.readFromStream(inFile);
1068 String savedVersion = restoredBundle.getString(KEY_VERSION);
1069 restoredBundle.remove(KEY_VERSION);
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001070
Meng Wang0f6b2ea2020-01-06 18:31:16 -08001071 if (!version.equals(savedVersion)) {
1072 loge("Saved version mismatch: " + version + " vs " + savedVersion);
1073 restoredBundle = null;
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001074 }
Meng Wang0f6b2ea2020-01-06 18:31:16 -08001075
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001076 inFile.close();
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001077 } catch (FileNotFoundException e) {
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001078 // Missing file is normal occurrence that might occur with a new sim or when restoring
1079 // an override file during boot and should not be treated as an error.
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001080 if (file != null) logd("File not found: " + file.getPath());
1081 } catch (IOException e) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001082 loge(e.toString());
1083 }
1084
1085 return restoredBundle;
1086 }
1087
Jayachandran C645ec612020-01-10 10:30:25 -08001088 private PersistableBundle restoreConfigFromXml(String packageName, @NonNull String extraString,
1089 int phoneId) {
1090 return restoreConfigFromXml(packageName, extraString, phoneId, false);
1091 }
1092
1093 private PersistableBundle restoreNoSimConfigFromXml(String packageName) {
1094 return restoreConfigFromXml(packageName, "", -1, true);
1095 }
1096
Junda Liu8a8a53a2015-05-15 16:19:57 -07001097 /**
Jonathan Basseri7697cae2015-07-06 15:49:23 -07001098 * Clears cached carrier config.
1099 * This deletes all saved XML files associated with the given package name. If packageName is
1100 * null, then it deletes all saved XML files.
1101 *
1102 * @param packageName the name of a carrier package, or null if all cached config should be
1103 * cleared.
1104 * @return true iff one or more files were deleted.
Junda Liu8a8a53a2015-05-15 16:19:57 -07001105 */
Jonathan Basseri7697cae2015-07-06 15:49:23 -07001106 private boolean clearCachedConfigForPackage(final String packageName) {
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001107 File dir = mContext.getFilesDir();
1108 File[] packageFiles = dir.listFiles(new FilenameFilter() {
1109 public boolean accept(File dir, String filename) {
Jonathan Basseri7697cae2015-07-06 15:49:23 -07001110 if (packageName != null) {
1111 return filename.startsWith("carrierconfig-" + packageName + "-");
1112 } else {
1113 return filename.startsWith("carrierconfig-");
1114 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001115 }
1116 });
Junda Liu8a8a53a2015-05-15 16:19:57 -07001117 if (packageFiles == null || packageFiles.length < 1) return false;
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001118 for (File f : packageFiles) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001119 logd("Deleting " + f.getName());
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001120 f.delete();
1121 }
Junda Liu8a8a53a2015-05-15 16:19:57 -07001122 return true;
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001123 }
1124
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001125 /** Builds a canonical file name for a config file. */
Jayachandran C645ec612020-01-10 10:30:25 -08001126 private static String getFilenameForConfig(
1127 @NonNull String packageName, @NonNull String extraString,
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001128 @NonNull String iccid, int cid) {
chen xu02581692018-11-11 19:03:44 -08001129 // the same carrier should have a single copy of XML file named after carrier id.
1130 // However, it's still possible that platform doesn't recognize the current sim carrier,
1131 // we will use iccid + carrierid as the canonical file name. carrierid can also handle the
1132 // cases SIM OTA resolves to different carrier while iccid remains the same.
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001133 return "carrierconfig-" + packageName + extraString + "-" + iccid + "-" + cid + ".xml";
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001134 }
1135
Jayachandran C645ec612020-01-10 10:30:25 -08001136 /** Builds a canonical file name for no SIM config file. */
1137 private String getFilenameForNoSimConfig(@NonNull String packageName) {
1138 return "carrierconfig-" + packageName + "-" + "nosim" + ".xml";
1139 }
1140
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001141 /** Return the current version code of a package, or null if the name is not found. */
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001142 private String getPackageVersion(String packageName) {
1143 try {
1144 PackageInfo info = mContext.getPackageManager().getPackageInfo(packageName, 0);
Dianne Hackbornb76ab202017-11-28 17:44:50 -08001145 return Long.toString(info.getLongVersionCode());
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001146 } catch (PackageManager.NameNotFoundException e) {
1147 return null;
1148 }
1149 }
1150
Jonathan Basseri65273c82017-07-25 15:08:42 -07001151 /**
1152 * Read up to date config.
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001153 *
1154 * This reads config bundles for the given phoneId. That means getting the latest bundle from
1155 * the default app and a privileged carrier app, if present. This will not bind to an app if we
1156 * have a saved config file to use instead.
1157 */
1158 private void updateConfigForPhoneId(int phoneId) {
Jonathan Basseri65273c82017-07-25 15:08:42 -07001159 mHandler.sendMessage(mHandler.obtainMessage(EVENT_DO_FETCH_DEFAULT, phoneId, -1));
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001160 }
1161
Malcolm Chen5ea18532019-10-24 19:55:44 -07001162 private void onMultiSimConfigChanged() {
1163 for (int i = TelephonyManager.from(mContext).getActiveModemCount();
1164 i < mConfigFromDefaultApp.length; i++) {
1165 clearConfigForPhone(i, false);
1166 }
1167 }
1168
Hall Liu506724b2018-10-22 18:16:14 -07001169 @Override
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001170 @NonNull
Rambo Wangd2b004b2021-03-30 10:10:23 -07001171 public PersistableBundle getConfigForSubId(int subscriptionId, String callingPackage) {
1172 return getConfigForSubIdWithFeature(subscriptionId, callingPackage, null);
Philip P. Moltmann9797cbb2020-01-07 13:45:00 -08001173 }
1174
1175 @Override
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001176 @NonNull
Rambo Wangd2b004b2021-03-30 10:10:23 -07001177 public PersistableBundle getConfigForSubIdWithFeature(int subscriptionId, String callingPackage,
Philip P. Moltmann9797cbb2020-01-07 13:45:00 -08001178 String callingFeatureId) {
Rambo Wangd2b004b2021-03-30 10:10:23 -07001179 if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subscriptionId,
1180 callingPackage, callingFeatureId, "getCarrierConfig")) {
Rambo Wang42026112021-04-07 20:57:28 +00001181 return new PersistableBundle();
Amit Mahajan40b3fa52015-07-14 10:27:19 -07001182 }
Jeff Davidsona8e4e242018-03-15 17:16:18 -07001183
Rambo Wangd2b004b2021-03-30 10:10:23 -07001184 int phoneId = SubscriptionManager.getPhoneId(subscriptionId);
Jonathan Basseric31f1f32015-05-12 10:13:03 -07001185 PersistableBundle retConfig = CarrierConfigManager.getDefaultConfig();
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001186 if (SubscriptionManager.isValidPhoneId(phoneId)) {
Jonathan Basseric31f1f32015-05-12 10:13:03 -07001187 PersistableBundle config = mConfigFromDefaultApp[phoneId];
yinxuc5e27622017-11-29 15:08:50 -08001188 if (config != null) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001189 retConfig.putAll(config);
yinxuc5e27622017-11-29 15:08:50 -08001190 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001191 config = mConfigFromCarrierApp[phoneId];
yinxuc5e27622017-11-29 15:08:50 -08001192 if (config != null) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001193 retConfig.putAll(config);
yinxuc5e27622017-11-29 15:08:50 -08001194 }
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001195 config = mPersistentOverrideConfigs[phoneId];
1196 if (config != null) {
1197 retConfig.putAll(config);
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001198 }
Hall Liu506724b2018-10-22 18:16:14 -07001199 config = mOverrideConfigs[phoneId];
1200 if (config != null) {
1201 retConfig.putAll(config);
Hall Liu506724b2018-10-22 18:16:14 -07001202 }
Nathan Harold1122e3d2021-01-22 15:45:24 -08001203 // Ignore the theoretical case of the default app not being present since that won't
1204 // work in CarrierConfigLoader today.
1205 final boolean allConfigsApplied =
1206 (mConfigFromCarrierApp[phoneId] != null
1207 || getCarrierPackageForPhoneId(phoneId) == null)
1208 && mConfigFromDefaultApp[phoneId] != null;
1209 retConfig.putBoolean(
1210 CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, allConfigsApplied);
Jayachandran C645ec612020-01-10 10:30:25 -08001211 } else {
1212 if (mNoSimConfig != null) {
1213 retConfig.putAll(mNoSimConfig);
1214 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001215 }
1216 return retConfig;
1217 }
1218
1219 @Override
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001220 public void overrideConfig(int subscriptionId, @Nullable PersistableBundle overrides,
1221 boolean persistent) {
Hall Liu506724b2018-10-22 18:16:14 -07001222 mContext.enforceCallingOrSelfPermission(
1223 android.Manifest.permission.MODIFY_PHONE_STATE, null);
Brad Ebingerf6281ad2019-04-25 11:02:04 -07001224 //TODO: Also check for SHELL UID to restrict this method to testing only (b/131326259)
Hall Liu506724b2018-10-22 18:16:14 -07001225 int phoneId = SubscriptionManager.getPhoneId(subscriptionId);
1226 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001227 logd("Ignore invalid phoneId: " + phoneId + " for subId: " + subscriptionId);
Rambo Wangd2b004b2021-03-30 10:10:23 -07001228 throw new IllegalArgumentException(
1229 "Invalid phoneId " + phoneId + " for subId " + subscriptionId);
Hall Liu506724b2018-10-22 18:16:14 -07001230 }
Rambo Wang38eb5cd2021-03-29 16:39:14 -07001231 // Post to run on handler thread on which all states should be confined.
1232 mHandler.post(() -> {
1233 overrideConfig(mOverrideConfigs, phoneId, overrides);
Hall Liu506724b2018-10-22 18:16:14 -07001234
Rambo Wang38eb5cd2021-03-29 16:39:14 -07001235 if (persistent) {
1236 overrideConfig(mPersistentOverrideConfigs, phoneId, overrides);
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001237
Rambo Wang38eb5cd2021-03-29 16:39:14 -07001238 if (overrides != null) {
1239 final CarrierIdentifier carrierId = getCarrierIdentifierForPhoneId(phoneId);
1240 saveConfigToXml(mPlatformCarrierConfigPackage, OVERRIDE_PACKAGE_ADDITION,
1241 phoneId,
1242 carrierId, mPersistentOverrideConfigs[phoneId]);
1243 } else {
1244 final String iccid = getIccIdForPhoneId(phoneId);
1245 final int cid = getSpecificCarrierIdForPhoneId(phoneId);
1246 String fileName = getFilenameForConfig(mPlatformCarrierConfigPackage,
1247 OVERRIDE_PACKAGE_ADDITION, iccid, cid);
1248 File fileToDelete = new File(mContext.getFilesDir(), fileName);
1249 fileToDelete.delete();
1250 }
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001251 }
Rambo Wang38eb5cd2021-03-29 16:39:14 -07001252 notifySubscriptionInfoUpdater(phoneId);
1253 });
Hall Liu506724b2018-10-22 18:16:14 -07001254 }
1255
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001256 private void overrideConfig(@NonNull PersistableBundle[] currentOverrides, int phoneId,
1257 @Nullable PersistableBundle overrides) {
1258 if (overrides == null) {
Rambo Wang42026112021-04-07 20:57:28 +00001259 currentOverrides[phoneId] = new PersistableBundle();
Torbjorn Eklund723527a2019-02-13 11:16:25 +01001260 } else if (currentOverrides[phoneId] == null) {
1261 currentOverrides[phoneId] = overrides;
1262 } else {
1263 currentOverrides[phoneId].putAll(overrides);
1264 }
1265 }
1266
Hall Liu506724b2018-10-22 18:16:14 -07001267 @Override
Rambo Wangd2b004b2021-03-30 10:10:23 -07001268 public void notifyConfigChangedForSubId(int subscriptionId) {
Jordan Liud7d57fe2019-04-16 12:29:43 -07001269 // Requires the calling app to be either a carrier privileged app for this subId or
Junda Liufbd2bcb2016-06-15 11:15:42 -07001270 // system privileged app with MODIFY_PHONE_STATE permission.
Rambo Wangd2b004b2021-03-30 10:10:23 -07001271 TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mContext,
1272 subscriptionId, "Require carrier privileges or MODIFY_PHONE_STATE permission.");
1273
1274 int phoneId = SubscriptionManager.getPhoneId(subscriptionId);
1275 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
1276 logd("Ignore invalid phoneId: " + phoneId + " for subId: " + subscriptionId);
1277 throw new IllegalArgumentException(
1278 "Invalid phoneId " + phoneId + " for subId " + subscriptionId);
1279 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001280
1281 // This method should block until deleting has completed, so that an error which prevents us
1282 // from clearing the cache is passed back to the carrier app. With the files successfully
1283 // deleted, this can return and we will eventually bind to the carrier app.
Jordan Liud7d57fe2019-04-16 12:29:43 -07001284 String callingPackageName = mContext.getPackageManager().getNameForUid(
1285 Binder.getCallingUid());
Jonathan Basseri7697cae2015-07-06 15:49:23 -07001286 clearCachedConfigForPackage(callingPackageName);
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001287 updateConfigForPhoneId(phoneId);
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001288 }
1289
1290 @Override
1291 public void updateConfigForPhoneId(int phoneId, String simState) {
Junda Liu1f2b34d2015-06-18 15:26:56 -07001292 mContext.enforceCallingOrSelfPermission(
1293 android.Manifest.permission.MODIFY_PHONE_STATE, null);
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001294 logdWithLocalLog("Update config for phoneId: " + phoneId + " simState: " + simState);
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001295 if (!SubscriptionManager.isValidPhoneId(phoneId)) {
Rambo Wangd2b004b2021-03-30 10:10:23 -07001296 throw new IllegalArgumentException("Invalid phoneId: " + phoneId);
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001297 }
1298 // requires Java 7 for switch on string.
1299 switch (simState) {
1300 case IccCardConstants.INTENT_VALUE_ICC_ABSENT:
1301 case IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR:
Junda Liu6f5fddf2016-05-24 16:14:41 -07001302 case IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED:
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001303 case IccCardConstants.INTENT_VALUE_ICC_UNKNOWN:
Malcolm Chendb66de12019-12-09 18:57:07 -08001304 case IccCardConstants.INTENT_VALUE_ICC_NOT_READY:
Junda Liu9f2d2712015-05-15 14:22:45 -07001305 mHandler.sendMessage(mHandler.obtainMessage(EVENT_CLEAR_CONFIG, phoneId, -1));
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001306 break;
1307 case IccCardConstants.INTENT_VALUE_ICC_LOADED:
1308 case IccCardConstants.INTENT_VALUE_ICC_LOCKED:
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001309 updateConfigForPhoneId(phoneId);
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001310 break;
1311 }
1312 }
1313
Junda Liu43d723a2015-05-12 17:23:45 -07001314 @Override
Jeff Sharkeya6fcfed2017-07-20 14:18:39 -06001315 public String getDefaultCarrierServicePackageName() {
Shuo Qianefdb7962019-12-19 15:54:27 -08001316 mContext.enforceCallingOrSelfPermission(
1317 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
1318 "getDefaultCarrierServicePackageName");
Jeff Sharkeya6fcfed2017-07-20 14:18:39 -06001319 return mPlatformCarrierConfigPackage;
1320 }
1321
Rambo Wang7e3bc122021-03-23 09:24:38 -07001322 @VisibleForTesting
1323 /* package */ Handler getHandler() {
1324 return mHandler;
1325 }
1326
1327 @VisibleForTesting
1328 /* package */ PersistableBundle getConfigFromDefaultApp(int phoneId) {
1329 return mConfigFromDefaultApp[phoneId];
1330 }
1331
1332 @VisibleForTesting
1333 /* package */ PersistableBundle getConfigFromCarrierApp(int phoneId) {
1334 return mConfigFromCarrierApp[phoneId];
1335 }
1336
1337 @VisibleForTesting
1338 /* package */ PersistableBundle getNoSimConfig() {
1339 return mNoSimConfig;
1340 }
1341
1342 @VisibleForTesting
1343 /* package */ PersistableBundle getOverrideConfig(int phoneId) {
1344 return mOverrideConfigs[phoneId];
1345 }
1346
Rambo Wangdba4ccd2021-09-17 13:18:35 -07001347 private void unbindIfBound(Context context, CarrierServiceConnection conn) {
1348 if (conn.isBound) {
1349 conn.isBound = false;
Jayachandran C645ec612020-01-10 10:30:25 -08001350 context.unbindService(conn);
1351 }
1352 }
1353
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001354 /**
Rambo Wang610fdf62021-03-08 21:37:11 -08001355 * Returns a boxed Integer object for phoneId, services as message token to distinguish messages
1356 * with same code when calling {@link Handler#removeMessages(int, Object)}.
1357 */
1358 private Integer getMessageToken(int phoneId) {
1359 if (phoneId < -128 || phoneId > 127) {
1360 throw new IllegalArgumentException("phoneId should be in range [-128, 127], inclusive");
1361 }
1362 // Integer#valueOf guarantees the integers within [-128, 127] are cached and thus memory
1363 // comparison (==) returns true for the same integer.
1364 return Integer.valueOf(phoneId);
1365 }
1366
1367 /**
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001368 * If {@code args} contains {@link #DUMP_ARG_REQUESTING_PACKAGE} and a following package name,
1369 * we'll also call {@link IBinder#dump} on the default carrier service (if bound) and the
1370 * specified carrier service (if bound). Typically, this is done for connectivity bug reports
1371 * where we don't call {@code dumpsys activity service all-non-platform} because that contains
1372 * too much info, but we still want to let carrier apps include their diagnostics.
1373 */
Jeff Sharkeya6fcfed2017-07-20 14:18:39 -06001374 @Override
Junda Liu43d723a2015-05-12 17:23:45 -07001375 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001376 IndentingPrintWriter indentPW = new IndentingPrintWriter(pw, " ");
Junda Liu43d723a2015-05-12 17:23:45 -07001377 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1378 != PackageManager.PERMISSION_GRANTED) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001379 indentPW.println("Permission Denial: can't dump carrierconfig from from pid="
Junda Liu43d723a2015-05-12 17:23:45 -07001380 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
1381 return;
1382 }
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001383 String requestingPackage = null;
1384 int requestingPackageIndex = ArrayUtils.indexOf(args, DUMP_ARG_REQUESTING_PACKAGE);
1385 if (requestingPackageIndex >= 0 && requestingPackageIndex < args.length - 1
1386 && !TextUtils.isEmpty(args[requestingPackageIndex + 1])) {
1387 requestingPackage = args[requestingPackageIndex + 1];
1388 // Throws a SecurityException if the caller is impersonating another app in an effort to
1389 // dump extra info (which may contain PII the caller doesn't have a right to).
1390 enforceCallerIsSystemOrRequestingPackage(requestingPackage);
1391 }
1392
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001393 indentPW.println("CarrierConfigLoader: " + this);
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001394 for (int i = 0; i < TelephonyManager.from(mContext).getActiveModemCount(); i++) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001395 indentPW.println("Phone Id = " + i);
shuoq26a3a4c2016-12-16 11:06:48 -08001396 // display default values in CarrierConfigManager
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001397 printConfig(CarrierConfigManager.getDefaultConfig(), indentPW,
shuoq26a3a4c2016-12-16 11:06:48 -08001398 "Default Values from CarrierConfigManager");
shuoq26a3a4c2016-12-16 11:06:48 -08001399 // display ConfigFromDefaultApp
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001400 printConfig(mConfigFromDefaultApp[i], indentPW, "mConfigFromDefaultApp");
shuoq26a3a4c2016-12-16 11:06:48 -08001401 // display ConfigFromCarrierApp
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001402 printConfig(mConfigFromCarrierApp[i], indentPW, "mConfigFromCarrierApp");
1403 printConfig(mPersistentOverrideConfigs[i], indentPW, "mPersistentOverrideConfigs");
1404 printConfig(mOverrideConfigs[i], indentPW, "mOverrideConfigs");
shuoq26a3a4c2016-12-16 11:06:48 -08001405 }
chen xudb04c292019-03-26 17:01:15 -07001406
Jayachandran C645ec612020-01-10 10:30:25 -08001407 printConfig(mNoSimConfig, indentPW, "mNoSimConfig");
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001408 indentPW.println("CarrierConfigLoadingLog=");
1409 mCarrierConfigLoadingLog.dump(fd, indentPW, args);
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001410
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001411 if (requestingPackage != null) {
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001412 logd("Including default and requesting package " + requestingPackage
1413 + " carrier services in dump");
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001414 indentPW.println("");
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001415 indentPW.println("Connected services");
1416 dumpCarrierServiceIfBound(fd, indentPW, "Default config package",
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001417 mPlatformCarrierConfigPackage, false /* considerCarrierPrivileges */);
1418 dumpCarrierServiceIfBound(fd, indentPW, "Requesting package", requestingPackage,
1419 true /* considerCarrierPrivileges */);
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001420 }
shuoq26a3a4c2016-12-16 11:06:48 -08001421 }
1422
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001423 private void printConfig(PersistableBundle configApp, IndentingPrintWriter indentPW,
1424 String name) {
1425 indentPW.increaseIndent();
shuoq26a3a4c2016-12-16 11:06:48 -08001426 if (configApp == null) {
shuoq26a3a4c2016-12-16 11:06:48 -08001427 indentPW.println(name + " : null ");
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001428 indentPW.decreaseIndent();
1429 indentPW.println("");
shuoq26a3a4c2016-12-16 11:06:48 -08001430 return;
1431 }
shuoq26a3a4c2016-12-16 11:06:48 -08001432 indentPW.println(name + " : ");
1433 List<String> sortedKeys = new ArrayList<String>(configApp.keySet());
1434 Collections.sort(sortedKeys);
1435 indentPW.increaseIndent();
1436 indentPW.increaseIndent();
1437 for (String key : sortedKeys) {
1438 if (configApp.get(key) != null && configApp.get(key) instanceof Object[]) {
1439 indentPW.println(key + " = " +
1440 Arrays.toString((Object[]) configApp.get(key)));
1441 } else if (configApp.get(key) != null && configApp.get(key) instanceof int[]) {
1442 indentPW.println(key + " = " + Arrays.toString((int[]) configApp.get(key)));
1443 } else {
1444 indentPW.println(key + " = " + configApp.get(key));
1445 }
Junda Liu43d723a2015-05-12 17:23:45 -07001446 }
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001447 indentPW.decreaseIndent();
1448 indentPW.decreaseIndent();
1449 indentPW.decreaseIndent();
1450 indentPW.println("");
Junda Liu43d723a2015-05-12 17:23:45 -07001451 }
1452
Hunter Knepshielde601f432020-02-19 10:16:04 -08001453 /**
1454 * Passes without problem when one of these conditions is true:
1455 * - The caller is a privileged UID (e.g. for dumpstate.cpp generating a bug report, where the
1456 * system knows the true caller plumbed in through the {@link android.os.BugreportManager} API).
1457 * - The caller's UID matches the supplied package.
1458 *
1459 * @throws SecurityException if none of the above conditions are met.
1460 */
1461 private void enforceCallerIsSystemOrRequestingPackage(String requestingPackage)
1462 throws SecurityException {
1463 final int callingUid = Binder.getCallingUid();
1464 if (callingUid == Process.ROOT_UID || callingUid == Process.SYSTEM_UID
1465 || callingUid == Process.SHELL_UID || callingUid == Process.PHONE_UID) {
1466 // Bug reports (dumpstate.cpp) run as SHELL, and let some other privileged UIDs through
1467 // as well.
1468 return;
1469 }
1470 // An app is trying to dump extra detail, block it if they aren't who they claim to be.
1471 AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class);
1472 if (appOps == null) {
1473 throw new SecurityException("No AppOps");
1474 }
1475 // Will throw a SecurityException if the UID and package don't match.
1476 appOps.checkPackage(callingUid, requestingPackage);
1477 }
1478
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001479 /**
1480 * Searches for one or more appropriate {@link CarrierService} instances to dump based on the
1481 * current connections.
1482 *
1483 * @param targetPkgName the target package name to dump carrier services for
1484 * @param considerCarrierPrivileges if true, allow a carrier service to be dumped if it shares
1485 * carrier privileges with {@code targetPkgName};
1486 * otherwise, only dump a carrier service if it is {@code
1487 * targetPkgName}
1488 */
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001489 private void dumpCarrierServiceIfBound(FileDescriptor fd, IndentingPrintWriter indentPW,
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001490 String prefix, String targetPkgName, boolean considerCarrierPrivileges) {
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001491 // Null package is possible if it's early in the boot process, there was a recent crash, we
1492 // loaded the config from XML most recently, or a SIM slot is empty. Carrier apps with
1493 // long-lived bindings should typically get dumped here regardless. Even if an app is being
1494 // used for multiple phoneIds, we assume that it's smart enough to handle that on its own,
1495 // and that in most cases we'd just be dumping duplicate information and bloating a report.
1496 indentPW.increaseIndent();
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001497 indentPW.println(prefix + " : " + targetPkgName);
1498 Set<String> dumpedPkgNames = new ArraySet<>(mServiceConnection.length);
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001499 for (CarrierServiceConnection connection : mServiceConnection) {
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001500 if (connection == null || !SubscriptionManager.isValidPhoneId(connection.phoneId)
1501 || TextUtils.isEmpty(connection.pkgName)) {
1502 continue;
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001503 }
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001504 final String servicePkgName = connection.pkgName;
1505 // Note: we intentionally ignore system components here because we should NOT match the
1506 // shell caller that's typically used for bug reports via non-BugreportManager triggers.
1507 final boolean exactPackageMatch = TextUtils.equals(targetPkgName, servicePkgName);
1508 final boolean carrierPrivilegesMatch =
1509 considerCarrierPrivileges && hasCarrierPrivileges(targetPkgName,
1510 connection.phoneId);
1511 if (!exactPackageMatch && !carrierPrivilegesMatch) continue;
1512 // Make sure this service is actually alive before trying to dump it. We don't pay
1513 // attention to mServiceBound[connection.phoneId] because typically carrier apps will
1514 // request long-lived bindings, and even if we unbind the app, it may still be alive due
1515 // to CarrierServiceBindHelper. Pull it out as a reference so even if it gets set to
1516 // null within the ServiceConnection during unbinding we can avoid an NPE.
1517 final IBinder service = connection.service;
1518 if (service == null || !service.isBinderAlive() || !service.pingBinder()) continue;
1519 // We've got a live service. Last check is just to make sure we don't dump a package
1520 // multiple times.
1521 if (!dumpedPkgNames.add(servicePkgName)) continue;
1522 if (!exactPackageMatch) {
1523 logd(targetPkgName + " has carrier privileges on phoneId " + connection.phoneId
1524 + ", service provided by " + servicePkgName);
1525 indentPW.increaseIndent();
1526 indentPW.println("Proxy : " + servicePkgName);
1527 indentPW.decreaseIndent();
1528 }
1529 // Flush before we let the app output anything to ensure correct ordering of output.
1530 // Internally, Binder#dump calls flush on its printer after finishing so we don't
1531 // need to do anything after.
1532 indentPW.flush();
1533 try {
1534 logd("Dumping " + servicePkgName);
1535 // We don't need to give the carrier service any args.
1536 connection.service.dump(fd, null /* args */);
1537 logd("Done with " + servicePkgName);
1538 } catch (RemoteException e) {
1539 logd("RemoteException from " + servicePkgName, e);
1540 indentPW.increaseIndent();
1541 indentPW.println("RemoteException");
1542 indentPW.increaseIndent();
1543 e.printStackTrace(indentPW);
1544 indentPW.decreaseIndent();
1545 indentPW.decreaseIndent();
1546 // We won't retry this package again because now it's in dumpedPkgNames.
1547 }
1548 indentPW.println("");
Jordan Liu46ed5db2020-01-28 08:55:20 -08001549 }
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001550 if (dumpedPkgNames.isEmpty()) {
1551 indentPW.increaseIndent();
1552 indentPW.println("Not bound");
1553 indentPW.decreaseIndent();
1554 indentPW.println("");
1555 }
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001556 indentPW.decreaseIndent();
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001557 }
1558
1559 private boolean hasCarrierPrivileges(String pkgName, int phoneId) {
1560 int[] subIds = SubscriptionManager.getSubId(phoneId);
1561 if (ArrayUtils.isEmpty(subIds)) {
1562 return false;
1563 }
1564 return TelephonyManager.from(mContext).createForSubscriptionId(
1565 subIds[0]).checkCarrierPrivilegesForPackage(pkgName)
1566 == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
Jordan Liu46ed5db2020-01-28 08:55:20 -08001567 }
1568
Zach Johnson36d7aab2015-05-22 15:43:00 -07001569 private class CarrierServiceConnection implements ServiceConnection {
Hunter Knepshieldeefb31b2020-02-19 15:30:54 -08001570 final int phoneId;
1571 final String pkgName;
1572 final int eventId;
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001573 IBinder service;
Rambo Wangdba4ccd2021-09-17 13:18:35 -07001574 // If bindService was called and return true which means unbindService
1575 // must be called later to release the connection
1576 boolean isBound;
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001577
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001578 CarrierServiceConnection(int phoneId, String pkgName, int eventId) {
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001579 this.phoneId = phoneId;
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001580 this.pkgName = pkgName;
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001581 this.eventId = eventId;
Rambo Wangdba4ccd2021-09-17 13:18:35 -07001582 this.isBound = false;
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001583 }
1584
1585 @Override
1586 public void onServiceConnected(ComponentName name, IBinder service) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001587 logd("Connected to config app: " + name.flattenToShortString());
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001588 this.service = service;
1589 mHandler.sendMessage(mHandler.obtainMessage(eventId, phoneId, -1, this));
1590 }
1591
1592 @Override
1593 public void onServiceDisconnected(ComponentName name) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001594 logd("Disconnected from config app: " + name.flattenToShortString());
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001595 this.service = null;
Jordan Liu46ed5db2020-01-28 08:55:20 -08001596 }
1597
1598 @Override
1599 public void onBindingDied(ComponentName name) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001600 logd("Binding died from config app: " + name.flattenToShortString());
Jordan Liu46ed5db2020-01-28 08:55:20 -08001601 this.service = null;
Jordan Liu46ed5db2020-01-28 08:55:20 -08001602 }
1603
1604 @Override
1605 public void onNullBinding(ComponentName name) {
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001606 logd("Null binding from config app: " + name.flattenToShortString());
Jordan Liu46ed5db2020-01-28 08:55:20 -08001607 this.service = null;
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001608 }
1609 }
1610
1611 private class ConfigLoaderBroadcastReceiver extends BroadcastReceiver {
1612 @Override
1613 public void onReceive(Context context, Intent intent) {
1614 String action = intent.getAction();
Junda Liu8a8a53a2015-05-15 16:19:57 -07001615 boolean replace = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
1616 // If replace is true, only care ACTION_PACKAGE_REPLACED.
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001617 if (replace && !Intent.ACTION_PACKAGE_REPLACED.equals(action)) {
Junda Liu8a8a53a2015-05-15 16:19:57 -07001618 return;
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001619 }
Junda Liu8a8a53a2015-05-15 16:19:57 -07001620
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001621 switch (action) {
Nanxi Chen3d670502016-03-17 16:32:09 -07001622 case Intent.ACTION_BOOT_COMPLETED:
1623 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SYSTEM_UNLOCKED, null));
1624 break;
1625
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001626 case Intent.ACTION_PACKAGE_ADDED:
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001627 case Intent.ACTION_PACKAGE_REMOVED:
Junda Liu8a8a53a2015-05-15 16:19:57 -07001628 case Intent.ACTION_PACKAGE_REPLACED:
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001629 int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
1630 String packageName = mContext.getPackageManager().getNameForUid(uid);
Junda Liu8a8a53a2015-05-15 16:19:57 -07001631 if (packageName != null) {
1632 // We don't have a phoneId for arg1.
1633 mHandler.sendMessage(
1634 mHandler.obtainMessage(EVENT_PACKAGE_CHANGED, packageName));
1635 }
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001636 break;
Jonathan Basseri1f743c92015-05-15 00:19:46 -07001637 }
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001638 }
1639 }
1640
Rambo Wangab13e3e2021-04-08 15:01:06 -07001641 // Get readable string for the message code supported in this class.
1642 private static String eventToString(int code) {
1643 switch (code) {
1644 case EVENT_CLEAR_CONFIG:
1645 return "EVENT_CLEAR_CONFIG";
1646 case EVENT_CONNECTED_TO_DEFAULT:
1647 return "EVENT_CONNECTED_TO_DEFAULT";
1648 case EVENT_CONNECTED_TO_CARRIER:
1649 return "EVENT_CONNECTED_TO_CARRIER";
1650 case EVENT_FETCH_DEFAULT_DONE:
1651 return "EVENT_FETCH_DEFAULT_DONE";
1652 case EVENT_FETCH_CARRIER_DONE:
1653 return "EVENT_FETCH_CARRIER_DONE";
1654 case EVENT_DO_FETCH_DEFAULT:
1655 return "EVENT_DO_FETCH_DEFAULT";
1656 case EVENT_DO_FETCH_CARRIER:
1657 return "EVENT_DO_FETCH_CARRIER";
1658 case EVENT_PACKAGE_CHANGED:
1659 return "EVENT_PACKAGE_CHANGED";
1660 case EVENT_BIND_DEFAULT_TIMEOUT:
1661 return "EVENT_BIND_DEFAULT_TIMEOUT";
1662 case EVENT_BIND_CARRIER_TIMEOUT:
1663 return "EVENT_BIND_CARRIER_TIMEOUT";
1664 case EVENT_CHECK_SYSTEM_UPDATE:
1665 return "EVENT_CHECK_SYSTEM_UPDATE";
1666 case EVENT_SYSTEM_UNLOCKED:
1667 return "EVENT_SYSTEM_UNLOCKED";
1668 case EVENT_FETCH_DEFAULT_TIMEOUT:
1669 return "EVENT_FETCH_DEFAULT_TIMEOUT";
1670 case EVENT_FETCH_CARRIER_TIMEOUT:
1671 return "EVENT_FETCH_CARRIER_TIMEOUT";
1672 case EVENT_SUBSCRIPTION_INFO_UPDATED:
1673 return "EVENT_SUBSCRIPTION_INFO_UPDATED";
1674 case EVENT_MULTI_SIM_CONFIG_CHANGED:
1675 return "EVENT_MULTI_SIM_CONFIG_CHANGED";
1676 case EVENT_DO_FETCH_DEFAULT_FOR_NO_SIM_CONFIG:
1677 return "EVENT_DO_FETCH_DEFAULT_FOR_NO_SIM_CONFIG";
1678 case EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE:
1679 return "EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_DONE";
1680 case EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG:
1681 return "EVENT_CONNECTED_TO_DEFAULT_FOR_NO_SIM_CONFIG";
1682 case EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT:
1683 return "EVENT_BIND_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT";
1684 case EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT:
1685 return "EVENT_FETCH_DEFAULT_FOR_NO_SIM_CONFIG_TIMEOUT";
1686 default:
1687 return "UNKNOWN(" + code + ")";
1688 }
1689 }
1690
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001691 private void logd(String msg) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001692 Log.d(LOG_TAG, msg);
1693 }
1694
Hunter Knepshieldd0ed6212020-01-28 17:43:16 -08001695 private void logd(String msg, Throwable tr) {
1696 Log.d(LOG_TAG, msg, tr);
1697 }
1698
Hunter Knepshield9f091fc2020-01-28 17:41:43 -08001699 private void logdWithLocalLog(String msg) {
chen xudb04c292019-03-26 17:01:15 -07001700 Log.d(LOG_TAG, msg);
1701 mCarrierConfigLoadingLog.log(msg);
1702 }
1703
1704 private void loge(String msg) {
Jonathan Basseri6b50e9f2015-05-12 20:18:31 -07001705 Log.e(LOG_TAG, msg);
chen xudb04c292019-03-26 17:01:15 -07001706 mCarrierConfigLoadingLog.log(msg);
Jonathan Basseri6465afd2015-02-25 13:05:57 -08001707 }
1708}