Added carrier_id support to the carrier_key table in CarrierInformation DB am: 6179d11af8 am: 1d88a85783

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/2033663

Change-Id: Iff3db24bc78a916f078165e6270d3bcaaf28b464
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index 06d8fdc..766cb12 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -947,6 +947,15 @@
         }
     };
 
+    private final BroadcastReceiver mUserAddedReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
+                restrictPhoneCallOps();
+            }
+        }
+    };
+
     private final SystemStateListener mSystemStateListener = new SystemStateListener() {
         @Override
         public void onCarModeChanged(int priority, String packageName, boolean isCarMode) {
@@ -1055,6 +1064,7 @@
         mSystemStateHelper.addListener(mSystemStateListener);
         mClockProxy = clockProxy;
         restrictPhoneCallOps();
+        mContext.registerReceiver(mUserAddedReceiver, new IntentFilter(Intent.ACTION_USER_ADDED));
     }
 
     private void restrictPhoneCallOps() {
diff --git a/src/com/android/server/telecom/ServiceBinder.java b/src/com/android/server/telecom/ServiceBinder.java
index 2fcd2f5..7274993 100644
--- a/src/com/android/server/telecom/ServiceBinder.java
+++ b/src/com/android/server/telecom/ServiceBinder.java
@@ -87,7 +87,8 @@
                 ServiceConnection connection = new ServiceBinderConnection(call);
 
                 Log.addEvent(call, LogUtils.Events.BIND_CS, mComponentName);
-                final int bindingFlags = Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE;
+                final int bindingFlags = Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
+                        | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS;
                 final boolean isBound;
                 if (mUserHandle != null) {
                     isBound = mContext.bindServiceAsUser(serviceIntent, connection, bindingFlags,
@@ -149,7 +150,6 @@
                     Log.i(this, "Service bound %s", componentName);
 
                     Log.addEvent(mCall, LogUtils.Events.CS_BOUND, componentName);
-                    mCall = null;
 
                     // Unbind request was queued so unbind immediately.
                     if (mIsBindingAborted) {
@@ -191,6 +191,30 @@
                 Log.endSession();
             }
         }
+
+        /**
+         * Handles the case where the {@link ConnectionService} we bound to returned a null binding.
+         * We want to unbind from the service and cleanup and call resources at this time.
+         * @param componentName The component of the {@link ConnectionService}.
+         */
+        @Override
+        public void onNullBinding(ComponentName componentName) {
+            try {
+                Log.startSession("SBC.oNB");
+                synchronized (mLock) {
+                    Log.w(this, "Null binding %s", componentName);
+                    Log.addEvent(mCall, "NULL_BINDING", componentName);
+                    String componentStr = componentName == null ? "null" : componentName.toString();
+                    android.util.EventLog.writeEvent(0x534e4554, "211114016", -1, componentStr);
+                    logServiceDisconnected("onNullBinding");
+                    mContext.unbindService(this);
+                    clearAbort();
+                    handleFailedConnection();
+                }
+            } finally {
+                Log.endSession();
+            }
+        }
     }
 
     private void handleDisconnect() {