diff options
author | Rohit Yengisetty <rohit@cyngn.com> | 2015-10-09 13:43:20 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-04-21 17:59:13 -0700 |
commit | a1756e05539aa5e4031f5f165d3d98bcbb22ba0a (patch) | |
tree | 145e226cd4c8e0275679095c9593626322d10739 | |
parent | 59526b3bf8b29ed565b3ff51f13ecfca6437869f (diff) | |
download | frameworks_base-a1756e05539aa5e4031f5f165d3d98bcbb22ba0a.zip frameworks_base-a1756e05539aa5e4031f5f165d3d98bcbb22ba0a.tar.gz frameworks_base-a1756e05539aa5e4031f5f165d3d98bcbb22ba0a.tar.bz2 |
SettingsProvider : load region-specific settings
load region specific mobile data and data roaming
for EU and LATAM region for feijao.
Issue-id: FEIJ-23
Change-Id: Icd250f6d2fd3978d4c34a88405e53d09e479b207
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 143d4ec..8515fdc 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -44,6 +44,12 @@ import android.provider.Settings.Secure; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.AssetManager; +import android.util.DisplayMetrics; +import android.content.pm.PackageManager.NameNotFoundException; + import com.android.ims.ImsConfig; import com.android.internal.content.PackageHelper; @@ -102,6 +108,7 @@ class DatabaseHelper extends SQLiteOpenHelper { private static final String TABLE_SYSTEM = "system"; private static final String TABLE_SECURE = "secure"; private static final String TABLE_GLOBAL = "global"; + private String mPublicSrcDir; static { mValidTables.add(TABLE_SYSTEM); @@ -133,6 +140,13 @@ class DatabaseHelper extends SQLiteOpenHelper { super(context, dbNameForUser(userHandle), null, DATABASE_VERSION); mContext = context; mUserHandle = userHandle; + try { + String packageName = mContext.getPackageName(); + mPublicSrcDir = mContext.getPackageManager().getApplicationInfo(packageName, 0) + .publicSourceDir; + } catch (NameNotFoundException e) { + e.printStackTrace(); + } } public static boolean isValidTable(String name) { @@ -2841,7 +2855,7 @@ class DatabaseHelper extends SQLiteOpenHelper { RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); // Data roaming default, based on build - loadBooleanSetting(stmt, Settings.Global.DATA_ROAMING, + loadRegionLockedBooleanSetting(stmt, Settings.Global.DATA_ROAMING, R.bool.def_enable_data_roaming); loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED, @@ -2862,18 +2876,18 @@ class DatabaseHelper extends SQLiteOpenHelper { } // Mobile Data default, based on build - loadBooleanSetting(stmt, Settings.Global.MOBILE_DATA, + loadRegionLockedBooleanSetting(stmt, Settings.Global.MOBILE_DATA, R.bool.def_enable_mobile_data); int phoneCount = TelephonyManager.getDefault().getPhoneCount(); // SUB specific flags for Multisim devices for (int phoneId = 0; phoneId < MAX_PHONE_COUNT; phoneId++) { // Mobile Data default, based on build - loadBooleanSetting(stmt, Settings.Global.MOBILE_DATA + phoneId, + loadRegionLockedBooleanSetting(stmt, Settings.Global.MOBILE_DATA + phoneId, R.bool.def_enable_mobile_data); // Data roaming default, based on build - loadBooleanSetting(stmt, Settings.Global.DATA_ROAMING + phoneId, + loadRegionLockedBooleanSetting(stmt, Settings.Global.DATA_ROAMING + phoneId, R.bool.def_enable_data_roaming); } @@ -3000,6 +3014,36 @@ class DatabaseHelper extends SQLiteOpenHelper { stmt.execute(); } + private Resources getRegionLockedResources() { + Configuration tempConfiguration = new Configuration(); + String mcc = SystemProperties.get("ro.prebundled.mcc"); + Resources customResources = null; + if (!TextUtils.isEmpty(mcc)) { + tempConfiguration.mcc = Integer.parseInt(mcc); + AssetManager assetManager = new AssetManager(); + assetManager.addAssetPath(mPublicSrcDir); + customResources = new Resources(assetManager, new DisplayMetrics(), + tempConfiguration); + } + + return customResources; + } + + private void loadRegionLockedStringSetting(SQLiteStatement stmt, String key, int resid) { + Resources customResources = getRegionLockedResources(); + loadSetting(stmt, key, customResources == null ? mContext.getResources().getString(resid) + : customResources.getString(resid)); + } + + private void loadRegionLockedBooleanSetting(SQLiteStatement stmt, String key, int resId) { + Resources customResources = getRegionLockedResources(); + if (customResources == null) { + customResources = mContext.getResources(); + } + + loadSetting(stmt, key, customResources.getBoolean(resId) ? "1" : "0"); + } + private void loadStringSetting(SQLiteStatement stmt, String key, int resid) { loadSetting(stmt, key, mContext.getResources().getString(resid)); } |