Modify ApnEditor app for new APN schema.

As the telephony db is changed, The ApnEditor app has to be changed also.
As your request, I changed the ListPreference object to read-only CheckBoxPreference object and "The Others" to "Unspecified".This is a pair set with below change-ids.
- https://partner.source.android.com/g/#/c/8515/
- https://partner.source.android.com/g/#/c/8517/
- https://partner.source.android.com/g/#/c/9048/

Change-Id: I2bdd4f3076adfbee0f277ddb59a150e51e45ac9b
bug:4991683
This commit is contained in:
sinikang
2011-09-08 15:44:09 -07:00
committed by Robert Greenwalt
parent 85eeb1c16a
commit cd8b7c3d0b
4 changed files with 82 additions and 0 deletions

View File

@@ -520,6 +520,22 @@
<item>IPV4V6</item> <item>IPV4V6</item>
</string-array> </string-array>
<!-- Bearer Info used in APN editor -->
<string-array name="bearer_entries">
<item>LTE</item>
<item>eHRPD</item>
<item>Unspecified</item>
</string-array>
<string-array translatable="false" name="bearer_values">
<!-- Do not translate. -->
<item>14</item>
<!-- Do not translate. -->
<item>13</item>
<!-- Do not translate. -->
<item>0</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>

View File

@@ -1881,6 +1881,12 @@
<string name="apn_type">APN type</string> <string name="apn_type">APN type</string>
<!-- Edit access point labels: The protocol of the APN, e.g., "IPv4", "IPv6", or "IPv4/IPv6". --> <!-- Edit access point labels: The protocol of the APN, e.g., "IPv4", "IPv6", or "IPv4/IPv6". -->
<string name="apn_protocol">APN protocol</string> <string name="apn_protocol">APN protocol</string>
<!-- Edit enable/disable of APN -->
<string name="carrier_enabled">APN Enable/Disable</string>
<string name="carrier_enabled_summaryOn">APN Enabled</string>
<string name="carrier_enabled_summaryOff">APN Disabled</string>
<!-- Edit Beaerer Info of APN -->
<string name="bearer">Bearer</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 -->

View File

@@ -121,4 +121,17 @@
android:entries="@array/apn_protocol_entries" android:entries="@array/apn_protocol_entries"
android:entryValues="@array/apn_protocol_values" android:entryValues="@array/apn_protocol_values"
/> />
<CheckBoxPreference
android:title="@string/carrier_enabled"
android:key="carrier_enabled"
android:enabled="false"
android:summaryOn="@string/carrier_enabled_summaryOn"
android:summaryOff="@@string/carrier_enabled_summaryOff"
/>
<ListPreference
android:title="@string/bearer"
android:key="bearer"
android:entries="@array/bearer_entries"
android:entryValues="@array/bearer_values"
/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -29,6 +29,7 @@ import android.os.Bundle;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.provider.Telephony; import android.provider.Telephony;
@@ -50,6 +51,8 @@ public class ApnEditor extends PreferenceActivity
private final static String SAVED_POS = "pos"; private final static String SAVED_POS = "pos";
private final static String KEY_AUTH_TYPE = "auth_type"; private final static String KEY_AUTH_TYPE = "auth_type";
private final static String KEY_PROTOCOL = "apn_protocol"; private final static String KEY_PROTOCOL = "apn_protocol";
private final static String KEY_CARRIER_ENABLED = "carrier_enabled";
private final static String KEY_BEARER = "bearer";
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;
@@ -72,6 +75,8 @@ public class ApnEditor extends PreferenceActivity
private ListPreference mAuthType; private ListPreference mAuthType;
private EditTextPreference mApnType; private EditTextPreference mApnType;
private ListPreference mProtocol; private ListPreference mProtocol;
private CheckBoxPreference mCarrierEnabled;
private ListPreference mBearer;
private String mCurMnc; private String mCurMnc;
private String mCurMcc; private String mCurMcc;
@@ -103,6 +108,8 @@ public class ApnEditor extends PreferenceActivity
Telephony.Carriers.AUTH_TYPE, // 14 Telephony.Carriers.AUTH_TYPE, // 14
Telephony.Carriers.TYPE, // 15 Telephony.Carriers.TYPE, // 15
Telephony.Carriers.PROTOCOL, // 16 Telephony.Carriers.PROTOCOL, // 16
Telephony.Carriers.CARRIER_ENABLED, // 17
Telephony.Carriers.BEARER, // 18
}; };
private static final int ID_INDEX = 0; private static final int ID_INDEX = 0;
@@ -121,6 +128,8 @@ public class ApnEditor extends PreferenceActivity
private static final int AUTH_TYPE_INDEX = 14; private static final int AUTH_TYPE_INDEX = 14;
private static final int TYPE_INDEX = 15; private static final int TYPE_INDEX = 15;
private static final int PROTOCOL_INDEX = 16; private static final int PROTOCOL_INDEX = 16;
private static final int CARRIER_ENABLED_INDEX = 17;
private static final int BEARER_INDEX = 18;
@Override @Override
@@ -150,6 +159,11 @@ public class ApnEditor extends PreferenceActivity
mProtocol = (ListPreference) findPreference(KEY_PROTOCOL); mProtocol = (ListPreference) findPreference(KEY_PROTOCOL);
mProtocol.setOnPreferenceChangeListener(this); mProtocol.setOnPreferenceChangeListener(this);
mCarrierEnabled = (CheckBoxPreference) findPreference(KEY_CARRIER_ENABLED);
mBearer = (ListPreference) findPreference(KEY_BEARER);
mBearer.setOnPreferenceChangeListener(this);
mRes = getResources(); mRes = getResources();
final Intent intent = getIntent(); final Intent intent = getIntent();
@@ -247,6 +261,8 @@ public class ApnEditor extends PreferenceActivity
} }
mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX)); mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX));
mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
mBearer.setValue(mCursor.getString(BEARER_INDEX));
} }
mName.setSummary(checkNull(mName.getText())); mName.setSummary(checkNull(mName.getText()));
@@ -276,6 +292,8 @@ public class ApnEditor extends PreferenceActivity
mProtocol.setSummary( mProtocol.setSummary(
checkNull(protocolDescription(mProtocol.getValue()))); checkNull(protocolDescription(mProtocol.getValue())));
mBearer.setSummary(
checkNull(bearerDescription(mBearer.getValue())));
} }
/** /**
@@ -297,6 +315,20 @@ public class ApnEditor extends PreferenceActivity
} }
} }
private String bearerDescription(String raw) {
int mBearerIndex = mBearer.findIndexOfValue(raw);
if (mBearerIndex == -1) {
return null;
} else {
String[] values = mRes.getStringArray(R.array.bearer_entries);
try {
return values[mBearerIndex];
} 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)) {
@@ -320,6 +352,16 @@ public class ApnEditor extends PreferenceActivity
mProtocol.setSummary(protocol); mProtocol.setSummary(protocol);
mProtocol.setValue((String) newValue); mProtocol.setValue((String) newValue);
} }
if (KEY_BEARER.equals(key)) {
String bearer = bearerDescription((String) newValue);
if (bearer == null) {
return false;
}
mBearer.setValue((String) newValue);
mBearer.setSummary(bearer);
}
return true; return true;
} }
@@ -450,6 +492,11 @@ public class ApnEditor extends PreferenceActivity
} }
} }
String bearerVal = mBearer.getValue();
if (bearerVal != null) {
values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
}
getContentResolver().update(mUri, values, null, null); getContentResolver().update(mUri, values, null, null);
return true; return true;