Add ability to enable/disable navigation features from In-Call UI

Also automatically reenables all navigation in unBind

Bug: 10692603
Change-Id: I88c79b9761da5c3462acfeb720442439148a8ddc
diff --git a/common/src/com/android/services/telephony/common/ICallCommandService.aidl b/common/src/com/android/services/telephony/common/ICallCommandService.aidl
index 660d8aa..7f3afe6 100644
--- a/common/src/com/android/services/telephony/common/ICallCommandService.aidl
+++ b/common/src/com/android/services/telephony/common/ICallCommandService.aidl
@@ -96,4 +96,12 @@
     void postDialCancel(int callId);
 
     void postDialWaitContinue(int callId);
+
+    /**
+     * Enables or disables navigation using the system bar, and also prevents the
+     * notification shade from being dragged down.
+     * Hides or shows the home, recent and back buttons in the navigation bar if the
+     * device has soft navigation buttons.
+     */
+    void setSystemBarNavigationEnabled(boolean enable);
 }
diff --git a/src/com/android/phone/CallCommandService.java b/src/com/android/phone/CallCommandService.java
index 90297d8..60c5802 100644
--- a/src/com/android/phone/CallCommandService.java
+++ b/src/com/android/phone/CallCommandService.java
@@ -25,6 +25,7 @@
 import com.android.internal.telephony.CallManager;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.phone.CallModeler.CallResult;
+import com.android.phone.NotificationMgr.StatusBarHelper;
 import com.android.services.telephony.common.AudioMode;
 import com.android.services.telephony.common.Call;
 import com.android.services.telephony.common.ICallCommandService;
@@ -253,4 +254,17 @@
             result.getConnection().proceedAfterWaitChar();
         }
     }
+
+    @Override
+    public void setSystemBarNavigationEnabled(boolean enable) {
+        try {
+            final StatusBarHelper statusBarHelper = PhoneGlobals.getInstance().notificationMgr.
+                    statusBarHelper;
+            statusBarHelper.enableSystemBarNavigation(enable);
+            statusBarHelper.enableExpandedView(enable);
+        } catch (Exception e) {
+            Log.e(TAG, "Error enabling or disabling system bar navigation", e);
+        }
+    }
+
 }
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 1d43fe8..0681fb4 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -32,6 +32,7 @@
 import android.util.Log;
 
 import com.android.phone.AudioRouter.AudioModeListener;
+import com.android.phone.NotificationMgr.StatusBarHelper;
 import com.android.services.telephony.common.AudioMode;
 import com.android.services.telephony.common.Call;
 import com.android.services.telephony.common.ICallHandlerService;
@@ -383,6 +384,12 @@
 
     private void unbind() {
         synchronized (mServiceAndQueueLock) {
+            // On unbind, reenable the notification shade and navigation bar just in case the
+            // in-call UI crashed on an incoming call.
+            final StatusBarHelper statusBarHelper = PhoneGlobals.getInstance().notificationMgr.
+                    statusBarHelper;
+            statusBarHelper.enableSystemBarNavigation(true);
+            statusBarHelper.enableExpandedView(true);
             if (mCallHandlerServiceGuarded != null) {
                 Log.d(TAG, "Unbinding service.");
                 mCallHandlerServiceGuarded = null;