diff options
Diffstat (limited to 'java/com/android/voicemail/impl/ActivationTask.java')
-rw-r--r-- | java/com/android/voicemail/impl/ActivationTask.java | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java index b0ad3bafc..91e369531 100644 --- a/java/com/android/voicemail/impl/ActivationTask.java +++ b/java/com/android/voicemail/impl/ActivationTask.java @@ -31,6 +31,7 @@ import android.telephony.ServiceState; import android.telephony.TelephonyManager; import com.android.dialer.logging.DialerImpression; import com.android.dialer.proguard.UsedByReflection; +import com.android.voicemail.VoicemailClient; import com.android.voicemail.impl.protocol.VisualVoicemailProtocol; import com.android.voicemail.impl.scheduling.BaseTask; import com.android.voicemail.impl.scheduling.RetryPolicy; @@ -105,7 +106,7 @@ public class ActivationTask extends BaseTask { if (messageData != null) { intent.putExtra(EXTRA_MESSAGE_DATA_BUNDLE, messageData); } - context.startService(intent); + context.sendBroadcast(intent); } @Override @@ -136,6 +137,8 @@ public class ActivationTask extends BaseTask { return; } + PreOMigrationHandler.migrate(getContext(), phoneAccountHandle); + if (!VisualVoicemailSettingsUtil.isEnabled(getContext(), phoneAccountHandle)) { VvmLog.i(TAG, "VVM is disabled"); return; @@ -163,6 +166,7 @@ public class ActivationTask extends BaseTask { if (VvmAccountManager.isAccountActivated(getContext(), phoneAccountHandle)) { VvmLog.i(TAG, "Account is already activated"); + onSuccess(getContext(), phoneAccountHandle); return; } helper.handleEvent( @@ -222,7 +226,7 @@ public class ActivationTask extends BaseTask { + message.getReturnCode()); if (message.getProvisioningStatus().equals(OmtpConstants.SUBSCRIBER_READY)) { VvmLog.d(TAG, "subscriber ready, no activation required"); - updateSource(getContext(), phoneAccountHandle, status, message); + updateSource(getContext(), phoneAccountHandle, message); } else { if (helper.supportsProvisioning()) { VvmLog.i(TAG, "Subscriber not ready, start provisioning"); @@ -232,7 +236,7 @@ public class ActivationTask extends BaseTask { VvmLog.i(TAG, "Subscriber new but provisioning is not supported"); // Ignore the non-ready state and attempt to use the provided info as is. // This is probably caused by not completing the new user tutorial. - updateSource(getContext(), phoneAccountHandle, status, message); + updateSource(getContext(), phoneAccountHandle, message); } else { VvmLog.i(TAG, "Subscriber not ready but provisioning is not supported"); helper.handleEvent(status, OmtpEvents.CONFIG_SERVICE_NOT_AVAILABLE); @@ -242,25 +246,38 @@ public class ActivationTask extends BaseTask { getContext(), DialerImpression.Type.VVM_ACTIVATION_COMPLETED); } - public static void updateSource( - Context context, - PhoneAccountHandle phone, - VoicemailStatus.Editor status, - StatusMessage message) { + private static void updateSource( + Context context, PhoneAccountHandle phone, StatusMessage message) { if (OmtpConstants.SUCCESS.equals(message.getReturnCode())) { - OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(context, phone); - helper.handleEvent(status, OmtpEvents.CONFIG_REQUEST_STATUS_SUCCESS); - // Save the IMAP credentials in preferences so they are persistent and can be retrieved. VvmAccountManager.addAccount(context, phone, message); - - SyncTask.start(context, phone, OmtpVvmSyncService.SYNC_FULL_SYNC); + onSuccess(context, phone); } else { VvmLog.e(TAG, "Visual voicemail not available for subscriber."); } } + private static void onSuccess(Context context, PhoneAccountHandle phoneAccountHandle) { + OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle); + helper.handleEvent( + VoicemailStatus.edit(context, phoneAccountHandle), + OmtpEvents.CONFIG_REQUEST_STATUS_SUCCESS); + clearLegacyVoicemailNotification(context, phoneAccountHandle); + SyncTask.start(context, phoneAccountHandle, OmtpVvmSyncService.SYNC_FULL_SYNC); + } + + /** Sends a broadcast to the dialer UI to clear legacy voicemail notifications if any. */ + private static void clearLegacyVoicemailNotification( + Context context, PhoneAccountHandle phoneAccountHandle) { + Intent intent = new Intent(VoicemailClient.ACTION_SHOW_LEGACY_VOICEMAIL); + intent.setPackage(context.getPackageName()); + intent.putExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle); + // Setting voicemail message count to zero will clear the notification. + intent.putExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, 0); + context.sendBroadcast(intent); + } + private static boolean hasSignal(Context context, PhoneAccountHandle phoneAccountHandle) { TelephonyManager telephonyManager = context |