From 592098024c2f5c7df232c73034b6ae17e8af53a4 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 13 Sep 2017 10:37:01 -0700 Subject: Setup SMS filter even if VVM is already activated VVM can be "activated" through restoring shared preferences from another device. In this case the SMS filter in telephony is still not configured, and needs to be set up. Bug: 65542413 Test: ActivationTaskTest PiperOrigin-RevId: 168560153 Change-Id: I46dd9b31e43899d8d567e7e6baebf06559548525 --- .../enrichedcall/videoshare/VideoShareListener.java | 4 +++- .../android/dialer/lightbringer/Lightbringer.java | 2 +- .../dialer/lightbringer/stub/LightbringerStub.java | 2 +- .../com/android/incallui/AnswerScreenPresenter.java | 2 +- java/com/android/incallui/CallButtonPresenter.java | 4 ++-- .../incallui/NotificationBroadcastReceiver.java | 2 +- java/com/android/incallui/videotech/VideoTech.java | 7 ++++--- .../incallui/videotech/empty/EmptyVideoTech.java | 7 ++++--- .../videotech/ims/ImsVideoCallCallback.java | 8 ++++++-- .../incallui/videotech/ims/ImsVideoTech.java | 9 +++++---- .../videotech/lightbringer/LightbringerTech.java | 16 +++++----------- java/com/android/voicemail/impl/ActivationTask.java | 21 +++++++++++++-------- .../impl/settings/VisualVoicemailSettingsUtil.java | 3 ++- 13 files changed, 48 insertions(+), 39 deletions(-) diff --git a/java/com/android/dialer/enrichedcall/videoshare/VideoShareListener.java b/java/com/android/dialer/enrichedcall/videoshare/VideoShareListener.java index 0e5f79f2b..a7d656a0a 100644 --- a/java/com/android/dialer/enrichedcall/videoshare/VideoShareListener.java +++ b/java/com/android/dialer/enrichedcall/videoshare/VideoShareListener.java @@ -16,7 +16,9 @@ package com.android.dialer.enrichedcall.videoshare; +import android.content.Context; import android.support.annotation.MainThread; +import android.support.annotation.NonNull; /** Receives updates when video share status has changed. */ public interface VideoShareListener { @@ -26,5 +28,5 @@ public interface VideoShareListener { * invite received or canceled, or when a session changes). */ @MainThread - void onVideoShareChanged(); + void onVideoShareChanged(@NonNull Context context); } diff --git a/java/com/android/dialer/lightbringer/Lightbringer.java b/java/com/android/dialer/lightbringer/Lightbringer.java index 9120b24db..fa57b0166 100644 --- a/java/com/android/dialer/lightbringer/Lightbringer.java +++ b/java/com/android/dialer/lightbringer/Lightbringer.java @@ -40,7 +40,7 @@ public interface Lightbringer { Intent getIntent(@NonNull Context context, @NonNull String number); @MainThread - void requestUpgrade(Call call); + void requestUpgrade(@NonNull Context context, Call call); @MainThread void registerListener(@NonNull LightbringerListener listener); diff --git a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java index c98ae091b..a0309220a 100644 --- a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java +++ b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java @@ -67,7 +67,7 @@ public class LightbringerStub implements Lightbringer { @MainThread @Override - public void requestUpgrade(Call call) { + public void requestUpgrade(@NonNull Context context, Call call) { Assert.isMainThread(); Assert.isNotNull(call); } diff --git a/java/com/android/incallui/AnswerScreenPresenter.java b/java/com/android/incallui/AnswerScreenPresenter.java index d53040145..58231d52b 100644 --- a/java/com/android/incallui/AnswerScreenPresenter.java +++ b/java/com/android/incallui/AnswerScreenPresenter.java @@ -104,7 +104,7 @@ public class AnswerScreenPresenter DialerImpression.Type.VIDEO_CALL_REQUEST_ACCEPTED, call.getUniqueCallId(), call.getTimeAddedMs()); - call.getVideoTech().acceptVideoRequest(); + call.getVideoTech().acceptVideoRequest(context); } } else { if (answerVideoAsAudio) { diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index 658ae649b..bd5bb78c9 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -294,7 +294,7 @@ public class CallButtonPresenter DialerImpression.Type.VIDEO_CALL_UPGRADE_REQUESTED, mCall.getUniqueCallId(), mCall.getTimeAddedMs()); - mCall.getVideoTech().upgradeToVideo(); + mCall.getVideoTech().upgradeToVideo(mContext); } @Override @@ -360,7 +360,7 @@ public class CallButtonPresenter } else { updateCamera( InCallPresenter.getInstance().getInCallCameraManager().isUsingFrontFacingCamera()); - mCall.getVideoTech().resumeTransmission(); + mCall.getVideoTech().resumeTransmission(mContext); } mInCallButtonUi.setVideoPaused(pause); diff --git a/java/com/android/incallui/NotificationBroadcastReceiver.java b/java/com/android/incallui/NotificationBroadcastReceiver.java index 5e757cf01..0daa017d7 100644 --- a/java/com/android/incallui/NotificationBroadcastReceiver.java +++ b/java/com/android/incallui/NotificationBroadcastReceiver.java @@ -95,7 +95,7 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver { } else { DialerCall call = callList.getVideoUpgradeRequestCall(); if (call != null) { - call.getVideoTech().acceptVideoRequest(); + call.getVideoTech().acceptVideoRequest(context); } } } diff --git a/java/com/android/incallui/videotech/VideoTech.java b/java/com/android/incallui/videotech/VideoTech.java index 79a8c605c..e3753bc65 100644 --- a/java/com/android/incallui/videotech/VideoTech.java +++ b/java/com/android/incallui/videotech/VideoTech.java @@ -17,6 +17,7 @@ package com.android.incallui.videotech; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.logging.DialerImpression; import com.android.incallui.video.protocol.VideoCallScreen; @@ -48,9 +49,9 @@ public interface VideoTech { @SessionModificationState int getSessionModificationState(); - void upgradeToVideo(); + void upgradeToVideo(@NonNull Context context); - void acceptVideoRequest(); + void acceptVideoRequest(@NonNull Context context); void acceptVideoRequestAsAudio(); @@ -60,7 +61,7 @@ public interface VideoTech { void stopTransmission(); - void resumeTransmission(); + void resumeTransmission(@NonNull Context context); void pause(); diff --git a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java index 34dd1bf8b..76766dfe8 100644 --- a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java +++ b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java @@ -17,6 +17,7 @@ package com.android.incallui.videotech.empty; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; import com.android.incallui.video.protocol.VideoCallScreen; @@ -65,10 +66,10 @@ public class EmptyVideoTech implements VideoTech { } @Override - public void upgradeToVideo() {} + public void upgradeToVideo(@NonNull Context context) {} @Override - public void acceptVideoRequest() {} + public void acceptVideoRequest(@NonNull Context context) {} @Override public void acceptVideoRequestAsAudio() {} @@ -85,7 +86,7 @@ public class EmptyVideoTech implements VideoTech { public void stopTransmission() {} @Override - public void resumeTransmission() {} + public void resumeTransmission(@NonNull Context context) {} @Override public void pause() {} diff --git a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java index 49170b8dc..954dfcd8b 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java @@ -16,6 +16,7 @@ package com.android.incallui.videotech.ims; +import android.content.Context; import android.os.Handler; import android.telecom.Call; import android.telecom.Connection; @@ -37,17 +38,20 @@ public class ImsVideoCallCallback extends VideoCall.Callback { private final Call call; private final ImsVideoTech videoTech; private final VideoTechListener listener; + private final Context context; private int requestedVideoState = VideoProfile.STATE_AUDIO_ONLY; ImsVideoCallCallback( final LoggingBindings logger, final Call call, ImsVideoTech videoTech, - VideoTechListener listener) { + VideoTechListener listener, + Context context) { this.logger = logger; this.call = call; this.videoTech = videoTech; this.listener = listener; + this.context = context; } @Override @@ -74,7 +78,7 @@ public class ImsVideoCallCallback extends VideoCall.Callback { } else { LogUtil.i( "ImsVideoTech.onSessionModifyRequestReceived", "call updated to %d", newVideoState); - videoTech.acceptVideoRequest(); + videoTech.acceptVideoRequest(context); } } } diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java index fec05dc55..c12474dc3 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java @@ -18,6 +18,7 @@ package com.android.incallui.videotech.ims; import android.content.Context; import android.os.Build; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.telecom.Call; import android.telecom.Call.Details; @@ -120,7 +121,7 @@ public class ImsVideoTech implements VideoTech { } if (callback == null) { - callback = new ImsVideoCallCallback(logger, call, this, listener); + callback = new ImsVideoCallCallback(logger, call, this, listener, context); call.getVideoCall().registerCallback(callback); } @@ -165,7 +166,7 @@ public class ImsVideoTech implements VideoTech { } @Override - public void upgradeToVideo() { + public void upgradeToVideo(@NonNull Context context) { LogUtil.enterBlock("ImsVideoTech.upgradeToVideo"); int unpausedVideoState = getUnpausedVideoState(call.getDetails().getVideoState()); @@ -177,7 +178,7 @@ public class ImsVideoTech implements VideoTech { } @Override - public void acceptVideoRequest() { + public void acceptVideoRequest(@NonNull Context context) { int requestedVideoState = callback.getRequestedVideoState(); Assert.checkArgument(requestedVideoState != VideoProfile.STATE_AUDIO_ONLY); LogUtil.i("ImsVideoTech.acceptUpgradeRequest", "videoState: " + requestedVideoState); @@ -223,7 +224,7 @@ public class ImsVideoTech implements VideoTech { } @Override - public void resumeTransmission() { + public void resumeTransmission(@NonNull Context context) { LogUtil.enterBlock("ImsVideoTech.resumeTransmission"); transmissionStopped = false; diff --git a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java index 4882ba879..a807759db 100644 --- a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java +++ b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java @@ -21,7 +21,6 @@ import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.telecom.Call; -import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -55,7 +54,7 @@ public class LightbringerTech implements VideoTech, LightbringerListener { @Override public boolean isAvailable(Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, only supported on O+"); return false; } @@ -71,11 +70,6 @@ public class LightbringerTech implements VideoTech, LightbringerListener { return false; } - if (!TelecomManagerCompat.supportsHandover()) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, telephony support missing"); - return false; - } - if (!lightbringer.supportsUpgrade(context, callingNumber)) { LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, number does not support it"); return false; @@ -125,13 +119,13 @@ public class LightbringerTech implements VideoTech, LightbringerListener { } @Override - public void upgradeToVideo() { + public void upgradeToVideo(@NonNull Context context) { listener.onImpressionLoggingNeeded(DialerImpression.Type.LIGHTBRINGER_UPGRADE_REQUESTED); - lightbringer.requestUpgrade(call); + lightbringer.requestUpgrade(context, call); } @Override - public void acceptVideoRequest() { + public void acceptVideoRequest(@NonNull Context context) { throw Assert.createUnsupportedOperationFailException(); } @@ -156,7 +150,7 @@ public class LightbringerTech implements VideoTech, LightbringerListener { } @Override - public void resumeTransmission() { + public void resumeTransmission(@NonNull Context context) { throw Assert.createUnsupportedOperationFailException(); } diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java index d7a122ce3..29c91e01e 100644 --- a/java/com/android/voicemail/impl/ActivationTask.java +++ b/java/com/android/voicemail/impl/ActivationTask.java @@ -170,7 +170,9 @@ public class ActivationTask extends BaseTask { if (VvmAccountManager.isAccountActivated(getContext(), phoneAccountHandle)) { VvmLog.i(TAG, "Account is already activated"); - onSuccess(getContext(), phoneAccountHandle); + // The activated state might come from restored data, the filter still needs to be set up. + helper.activateSmsFilter(); + onSuccess(getContext(), phoneAccountHandle, helper); return; } helper.handleEvent( @@ -230,7 +232,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, message); + updateSource(getContext(), phoneAccountHandle, message, helper); } else { if (helper.supportsProvisioning()) { VvmLog.i(TAG, "Subscriber not ready, start provisioning"); @@ -240,7 +242,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, message); + updateSource(getContext(), phoneAccountHandle, message, helper); } else { VvmLog.i(TAG, "Subscriber not ready but provisioning is not supported"); helper.handleEvent(status, OmtpEvents.CONFIG_SERVICE_NOT_AVAILABLE); @@ -251,20 +253,23 @@ public class ActivationTask extends BaseTask { } private static void updateSource( - Context context, PhoneAccountHandle phone, StatusMessage message) { + Context context, + PhoneAccountHandle phone, + StatusMessage message, + OmtpVvmCarrierConfigHelper config) { if (OmtpConstants.SUCCESS.equals(message.getReturnCode())) { // Save the IMAP credentials in preferences so they are persistent and can be retrieved. VvmAccountManager.addAccount(context, phone, message); - onSuccess(context, phone); + onSuccess(context, phone, config); } 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( + private static void onSuccess( + Context context, PhoneAccountHandle phoneAccountHandle, OmtpVvmCarrierConfigHelper config) { + config.handleEvent( VoicemailStatus.edit(context, phoneAccountHandle), OmtpEvents.CONFIG_REQUEST_STATUS_SUCCESS); clearLegacyVoicemailNotification(context, phoneAccountHandle); diff --git a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java index 9ce32a97c..ae526d168 100644 --- a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java +++ b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java @@ -16,6 +16,7 @@ package com.android.voicemail.impl.settings; import android.content.Context; +import android.support.annotation.VisibleForTesting; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.voicemail.VoicemailComponent; @@ -28,7 +29,7 @@ import com.android.voicemail.impl.sync.VvmAccountManager; /** Save whether or not a particular account is enabled in shared to be retrieved later. */ public class VisualVoicemailSettingsUtil { - private static final String IS_ENABLED_KEY = "is_enabled"; + @VisibleForTesting public static final String IS_ENABLED_KEY = "is_enabled"; public static void setEnabled( Context context, PhoneAccountHandle phoneAccount, boolean isEnabled) { -- cgit v1.2.3