Merge "Fix permissions." into mnc-dev
diff --git a/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java b/src/com/android/phone/VvmPhoneStateListener.java
similarity index 70%
rename from src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java
rename to src/com/android/phone/VvmPhoneStateListener.java
index 84449d7..d2d84b2 100644
--- a/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java
+++ b/src/com/android/phone/VvmPhoneStateListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License
*/
-package com.android.phone.vvm.omtp.sync;
+package com.android.phone;
import android.content.Context;
import android.content.Intent;
@@ -22,8 +22,10 @@
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
-import com.android.phone.PhoneUtils;
import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+import com.android.phone.vvm.omtp.sync.OmtpVvmSourceManager;
+import com.android.phone.vvm.omtp.sync.OmtpVvmSyncService;
+import com.android.phone.vvm.omtp.sync.VoicemailStatusQueryHelper;
/**
* Check if service is lost and indicate this in the voicemail status.
@@ -49,15 +51,22 @@
VoicemailContract.Status.CONFIGURATION_STATE_OK,
VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
- // Run a full sync in case something was missed while signal was down.
- Intent serviceIntent = OmtpVvmSyncService.getSyncIntent(
- mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
- true /* firstAttempt */);
- mContext.startService(serviceIntent);
+ PhoneGlobals.getInstance().notificationMgr.updateMwi(
+ PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount), false);
}
}
- if (!OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
+ if (OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
+ // If the source is already registered, run a full sync in case something was missed
+ // while signal was down.
+ Intent serviceIntent = OmtpVvmSyncService.getSyncIntent(
+ mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
+ true /* firstAttempt */);
+ mContext.startService(serviceIntent);
+ } else {
+ // Otherwise initiate an activation because this means that an OMTP source was
+ // recognized but either the activation text was not successfully sent or a response
+ // was not received.
OmtpVvmCarrierConfigHelper carrierConfigHelper = new OmtpVvmCarrierConfigHelper(
mContext, PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
carrierConfigHelper.startActivation();
diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java
index fdc5bf3..bb8c6fe 100644
--- a/src/com/android/phone/settings/VoicemailSettingsActivity.java
+++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java
@@ -392,6 +392,7 @@
boolean isEnabled = (Boolean) objValue;
VisualVoicemailSettingsUtil.setVisualVoicemailEnabled(mPhone, isEnabled, true);
if (isEnabled) {
+ OmtpVvmSourceManager.getInstance(mPhone.getContext()).addPhoneStateListener(mPhone);
mOmtpVvmCarrierConfigHelper.startActivation();
} else {
OmtpVvmSourceManager.getInstance(mPhone.getContext()).removeSource(mPhone);
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
index 63e9fee..286dde3 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
@@ -24,6 +24,7 @@
import com.android.internal.telephony.Phone;
import com.android.phone.PhoneUtils;
+import com.android.phone.VvmPhoneStateListener;
import java.util.HashMap;
import java.util.HashSet;
@@ -104,6 +105,10 @@
OmtpVvmSyncService.cancelAllRetries(mContext, phoneAccount);
}
+ public void addPhoneStateListener(Phone phone) {
+ addPhoneStateListener(PhoneUtils.makePstnPhoneAccountHandle(phone));
+ }
+
public void addPhoneStateListener(PhoneAccountHandle phoneAccount) {
if (!mPhoneStateListenerMap.containsKey(phoneAccount)) {
VvmPhoneStateListener phoneStateListener = new VvmPhoneStateListener(mContext,
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 72c9b07..5848135 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -171,7 +171,7 @@
}
}
- boolean isEmergencyNumber = PhoneNumberUtils.isPotentialEmergencyNumber(number);
+ boolean isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(this, number);
// Get the right phone object from the account data passed in.
final Phone phone = getPhoneForAccount(request.getAccountHandle(), isEmergencyNumber);