diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-31 22:33:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-31 22:33:25 +0000 |
commit | c61a76fc39f1a05d673d8ba75b489749ac278f0d (patch) | |
tree | 2b662fecbe22614571a9055c264717b0820ec3d0 /java/com/android/incallui/NewReturnToCallController.java | |
parent | a50c9bd73cd75a3bc049a81f2d51b874663b5b21 (diff) | |
parent | b6e16f578629eee53457a3fc17778f2252102891 (diff) |
Merge "Remove bubble from AOSP."
Diffstat (limited to 'java/com/android/incallui/NewReturnToCallController.java')
-rw-r--r-- | java/com/android/incallui/NewReturnToCallController.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/java/com/android/incallui/NewReturnToCallController.java b/java/com/android/incallui/NewReturnToCallController.java index 4c3c2a2eb..0b637f89c 100644 --- a/java/com/android/incallui/NewReturnToCallController.java +++ b/java/com/android/incallui/NewReturnToCallController.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; +import android.provider.Settings; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import android.telecom.CallAudioState; @@ -41,6 +42,7 @@ import com.android.incallui.call.DialerCall; import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo; import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo.IconSize; import com.android.newbubble.NewBubble; +import com.android.newbubble.NewBubbleComponent; import com.android.newbubble.NewBubbleInfo; import com.android.newbubble.NewBubbleInfo.Action; import java.lang.ref.WeakReference; @@ -58,6 +60,8 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) NewBubble bubble; + private static Boolean canShowBubblesForTesting = null; + private CallAudioState audioState; private final PendingIntent toggleSpeaker; @@ -132,13 +136,32 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au startContactInfoSearch(); } + /** + * Determines whether bubbles can be shown based on permissions obtained. This should be checked + * before attempting to create a Bubble. + * + * @return true iff bubbles are able to be shown. + * @see Settings#canDrawOverlays(Context) + */ + private static boolean canShowBubbles(@NonNull Context context) { + return canShowBubblesForTesting != null + ? canShowBubblesForTesting + : Settings.canDrawOverlays(context); + } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + static void setCanShowBubblesForTesting(boolean canShowBubbles) { + canShowBubblesForTesting = canShowBubbles; + } + @VisibleForTesting public NewBubble startBubble() { - if (!NewBubble.canShowBubbles(context)) { + if (!canShowBubbles(context)) { LogUtil.i("ReturnToCallController.startNewBubble", "can't show bubble, no permission"); return null; } - NewBubble returnToCallBubble = NewBubble.createBubble(context, generateBubbleInfo()); + NewBubble returnToCallBubble = NewBubbleComponent.get(context).getNewBubble(); + returnToCallBubble.setBubbleInfo(generateBubbleInfo()); returnToCallBubble.show(); return returnToCallBubble; } |