Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f96da6ce authored by Rohit Yengisetty's avatar Rohit Yengisetty Committed by Ed Mancebo
Browse files

SettingsProvider : load region-specific settings for mobile data

issue-id: PAELLA-48
Change-Id: Icd250f6d2fd3978d4c34a88405e53d09e479b207
(cherry picked from commit 0a9778ae)
parent dc2771c6
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -2824,14 +2824,14 @@ public 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
@@ -2952,7 +2952,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        stmt.execute();
    }

    private void loadRegionLockedStringSetting(SQLiteStatement stmt, String key, int resid) {
    private Resources getRegionLockedResources() {
        Configuration tempConfiguration = new Configuration();
        String mcc = SystemProperties.get("ro.prebundled.mcc");
        Resources customResources = null;
@@ -2963,10 +2963,25 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            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));
    }