diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:29:54 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:29:54 +0000 |
commit | 43b3152d075138b11e1fe297682b3bbc775e5641 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/voicemail/impl/ActivationTask.java | |
parent | 2034759538273aed8a0b412d8fb90994eba1f7ea (diff) | |
parent | 300a8683b9c28424fb0f0c571a0abe128c461f69 (diff) |
Update Dialer to V10 RC16 am: 10b34a5ebf
am: 300a8683b9
Change-Id: If5695bad59f8a4dab6e6c90b54943b900bd2652a
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 |