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

Commit 3c8a4c3b authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Android Git Automerger
Browse files

am cd1c38cf: am ae9ebfd1: Merge "add MVNO field for APN Editor"

* commit 'cd1c38cf':
  add MVNO field for APN Editor
parents 474958fc cd1c38cf
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -547,6 +547,29 @@
        <item>0</item>
        <item>0</item>
    </string-array>
    </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 -->
    <!-- Apps on SD instalaltion location options in ApplicationSettings -->
    <string-array name="app_install_location_entries">
    <string-array name="app_install_location_entries">
        <item>Internal device storage</item>
        <item>Internal device storage</item>
+4 −0
Original line number Original line Diff line number Diff line
@@ -2121,6 +2121,10 @@
    <string name="carrier_enabled_summaryOff">APN disabled</string>
    <string name="carrier_enabled_summaryOff">APN disabled</string>
    <!-- Edit Beaerer Info of APN -->
    <!-- Edit Beaerer Info of APN -->
    <string name="bearer">Bearer</string>
    <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 -->
    <!-- Edit access point screen menu option to delete this APN -->
    <string name="menu_delete">Delete APN</string>
    <string name="menu_delete">Delete APN</string>
    <!-- APNs screen menu option to create a brand spanking new APN -->
    <!-- APNs screen menu option to create a brand spanking new APN -->
+13 −0
Original line number Original line Diff line number Diff line
@@ -141,4 +141,17 @@
        android:entries="@array/bearer_entries"
        android:entries="@array/bearer_entries"
        android:entryValues="@array/bearer_values"
        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>   
</PreferenceScreen>   
+49 −1
Original line number Original line 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_ROAMING_PROTOCOL = "apn_roaming_protocol";
    private final static String KEY_CARRIER_ENABLED = "carrier_enabled";
    private final static String KEY_CARRIER_ENABLED = "carrier_enabled";
    private final static String KEY_BEARER = "bearer";
    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_DELETE = Menu.FIRST;
    private static final int MENU_SAVE = Menu.FIRST + 1;
    private static final int MENU_SAVE = Menu.FIRST + 1;
@@ -82,6 +83,8 @@ public class ApnEditor extends PreferenceActivity
    private ListPreference mRoamingProtocol;
    private ListPreference mRoamingProtocol;
    private CheckBoxPreference mCarrierEnabled;
    private CheckBoxPreference mCarrierEnabled;
    private ListPreference mBearer;
    private ListPreference mBearer;
    private ListPreference mMvnoType;
    private EditTextPreference mMvnoMatchData;


    private String mCurMnc;
    private String mCurMnc;
    private String mCurMcc;
    private String mCurMcc;
@@ -115,7 +118,9 @@ public class ApnEditor extends PreferenceActivity
            Telephony.Carriers.PROTOCOL, // 16
            Telephony.Carriers.PROTOCOL, // 16
            Telephony.Carriers.CARRIER_ENABLED, // 17
            Telephony.Carriers.CARRIER_ENABLED, // 17
            Telephony.Carriers.BEARER, // 18
            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;
    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 CARRIER_ENABLED_INDEX = 17;
    private static final int BEARER_INDEX = 18;
    private static final int BEARER_INDEX = 18;
    private static final int ROAMING_PROTOCOL_INDEX = 19;
    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
    @Override
@@ -174,6 +181,10 @@ public class ApnEditor extends PreferenceActivity
        mBearer = (ListPreference) findPreference(KEY_BEARER);
        mBearer = (ListPreference) findPreference(KEY_BEARER);
        mBearer.setOnPreferenceChangeListener(this);
        mBearer.setOnPreferenceChangeListener(this);


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

        mRes = getResources();
        mRes = getResources();


        final Intent intent = getIntent();
        final Intent intent = getIntent();
@@ -274,6 +285,9 @@ public class ApnEditor extends PreferenceActivity
            mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX));
            mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX));
            mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
            mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
            mBearer.setValue(mCursor.getString(BEARER_INDEX));
            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()));
        mName.setSummary(checkNull(mName.getText()));
@@ -307,6 +321,9 @@ public class ApnEditor extends PreferenceActivity
                checkNull(protocolDescription(mRoamingProtocol.getValue(), mRoamingProtocol)));
                checkNull(protocolDescription(mRoamingProtocol.getValue(), mRoamingProtocol)));
        mBearer.setSummary(
        mBearer.setSummary(
                checkNull(bearerDescription(mBearer.getValue())));
                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) {
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        String key = preference.getKey();
        String key = preference.getKey();
        if (KEY_AUTH_TYPE.equals(key)) {
        if (KEY_AUTH_TYPE.equals(key)) {
@@ -375,6 +413,13 @@ public class ApnEditor extends PreferenceActivity
            }
            }
            mBearer.setValue((String) newValue);
            mBearer.setValue((String) newValue);
            mBearer.setSummary(bearer);
            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;
        return true;
@@ -508,6 +553,9 @@ public class ApnEditor extends PreferenceActivity
            values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
            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);
        getContentResolver().update(mUri, values, null, null);


        return true;
        return true;