Merge changes I845855d0,Id1518174

* changes:
  Fix bubble not showing on device restart.
  Add Brazil to the set of countries we do not format phone numbers
diff --git a/java/com/android/dialer/oem/res/values-mcc724/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc724/motorola_config.xml
new file mode 100644
index 0000000..bfe0cb7
--- /dev/null
+++ b/java/com/android/dialer/oem/res/values-mcc724/motorola_config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2018 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
+  -->
+
+<resources>
+  <!-- Flag to control whether to disable phone number formatting -->
+  <bool name="motorola_disable_phone_number_formatting">true</bool>
+</resources>
diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java
index 959f13f..2b147e7 100644
--- a/java/com/android/incallui/InCallServiceImpl.java
+++ b/java/com/android/incallui/InCallServiceImpl.java
@@ -111,10 +111,8 @@
     InCallPresenter.getInstance().onServiceBind();
     InCallPresenter.getInstance().maybeStartRevealAnimation(intent);
     TelecomAdapter.getInstance().setInCallService(this);
-    if (ReturnToCallController.isEnabled(this)) {
-      returnToCallController =
-          new ReturnToCallController(this, ContactInfoCache.getInstance(context));
-    }
+    returnToCallController =
+        new ReturnToCallController(this, ContactInfoCache.getInstance(context));
     feedbackListener = FeedbackComponent.get(context).getCallFeedbackListener();
     CallList.getInstance().addListener(feedbackListener);
 
diff --git a/java/com/android/incallui/ReturnToCallController.java b/java/com/android/incallui/ReturnToCallController.java
index 6227c77..9dfb73b 100644
--- a/java/com/android/incallui/ReturnToCallController.java
+++ b/java/com/android/incallui/ReturnToCallController.java
@@ -108,6 +108,11 @@
 
   @Override
   public void onUiShowing(boolean showing) {
+    if (!isEnabled(context)) {
+      hide();
+      return;
+    }
+
     LogUtil.i("ReturnToCallController.onUiShowing", "showing: " + showing);
     if (showing) {
       LogUtil.i("ReturnToCallController.onUiShowing", "going to hide");
@@ -155,8 +160,7 @@
     canShowBubblesForTesting = canShowBubbles;
   }
 
-  @VisibleForTesting
-  public Bubble startBubble() {
+  private Bubble startBubble() {
     if (!canShowBubbles(context)) {
       LogUtil.i("ReturnToCallController.startBubble", "can't show bubble, no permission");
       return null;
@@ -178,6 +182,11 @@
 
   @Override
   public void onCallListChange(CallList callList) {
+    if (!isEnabled(context)) {
+      hide();
+      return;
+    }
+
     if ((bubble == null || !bubble.isVisible())
         && getCall() != null
         && !InCallPresenter.getInstance().isShowingInCallUi()) {
@@ -188,6 +197,11 @@
 
   @Override
   public void onDisconnect(DialerCall call) {
+    if (!isEnabled(context)) {
+      hide();
+      return;
+    }
+
     LogUtil.enterBlock("ReturnToCallController.onDisconnect");
     if (bubble != null && bubble.isVisible() && (getCall() == null)) {
       // Show "Call ended" and hide bubble when there is no outgoing, active or background call
@@ -214,6 +228,11 @@
 
   @Override
   public void onAudioStateChanged(CallAudioState audioState) {
+    if (!isEnabled(context)) {
+      hide();
+      return;
+    }
+
     this.audioState = audioState;
     if (bubble != null) {
       bubble.updateActions(generateActions());