add skeleton for CarServiceHelperService support

- CarServiceHelperService is system server side companion for car service
  and it launches car service and provides ICarServiceHelper interface.
- Remove BootReceiver as CarServiceHelper is launching car service

bug: 62342376
Test: confirm boot-up
Change-Id: Ieae18dffe054eceb0e7840aba4e09769dae40687
diff --git a/car-lib/src/android/car/ICar.aidl b/car-lib/src/android/car/ICar.aidl
index 1510438..9f8c367 100644
--- a/car-lib/src/android/car/ICar.aidl
+++ b/car-lib/src/android/car/ICar.aidl
@@ -16,12 +16,14 @@
 
 package android.car;
 
-import android.content.Intent;
-
-import android.car.ICarConnectionListener;
-
 /** @hide */
 interface ICar {
-    IBinder getCarService(in String serviceName) = 0;
-    int getCarConnectionType() = 1;
+    /**
+     * IBinder is ICarServiceHelper but passed as IBinder due to aidl hidden.
+     * Only this method is oneway as it is called from system server.
+     * This should be the 1st method. Do not change the order.
+     */
+    oneway void setCarServiceHelper(in IBinder helper) = 0;
+    IBinder getCarService(in String serviceName) = 1;
+    int getCarConnectionType() = 2;
 }
diff --git a/service/AndroidManifest.xml b/service/AndroidManifest.xml
index 263c83a..175a8bb 100644
--- a/service/AndroidManifest.xml
+++ b/service/AndroidManifest.xml
@@ -168,12 +168,6 @@
             </intent-filter>
         </service>
         <service android:name=".PerUserCarService" android:exported="false" />
-        <receiver android:name=".BootReceiver">
-            <intent-filter android:priority="1000">
-                <action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
-                <action android:name="android.intent.action.BOOT_COMPLETED"/>
-            </intent-filter>
-        </receiver>
         <activity android:name="com.android.car.pm.ActivityBlockingActivity"
                   android:excludeFromRecents="true"
                   android:exported="false">
diff --git a/service/src/com/android/car/BootReceiver.java b/service/src/com/android/car/BootReceiver.java
deleted file mode 100644
index 10c6f2f..0000000
--- a/service/src/com/android/car/BootReceiver.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.car;
-
-import android.car.Car;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.util.Log;
-
-
-/**
- *  When system boots up, start car service.
- */
-public class BootReceiver extends BroadcastReceiver {
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        Log.w(CarLog.TAG_SERVICE, "Starting...");
-        Intent carServiceIntent = new Intent();
-        carServiceIntent.setPackage(context.getPackageName());
-        carServiceIntent.setAction(Car.CAR_SERVICE_INTERFACE_NAME);
-        context.startServiceAsUser(carServiceIntent, UserHandle.SYSTEM);
-    }
-}
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index 09e1226..f23f10c 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -26,7 +26,9 @@
 import android.hardware.automotive.vehicle.V2_0.IVehicle;
 import android.hardware.automotive.vehicle.V2_0.VehicleAreaDoor;
 import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
+import android.os.Binder;
 import android.os.IBinder;
+import android.os.Process;
 import android.util.Log;
 
 import com.android.car.cluster.InstrumentClusterService;
@@ -35,6 +37,7 @@
 import com.android.car.internal.FeatureUtil;
 import com.android.car.pm.CarPackageManagerService;
 import com.android.internal.annotations.GuardedBy;
+import com.android.internal.car.ICarServiceHelper;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -82,6 +85,9 @@
     @GuardedBy("this")
     private CarTestService mCarTestService;
 
+    @GuardedBy("this")
+    private ICarServiceHelper mICarServiceHelper;
+
     public ICarImpl(Context serviceContext, IVehicle vehicle, SystemInterface systemInterface,
             CanBusErrorNotifier errorNotifier) {
         mContext = serviceContext;
@@ -171,6 +177,17 @@
     }
 
     @Override
+    public void setCarServiceHelper(IBinder helper) {
+        int uid = Binder.getCallingUid();
+        if (uid != Process.SYSTEM_UID) {
+            throw new SecurityException("Only allowed from system");
+        }
+        synchronized (this) {
+            mICarServiceHelper = ICarServiceHelper.Stub.asInterface(helper);
+        }
+    }
+
+    @Override
     public IBinder getCarService(String serviceName) {
         switch (serviceName) {
             case Car.AUDIO_SERVICE:
@@ -475,4 +492,4 @@
         }
 
     }
-}
\ No newline at end of file
+}