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

Commit ae9ebfd1 authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Gerrit Code Review
Browse files

Merge "add MVNO field for APN Editor"

parents 53309365 aa4d4c65
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -539,6 +539,29 @@
        <item>0</item>
    </string-array>

    <!-- MVNO Info used in APN editor -->
    <string-array name="mvno_type_entries">
        <!-- Do not translate. -->
        <item>None</item>
        <!-- Do not translate. -->
        <item>SPN</item>
        <!-- Do not translate. -->
        <item>IMSI</item>
        <!-- Do not translate. -->
        <item>GID</item>
    </string-array>

    <string-array translatable="false" name="mvno_type_values">
        <!-- Do not translate. -->
        <item></item>
        <!-- Do not translate. -->
        <item>spn</item>
        <!-- Do not translate. -->
        <item>imsi</item>
        <!-- Do not translate. -->
        <item>gid</item>
    </string-array>

    <!-- Apps on SD instalaltion location options in ApplicationSettings -->
    <string-array name="app_install_location_entries">
        <item>Internal device storage</item>
+4 −0
Original line number Diff line number Diff line
@@ -2117,6 +2117,10 @@
    <string name="carrier_enabled_summaryOff">APN disabled</string>
    <!-- Edit Beaerer Info of APN -->
    <string name="bearer">Bearer</string>
    <!-- Edit Mvno Type Info of APN -->
    <string name="mvno_type">MVNO type</string>
    <!-- Edit Mvno Match Data Info of APN -->
    <string name="mvno_match_data">MVNO value</string>
    <!-- Edit access point screen menu option to delete this APN -->
    <string name="menu_delete">Delete APN</string>
    <!-- APNs screen menu option to create a brand spanking new APN -->
+13 −0
Original line number Diff line number Diff line
@@ -141,4 +141,17 @@
        android:entries="@array/bearer_entries"
        android:entryValues="@array/bearer_values"
        />
    <ListPreference
        android:title="@string/mvno_type"
        android:key="mvno_type"
        android:entries="@array/mvno_type_entries"
        android:entryValues="@array/mvno_type_values"
        />
    <EditTextPreference
        android:title="@string/mvno_match_data"
        android:dialogTitle="@string/mvno_match_data"
        android:key="mvno_match_data"
        android:singleLine="true"
        android:inputType="text"
        />
</PreferenceScreen>   
+49 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class ApnEditor extends PreferenceActivity
    private final static String KEY_ROAMING_PROTOCOL = "apn_roaming_protocol";
    private final static String KEY_CARRIER_ENABLED = "carrier_enabled";
    private final static String KEY_BEARER = "bearer";
    private final static String KEY_MVNO_TYPE = "mvno_type";

    private static final int MENU_DELETE = Menu.FIRST;
    private static final int MENU_SAVE = Menu.FIRST + 1;
@@ -82,6 +83,8 @@ public class ApnEditor extends PreferenceActivity
    private ListPreference mRoamingProtocol;
    private CheckBoxPreference mCarrierEnabled;
    private ListPreference mBearer;
    private ListPreference mMvnoType;
    private EditTextPreference mMvnoMatchData;

    private String mCurMnc;
    private String mCurMcc;
@@ -115,7 +118,9 @@ public class ApnEditor extends PreferenceActivity
            Telephony.Carriers.PROTOCOL, // 16
            Telephony.Carriers.CARRIER_ENABLED, // 17
            Telephony.Carriers.BEARER, // 18
            Telephony.Carriers.ROAMING_PROTOCOL // 19
            Telephony.Carriers.ROAMING_PROTOCOL, // 19
            Telephony.Carriers.MVNO_TYPE,   // 20
            Telephony.Carriers.MVNO_MATCH_DATA  // 21
    };

    private static final int ID_INDEX = 0;
@@ -137,6 +142,8 @@ public class ApnEditor extends PreferenceActivity
    private static final int CARRIER_ENABLED_INDEX = 17;
    private static final int BEARER_INDEX = 18;
    private static final int ROAMING_PROTOCOL_INDEX = 19;
    private static final int MVNO_TYPE_INDEX = 20;
    private static final int MVNO_MATCH_DATA_INDEX = 21;


    @Override
@@ -174,6 +181,10 @@ public class ApnEditor extends PreferenceActivity
        mBearer = (ListPreference) findPreference(KEY_BEARER);
        mBearer.setOnPreferenceChangeListener(this);

        mMvnoType = (ListPreference) findPreference(KEY_MVNO_TYPE);
        mMvnoType.setOnPreferenceChangeListener(this);
        mMvnoMatchData = (EditTextPreference) findPreference("mvno_match_data");

        mRes = getResources();

        final Intent intent = getIntent();
@@ -274,6 +285,9 @@ public class ApnEditor extends PreferenceActivity
            mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX));
            mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
            mBearer.setValue(mCursor.getString(BEARER_INDEX));
            mMvnoType.setValue(mCursor.getString(MVNO_TYPE_INDEX));
            mMvnoMatchData.setEnabled(false);
            mMvnoMatchData.setText(mCursor.getString(MVNO_MATCH_DATA_INDEX));
        }

        mName.setSummary(checkNull(mName.getText()));
@@ -307,6 +321,9 @@ public class ApnEditor extends PreferenceActivity
                checkNull(protocolDescription(mRoamingProtocol.getValue(), mRoamingProtocol)));
        mBearer.setSummary(
                checkNull(bearerDescription(mBearer.getValue())));
        mMvnoType.setSummary(
                checkNull(mvnoDescription(mMvnoType.getValue())));
        mMvnoMatchData.setSummary(checkNull(mMvnoMatchData.getText()));
    }

    /**
@@ -342,6 +359,27 @@ public class ApnEditor extends PreferenceActivity
        }
    }

    private String mvnoDescription(String raw) {
        int mvnoIndex = mMvnoType.findIndexOfValue(raw);
        if (mvnoIndex == -1) {
            return null;
        } else {
            String[] values = mRes.getStringArray(R.array.mvno_type_entries);
            if (values[mvnoIndex].equals("None")) {
                mMvnoMatchData.setEnabled(false);
                mMvnoMatchData.setText("");
            } else {
                mMvnoMatchData.setEnabled(true);
            }

            try {
                return values[mvnoIndex];
            } catch (ArrayIndexOutOfBoundsException e) {
                return null;
            }
        }
    }

    public boolean onPreferenceChange(Preference preference, Object newValue) {
        String key = preference.getKey();
        if (KEY_AUTH_TYPE.equals(key)) {
@@ -375,6 +413,13 @@ public class ApnEditor extends PreferenceActivity
            }
            mBearer.setValue((String) newValue);
            mBearer.setSummary(bearer);
        } else if (KEY_MVNO_TYPE.equals(key)) {
            String mvno = mvnoDescription((String) newValue);
            if (mvno == null) {
                return false;
            }
            mMvnoType.setValue((String) newValue);
            mMvnoType.setSummary(mvno);
        }

        return true;
@@ -508,6 +553,9 @@ public class ApnEditor extends PreferenceActivity
            values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
        }

        values.put(Telephony.Carriers.MVNO_TYPE, checkNotSet(mMvnoType.getValue()));
        values.put(Telephony.Carriers.MVNO_MATCH_DATA, checkNotSet(mMvnoMatchData.getText()));

        getContentResolver().update(mUri, values, null, null);

        return true;