implement activity blocking

- monitor activity launch and shut it down if
  car is not parked and if the app is not allowed.
- Launch blocking activity for unsafe app.
- Blocking activity stays up to timeout (3 secs) and
  finish itself if there is safe app behind.
  If safe app is not there, launch home. If home is
  not safe either. stay.
- allow OEMs to give static whitelist as overlay.

bug: 25267050

Change-Id: Id0bdae757fa98345069f2d83711b46447506f888
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index d2329ba..c296c53 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -34,6 +34,8 @@
 public class ICarImpl extends ICar.Stub {
 
     public static final String INTERNAL_INPUT_SERVICE =  "internal_input";
+    public static final String INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE =
+            "system_activity_monitoring";
 
     // load jni for all services here
     static {
@@ -46,6 +48,7 @@
     private final Context mContext;
     private final VehicleHal mHal;
 
+    private final SystemActivityMonitoringService mSystemActivityMonitoringService;
     private final CarPowerManagementService mCarPowerManagementService;
     private final CarPackageManagerService mCarPackageManagerService;
     private final CarInputService mCarInputService;
@@ -86,19 +89,21 @@
     public ICarImpl(Context serviceContext) {
         mContext = serviceContext;
         mHal = VehicleHal.getInstance();
+        mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext);
         mCarPowerManagementService = new CarPowerManagementService(serviceContext);
+        mCarSensorService = new CarSensorService(serviceContext);
+        mCarPackageManagerService = new CarPackageManagerService(serviceContext, mCarSensorService,
+                mSystemActivityMonitoringService);
         mCarInputService = new CarInputService(serviceContext);
         mCarProjectionService = new CarProjectionService(serviceContext, mCarInputService);
         mGarageModeService = new GarageModeService(mContext, mCarPowerManagementService);
         mCarInfoService = new CarInfoService(serviceContext);
         mAppFocusService = new AppFocusService(serviceContext);
-        mCarSensorService = new CarSensorService(serviceContext);
         mCarAudioService = new CarAudioService(serviceContext, mCarInputService);
         mCarHvacService = new CarHvacService(serviceContext);
         mCarRadioService = new CarRadioService(serviceContext);
         mCarCameraService = new CarCameraService(serviceContext);
         mCarNightService = new CarNightService(serviceContext);
-        mCarPackageManagerService = new CarPackageManagerService(serviceContext);
         mInstrumentClusterService = new InstrumentClusterService(serviceContext,
                 mAppFocusService);
         mSystemStateControllerService = new SystemStateControllerService(serviceContext,
@@ -106,13 +111,14 @@
 
         // Be careful with order. Service depending on other service should be inited later.
         mAllServices = new CarServiceBase[] {
+                mSystemActivityMonitoringService,
                 mCarPowerManagementService,
+                mCarSensorService,
                 mCarPackageManagerService,
                 mCarInputService,
                 mGarageModeService,
                 mCarInfoService,
                 mAppFocusService,
-                mCarSensorService,
                 mCarAudioService,
                 mCarHvacService,
                 mCarRadioService,
@@ -218,6 +224,8 @@
         switch (serviceName) {
             case INTERNAL_INPUT_SERVICE:
                 return mCarInputService;
+            case INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE:
+                return mSystemActivityMonitoringService;
             default:
                 Log.w(CarLog.TAG_SERVICE, "getCarInternalService for unknown service:" +
                         serviceName);