Switching to PersistableBundle in carrier config API.
Part of this API involves persisting config bundles to avoid binding to
apps at critical moments (like boot). Regular bundles should not be
written to disk because they support object types that can lose their
meaning while the data is at rest.
In order to use PersistableBundle, we must either start with one or
filter unwanted types out of Bundle objects. Since the carrier config
API has no use for unsupported types, we chose to use PersistableBundle
everywhere.
Bug: 20268926
Change-Id: Ia85c1b2426907a5e6431095dbd3776213c7eb45d
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 53e67bd..75acefe 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -26,16 +26,16 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.PackageManager;
import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.AsyncResult;
import android.os.Binder;
-import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
+import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -75,9 +75,9 @@
// The context for phone app, passed from PhoneGlobals.
private Context mContext;
// Carrier configs from default app, indexed by phoneID.
- private Bundle[] mConfigFromDefaultApp;
+ private PersistableBundle[] mConfigFromDefaultApp;
// Carrier configs from privileged carrier config app, indexed by phoneID.
- private Bundle[] mConfigFromCarrierApp;
+ private PersistableBundle[] mConfigFromCarrierApp;
// Service connection for binding to config app.
private ConfigServiceConnection[] mServiceConnection;
@@ -117,7 +117,7 @@
log("mHandler: " + msg.what + " phoneId: " + phoneId);
CarrierIdentifier carrierId;
ConfigServiceConnection conn;
- Bundle config;
+ PersistableBundle config;
switch (msg.what) {
case EVENT_CLEAR_CONFIG:
mConfigFromDefaultApp[phoneId] = null;
@@ -220,8 +220,8 @@
mContext.registerReceiver(mReceiver, triggers);
int numPhones = TelephonyManager.from(context).getPhoneCount();
- mConfigFromDefaultApp = new Bundle[numPhones];
- mConfigFromCarrierApp = new Bundle[numPhones];
+ mConfigFromDefaultApp = new PersistableBundle[numPhones];
+ mConfigFromCarrierApp = new PersistableBundle[numPhones];
mServiceConnection = new ConfigServiceConnection[numPhones];
// Make this service available through ServiceManager.
ServiceManager.addService(Context.CARRIER_CONFIG_SERVICE, this);
@@ -291,11 +291,11 @@
}
@Override
- public Bundle getConfigForSubId(int subId) {
+ public PersistableBundle getConfigForSubId(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
- Bundle retConfig = CarrierConfigManager.getDefaultConfig();
+ PersistableBundle retConfig = CarrierConfigManager.getDefaultConfig();
if (SubscriptionManager.isValidPhoneId(phoneId)) {
- Bundle config = mConfigFromDefaultApp[phoneId];
+ PersistableBundle config = mConfigFromDefaultApp[phoneId];
if (config != null) retConfig.putAll(config);
config = mConfigFromCarrierApp[phoneId];
if (config != null) retConfig.putAll(config);