From beaaff27e6ea36ddab00ccf259bb73a18208f5c2 Mon Sep 17 00:00:00 2001 From: yueg Date: Fri, 2 Feb 2018 17:28:02 -0800 Subject: Remove bubble v1. Bug: 67605985 Test: manual PiperOrigin-RevId: 184358120 Change-Id: I17288da2b059f18bd51247e27aa174c7994e6f05 --- java/com/android/incallui/AndroidManifest.xml | 3 - java/com/android/incallui/InCallActivity.java | 6 - java/com/android/incallui/InCallServiceImpl.java | 8 - .../incallui/ReturnToCallActionReceiver.java | 138 ---------- .../android/incallui/ReturnToCallController.java | 280 --------------------- java/com/android/incallui/StatusBarNotifier.java | 4 +- 6 files changed, 2 insertions(+), 437 deletions(-) delete mode 100644 java/com/android/incallui/ReturnToCallActionReceiver.java delete mode 100644 java/com/android/incallui/ReturnToCallController.java (limited to 'java/com/android/incallui') diff --git a/java/com/android/incallui/AndroidManifest.xml b/java/com/android/incallui/AndroidManifest.xml index 3d5aa1ceb..eb080bc82 100644 --- a/java/com/android/incallui/AndroidManifest.xml +++ b/java/com/android/incallui/AndroidManifest.xml @@ -112,9 +112,6 @@ android:exported="false" android:name="com.android.incallui.NotificationBroadcastReceiver"/> - diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index 535b894f6..8769be5d9 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -60,7 +60,6 @@ import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.compat.ActivityCompat; import com.android.dialer.compat.CompatUtils; import com.android.dialer.configprovider.ConfigProviderBindings; -import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.LoggingBindings; import com.android.dialer.logging.ScreenEvent; @@ -173,11 +172,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity Trace.beginSection("InCallActivity.onCreate"); super.onCreate(bundle); - if (getIntent().getBooleanExtra(ReturnToCallController.RETURN_TO_CALL_EXTRA_KEY, false)) { - Logger.get(this).logImpression(DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_RETURN_TO_CALL); - getIntent().removeExtra(ReturnToCallController.RETURN_TO_CALL_EXTRA_KEY); - } - if (bundle != null) { didShowAnswerScreen = bundle.getBoolean(KeysForSavedInstance.DID_SHOW_ANSWER_SCREEN); didShowInCallScreen = bundle.getBoolean(KeysForSavedInstance.DID_SHOW_IN_CALL_SCREEN); diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java index c4d6d064f..a7095f818 100644 --- a/java/com/android/incallui/InCallServiceImpl.java +++ b/java/com/android/incallui/InCallServiceImpl.java @@ -40,7 +40,6 @@ import com.android.incallui.speakeasy.SpeakEasyComponent; */ public class InCallServiceImpl extends InCallService { - private ReturnToCallController returnToCallController; private NewReturnToCallController newReturnToCallController; private CallList.Listener feedbackListener; // We only expect there to be one speakEasyCallManager to be instantiated at a time. @@ -112,9 +111,6 @@ public class InCallServiceImpl extends InCallService { InCallPresenter.getInstance().onServiceBind(); InCallPresenter.getInstance().maybeStartRevealAnimation(intent); TelecomAdapter.getInstance().setInCallService(this); - if (ReturnToCallController.isEnabled(this)) { - returnToCallController = new ReturnToCallController(this); - } if (NewReturnToCallController.isEnabled(this)) { newReturnToCallController = new NewReturnToCallController(this, ContactInfoCache.getInstance(context)); @@ -145,10 +141,6 @@ public class InCallServiceImpl extends InCallService { // Tear down the InCall system InCallPresenter.getInstance().tearDown(); TelecomAdapter.getInstance().clearInCallService(); - if (returnToCallController != null) { - returnToCallController.tearDown(); - returnToCallController = null; - } if (newReturnToCallController != null) { newReturnToCallController.tearDown(); newReturnToCallController = null; diff --git a/java/com/android/incallui/ReturnToCallActionReceiver.java b/java/com/android/incallui/ReturnToCallActionReceiver.java deleted file mode 100644 index c37b0b816..000000000 --- a/java/com/android/incallui/ReturnToCallActionReceiver.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2017 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 - */ - -package com.android.incallui; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.telecom.CallAudioState; -import com.android.dialer.common.Assert; -import com.android.dialer.common.LogUtil; -import com.android.dialer.logging.DialerImpression; -import com.android.dialer.logging.Logger; -import com.android.incallui.audiomode.AudioModeProvider; -import com.android.incallui.call.CallList; -import com.android.incallui.call.DialerCall; -import com.android.incallui.call.TelecomAdapter; - -/** Handles clicks on the return-to-call bubble */ -public class ReturnToCallActionReceiver extends BroadcastReceiver { - - public static final String ACTION_TOGGLE_SPEAKER = "toggleSpeaker"; - public static final String ACTION_SHOW_AUDIO_ROUTE_SELECTOR = "showAudioRouteSelector"; - public static final String ACTION_TOGGLE_MUTE = "toggleMute"; - public static final String ACTION_END_CALL = "endCall"; - - @Override - public void onReceive(Context context, Intent intent) { - switch (intent.getAction()) { - case ACTION_TOGGLE_SPEAKER: - toggleSpeaker(context); - break; - case ACTION_SHOW_AUDIO_ROUTE_SELECTOR: - showAudioRouteSelector(context); - break; - case ACTION_TOGGLE_MUTE: - toggleMute(context); - break; - case ACTION_END_CALL: - endCall(context); - break; - default: - throw Assert.createIllegalStateFailException( - "Invalid intent action: " + intent.getAction()); - } - } - - private void toggleSpeaker(Context context) { - CallAudioState audioState = AudioModeProvider.getInstance().getAudioState(); - - if ((audioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH) - == CallAudioState.ROUTE_BLUETOOTH) { - LogUtil.w( - "ReturnToCallActionReceiver.toggleSpeaker", - "toggleSpeaker() called when bluetooth available." - + " Probably should have shown audio route selector"); - } - - DialerCall call = getCall(); - - int newRoute; - if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) { - newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE; - Logger.get(context) - .logCallImpression( - DialerImpression.Type.BUBBLE_TURN_ON_WIRED_OR_EARPIECE, - call != null ? call.getUniqueCallId() : "", - call != null ? call.getTimeAddedMs() : 0); - } else { - newRoute = CallAudioState.ROUTE_SPEAKER; - Logger.get(context) - .logCallImpression( - DialerImpression.Type.BUBBLE_TURN_ON_SPEAKERPHONE, - call != null ? call.getUniqueCallId() : "", - call != null ? call.getTimeAddedMs() : 0); - } - TelecomAdapter.getInstance().setAudioRoute(newRoute); - } - - public void showAudioRouteSelector(Context context) { - Intent intent = new Intent(context, AudioRouteSelectorActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - context.startActivity(intent); - } - - private void toggleMute(Context context) { - DialerCall call = getCall(); - boolean shouldMute = !AudioModeProvider.getInstance().getAudioState().isMuted(); - Logger.get(context) - .logCallImpression( - shouldMute - ? DialerImpression.Type.BUBBLE_MUTE_CALL - : DialerImpression.Type.BUBBLE_UNMUTE_CALL, - call != null ? call.getUniqueCallId() : "", - call != null ? call.getTimeAddedMs() : 0); - TelecomAdapter.getInstance().mute(shouldMute); - } - - private void endCall(Context context) { - DialerCall call = getCall(); - - Logger.get(context) - .logCallImpression( - DialerImpression.Type.BUBBLE_END_CALL, - call != null ? call.getUniqueCallId() : "", - call != null ? call.getTimeAddedMs() : 0); - if (call != null) { - call.disconnect(); - } - } - - private DialerCall getCall() { - CallList callList = InCallPresenter.getInstance().getCallList(); - if (callList != null) { - DialerCall call = callList.getOutgoingCall(); - if (call == null) { - call = callList.getActiveOrBackgroundCall(); - } - if (call != null) { - return call; - } - } - return null; - } -} diff --git a/java/com/android/incallui/ReturnToCallController.java b/java/com/android/incallui/ReturnToCallController.java deleted file mode 100644 index 58d868818..000000000 --- a/java/com/android/incallui/ReturnToCallController.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2017 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 - */ - -package com.android.incallui; - -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.Icon; -import android.support.annotation.NonNull; -import android.support.annotation.VisibleForTesting; -import android.telecom.CallAudioState; -import com.android.bubble.Bubble; -import com.android.bubble.Bubble.BubbleExpansionStateListener; -import com.android.bubble.Bubble.ExpansionState; -import com.android.bubble.BubbleInfo; -import com.android.bubble.BubbleInfo.Action; -import com.android.dialer.common.LogUtil; -import com.android.dialer.configprovider.ConfigProviderBindings; -import com.android.dialer.logging.DialerImpression; -import com.android.dialer.logging.Logger; -import com.android.dialer.telecom.TelecomUtil; -import com.android.incallui.InCallPresenter.InCallUiListener; -import com.android.incallui.audiomode.AudioModeProvider; -import com.android.incallui.audiomode.AudioModeProvider.AudioModeListener; -import com.android.incallui.call.CallList; -import com.android.incallui.call.CallList.Listener; -import com.android.incallui.call.DialerCall; -import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo; -import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo.IconSize; -import java.util.ArrayList; -import java.util.List; - -/** - * Listens for events relevant to the return-to-call bubble and updates the bubble's state as - * necessary - */ -public class ReturnToCallController implements InCallUiListener, Listener, AudioModeListener { - - public static final String RETURN_TO_CALL_EXTRA_KEY = "RETURN_TO_CALL_BUBBLE"; - - private final Context context; - - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) - Bubble bubble; - - private CallAudioState audioState; - - private final PendingIntent toggleSpeaker; - private final PendingIntent showSpeakerSelect; - private final PendingIntent toggleMute; - private final PendingIntent endCall; - - public static boolean isEnabled(Context context) { - return ConfigProviderBindings.get(context).getBoolean("enable_return_to_call_bubble", false); - } - - public ReturnToCallController(Context context) { - this.context = context; - - toggleSpeaker = createActionIntent(ReturnToCallActionReceiver.ACTION_TOGGLE_SPEAKER); - showSpeakerSelect = - createActionIntent(ReturnToCallActionReceiver.ACTION_SHOW_AUDIO_ROUTE_SELECTOR); - toggleMute = createActionIntent(ReturnToCallActionReceiver.ACTION_TOGGLE_MUTE); - endCall = createActionIntent(ReturnToCallActionReceiver.ACTION_END_CALL); - - InCallPresenter.getInstance().addInCallUiListener(this); - CallList.getInstance().addListener(this); - AudioModeProvider.getInstance().addListener(this); - audioState = AudioModeProvider.getInstance().getAudioState(); - } - - public void tearDown() { - hide(); - InCallPresenter.getInstance().removeInCallUiListener(this); - CallList.getInstance().removeListener(this); - AudioModeProvider.getInstance().removeListener(this); - } - - @Override - public void onUiShowing(boolean showing) { - if (showing) { - hide(); - } else { - if (TelecomUtil.isInManagedCall(context)) { - show(); - } - } - } - - private void hide() { - if (bubble != null) { - bubble.hide(); - } else { - LogUtil.i("ReturnToCallController.hide", "hide() called without calling show()"); - } - } - - private void hideAndReset() { - if (bubble != null) { - bubble.hideAndReset(); - } else { - LogUtil.i("ReturnToCallController.reset", "reset() called without calling show()"); - } - } - - private void show() { - if (bubble == null) { - bubble = startNewBubble(); - } else { - bubble.show(); - } - } - - @VisibleForTesting - public Bubble startNewBubble() { - if (!Bubble.canShowBubbles(context)) { - LogUtil.i("ReturnToCallController.startNewBubble", "can't show bubble, no permission"); - return null; - } - Bubble returnToCallBubble = Bubble.createBubble(context, generateBubbleInfo()); - returnToCallBubble.setBubbleExpansionStateListener( - new BubbleExpansionStateListener() { - @Override - public void onBubbleExpansionStateChanged( - @ExpansionState int expansionState, boolean isUserAction) { - if (!isUserAction) { - return; - } - - DialerCall call = CallList.getInstance().getActiveOrBackgroundCall(); - switch (expansionState) { - case ExpansionState.START_EXPANDING: - if (call != null) { - Logger.get(context) - .logCallImpression( - DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND, - call.getUniqueCallId(), - call.getTimeAddedMs()); - } else { - Logger.get(context) - .logImpression(DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND); - } - break; - case ExpansionState.START_COLLAPSING: - if (call != null) { - Logger.get(context) - .logCallImpression( - DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER, - call.getUniqueCallId(), - call.getTimeAddedMs()); - } else { - Logger.get(context).logImpression(DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER); - } - break; - default: - break; - } - } - }); - returnToCallBubble.show(); - return returnToCallBubble; - } - - @Override - public void onIncomingCall(DialerCall call) {} - - @Override - public void onUpgradeToVideo(DialerCall call) {} - - @Override - public void onSessionModificationStateChange(DialerCall call) {} - - @Override - public void onCallListChange(CallList callList) {} - - @Override - public void onDisconnect(DialerCall call) { - if (call.wasParentCall()) { - // It's disconnected after the last child call is disconnected, and we already did everything - // for the last child. - LogUtil.i( - "ReturnToCallController.onDisconnect", "being called for a parent call and do nothing"); - return; - } - if (bubble != null - && bubble.isVisible() - && (!TelecomUtil.isInManagedCall(context) - || CallList.getInstance().getActiveOrBackgroundCall() != null)) { - bubble.showText(context.getText(R.string.incall_call_ended)); - } - // For conference call, we should hideAndReset for the last disconnected child call while the - // parent call is still there. - if (!CallList.getInstance().hasNonParentActiveOrBackgroundCall()) { - hideAndReset(); - } - } - - @Override - public void onWiFiToLteHandover(DialerCall call) {} - - @Override - public void onHandoverToWifiFailed(DialerCall call) {} - - @Override - public void onInternationalCallOnWifi(@NonNull DialerCall call) {} - - @Override - public void onAudioStateChanged(CallAudioState audioState) { - this.audioState = audioState; - if (bubble != null) { - bubble.updateActions(generateActions()); - } - } - - private BubbleInfo generateBubbleInfo() { - Intent activityIntent = InCallActivity.getIntent(context, false, false, false); - activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - activityIntent.putExtra(RETURN_TO_CALL_EXTRA_KEY, true); - return BubbleInfo.builder() - .setPrimaryColor(context.getResources().getColor(R.color.dialer_theme_color, null)) - .setPrimaryIcon(Icon.createWithResource(context, R.drawable.on_going_call)) - .setStartingYPosition( - context.getResources().getDimensionPixelOffset(R.dimen.return_to_call_initial_offset_y)) - .setPrimaryIntent( - PendingIntent.getActivity( - context, InCallActivity.PendingIntentRequestCodes.BUBBLE, activityIntent, 0)) - .setActions(generateActions()) - .build(); - } - - @NonNull - private List generateActions() { - List actions = new ArrayList<>(); - SpeakerButtonInfo speakerButtonInfo = new SpeakerButtonInfo(audioState, IconSize.SIZE_24_DP); - - actions.add( - Action.builder() - .setIcon(Icon.createWithResource(context, speakerButtonInfo.icon)) - .setName(context.getText(speakerButtonInfo.label)) - .setChecked(speakerButtonInfo.isChecked) - .setIntent(speakerButtonInfo.checkable ? toggleSpeaker : showSpeakerSelect) - .build()); - - actions.add( - Action.builder() - .setIcon(Icon.createWithResource(context, R.drawable.quantum_ic_mic_off_white_24)) - .setName(context.getText(R.string.incall_label_mute)) - .setChecked(audioState.isMuted()) - .setIntent(toggleMute) - .build()); - actions.add( - Action.builder() - .setIcon(Icon.createWithResource(context, R.drawable.quantum_ic_call_end_vd_theme_24)) - .setName(context.getText(R.string.incall_label_end_call)) - .setIntent(endCall) - .build()); - return actions; - } - - @NonNull - private PendingIntent createActionIntent(String action) { - Intent toggleSpeaker = new Intent(context, ReturnToCallActionReceiver.class); - toggleSpeaker.setAction(action); - return PendingIntent.getBroadcast(context, 0, toggleSpeaker, 0); - } -} diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 960fd14df..87f332a1d 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -657,8 +657,8 @@ public class StatusBarNotifier } else if (call.hasProperty(Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { return R.drawable.quantum_ic_phone_locked_vd_theme_24; } - // If ReturnToCall is enabled, use the static icon. The animated one will show in the bubble. - if (ReturnToCallController.isEnabled(context) || NewReturnToCallController.isEnabled(context)) { + // If NewReturnToCall is enabled, use the static icon. The animated one will show in the bubble. + if (NewReturnToCallController.isEnabled(context)) { return R.drawable.quantum_ic_call_vd_theme_24; } else { return R.drawable.on_going_call; -- cgit v1.2.3