Merge changes I71e70d6f,I40955c6e,I70ed303b

* changes:
  Bubble change when display size change.
  Update Assisted Dialing references.
  Pressing back button twice really quickly no longer crashes dialer.
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
index a3c96db..c1ffbd3 100644
--- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java
+++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
@@ -23,6 +23,7 @@
 import android.preference.PreferenceManager;
 import android.support.annotation.NonNull;
 import android.support.annotation.VisibleForTesting;
+import android.support.v4.os.BuildCompat;
 import android.support.v4.os.UserManagerCompat;
 import android.telephony.TelephonyManager;
 import com.android.dialer.common.LogUtil;
@@ -102,7 +103,8 @@
     }
 
     return (Build.VERSION.SDK_INT >= BUILD_CODE_FLOOR
-            && Build.VERSION.SDK_INT <= BUILD_CODE_CEILING)
+            && Build.VERSION.SDK_INT <= BUILD_CODE_CEILING
+            && !BuildCompat.isAtLeastP())
         && configProvider.getBoolean("assisted_dialing_enabled", false);
   }
 
diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
index 92e2569..86f344f 100644
--- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
+++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
@@ -65,8 +65,11 @@
   public static final String ASSISTED_DIALING_EXTRAS =
       "android.telecom.extra.ASSISTED_DIALING_EXTRAS";
 
+  public static final String EXTRA_ASSISTED_DIALING_TRANSFORMATION_INFO =
+      "android.telecom.extra.ASSISTED_DIALING_TRANSFORMATION_INFO";
+
   /** Indicates the Connection/Call used assisted dialing. */
-  public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200;
+  public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9;
 
   public static final String EXTRA_IS_REFRESH =
       BuildCompat.isAtLeastOMR1() ? "android.telephony.extra.IS_REFRESH" : "is_refresh";
@@ -75,7 +78,7 @@
    * Indicates the call underwent Assisted Dialing; typically set as a feature available from the
    * CallLog.
    */
-  public static final Integer FEATURES_ASSISTED_DIALING = 0x10;
+  public static final Integer FEATURES_ASSISTED_DIALING = 1 << 4;
 
   /**
    * Returns the number of phones available. Returns 1 for Single standby mode (Single SIM
diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
index c84b8fc..9592938 100644
--- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
+++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
@@ -82,6 +82,10 @@
   }
 
   private void onSearchBackButtonClicked() {
+    if (!isExpanded) {
+      return;
+    }
+
     listener.onSearchBackButtonClicked();
     collapse(true);
   }
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index 2724322..a30367f 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -1114,7 +1114,7 @@
     // perform assisted dialing. PROPERTY_ASSISTED_DIALING_USED indicates assisted dialing took
     // place.
     if (hasProperty(TelephonyManagerCompat.PROPERTY_ASSISTED_DIALING_USED)
-        && Build.VERSION.SDK_INT > ConcreteCreator.BUILD_CODE_CEILING) {
+        && BuildCompat.isAtLeastP()) {
       return true;
     }
     return false;
@@ -1126,10 +1126,26 @@
       return null;
     }
 
+    if (BuildCompat.isAtLeastP()) {
+      if (getExtras() == null) {
+        return null;
+      }
+
+      if (getExtras()
+              .getParcelable(TelephonyManagerCompat.EXTRA_ASSISTED_DIALING_TRANSFORMATION_INFO)
+          == null) {
+        return null;
+      }
+
+      // TODO(erfanian): Use the framework transformation info when we can link against it
+      return null;
+    }
+
     if (getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS) == null) {
       return null;
     }
 
+    // Used in N-OMR1
     return TransformationInfo.newInstanceFromBundle(
         getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS));
   }
diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java
index c0f93e2..8b188ba 100644
--- a/java/com/android/newbubble/NewBubble.java
+++ b/java/com/android/newbubble/NewBubble.java
@@ -25,6 +25,7 @@
 import android.app.PendingIntent.CanceledException;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Outline;
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
 import android.graphics.drawable.Animatable;
@@ -46,6 +47,7 @@
 import android.view.View;
 import android.view.View.AccessibilityDelegate;
 import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
 import android.view.ViewTreeObserver.OnPreDrawListener;
 import android.view.WindowManager;
 import android.view.WindowManager.LayoutParams;
@@ -112,7 +114,7 @@
   @VisibleForTesting AnimatorSet exitAnimatorSet;
   @VisibleForTesting AnimatorSet enterAnimatorSet;
 
-  private final int primaryIconMoveDistance;
+  private int primaryIconMoveDistance;
   private final int leftBoundary;
   private int savedYPosition = -1;
 
@@ -663,6 +665,22 @@
   }
 
   private void update() {
+    // The value may change on display size changed.
+    primaryIconMoveDistance =
+        context.getResources().getDimensionPixelSize(R.dimen.bubble_size)
+            - context.getResources().getDimensionPixelSize(R.dimen.bubble_small_icon_size);
+    // Set boundary for primary button to show elevation (background is transparent)
+    viewHolder
+        .getPrimaryButton()
+        .setOutlineProvider(
+            new ViewOutlineProvider() {
+              @Override
+              public void getOutline(View view, Outline outline) {
+                ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
+                outline.setAlpha(1);
+              }
+            });
+
     // Small icon
     Drawable smallIconBackgroundCircle =
         context
@@ -914,9 +932,10 @@
               startCollapse(CollapseEnd.NOTHING, false /* shouldRecoverYPosition */);
             }
             // The values in the current MoveHandler may be stale, so replace it. Then ensure the
-            // Window is in bounds
+            // Window is in bounds, and redraw the changes
             moveHandler = new NewMoveHandler(primaryButton, NewBubble.this);
             moveHandler.snapToBounds();
+            replaceViewHolder();
           });
       root.setOnTouchListener(
           (v, event) -> {
diff --git a/java/com/android/newbubble/res/drawable/bubble_shape_circle.xml b/java/com/android/newbubble/res/drawable/bubble_shape_circle.xml
index af9d858..b188e9d 100644
--- a/java/com/android/newbubble/res/drawable/bubble_shape_circle.xml
+++ b/java/com/android/newbubble/res/drawable/bubble_shape_circle.xml
@@ -15,11 +15,10 @@
   ~ limitations under the License
   -->
 
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
-  <corners
-      android:bottomRightRadius="@dimen/bubble_size"
-      android:topRightRadius="@dimen/bubble_size"
-      android:bottomLeftRadius="@dimen/bubble_size"
-      android:topLeftRadius="@dimen/bubble_size"/>
-  <solid android:color="@android:color/white"/>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+  <size
+      android:width="@dimen/bubble_size"
+      android:height="@dimen/bubble_size"/>
+  <solid android:color="@android:color/transparent"/>
 </shape>