Merge "Move FDN-specific classes into own package." into lmp-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ce9ea49..9e5c664 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -95,7 +95,8 @@
<uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
<uses-permission android:name="android.permission.DUMP" />
- <uses-permission android:name="android.permission.REGISTER_PROVIDER_OR_SUBSCRIPTION" />
+ <uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
+ <uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
<!-- This tells the activity manager to not delay any of our activity
start requests, even if they happen immediately after the user
diff --git a/res/values-mcc204-mnc04/strings.xml b/res/values-mcc204-mnc04/strings.xml
new file mode 100644
index 0000000..fec694f
--- /dev/null
+++ b/res/values-mcc204-mnc04/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string translatable="false" name="config_world_mode">true;BAE0000000000000</string>
+</resources>
diff --git a/res/values-mcc310-mnc004/strings.xml b/res/values-mcc310-mnc004/strings.xml
new file mode 100644
index 0000000..55cbcd6
--- /dev/null
+++ b/res/values-mcc310-mnc004/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string translatable="false" name="config_world_mode">true</string>
+</resources>
diff --git a/res/values-mcc311-mnc480/strings.xml b/res/values-mcc311-mnc480/strings.xml
new file mode 100644
index 0000000..55cbcd6
--- /dev/null
+++ b/res/values-mcc311-mnc480/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string translatable="false" name="config_world_mode">true</string>
+</resources>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
new file mode 100644
index 0000000..8187ff3
--- /dev/null
+++ b/res/values/arrays.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <!--String arrays for World preferred netwrok modes -->
+ <string-array name="preferred_network_mode_choices_world_mode">
+ <item>Global</item>
+ <item>LTE / CDMA</item>
+ <item>LTE / GSM / UMTS</item>
+ </string-array>
+
+ <string-array name="preferred_network_mode_values_world_mode">
+ <item>"10"</item>
+ <item>"8"</item>
+ <item>"9"</item>
+ </string-array>
+
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5d9f835..4c7f558 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -382,7 +382,10 @@
<string name="preferred_network_mode_global_summary">Preferred network mode: Global</string>
<!-- Mobile network settings, summary for preferred network mode LTE / WCDMA[CHAR LIMIT=100] -->
<string name="preferred_network_mode_lte_wcdma_summary">Preferred network mode: LTE / WCDMA</string>
-
+ <!-- Mobile network settings, summary for preferred network mode LTE / GSM / UMTS [CHAR LIMIT=100] -->
+ <string name="preferred_network_mode_lte_gsm_umts_summary">Preferred network mode: LTE / GSM / UMTS</string>
+ <!-- Mobile network settings, summary for preferred network mode LTE / CDMA [CHAR LIMIT=100] -->
+ <string name="preferred_network_mode_lte_cdma_summary">Preferred network mode: LTE / CDMA</string>
<string-array name="preferred_network_mode_choices">
<item>LTE / WCDMA</item>
@@ -1245,4 +1248,6 @@
<string name="sim_label_emergency_calls">Emergency calls</string>
<string name="sim_description_emergency_calls">Emergency calling only</string>
<string name="sim_description_default">SIM card, slot: <xliff:g id="slot_id">%s</xliff:g></string>
+ <!-- Configuration setting for world mode Format is <true;GID if any to be checked>-->
+ <string translatable="false" name="config_world_mode"/>
</resources>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index abc0edd..796e3e5 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -216,6 +216,11 @@
private static final int MSG_VM_OK = 600;
private static final int MSG_VM_NOCHANGE = 700;
+ /**
+ * @see CallForwardInfo#status
+ */
+ private static final int CALL_FORWARD_INFO_INACTIVE_STATUS = 0;
+
// voicemail notification vibration string constants
private static final String VOICEMAIL_VIBRATION_ALWAYS = "always";
private static final String VOICEMAIL_VIBRATION_NEVER = "never";
@@ -500,7 +505,10 @@
}
if (preference == mSubMenuVoicemailSettings) {
- handleVMBtnClickRequest();
+ VoicemailProviderSettings newSettings = new VoicemailProviderSettings(
+ mSubMenuVoicemailSettings.getPhoneNumber(),
+ VoicemailProviderSettings.NO_FORWARDING);
+ saveVoiceMailAndForwardingNumber(getCurrentVoicemailProviderKey(), newSettings);
}
}
@@ -531,20 +539,6 @@
return getString(R.string.voicemail_abbreviated) + " " + vmDisplay;
}
-
- // override the startsubactivity call to make changes in state consistent.
- @Override
- public void startActivityForResult(Intent intent, int requestCode) {
- if (requestCode == -1) {
- // this is an intent requested from the preference framework.
- super.startActivityForResult(intent, requestCode);
- return;
- }
-
- if (DBG) log("startSubActivity: starting requested subactivity");
- super.startActivityForResult(intent, requestCode);
- }
-
private void switchToPreviousVoicemailProvider() {
if (DBG) log("switchToPreviousVoicemailProvider " + mPreviousVMProviderKey);
if (mPreviousVMProviderKey != null) {
@@ -721,21 +715,6 @@
super.onActivityResult(requestCode, resultCode, data);
}
- // Voicemail button logic
- private void handleVMBtnClickRequest() {
- // normally called on the dialog close.
-
- // Since we're stripping the formatting out on the getPhoneNumber()
- // call now, we won't need to do so here anymore.
-
- saveVoiceMailAndForwardingNumber(
- getCurrentVoicemailProviderKey(),
- new VoicemailProviderSettings(mSubMenuVoicemailSettings.getPhoneNumber(),
- VoicemailProviderSettings.NO_FORWARDING)
- );
- }
-
-
/**
* Wrapper around showDialog() that will silently do nothing if we're
* not in the foreground.
@@ -928,17 +907,18 @@
return result;
}
- private boolean isUpdateRequired(CallForwardInfo oldInfo,
- CallForwardInfo newInfo) {
- boolean result = true;
- if (0 == newInfo.status) {
- // If we're disabling a type of forwarding, and it's already
- // disabled for the account, don't make any change
- if (oldInfo != null && oldInfo.status == 0) {
- result = false;
- }
+ private boolean isUpdateRequired(CallForwardInfo oldInfo, CallForwardInfo newInfo) {
+ if (oldInfo == null) {
+ return true;
}
- return result;
+
+ // If we're disabling a type of forwarding, don't make any change if it's already disabled.
+ if (newInfo.status == CALL_FORWARD_INFO_INACTIVE_STATUS
+ && oldInfo.status == CALL_FORWARD_INFO_INACTIVE_STATUS) {
+ return false;
+ }
+
+ return true;
}
private void resetForwardingChangeState() {
@@ -1000,9 +980,7 @@
switch (msg.what) {
case EVENT_VOICEMAIL_CHANGED:
mVoicemailChangeResult = result;
- mVMChangeCompletedSuccessfully = checkVMChangeSuccess() == null;
- if (DBG) log("VM change complete msg, VM change done = " +
- String.valueOf(mVMChangeCompletedSuccessfully));
+ mVMChangeCompletedSuccessfully = isVmChangeSuccess();
done = true;
break;
case EVENT_FORWARDING_CHANGED:
@@ -1013,9 +991,8 @@
} else {
if (DBG) log("Success in setting fwd# " + msg.arg1);
}
- final boolean completed = checkForwardingCompleted();
- if (completed) {
- if (checkFwdChangeSuccess() == null) {
+ if (isForwardingCompleted()) {
+ if (isFwdChangeSuccess()) {
if (DBG) log("Overall fwd changes completed ok, starting vm change");
setVMNumberWithCarrier();
} else {
@@ -1048,7 +1025,7 @@
if (mForwardingChangeResults != null) {
dismissDialogSafely(VOICEMAIL_FWD_SAVING_DIALOG);
}
- handleSetVMOrFwdMessage();
+ handleSetVmOrFwdMessage();
}
}
};
@@ -1080,7 +1057,7 @@
}
final boolean done =
(!mVMChangeCompletedSuccessfully || mVoicemailChangeResult != null) &&
- (!mFwdChangesRequireRollback || checkForwardingCompleted());
+ (!mFwdChangesRequireRollback || isForwardingCompleted());
if (done) {
if (DBG) log("All VM reverts done");
dismissDialogSafely(VOICEMAIL_REVERTING_DIALOG);
@@ -1090,91 +1067,61 @@
};
/**
- * @return true if forwarding change has completed
+ * Return true if there is a change result for every reason for which we expect a result.
*/
- private boolean checkForwardingCompleted() {
- boolean result;
+ private boolean isForwardingCompleted() {
if (mForwardingChangeResults == null) {
- result = true;
- } else {
- // return true iff there is a change result for every reason for
- // which we expected a result
- result = true;
- for (Integer reason : mExpectedChangeResultReasons) {
- if (mForwardingChangeResults.get(reason) == null) {
- result = false;
- break;
- }
+ return true;
+ }
+
+ for (Integer reason : mExpectedChangeResultReasons) {
+ if (mForwardingChangeResults.get(reason) == null) {
+ return false;
}
}
- return result;
+
+ return true;
}
- /**
- * @return error string or null if successful
- */
- private String checkFwdChangeSuccess() {
- String result = null;
- Iterator<Map.Entry<Integer,AsyncResult>> it =
- mForwardingChangeResults.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<Integer,AsyncResult> entry = it.next();
- Throwable exception = entry.getValue().exception;
+
+ private boolean isFwdChangeSuccess() {
+ if (mForwardingChangeResults == null) {
+ return true;
+ }
+
+ for (AsyncResult result : mForwardingChangeResults.values()) {
+ Throwable exception = result.exception;
if (exception != null) {
- result = exception.getMessage();
- if (result == null) {
- result = "";
- }
- break;
+ String msg = exception.getMessage();
+ msg = (msg != null) ? msg : "";
+ Log.w(LOG_TAG, "Failed to change forwarding setting. Reason: " + msg);
+ return false;
}
}
- return result;
+ return true;
}
- /**
- * @return error string or null if successful
- */
- private String checkVMChangeSuccess() {
+ private boolean isVmChangeSuccess() {
if (mVoicemailChangeResult.exception != null) {
- final String msg = mVoicemailChangeResult.exception.getMessage();
- if (msg == null) {
- return "";
- }
- return msg;
+ String msg = mVoicemailChangeResult.exception.getMessage();
+ msg = (msg != null) ? msg : "";
+ Log.w(LOG_TAG, "Failed to change voicemail. Reason: " + msg);
+ return false;
}
- return null;
+
+ if (DBG) log("VM change completed successfully.");
+ return true;
}
- private void handleSetVMOrFwdMessage() {
- if (DBG) {
- log("handleSetVMMessage: set VM request complete");
- }
- boolean success = true;
- boolean fwdFailure = false;
- String exceptionMessage = "";
- if (mForwardingChangeResults != null) {
- exceptionMessage = checkFwdChangeSuccess();
- if (exceptionMessage != null) {
- success = false;
- fwdFailure = true;
- }
- }
- if (success) {
- exceptionMessage = checkVMChangeSuccess();
- if (exceptionMessage != null) {
- success = false;
- }
- }
- if (success) {
- if (DBG) log("change VM success!");
- handleVMAndFwdSetSuccess(MSG_VM_OK);
+ private void handleSetVmOrFwdMessage() {
+ if (DBG) log("handleSetVMMessage: set VM request complete");
+
+ if (!isFwdChangeSuccess()) {
+ handleVmOrFwdSetError(MSG_FW_SET_EXCEPTION);
+ } else if (!isVmChangeSuccess()) {
+ handleVmOrFwdSetError(MSG_VM_EXCEPTION);
} else {
- if (fwdFailure) {
- Log.w(LOG_TAG, "Failed to change fowarding setting. Reason: " + exceptionMessage);
- handleVMOrFwdSetError(MSG_FW_SET_EXCEPTION);
- } else {
- Log.w(LOG_TAG, "Failed to change voicemail. Reason: " + exceptionMessage);
- handleVMOrFwdSetError(MSG_VM_EXCEPTION);
- }
+ if (DBG) log("change VM success!");
+ handleVmAndFwdSetSuccess(MSG_VM_OK);
}
}
@@ -1185,7 +1132,7 @@
* @param msgId Message ID used for the specific error case. {@link #MSG_FW_SET_EXCEPTION} or
* {@link #MSG_VM_EXCEPTION}
*/
- private void handleVMOrFwdSetError(int msgId) {
+ private void handleVmOrFwdSetError(int msgId) {
if (mChangingVMorFwdDueToProviderChange) {
mVMOrFwdSetError = msgId;
mChangingVMorFwdDueToProviderChange = false;
@@ -1201,9 +1148,9 @@
* Called when Voicemail Provider and its forwarding settings were successfully finished.
* This updates a bunch of variables and show "success" dialog.
*/
- private void handleVMAndFwdSetSuccess(int msg) {
+ private void handleVmAndFwdSetSuccess(int msg) {
if (DBG) {
- log("handleVMAndFwdSetSuccess(). current voicemail provider key: "
+ log("handleVmAndFwdSetSuccess(). current voicemail provider key: "
+ getCurrentVoicemailProviderKey());
}
mPreviousVMProviderKey = getCurrentVoicemailProviderKey();
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 2c57b47..d618b5c 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -312,6 +312,12 @@
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
}
+ if (isWorldMode()) {
+ mButtonEnabledNetworks.setEntries(
+ R.array.preferred_network_mode_choices_world_mode);
+ mButtonEnabledNetworks.setEntryValues(
+ R.array.preferred_network_mode_values_world_mode);
+ }
mButtonEnabledNetworks.setOnPreferenceChangeListener(this);
int settingsNetworkMode = android.provider.Settings.Global.getInt(
mPhone.getContext().getContentResolver(),
@@ -731,6 +737,11 @@
}
break;
case Phone.NT_MODE_LTE_GSM_WCDMA:
+ if(isWorldMode()) {
+ mButtonEnabledNetworks.setSummary(
+ R.string.preferred_network_mode_lte_gsm_umts_summary);
+ break;
+ }
case Phone.NT_MODE_LTE_ONLY:
case Phone.NT_MODE_LTE_WCDMA:
if (!mIsGlobalCdma) {
@@ -745,9 +756,14 @@
}
break;
case Phone.NT_MODE_LTE_CDMA_AND_EVDO:
- mButtonEnabledNetworks.setValue(
- Integer.toString(Phone.NT_MODE_LTE_CDMA_AND_EVDO));
- mButtonEnabledNetworks.setSummary(R.string.network_lte);
+ if(isWorldMode()) {
+ mButtonEnabledNetworks.setSummary(
+ R.string.preferred_network_mode_lte_cdma_summary);
+ } else {
+ mButtonEnabledNetworks.setValue(
+ Integer.toString(Phone.NT_MODE_LTE_CDMA_AND_EVDO));
+ mButtonEnabledNetworks.setSummary(R.string.network_lte);
+ }
break;
case Phone.NT_MODE_CDMA:
case Phone.NT_MODE_EVDO_NO_CDMA:
@@ -820,4 +836,28 @@
}
return super.onOptionsItemSelected(item);
}
+
+ private boolean isWorldMode() {
+ boolean worldModeOn = false;
+ final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+ final String configString = getResources().getString(R.string.config_world_mode);
+
+ if (!TextUtils.isEmpty(configString)) {
+ String[] configArray = configString.split(";");
+ // Check if we have World mode configuration set to True only or config is set to True
+ // and SIM GID value is also set and matches to the current SIM GID.
+ if (configArray != null &&
+ ((configArray.length == 1 && configArray[0].equalsIgnoreCase("true")) ||
+ (configArray.length == 2 && !TextUtils.isEmpty(configArray[1]) &&
+ tm != null && configArray[1].equalsIgnoreCase(tm.getGroupIdLevel1())))) {
+ worldModeOn = true;
+ }
+ }
+
+ if (DBG) {
+ log("World mode is set to" + worldModeOn);
+ }
+
+ return worldModeOn;
+ }
}