keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.car; |
| 18 | |
Pavel Maltsev | abd4723 | 2017-10-10 16:54:57 -0700 | [diff] [blame] | 19 | import android.annotation.MainThread; |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Keun young Park | f3523cd | 2019-04-08 10:09:17 -0700 | [diff] [blame] | 21 | import android.app.ActivityManager; |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 22 | import android.app.ActivityOptions; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 23 | import android.app.UiModeManager; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 24 | import android.car.Car; |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 25 | import android.car.CarFeatures; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 26 | import android.car.ICar; |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 27 | import android.car.cluster.renderer.IInstrumentClusterNavigation; |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 28 | import android.car.user.CarUserManager; |
Ying Zheng | 9fc9940 | 2018-09-19 14:23:59 -0700 | [diff] [blame] | 29 | import android.car.userlib.CarUserManagerHelper; |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 30 | import android.content.ComponentName; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 31 | import android.content.Context; |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 32 | import android.content.Intent; |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 33 | import android.content.pm.PackageManager; |
Keun young Park | f3523cd | 2019-04-08 10:09:17 -0700 | [diff] [blame] | 34 | import android.content.res.Resources; |
Pavel Maltsev | cfe9310 | 2017-02-02 12:38:08 -0800 | [diff] [blame] | 35 | import android.hardware.automotive.vehicle.V2_0.IVehicle; |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 36 | import android.hardware.automotive.vehicle.V2_0.InitialUserInfoResponseAction; |
| 37 | import android.hardware.automotive.vehicle.V2_0.UsersInfo; |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 38 | import android.hardware.automotive.vehicle.V2_0.VehicleArea; |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 39 | import android.os.Binder; |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 40 | import android.os.Build; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 41 | import android.os.IBinder; |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 42 | import android.os.Process; |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 43 | import android.os.RemoteException; |
| 44 | import android.os.ResultReceiver; |
| 45 | import android.os.ShellCallback; |
| 46 | import android.os.ShellCommand; |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 47 | import android.os.SystemClock; |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 48 | import android.os.Trace; |
Anthony Hugh | 9932a25 | 2019-06-12 16:19:56 -0700 | [diff] [blame] | 49 | import android.os.UserManager; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 50 | import android.util.Log; |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 51 | import android.util.Slog; |
Keun-young Park | 4a79a38 | 2017-08-10 18:19:14 -0700 | [diff] [blame] | 52 | import android.util.TimingsTraceLog; |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 53 | import android.view.KeyEvent; |
Gregory Clark | 26fa601 | 2018-03-14 18:38:56 -0700 | [diff] [blame] | 54 | |
Keun young Park | a4d1220 | 2019-10-03 10:51:12 -0700 | [diff] [blame] | 55 | import com.android.car.am.FixedActivityService; |
Hongwei Wang | 3854909 | 2018-08-22 12:32:42 -0700 | [diff] [blame] | 56 | import com.android.car.audio.CarAudioService; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 57 | import com.android.car.cluster.InstrumentClusterService; |
Serik Beketayev | 06a6668 | 2018-06-12 16:54:29 -0700 | [diff] [blame] | 58 | import com.android.car.garagemode.GarageModeService; |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 59 | import com.android.car.hal.InputHalService; |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 60 | import com.android.car.hal.UserHalHelper; |
| 61 | import com.android.car.hal.UserHalService; |
| 62 | import com.android.car.hal.UserHalService.HalCallback; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 63 | import com.android.car.hal.VehicleHal; |
Keun-young Park | 4aeb4bf | 2015-12-08 18:31:33 -0800 | [diff] [blame] | 64 | import com.android.car.pm.CarPackageManagerService; |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 65 | import com.android.car.stats.CarStatsService; |
Enrico Granata | b19bc32 | 2017-10-12 12:25:06 -0700 | [diff] [blame] | 66 | import com.android.car.systeminterface.SystemInterface; |
Ram Periathiruvadi | de0ca08 | 2019-03-20 11:16:44 -0700 | [diff] [blame] | 67 | import com.android.car.trust.CarTrustedDeviceService; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 68 | import com.android.car.user.CarUserNoticeService; |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 69 | import com.android.car.user.CarUserService; |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 70 | import com.android.car.user.UserMetrics; |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 71 | import com.android.car.vms.VmsNewBrokerService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 72 | import com.android.internal.annotations.GuardedBy; |
Felipe Leme | 6ef8965 | 2019-12-19 16:47:14 -0800 | [diff] [blame] | 73 | import com.android.internal.annotations.VisibleForTesting; |
Steve Paik | 1d8bea2 | 2018-02-03 01:54:06 +0000 | [diff] [blame] | 74 | import com.android.internal.car.ICarServiceHelper; |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 75 | import com.android.internal.util.ArrayUtils; |
Gregory Clark | 26fa601 | 2018-03-14 18:38:56 -0700 | [diff] [blame] | 76 | |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 77 | import java.io.FileDescriptor; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 78 | import java.io.PrintWriter; |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 79 | import java.util.ArrayList; |
Antonio Cortes | e4619c7 | 2017-02-02 07:53:27 -0800 | [diff] [blame] | 80 | import java.util.Arrays; |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 81 | import java.util.List; |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 82 | import java.util.concurrent.CountDownLatch; |
| 83 | import java.util.concurrent.TimeUnit; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 84 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 85 | public class ICarImpl extends ICar.Stub { |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 86 | |
Ram Periathiruvadi | 49d5a5a | 2017-02-17 18:50:09 -0800 | [diff] [blame] | 87 | public static final String INTERNAL_INPUT_SERVICE = "internal_input"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 88 | public static final String INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE = |
| 89 | "system_activity_monitoring"; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 90 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 91 | private final Context mContext; |
Pavel Maltsev | ec83b63 | 2017-01-05 15:10:55 -0800 | [diff] [blame] | 92 | private final VehicleHal mHal; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 93 | |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 94 | private final CarFeatureController mFeatureController; |
| 95 | |
Anthony Chen | 12aec30 | 2018-04-25 16:41:48 -0700 | [diff] [blame] | 96 | private final SystemInterface mSystemInterface; |
| 97 | |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 98 | private final SystemActivityMonitoringService mSystemActivityMonitoringService; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 99 | private final CarPowerManagementService mCarPowerManagementService; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 100 | private final CarPackageManagerService mCarPackageManagerService; |
| 101 | private final CarInputService mCarInputService; |
Ram Periathiruvadi | 25c16f1 | 2017-11-17 16:48:37 -0800 | [diff] [blame] | 102 | private final CarDrivingStateService mCarDrivingStateService; |
Ram Periathiruvadi | 4526a43 | 2018-01-24 13:00:54 -0800 | [diff] [blame] | 103 | private final CarUxRestrictionsManagerService mCarUXRestrictionsService; |
Michael Keller | c0f0bdb | 2019-12-11 14:58:19 -0800 | [diff] [blame] | 104 | private final OccupantAwarenessService mOccupantAwarenessService; |
keunyoung | d32f4e6 | 2015-09-21 11:33:06 -0700 | [diff] [blame] | 105 | private final CarAudioService mCarAudioService; |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 106 | private final CarProjectionService mCarProjectionService; |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 107 | private final CarPropertyService mCarPropertyService; |
Joseph Pirozzo | 317343d | 2016-01-25 10:22:37 -0800 | [diff] [blame] | 108 | private final CarNightService mCarNightService; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 109 | private final AppFocusService mAppFocusService; |
Keun young Park | a4d1220 | 2019-10-03 10:51:12 -0700 | [diff] [blame] | 110 | private final FixedActivityService mFixedActivityService; |
Yao Chen | 3a7976d | 2016-01-20 17:27:08 -0800 | [diff] [blame] | 111 | private final GarageModeService mGarageModeService; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 112 | private final InstrumentClusterService mInstrumentClusterService; |
Gregory Clark | d813606 | 2017-12-11 14:27:53 -0800 | [diff] [blame] | 113 | private final CarLocationService mCarLocationService; |
Keun-young Park | d73afae | 2016-04-08 20:03:32 -0700 | [diff] [blame] | 114 | private final SystemStateControllerService mSystemStateControllerService; |
Ram Periathiruvadi | 7ed8418 | 2017-01-20 15:18:08 -0800 | [diff] [blame] | 115 | private final CarBluetoothService mCarBluetoothService; |
Ram Periathiruvadi | acb6024 | 2017-04-13 16:19:09 -0700 | [diff] [blame] | 116 | private final PerUserCarServiceHelper mPerUserCarServiceHelper; |
Enrico Granata | 9a916d7 | 2017-09-19 14:33:08 -0700 | [diff] [blame] | 117 | private final CarDiagnosticService mCarDiagnosticService; |
| 118 | private final CarStorageMonitoringService mCarStorageMonitoringService; |
Anthony Chen | 12aec30 | 2018-04-25 16:41:48 -0700 | [diff] [blame] | 119 | private final CarConfigurationService mCarConfigurationService; |
Ram Periathiruvadi | de0ca08 | 2019-03-20 11:16:44 -0700 | [diff] [blame] | 120 | private final CarTrustedDeviceService mCarTrustedDeviceService; |
Simon Dai | 527eb55 | 2019-02-12 13:06:15 -0800 | [diff] [blame] | 121 | private final CarMediaService mCarMediaService; |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 122 | private final CarUserManagerHelper mUserManagerHelper; |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 123 | private final CarUserService mCarUserService; |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 124 | private final CarOccupantZoneService mCarOccupantZoneService; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 125 | private final CarUserNoticeService mCarUserNoticeService; |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 126 | private final VmsNewBrokerService mVmsBrokerService; |
Selim Gurun | c8c82f6 | 2019-04-17 14:07:30 -0700 | [diff] [blame] | 127 | private final CarBugreportManagerService mCarBugreportManagerService; |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 128 | private final CarStatsService mCarStatsService; |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 129 | private final CarExperimentalFeatureServiceController mCarExperimentalFeatureServiceController; |
keunyoung | a74b9ca | 2015-10-21 13:33:58 -0700 | [diff] [blame] | 130 | |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 131 | private final CarServiceBase[] mAllServices; |
| 132 | |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 133 | private static final String TAG = "ICarImpl"; |
| 134 | private static final String VHAL_TIMING_TAG = "VehicleHalTiming"; |
Serik Beketayev | 74debf2 | 2018-10-04 12:18:09 -0700 | [diff] [blame] | 135 | |
| 136 | private TimingsTraceLog mBootTiming; |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 137 | |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 138 | /** Test only service. Populate it only when necessary. */ |
| 139 | @GuardedBy("this") |
| 140 | private CarTestService mCarTestService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 141 | |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 142 | @GuardedBy("this") |
| 143 | private ICarServiceHelper mICarServiceHelper; |
| 144 | |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 145 | private final String mVehicleInterfaceName; |
| 146 | |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 147 | private final UserMetrics mUserMetrics = new UserMetrics(); |
| 148 | |
Pavel Maltsev | ec83b63 | 2017-01-05 15:10:55 -0800 | [diff] [blame] | 149 | public ICarImpl(Context serviceContext, IVehicle vehicle, SystemInterface systemInterface, |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 150 | CanBusErrorNotifier errorNotifier, String vehicleInterfaceName) { |
Felipe Leme | 6ef8965 | 2019-12-19 16:47:14 -0800 | [diff] [blame] | 151 | this(serviceContext, vehicle, systemInterface, errorNotifier, vehicleInterfaceName, |
| 152 | /* carUserService= */ null); |
| 153 | } |
| 154 | |
| 155 | @VisibleForTesting |
| 156 | ICarImpl(Context serviceContext, IVehicle vehicle, SystemInterface systemInterface, |
| 157 | CanBusErrorNotifier errorNotifier, String vehicleInterfaceName, |
| 158 | @Nullable CarUserService carUserService) { |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 159 | mContext = serviceContext; |
Steve Paik | 0f9fc00 | 2018-02-09 17:42:00 -0800 | [diff] [blame] | 160 | mSystemInterface = systemInterface; |
Mark Tabry | b588d2e | 2019-09-12 10:50:11 -0700 | [diff] [blame] | 161 | mHal = new VehicleHal(serviceContext, vehicle); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 162 | Resources res = mContext.getResources(); |
| 163 | String[] defaultEnabledFeatures = res.getStringArray( |
| 164 | R.array.config_allowed_optional_car_features); |
| 165 | // Do this before any other service components to allow feature check. It should work |
| 166 | // even without init. |
| 167 | // TODO (b/144504820) Add vhal plumbing |
| 168 | mFeatureController = new CarFeatureController(serviceContext, defaultEnabledFeatures, |
| 169 | /* disabledFeaturesFromVhal= */ new String[0], mSystemInterface.getSystemCarDir()); |
| 170 | CarLocalServices.addService(CarFeatureController.class, mFeatureController); |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 171 | mVehicleInterfaceName = vehicleInterfaceName; |
Yao, Yuxing | 0811d5a | 2018-11-29 16:18:53 -0800 | [diff] [blame] | 172 | mUserManagerHelper = new CarUserManagerHelper(serviceContext); |
Felipe Leme | 6ef8965 | 2019-12-19 16:47:14 -0800 | [diff] [blame] | 173 | if (carUserService != null) { |
| 174 | mCarUserService = carUserService; |
| 175 | } else { |
| 176 | UserManager userManager = |
| 177 | (UserManager) serviceContext.getSystemService(Context.USER_SERVICE); |
| 178 | int maxRunningUsers = res.getInteger( |
| 179 | com.android.internal.R.integer.config_multiuserMaxRunningUsers); |
Felipe Leme | 5841220 | 2020-01-09 13:45:33 -0800 | [diff] [blame] | 180 | mCarUserService = new CarUserService(serviceContext, mHal.getUserHal(), |
| 181 | mUserManagerHelper, userManager, ActivityManager.getService(), maxRunningUsers); |
Felipe Leme | 6ef8965 | 2019-12-19 16:47:14 -0800 | [diff] [blame] | 182 | } |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 183 | mCarOccupantZoneService = new CarOccupantZoneService(serviceContext); |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 184 | mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext); |
Steve Paik | 388d777 | 2018-02-12 10:54:51 -0800 | [diff] [blame] | 185 | mCarPowerManagementService = new CarPowerManagementService(mContext, mHal.getPowerHal(), |
Keun young Park | 9b3f266 | 2019-03-19 10:30:25 -0700 | [diff] [blame] | 186 | systemInterface, mUserManagerHelper); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 187 | if (mFeatureController.isFeatureEnabled(CarFeatures.FEATURE_CAR_USER_NOTICE_SERVICE)) { |
| 188 | mCarUserNoticeService = new CarUserNoticeService(serviceContext); |
| 189 | } else { |
| 190 | mCarUserNoticeService = null; |
| 191 | } |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 192 | mCarPropertyService = new CarPropertyService(serviceContext, mHal.getPropertyHal()); |
| 193 | mCarDrivingStateService = new CarDrivingStateService(serviceContext, mCarPropertyService); |
Ram Periathiruvadi | 4526a43 | 2018-01-24 13:00:54 -0800 | [diff] [blame] | 194 | mCarUXRestrictionsService = new CarUxRestrictionsManagerService(serviceContext, |
Yao, Yuxing | 9bfb749 | 2019-02-15 11:53:34 -0800 | [diff] [blame] | 195 | mCarDrivingStateService, mCarPropertyService); |
Michael Keller | c0f0bdb | 2019-12-11 14:58:19 -0800 | [diff] [blame] | 196 | if (mFeatureController.isFeatureEnabled(Car.OCCUPANT_AWARENESS_SERVICE)) { |
| 197 | mOccupantAwarenessService = new OccupantAwarenessService(serviceContext); |
| 198 | } else { |
| 199 | mOccupantAwarenessService = null; |
| 200 | } |
Ram Periathiruvadi | 2da6d0e | 2018-01-26 18:02:10 -0800 | [diff] [blame] | 201 | mCarPackageManagerService = new CarPackageManagerService(serviceContext, |
| 202 | mCarUXRestrictionsService, |
Mayank Garg | 31e7304 | 2020-01-23 00:10:38 -0800 | [diff] [blame] | 203 | mSystemActivityMonitoringService, |
| 204 | mCarUserService); |
| 205 | mPerUserCarServiceHelper = new PerUserCarServiceHelper(serviceContext, mCarUserService); |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 206 | mCarBluetoothService = new CarBluetoothService(serviceContext, mPerUserCarServiceHelper); |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 207 | mCarInputService = new CarInputService(serviceContext, mHal.getInputHal()); |
Justin Paupore | 44985ba | 2019-01-30 18:53:41 -0800 | [diff] [blame] | 208 | mCarProjectionService = new CarProjectionService( |
Pavel Maltsev | 079873b | 2019-02-25 12:15:09 -0800 | [diff] [blame] | 209 | serviceContext, null /* handler */, mCarInputService, mCarBluetoothService); |
Serik Beketayev | c6ab8be | 2018-08-28 21:20:53 -0700 | [diff] [blame] | 210 | mGarageModeService = new GarageModeService(mContext); |
Vitalii Tomkiv | 8c7f297 | 2016-07-11 15:42:04 -0700 | [diff] [blame] | 211 | mAppFocusService = new AppFocusService(serviceContext, mSystemActivityMonitoringService); |
Hongwei Wang | 3055723 | 2018-01-02 10:25:08 -0800 | [diff] [blame] | 212 | mCarAudioService = new CarAudioService(serviceContext); |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 213 | mCarNightService = new CarNightService(serviceContext, mCarPropertyService); |
Keun young Park | a4d1220 | 2019-10-03 10:51:12 -0700 | [diff] [blame] | 214 | mFixedActivityService = new FixedActivityService(serviceContext); |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 215 | mInstrumentClusterService = new InstrumentClusterService(serviceContext, |
Pavel Maltsev | 03cf60c | 2016-06-27 15:11:51 -0700 | [diff] [blame] | 216 | mAppFocusService, mCarInputService); |
Serik Beketayev | f9f2ef0 | 2018-09-06 12:37:02 -0700 | [diff] [blame] | 217 | mSystemStateControllerService = new SystemStateControllerService( |
| 218 | serviceContext, mCarAudioService, this); |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 219 | mCarStatsService = new CarStatsService(serviceContext); |
Ruchir Rastogi | a683d74 | 2020-01-22 00:17:51 -0800 | [diff] [blame] | 220 | mCarStatsService.init(); |
Mark Tabry | 62e749c | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 221 | if (mFeatureController.isFeatureEnabled(Car.VEHICLE_MAP_SERVICE) |
| 222 | || mFeatureController.isFeatureEnabled(Car.VMS_SUBSCRIBER_SERVICE)) { |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 223 | mVmsBrokerService = new VmsNewBrokerService(mContext, mCarStatsService); |
Keun young Park | c6d80af | 2020-01-17 18:14:28 -0800 | [diff] [blame] | 224 | } else { |
| 225 | mVmsBrokerService = null; |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 226 | } |
Keun young Park | c6d80af | 2020-01-17 18:14:28 -0800 | [diff] [blame] | 227 | if (mFeatureController.isFeatureEnabled(Car.DIAGNOSTIC_SERVICE)) { |
| 228 | mCarDiagnosticService = new CarDiagnosticService(serviceContext, |
| 229 | mHal.getDiagnosticHal()); |
| 230 | } else { |
| 231 | mCarDiagnosticService = null; |
| 232 | } |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 233 | if (mFeatureController.isFeatureEnabled(Car.STORAGE_MONITORING_SERVICE)) { |
| 234 | mCarStorageMonitoringService = new CarStorageMonitoringService(serviceContext, |
| 235 | systemInterface); |
| 236 | } else { |
| 237 | mCarStorageMonitoringService = null; |
| 238 | } |
Anthony Chen | 12aec30 | 2018-04-25 16:41:48 -0700 | [diff] [blame] | 239 | mCarConfigurationService = |
| 240 | new CarConfigurationService(serviceContext, new JsonReaderImpl()); |
Anthony Hugh | 5f2465e | 2019-10-08 15:07:01 -0700 | [diff] [blame] | 241 | mCarLocationService = new CarLocationService(serviceContext); |
Ram Periathiruvadi | de0ca08 | 2019-03-20 11:16:44 -0700 | [diff] [blame] | 242 | mCarTrustedDeviceService = new CarTrustedDeviceService(serviceContext); |
Mayank Garg | 31e7304 | 2020-01-23 00:10:38 -0800 | [diff] [blame] | 243 | mCarMediaService = new CarMediaService(serviceContext, mCarUserService); |
Selim Gurun | c8c82f6 | 2019-04-17 14:07:30 -0700 | [diff] [blame] | 244 | mCarBugreportManagerService = new CarBugreportManagerService(serviceContext); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 245 | if (!Build.IS_USER) { |
| 246 | mCarExperimentalFeatureServiceController = new CarExperimentalFeatureServiceController( |
| 247 | serviceContext); |
| 248 | } else { |
| 249 | mCarExperimentalFeatureServiceController = null; |
| 250 | } |
keunyoung | a74b9ca | 2015-10-21 13:33:58 -0700 | [diff] [blame] | 251 | |
Keun young Park | a5fa478 | 2019-04-16 18:56:27 -0700 | [diff] [blame] | 252 | CarLocalServices.addService(CarPowerManagementService.class, mCarPowerManagementService); |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 253 | CarLocalServices.addService(CarPropertyService.class, mCarPropertyService); |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 254 | CarLocalServices.addService(CarUserService.class, mCarUserService); |
Gregory Clark | 18a0ef9 | 2019-05-23 20:00:49 -0700 | [diff] [blame] | 255 | CarLocalServices.addService(CarTrustedDeviceService.class, mCarTrustedDeviceService); |
Gregory Clark | a440e81 | 2019-02-14 16:05:51 -0800 | [diff] [blame] | 256 | CarLocalServices.addService(SystemInterface.class, mSystemInterface); |
Gregory Clark | 18a0ef9 | 2019-05-23 20:00:49 -0700 | [diff] [blame] | 257 | CarLocalServices.addService(CarDrivingStateService.class, mCarDrivingStateService); |
Gregory Clark | 55620c1 | 2019-06-03 17:42:58 -0700 | [diff] [blame] | 258 | CarLocalServices.addService(PerUserCarServiceHelper.class, mPerUserCarServiceHelper); |
Keun young Park | a4d1220 | 2019-10-03 10:51:12 -0700 | [diff] [blame] | 259 | CarLocalServices.addService(FixedActivityService.class, mFixedActivityService); |
Mark Tabry | 62e749c | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 260 | CarLocalServices.addService(VmsNewBrokerService.class, mVmsBrokerService); |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 261 | |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 262 | // Be careful with order. Service depending on other service should be inited later. |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 263 | List<CarServiceBase> allServices = new ArrayList<>(); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 264 | allServices.add(mFeatureController); |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 265 | allServices.add(mCarUserService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 266 | allServices.add(mSystemActivityMonitoringService); |
| 267 | allServices.add(mCarPowerManagementService); |
| 268 | allServices.add(mCarPropertyService); |
| 269 | allServices.add(mCarDrivingStateService); |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 270 | allServices.add(mCarOccupantZoneService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 271 | allServices.add(mCarUXRestrictionsService); |
Michael Keller | c0f0bdb | 2019-12-11 14:58:19 -0800 | [diff] [blame] | 272 | addServiceIfNonNull(allServices, mOccupantAwarenessService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 273 | allServices.add(mCarPackageManagerService); |
| 274 | allServices.add(mCarInputService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 275 | allServices.add(mGarageModeService); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 276 | addServiceIfNonNull(allServices, mCarUserNoticeService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 277 | allServices.add(mAppFocusService); |
| 278 | allServices.add(mCarAudioService); |
| 279 | allServices.add(mCarNightService); |
Keun young Park | a4d1220 | 2019-10-03 10:51:12 -0700 | [diff] [blame] | 280 | allServices.add(mFixedActivityService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 281 | allServices.add(mInstrumentClusterService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 282 | allServices.add(mSystemStateControllerService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 283 | allServices.add(mPerUserCarServiceHelper); |
Justin Paupore | 44985ba | 2019-01-30 18:53:41 -0800 | [diff] [blame] | 284 | allServices.add(mCarBluetoothService); |
| 285 | allServices.add(mCarProjectionService); |
Keun young Park | c6d80af | 2020-01-17 18:14:28 -0800 | [diff] [blame] | 286 | addServiceIfNonNull(allServices, mCarDiagnosticService); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 287 | addServiceIfNonNull(allServices, mCarStorageMonitoringService); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 288 | allServices.add(mCarConfigurationService); |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 289 | addServiceIfNonNull(allServices, mVmsBrokerService); |
Ram Periathiruvadi | de0ca08 | 2019-03-20 11:16:44 -0700 | [diff] [blame] | 290 | allServices.add(mCarTrustedDeviceService); |
Simon Dai | 527eb55 | 2019-02-12 13:06:15 -0800 | [diff] [blame] | 291 | allServices.add(mCarMediaService); |
Gregory Clark | a63ba02 | 2018-06-07 16:42:12 -0700 | [diff] [blame] | 292 | allServices.add(mCarLocationService); |
Selim Gurun | c8c82f6 | 2019-04-17 14:07:30 -0700 | [diff] [blame] | 293 | allServices.add(mCarBugreportManagerService); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 294 | // Always put mCarExperimentalFeatureServiceController in last. |
| 295 | addServiceIfNonNull(allServices, mCarExperimentalFeatureServiceController); |
Ying Zheng | 86d1c3e | 2018-05-11 11:42:48 -0700 | [diff] [blame] | 296 | mAllServices = allServices.toArray(new CarServiceBase[allServices.size()]); |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 299 | private void addServiceIfNonNull(List<CarServiceBase> services, CarServiceBase service) { |
| 300 | if (service != null) { |
| 301 | services.add(service); |
| 302 | } |
| 303 | } |
| 304 | |
Pavel Maltsev | abd4723 | 2017-10-10 16:54:57 -0700 | [diff] [blame] | 305 | @MainThread |
Pavel Maltsev | 8edd255 | 2017-09-18 14:52:16 -0700 | [diff] [blame] | 306 | void init() { |
Serik Beketayev | 74debf2 | 2018-10-04 12:18:09 -0700 | [diff] [blame] | 307 | mBootTiming = new TimingsTraceLog(VHAL_TIMING_TAG, Trace.TRACE_TAG_HAL); |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 308 | traceBegin("VehicleHal.init"); |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 309 | mHal.init(); |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 310 | traceEnd(); |
| 311 | traceBegin("CarService.initAllServices"); |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 312 | for (CarServiceBase service : mAllServices) { |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 313 | service.init(); |
| 314 | } |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 315 | traceEnd(); |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 316 | } |
| 317 | |
Pavel Maltsev | 8edd255 | 2017-09-18 14:52:16 -0700 | [diff] [blame] | 318 | void release() { |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 319 | // release done in opposite order from init |
| 320 | for (int i = mAllServices.length - 1; i >= 0; i--) { |
| 321 | mAllServices[i].release(); |
| 322 | } |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 323 | mHal.release(); |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Pavel Maltsev | 8edd255 | 2017-09-18 14:52:16 -0700 | [diff] [blame] | 326 | void vehicleHalReconnected(IVehicle vehicle) { |
Pavel Maltsev | ec83b63 | 2017-01-05 15:10:55 -0800 | [diff] [blame] | 327 | mHal.vehicleHalReconnected(vehicle); |
| 328 | for (CarServiceBase service : mAllServices) { |
| 329 | service.vehicleHalReconnected(); |
| 330 | } |
| 331 | } |
| 332 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 333 | @Override |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 334 | public void setCarServiceHelper(IBinder helper) { |
Pavel Maltsev | 17e8183 | 2019-04-04 14:38:41 -0700 | [diff] [blame] | 335 | assertCallingFromSystemProcess(); |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 336 | synchronized (this) { |
| 337 | mICarServiceHelper = ICarServiceHelper.Stub.asInterface(helper); |
Steve Paik | 0f9fc00 | 2018-02-09 17:42:00 -0800 | [diff] [blame] | 338 | mSystemInterface.setCarServiceHelper(mICarServiceHelper); |
Keun-young Park | aab47cd | 2017-06-05 11:04:50 -0700 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
| 342 | @Override |
Eric Jeong | 1545f3b | 2019-09-16 13:56:52 -0700 | [diff] [blame] | 343 | public void setUserLockStatus(int userId, int unlocked) { |
Pavel Maltsev | 17e8183 | 2019-04-04 14:38:41 -0700 | [diff] [blame] | 344 | assertCallingFromSystemProcess(); |
Eric Jeong | 1545f3b | 2019-09-16 13:56:52 -0700 | [diff] [blame] | 345 | mCarUserService.setUserLockStatus(userId, unlocked == 1); |
| 346 | mCarMediaService.setUserLockStatus(userId, unlocked == 1); |
Pavel Maltsev | 17e8183 | 2019-04-04 14:38:41 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | @Override |
Eric Jeong | 1545f3b | 2019-09-16 13:56:52 -0700 | [diff] [blame] | 350 | public void onSwitchUser(int userId) { |
Pavel Maltsev | 17e8183 | 2019-04-04 14:38:41 -0700 | [diff] [blame] | 351 | assertCallingFromSystemProcess(); |
| 352 | |
Eric Jeong | 1545f3b | 2019-09-16 13:56:52 -0700 | [diff] [blame] | 353 | Log.i(TAG, "Foreground user switched to " + userId); |
| 354 | mCarUserService.onSwitchUser(userId); |
Pavel Maltsev | 17e8183 | 2019-04-04 14:38:41 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 357 | // TODO(b/146207078): this method is currently used just for metrics logging purposes, but we |
| 358 | // should fold the other too (onSwitchUser() and setUserLockStatus()) onto it. |
| 359 | @Override |
| 360 | public void onUserLifecycleEvent(int eventType, long timestampMs, int fromUserId, |
| 361 | int toUserId) { |
| 362 | assertCallingFromSystemProcess(); |
| 363 | Log.i(TAG, "onUserLifecycleEvent(" + CarUserManager.lifecycleEventTypeToString(eventType) |
| 364 | + ", " + toUserId); |
| 365 | mUserMetrics.onEvent(eventType, timestampMs, fromUserId, toUserId); |
| 366 | } |
| 367 | |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 368 | @Override |
Felipe Leme | 30b4e1e | 2020-02-25 10:26:07 -0800 | [diff] [blame^] | 369 | public void onFirstUserUnlocked(int userId, long timestampMs, long duration) { |
| 370 | mUserMetrics.logFirstUnlockedUser(userId, timestampMs, duration); |
| 371 | } |
| 372 | |
| 373 | @Override |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 374 | public boolean isFeatureEnabled(String featureName) { |
| 375 | return mFeatureController.isFeatureEnabled(featureName); |
| 376 | } |
| 377 | |
| 378 | @Override |
| 379 | public int enableFeature(String featureName) { |
| 380 | // permission check inside the controller |
| 381 | return mFeatureController.enableFeature(featureName); |
| 382 | } |
| 383 | |
| 384 | @Override |
| 385 | public int disableFeature(String featureName) { |
| 386 | // permission check inside the controller |
| 387 | return mFeatureController.disableFeature(featureName); |
| 388 | } |
| 389 | |
| 390 | @Override |
| 391 | public List<String> getAllEnabledFeatures() { |
| 392 | // permission check inside the controller |
| 393 | return mFeatureController.getAllEnabledFeatures(); |
| 394 | } |
| 395 | |
| 396 | @Override |
| 397 | public List<String> getAllPendingDisabledFeatures() { |
| 398 | // permission check inside the controller |
| 399 | return mFeatureController.getAllPendingDisabledFeatures(); |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public List<String> getAllPendingEnabledFeatures() { |
| 404 | // permission check inside the controller |
| 405 | return mFeatureController.getAllPendingEnabledFeatures(); |
| 406 | } |
| 407 | |
| 408 | @Override |
| 409 | public String getCarManagerClassForFeature(String featureName) { |
| 410 | if (mCarExperimentalFeatureServiceController == null) { |
| 411 | return null; |
| 412 | } |
| 413 | return mCarExperimentalFeatureServiceController.getCarManagerClassForFeature(featureName); |
| 414 | } |
| 415 | |
Jim Kaye | e513316 | 2019-04-22 12:50:27 -0700 | [diff] [blame] | 416 | static void assertCallingFromSystemProcess() { |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 417 | int uid = Binder.getCallingUid(); |
| 418 | if (uid != Process.SYSTEM_UID) { |
| 419 | throw new SecurityException("Only allowed from system"); |
| 420 | } |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Keun young Park | aabecd9 | 2019-05-03 17:31:27 -0700 | [diff] [blame] | 423 | /** |
| 424 | * Assert if binder call is coming from system process like system server or if it is called |
| 425 | * from its own process even if it is not system. The latter can happen in test environment. |
| 426 | * Note that car service runs as system user but test like car service test will not. |
| 427 | */ |
| 428 | static void assertCallingFromSystemProcessOrSelf() { |
| 429 | int uid = Binder.getCallingUid(); |
| 430 | int pid = Binder.getCallingPid(); |
| 431 | if (uid != Process.SYSTEM_UID && pid != Process.myPid()) { |
| 432 | throw new SecurityException("Only allowed from system or self"); |
| 433 | } |
| 434 | } |
| 435 | |
Keun-young Park | d462a91 | 2019-02-11 08:53:42 -0800 | [diff] [blame] | 436 | @Override |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 437 | public IBinder getCarService(String serviceName) { |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 438 | if (!mFeatureController.isFeatureEnabled(serviceName)) { |
| 439 | Log.w(CarLog.TAG_SERVICE, "getCarService for disabled service:" + serviceName); |
| 440 | return null; |
| 441 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 442 | switch (serviceName) { |
Keun-young Park | 5672e85 | 2016-02-09 19:53:48 -0800 | [diff] [blame] | 443 | case Car.AUDIO_SERVICE: |
| 444 | return mCarAudioService; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 445 | case Car.APP_FOCUS_SERVICE: |
| 446 | return mAppFocusService; |
Keun-young Park | 45fdcba | 2015-12-08 11:38:58 -0800 | [diff] [blame] | 447 | case Car.PACKAGE_SERVICE: |
| 448 | return mCarPackageManagerService; |
Enrico Granata | 5c56d2a | 2017-02-07 15:38:12 -0800 | [diff] [blame] | 449 | case Car.DIAGNOSTIC_SERVICE: |
Enrico Granata | b3634e2 | 2017-05-05 18:02:31 -0700 | [diff] [blame] | 450 | assertAnyDiagnosticPermission(mContext); |
| 451 | return mCarDiagnosticService; |
Steve Paik | 388d777 | 2018-02-12 10:54:51 -0800 | [diff] [blame] | 452 | case Car.POWER_SERVICE: |
| 453 | assertPowerPermission(mContext); |
| 454 | return mCarPowerManagementService; |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 455 | case Car.CABIN_SERVICE: |
| 456 | case Car.HVAC_SERVICE: |
| 457 | case Car.INFO_SERVICE: |
| 458 | case Car.PROPERTY_SERVICE: |
| 459 | case Car.SENSOR_SERVICE: |
| 460 | case Car.VENDOR_EXTENSION_SERVICE: |
| 461 | return mCarPropertyService; |
Pavel Maltsev | 7a948e5 | 2016-02-02 23:30:14 -0800 | [diff] [blame] | 462 | case Car.CAR_NAVIGATION_SERVICE: |
Keun-young Park | e31a8b2 | 2016-03-16 17:34:08 -0700 | [diff] [blame] | 463 | assertNavigationManagerPermission(mContext); |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 464 | IInstrumentClusterNavigation navService = |
| 465 | mInstrumentClusterService.getNavigationService(); |
| 466 | return navService == null ? null : navService.asBinder(); |
Pavel Maltsev | 905968c | 2017-07-16 19:48:57 -0700 | [diff] [blame] | 467 | case Car.CAR_INSTRUMENT_CLUSTER_SERVICE: |
| 468 | assertClusterManagerPermission(mContext); |
| 469 | return mInstrumentClusterService.getManagerService(); |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 470 | case Car.PROJECTION_SERVICE: |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 471 | return mCarProjectionService; |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 472 | case Car.VEHICLE_MAP_SERVICE: |
| 473 | assertAnyVmsPermission(mContext); |
| 474 | return mVmsBrokerService; |
Antonio Cortes | e4619c7 | 2017-02-02 07:53:27 -0800 | [diff] [blame] | 475 | case Car.VMS_SUBSCRIBER_SERVICE: |
Asaf Rosenfeld | 39e4f03 | 2017-09-16 11:33:50 -0700 | [diff] [blame] | 476 | assertVmsSubscriberPermission(mContext); |
Mark Tabry | 62e749c | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 477 | return mVmsBrokerService; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 478 | case Car.TEST_SERVICE: { |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 479 | assertPermission(mContext, Car.PERMISSION_CAR_TEST_SERVICE); |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 480 | synchronized (this) { |
| 481 | if (mCarTestService == null) { |
| 482 | mCarTestService = new CarTestService(mContext, this); |
| 483 | } |
| 484 | return mCarTestService; |
| 485 | } |
| 486 | } |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 487 | case Car.BLUETOOTH_SERVICE: |
| 488 | return mCarBluetoothService; |
Enrico Granata | 9a916d7 | 2017-09-19 14:33:08 -0700 | [diff] [blame] | 489 | case Car.STORAGE_MONITORING_SERVICE: |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame] | 490 | assertPermission(mContext, Car.PERMISSION_STORAGE_MONITORING); |
Enrico Granata | 9a916d7 | 2017-09-19 14:33:08 -0700 | [diff] [blame] | 491 | return mCarStorageMonitoringService; |
Ram Periathiruvadi | 25c16f1 | 2017-11-17 16:48:37 -0800 | [diff] [blame] | 492 | case Car.CAR_DRIVING_STATE_SERVICE: |
| 493 | assertDrivingStatePermission(mContext); |
| 494 | return mCarDrivingStateService; |
| 495 | case Car.CAR_UX_RESTRICTION_SERVICE: |
| 496 | return mCarUXRestrictionsService; |
Michael Keller | ac2ed20 | 2020-01-30 14:11:16 -0800 | [diff] [blame] | 497 | case Car.OCCUPANT_AWARENESS_SERVICE: |
| 498 | return mOccupantAwarenessService; |
Anthony Chen | d4203d8 | 2018-05-16 16:21:52 -0700 | [diff] [blame] | 499 | case Car.CAR_CONFIGURATION_SERVICE: |
| 500 | return mCarConfigurationService; |
Ram Periathiruvadi | 194ce1b | 2019-01-14 09:42:12 -0800 | [diff] [blame] | 501 | case Car.CAR_TRUST_AGENT_ENROLLMENT_SERVICE: |
| 502 | assertTrustAgentEnrollmentPermission(mContext); |
Ram Periathiruvadi | de0ca08 | 2019-03-20 11:16:44 -0700 | [diff] [blame] | 503 | return mCarTrustedDeviceService.getCarTrustAgentEnrollmentService(); |
Simon Dai | 527eb55 | 2019-02-12 13:06:15 -0800 | [diff] [blame] | 504 | case Car.CAR_MEDIA_SERVICE: |
| 505 | return mCarMediaService; |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 506 | case Car.CAR_OCCUPANT_ZONE_SERVICE: |
| 507 | return mCarOccupantZoneService; |
Selim Gurun | c8c82f6 | 2019-04-17 14:07:30 -0700 | [diff] [blame] | 508 | case Car.CAR_BUGREPORT_SERVICE: |
| 509 | return mCarBugreportManagerService; |
Eric Jeong | 1545f3b | 2019-09-16 13:56:52 -0700 | [diff] [blame] | 510 | case Car.CAR_USER_SERVICE: |
| 511 | return mCarUserService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 512 | default: |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 513 | IBinder service = null; |
| 514 | if (mCarExperimentalFeatureServiceController != null) { |
| 515 | service = mCarExperimentalFeatureServiceController.getCarService(serviceName); |
| 516 | } |
| 517 | if (service == null) { |
| 518 | Log.w(CarLog.TAG_SERVICE, "getCarService for unknown service:" |
| 519 | + serviceName); |
| 520 | } |
| 521 | return service; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 525 | @Override |
| 526 | public int getCarConnectionType() { |
Pavel Maltsev | 0d07c76 | 2016-11-03 16:40:15 -0700 | [diff] [blame] | 527 | return Car.CONNECTION_TYPE_EMBEDDED; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 528 | } |
| 529 | |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 530 | public CarServiceBase getCarInternalService(String serviceName) { |
| 531 | switch (serviceName) { |
| 532 | case INTERNAL_INPUT_SERVICE: |
| 533 | return mCarInputService; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 534 | case INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE: |
| 535 | return mSystemActivityMonitoringService; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 536 | default: |
| 537 | Log.w(CarLog.TAG_SERVICE, "getCarInternalService for unknown service:" + |
| 538 | serviceName); |
| 539 | return null; |
| 540 | } |
| 541 | } |
| 542 | |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 543 | public static void assertVehicleHalMockPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 544 | assertPermission(context, Car.PERMISSION_MOCK_VEHICLE_HAL); |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Keun-young Park | e31a8b2 | 2016-03-16 17:34:08 -0700 | [diff] [blame] | 547 | public static void assertNavigationManagerPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 548 | assertPermission(context, Car.PERMISSION_CAR_NAVIGATION_MANAGER); |
Pavel Maltsev | ce4ffd9 | 2016-03-09 10:56:23 -0800 | [diff] [blame] | 549 | } |
| 550 | |
Pavel Maltsev | 905968c | 2017-07-16 19:48:57 -0700 | [diff] [blame] | 551 | public static void assertClusterManagerPermission(Context context) { |
| 552 | assertPermission(context, Car.PERMISSION_CAR_INSTRUMENT_CLUSTER_CONTROL); |
| 553 | } |
| 554 | |
Steve Paik | 388d777 | 2018-02-12 10:54:51 -0800 | [diff] [blame] | 555 | public static void assertPowerPermission(Context context) { |
| 556 | assertPermission(context, Car.PERMISSION_CAR_POWER); |
| 557 | } |
| 558 | |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 559 | public static void assertProjectionPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 560 | assertPermission(context, Car.PERMISSION_CAR_PROJECTION); |
| 561 | } |
| 562 | |
Pavel Maltsev | 079873b | 2019-02-25 12:15:09 -0800 | [diff] [blame] | 563 | /** Verify the calling context has the {@link Car#PERMISSION_CAR_PROJECTION_STATUS} */ |
| 564 | public static void assertProjectionStatusPermission(Context context) { |
| 565 | assertPermission(context, Car.PERMISSION_CAR_PROJECTION_STATUS); |
| 566 | } |
| 567 | |
Enrico Granata | 3c7a666 | 2017-02-23 18:07:59 -0800 | [diff] [blame] | 568 | public static void assertAnyDiagnosticPermission(Context context) { |
| 569 | assertAnyPermission(context, |
Enrico Granata | ae25b92 | 2017-07-07 11:28:15 -0700 | [diff] [blame] | 570 | Car.PERMISSION_CAR_DIAGNOSTIC_READ_ALL, |
Enrico Granata | 3c7a666 | 2017-02-23 18:07:59 -0800 | [diff] [blame] | 571 | Car.PERMISSION_CAR_DIAGNOSTIC_CLEAR); |
| 572 | } |
| 573 | |
Ram Periathiruvadi | 25c16f1 | 2017-11-17 16:48:37 -0800 | [diff] [blame] | 574 | public static void assertDrivingStatePermission(Context context) { |
| 575 | assertPermission(context, Car.PERMISSION_CAR_DRIVING_STATE); |
| 576 | } |
| 577 | |
Mark Tabry | 6fa123d | 2020-01-10 19:52:59 -0800 | [diff] [blame] | 578 | /** |
| 579 | * Verify the calling context has either {@link Car#PERMISSION_VMS_SUBSCRIBER} or |
| 580 | * {@link Car#PERMISSION_VMS_PUBLISHER} |
| 581 | */ |
| 582 | public static void assertAnyVmsPermission(Context context) { |
| 583 | assertAnyPermission(context, |
| 584 | Car.PERMISSION_VMS_SUBSCRIBER, |
| 585 | Car.PERMISSION_VMS_PUBLISHER); |
| 586 | } |
| 587 | |
Antonio Cortes | 6b3544c | 2017-02-06 16:54:58 -0800 | [diff] [blame] | 588 | public static void assertVmsPublisherPermission(Context context) { |
| 589 | assertPermission(context, Car.PERMISSION_VMS_PUBLISHER); |
| 590 | } |
| 591 | |
Antonio Cortes | e4619c7 | 2017-02-02 07:53:27 -0800 | [diff] [blame] | 592 | public static void assertVmsSubscriberPermission(Context context) { |
| 593 | assertPermission(context, Car.PERMISSION_VMS_SUBSCRIBER); |
| 594 | } |
| 595 | |
Ram Periathiruvadi | 194ce1b | 2019-01-14 09:42:12 -0800 | [diff] [blame] | 596 | /** |
| 597 | * Ensures the caller has the permission to enroll a Trust Agent. |
Ram Periathiruvadi | 194ce1b | 2019-01-14 09:42:12 -0800 | [diff] [blame] | 598 | */ |
| 599 | public static void assertTrustAgentEnrollmentPermission(Context context) { |
| 600 | assertPermission(context, Car.PERMISSION_CAR_ENROLL_TRUST); |
| 601 | } |
| 602 | |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 603 | public static void assertPermission(Context context, String permission) { |
| 604 | if (context.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { |
| 605 | throw new SecurityException("requires " + permission); |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 606 | } |
| 607 | } |
| 608 | |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 609 | /** |
| 610 | * Checks to see if the caller has a permission. |
Steve Paik | 9ec53d7 | 2018-04-27 13:28:31 -0700 | [diff] [blame] | 611 | * |
| 612 | * @return boolean TRUE if caller has the permission. |
| 613 | */ |
| 614 | public static boolean hasPermission(Context context, String permission) { |
| 615 | return context.checkCallingOrSelfPermission(permission) |
| 616 | == PackageManager.PERMISSION_GRANTED; |
| 617 | } |
| 618 | |
Enrico Granata | 3c7a666 | 2017-02-23 18:07:59 -0800 | [diff] [blame] | 619 | public static void assertAnyPermission(Context context, String... permissions) { |
| 620 | for (String permission : permissions) { |
| 621 | if (context.checkCallingOrSelfPermission(permission) == |
| 622 | PackageManager.PERMISSION_GRANTED) { |
| 623 | return; |
| 624 | } |
| 625 | } |
| 626 | throw new SecurityException("requires any of " + Arrays.toString(permissions)); |
| 627 | } |
| 628 | |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 629 | @Override |
| 630 | protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |
| 631 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
Anthony Chen | 12aec30 | 2018-04-25 16:41:48 -0700 | [diff] [blame] | 632 | != PackageManager.PERMISSION_GRANTED) { |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 633 | writer.println("Permission Denial: can't dump CarService from from pid=" |
Anthony Chen | 12aec30 | 2018-04-25 16:41:48 -0700 | [diff] [blame] | 634 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() |
| 635 | + " without permission " + android.Manifest.permission.DUMP); |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 636 | return; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 637 | } |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 638 | |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 639 | if (args == null || args.length == 0 || (args.length > 0 && "-a".equals(args[0]))) { |
| 640 | writer.println("*Dump car service*"); |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 641 | dumpAllServices(writer); |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 642 | dumpAllHals(writer); |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 643 | mUserMetrics.dump(writer); |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 644 | } else if ("--list".equals(args[0])) { |
| 645 | dumpListOfServices(writer); |
| 646 | return; |
| 647 | } else if ("--services".equals(args[0])) { |
| 648 | if (args.length < 2) { |
| 649 | writer.print("Must pass services to dump when using --services"); |
| 650 | return; |
| 651 | } |
| 652 | int length = args.length - 1; |
| 653 | String[] services = new String[length]; |
| 654 | System.arraycopy(args, 1, services, 0, length); |
| 655 | dumpIndividualServices(writer, services); |
| 656 | return; |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 657 | } else if ("--metrics".equals(args[0])) { |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 658 | // Strip the --metrics flag when passing dumpsys arguments to CarStatsService |
Mark Tabry | c98f995 | 2019-12-03 11:03:48 -0800 | [diff] [blame] | 659 | // allowing for nested flag selection |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 660 | mCarStatsService.dump(fd, writer, Arrays.copyOfRange(args, 1, args.length)); |
Mark Tabry | b588d2e | 2019-09-12 10:50:11 -0700 | [diff] [blame] | 661 | } else if ("--vms-hal".equals(args[0])) { |
| 662 | mHal.getVmsHal().dumpMetrics(fd); |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 663 | } else if ("--hal".equals(args[0])) { |
| 664 | if (args.length == 1) { |
| 665 | dumpAllHals(writer); |
| 666 | return; |
| 667 | } |
| 668 | int length = args.length - 1; |
| 669 | String[] halNames = new String[length]; |
| 670 | System.arraycopy(args, 1, halNames, 0, length); |
| 671 | mHal.dumpSpecificHals(writer, halNames); |
| 672 | |
| 673 | } else if ("--list-hals".equals(args[0])) { |
| 674 | mHal.dumpListHals(writer); |
| 675 | return; |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 676 | } else if ("--user-metrics".equals(args[0])) { |
| 677 | mUserMetrics.dump(writer); |
Felipe Leme | 30b4e1e | 2020-02-25 10:26:07 -0800 | [diff] [blame^] | 678 | } else if ("--first-user-metrics".equals(args[0])) { |
| 679 | mUserMetrics.dumpFirstUserUnlockDuration(writer); |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 680 | } else if ("--help".equals(args[0])) { |
| 681 | showDumpHelp(writer); |
Enrico Granata | e8056ca | 2018-04-03 13:19:52 -0700 | [diff] [blame] | 682 | } else if (Build.IS_USERDEBUG || Build.IS_ENG) { |
| 683 | execShellCmd(args, writer); |
| 684 | } else { |
| 685 | writer.println("Commands not supported in " + Build.TYPE); |
Brad Stenning | ed3d59b | 2017-11-09 16:15:17 -0800 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 689 | private void dumpAllHals(PrintWriter writer) { |
| 690 | writer.println("*Dump Vehicle HAL*"); |
| 691 | writer.println("Vehicle HAL Interface: " + mVehicleInterfaceName); |
| 692 | try { |
| 693 | // TODO dump all feature flags by creating a dumpable interface |
| 694 | mHal.dump(writer); |
| 695 | } catch (Exception e) { |
| 696 | writer.println("Failed dumping: " + mHal.getClass().getName()); |
| 697 | e.printStackTrace(writer); |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | private void showDumpHelp(PrintWriter writer) { |
| 702 | writer.println("Car service dump usage:"); |
| 703 | writer.println("[NO ARG]"); |
| 704 | writer.println("\t dumps everything (all services and HALs)"); |
| 705 | writer.println("--help"); |
| 706 | writer.println("\t shows this help"); |
| 707 | writer.println("--list"); |
| 708 | writer.println("\t lists the name of all services"); |
| 709 | writer.println("--list"); |
| 710 | writer.println("\t lists the name of all HAls"); |
| 711 | writer.println("--services <SVC1> [SVC2] [SVCN]"); |
| 712 | writer.println("\t dumps just the specific services, where SVC is just the service class"); |
| 713 | writer.println("\t name (like CarUserService)"); |
| 714 | writer.println("--vms-hal"); |
| 715 | writer.println("\t dumps the VMS HAL metrics"); |
| 716 | writer.println("--hal [HAL1] [HAL2] [HALN]"); |
| 717 | writer.println("\t dumps just the specified HALs (or all of them if none specified),"); |
| 718 | writer.println("\t where HAL is just the class name (like UserHalService)"); |
Felipe Leme | e93218b | 2020-02-13 14:10:52 -0800 | [diff] [blame] | 719 | writer.println("--user-metrics"); |
| 720 | writer.println("\t dumps user switching and stopping metrics "); |
Felipe Leme | 30b4e1e | 2020-02-25 10:26:07 -0800 | [diff] [blame^] | 721 | writer.println("--first-user-metrics"); |
| 722 | writer.println("\t dumps how long it took to unlock first user since Android started\n"); |
| 723 | writer.println("\t (or -1 if not unlocked)"); |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 724 | writer.println("-h"); |
| 725 | writer.println("\t shows commands usage (NOTE: commands are not available on USER builds"); |
| 726 | writer.println("[ANYTHING ELSE]"); |
| 727 | writer.println("\t runs the given command (use --h to see the available commands)"); |
| 728 | } |
| 729 | |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 730 | @Override |
| 731 | public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, |
| 732 | String[] args, ShellCallback callback, ResultReceiver resultReceiver) |
| 733 | throws RemoteException { |
| 734 | new CarShellCommand().exec(this, in, out, err, args, callback, resultReceiver); |
| 735 | } |
| 736 | |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 737 | private void dumpListOfServices(PrintWriter writer) { |
| 738 | for (CarServiceBase service : mAllServices) { |
| 739 | writer.println(service.getClass().getName()); |
| 740 | } |
| 741 | } |
| 742 | |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 743 | private void dumpAllServices(PrintWriter writer) { |
Felipe Leme | f07c3f9 | 2020-02-12 14:26:33 -0800 | [diff] [blame] | 744 | writer.println("*Dump all services*"); |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 745 | for (CarServiceBase service : mAllServices) { |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 746 | dumpService(service, writer); |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 747 | } |
| 748 | if (mCarTestService != null) { |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 749 | dumpService(mCarTestService, writer); |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 750 | } |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 751 | } |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 752 | |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 753 | private void dumpIndividualServices(PrintWriter writer, String... serviceNames) { |
| 754 | for (String serviceName : serviceNames) { |
| 755 | writer.println("** Dumping " + serviceName + "\n"); |
| 756 | CarServiceBase service = getCarServiceBySubstring(serviceName); |
| 757 | if (service == null) { |
| 758 | writer.println("No such service!"); |
| 759 | } else { |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 760 | dumpService(service, writer); |
felipeal | 080e565 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 761 | } |
| 762 | writer.println(); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | @Nullable |
| 767 | private CarServiceBase getCarServiceBySubstring(String className) { |
| 768 | return Arrays.asList(mAllServices).stream() |
| 769 | .filter(s -> s.getClass().getSimpleName().equals(className)) |
| 770 | .findFirst().orElse(null); |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 773 | private void dumpService(CarServiceBase service, PrintWriter writer) { |
Brad Stenning | ed3d59b | 2017-11-09 16:15:17 -0800 | [diff] [blame] | 774 | try { |
Mark Tabry | 7e2a782 | 2019-10-17 10:18:32 -0700 | [diff] [blame] | 775 | service.dump(writer); |
Brad Stenning | ed3d59b | 2017-11-09 16:15:17 -0800 | [diff] [blame] | 776 | } catch (Exception e) { |
| 777 | writer.println("Failed dumping: " + service.getClass().getName()); |
| 778 | e.printStackTrace(writer); |
| 779 | } |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 780 | } |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 781 | |
| 782 | void execShellCmd(String[] args, PrintWriter writer) { |
| 783 | new CarShellCommand().exec(args, writer); |
| 784 | } |
| 785 | |
Pavel Maltsev | abd4723 | 2017-10-10 16:54:57 -0700 | [diff] [blame] | 786 | @MainThread |
Serik Beketayev | 74debf2 | 2018-10-04 12:18:09 -0700 | [diff] [blame] | 787 | private void traceBegin(String name) { |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 788 | Slog.i(TAG, name); |
| 789 | mBootTiming.traceBegin(name); |
| 790 | } |
| 791 | |
Pavel Maltsev | abd4723 | 2017-10-10 16:54:57 -0700 | [diff] [blame] | 792 | @MainThread |
Serik Beketayev | 74debf2 | 2018-10-04 12:18:09 -0700 | [diff] [blame] | 793 | private void traceEnd() { |
Steve Paik | c302c7c | 2017-08-04 14:01:58 -0700 | [diff] [blame] | 794 | mBootTiming.traceEnd(); |
| 795 | } |
| 796 | |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 797 | private final class CarShellCommand extends ShellCommand { |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 798 | private static final String COMMAND_HELP = "-h"; |
| 799 | private static final String COMMAND_DAY_NIGHT_MODE = "day-night-mode"; |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 800 | private static final String COMMAND_INJECT_VHAL_EVENT = "inject-vhal-event"; |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 801 | private static final String COMMAND_INJECT_ERROR_EVENT = "inject-error-event"; |
Ram Periathiruvadi | bf0eab7 | 2018-02-06 12:32:43 -0800 | [diff] [blame] | 802 | private static final String COMMAND_ENABLE_UXR = "enable-uxr"; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 803 | private static final String COMMAND_GARAGE_MODE = "garage-mode"; |
Ram Periathiruvadi | 3838830 | 2018-02-22 16:42:49 -0800 | [diff] [blame] | 804 | private static final String COMMAND_GET_DO_ACTIVITIES = "get-do-activities"; |
Kai | dd4ef5a | 2019-03-04 14:07:26 -0800 | [diff] [blame] | 805 | private static final String COMMAND_GET_CARPROPERTYCONFIG = "get-carpropertyconfig"; |
Kai | 29fba11 | 2019-04-22 18:37:38 -0700 | [diff] [blame] | 806 | private static final String COMMAND_GET_PROPERTY_VALUE = "get-property-value"; |
Pavel Maltsev | 371d97f | 2019-05-20 14:51:31 -0700 | [diff] [blame] | 807 | private static final String COMMAND_PROJECTION_AP_TETHERING = "projection-tethering"; |
Pavel Maltsev | 48a3194 | 2019-03-03 22:08:28 -0800 | [diff] [blame] | 808 | private static final String COMMAND_PROJECTION_UI_MODE = "projection-ui-mode"; |
Jim Kaye | d76c274 | 2019-04-02 11:33:27 -0700 | [diff] [blame] | 809 | private static final String COMMAND_RESUME = "resume"; |
| 810 | private static final String COMMAND_SUSPEND = "suspend"; |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 811 | private static final String COMMAND_ENABLE_TRUSTED_DEVICE = "enable-trusted-device"; |
| 812 | private static final String COMMAND_REMOVE_TRUSTED_DEVICES = "remove-trusted-devices"; |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 813 | private static final String COMMAND_SET_UID_TO_ZONE = "set-zoneid-for-uid"; |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 814 | private static final String COMMAND_START_FIXED_ACTIVITY_MODE = "start-fixed-activity-mode"; |
| 815 | private static final String COMMAND_STOP_FIXED_ACTIVITY_MODE = "stop-fixed-activity-mode"; |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 816 | private static final String COMMAND_ENABLE_FEATURE = "enable-feature"; |
| 817 | private static final String COMMAND_DISABLE_FEATURE = "disable-feature"; |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 818 | private static final String COMMAND_INJECT_KEY = "inject-key"; |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 819 | private static final String COMMAND_GET_INITIAL_USER_INFO = "get-initial-user-info"; |
Felipe Leme | 5bf135b | 2020-02-07 12:22:14 -0800 | [diff] [blame] | 820 | |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 821 | private static final String PARAM_DAY_MODE = "day"; |
| 822 | private static final String PARAM_NIGHT_MODE = "night"; |
| 823 | private static final String PARAM_SENSOR_MODE = "sensor"; |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 824 | private static final String PARAM_VEHICLE_PROPERTY_AREA_GLOBAL = "0"; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 825 | private static final String PARAM_ON_MODE = "on"; |
| 826 | private static final String PARAM_OFF_MODE = "off"; |
| 827 | private static final String PARAM_QUERY_MODE = "query"; |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 828 | private static final String PARAM_REBOOT = "reboot"; |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 829 | |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 830 | private static final int RESULT_OK = 0; |
| 831 | private static final int RESULT_ERROR = -1; // Arbitrary value, any non-0 is fine |
| 832 | |
| 833 | |
| 834 | @Override |
| 835 | public int onCommand(String cmd) { |
| 836 | if (cmd == null) { |
| 837 | onHelp(); |
| 838 | return RESULT_ERROR; |
| 839 | } |
| 840 | ArrayList<String> argsList = new ArrayList<>(); |
| 841 | argsList.add(cmd); |
| 842 | String arg = null; |
| 843 | do { |
| 844 | arg = getNextArg(); |
| 845 | if (arg != null) { |
| 846 | argsList.add(arg); |
| 847 | } |
| 848 | } while (arg != null); |
| 849 | String[] args = new String[argsList.size()]; |
| 850 | argsList.toArray(args); |
| 851 | return exec(args, getOutPrintWriter()); |
| 852 | } |
| 853 | |
| 854 | @Override |
| 855 | public void onHelp() { |
| 856 | dumpHelp(getOutPrintWriter()); |
| 857 | } |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 858 | |
| 859 | private void dumpHelp(PrintWriter pw) { |
| 860 | pw.println("Car service commands:"); |
| 861 | pw.println("\t-h"); |
| 862 | pw.println("\t Print this help text."); |
| 863 | pw.println("\tday-night-mode [day|night|sensor]"); |
| 864 | pw.println("\t Force into day/night mode or restore to auto."); |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 865 | pw.println("\tinject-vhal-event property [zone] data(can be comma separated list)"); |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 866 | pw.println("\t Inject a vehicle property for testing."); |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 867 | pw.println("\tinject-error-event property zone errorCode"); |
| 868 | pw.println("\t Inject an error event from VHAL for testing."); |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 869 | pw.println("\tenable-uxr true|false"); |
| 870 | pw.println("\t Enable/Disable UX restrictions and App blocking."); |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 871 | pw.println("\tgarage-mode [on|off|query|reboot]"); |
| 872 | pw.println("\t Force into or out of garage mode, or check status."); |
| 873 | pw.println("\t With 'reboot', enter garage mode, then reboot when it completes."); |
Ram Periathiruvadi | 3838830 | 2018-02-22 16:42:49 -0800 | [diff] [blame] | 874 | pw.println("\tget-do-activities pkgname"); |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 875 | pw.println("\t Get Distraction Optimized activities in given package."); |
Kai | dd4ef5a | 2019-03-04 14:07:26 -0800 | [diff] [blame] | 876 | pw.println("\tget-carpropertyconfig [propertyId]"); |
| 877 | pw.println("\t Get a CarPropertyConfig by Id in Hex or list all CarPropertyConfigs"); |
Kai | 29fba11 | 2019-04-22 18:37:38 -0700 | [diff] [blame] | 878 | pw.println("\tget-property-value [propertyId] [areaId]"); |
| 879 | pw.println("\t Get a vehicle property value by property id in Hex and areaId"); |
| 880 | pw.println("\t or list all property values for all areaId"); |
Jim Kaye | d76c274 | 2019-04-02 11:33:27 -0700 | [diff] [blame] | 881 | pw.println("\tsuspend"); |
| 882 | pw.println("\t Suspend the system to Deep Sleep."); |
| 883 | pw.println("\tresume"); |
| 884 | pw.println("\t Wake the system up after a 'suspend.'"); |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 885 | pw.println("\tenable-trusted-device true|false"); |
| 886 | pw.println("\t Enable/Disable Trusted device feature."); |
| 887 | pw.println("\tremove-trusted-devices"); |
| 888 | pw.println("\t Remove all trusted devices for the current foreground user."); |
Pavel Maltsev | 371d97f | 2019-05-20 14:51:31 -0700 | [diff] [blame] | 889 | pw.println("\tprojection-tethering [true|false]"); |
| 890 | pw.println("\t Whether tethering should be used when creating access point for" |
| 891 | + " wireless projection"); |
Andrew T Nguyen | a9228c7 | 2019-06-12 11:28:42 -0700 | [diff] [blame] | 892 | pw.println("\t--metrics"); |
| 893 | pw.println("\t When used with dumpsys, only metrics will be in the dumpsys output."); |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 894 | pw.println("\tset-zoneid-for-uid [zoneid] [uid]"); |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 895 | pw.println("\t Maps the audio zoneid to uid."); |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 896 | pw.println("\tstart-fixed-activity displayId packageName activityName"); |
| 897 | pw.println("\t Start an Activity the specified display as fixed mode"); |
| 898 | pw.println("\tstop-fixed-mode displayId"); |
| 899 | pw.println("\t Stop fixed Activity mode for the given display. " |
| 900 | + "The Activity will not be restarted upon crash."); |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 901 | pw.println("\tenable-feature featureName"); |
| 902 | pw.println("\t Enable the requested feature. Change will happen after reboot."); |
| 903 | pw.println("\t This requires root/su."); |
| 904 | pw.println("\tdisable-feature featureName"); |
| 905 | pw.println("\t Disable the requested feature. Change will happen after reboot"); |
| 906 | pw.println("\t This requires root/su."); |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 907 | pw.println("\tinject-key [-d display] [-t down_delay_ms] key_code"); |
| 908 | pw.println("\t inject key down / up event to car service"); |
| 909 | pw.println("\t display: 0 for main, 1 for cluster. If not specified, it will be 0."); |
| 910 | pw.println("\t down_delay_ms: delay from down to up key event. If not specified,"); |
| 911 | pw.println("\t it will be 0"); |
| 912 | pw.println("\t key_code: int key code defined in android KeyEvent"); |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 913 | pw.printf("\t%s <REQ_TYPE> [--timeout TIMEOUT_MS]\n", COMMAND_GET_INITIAL_USER_INFO); |
| 914 | pw.println("\t Calls the Vehicle HAL to get the initial boot info, passing the given"); |
| 915 | pw.println("\t REQ_TYPE (which could be either FIRST_BOOT, FIRST_BOOT_AFTER_OTA, "); |
| 916 | pw.println("\t COLD_BOOT, RESUME, or any numeric value that would be passed 'as-is')"); |
| 917 | pw.println("\t and an optional TIMEOUT_MS to wait for the HAL response (if not set,"); |
| 918 | pw.println("\t it will use a default value)."); |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 919 | } |
| 920 | |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 921 | private int dumpInvalidArguments(PrintWriter pw) { |
| 922 | pw.println("Incorrect number of arguments."); |
| 923 | dumpHelp(pw); |
| 924 | return RESULT_ERROR; |
| 925 | } |
| 926 | |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 927 | private String runSetZoneIdForUid(String zoneString, String uidString) { |
| 928 | int uid = Integer.parseInt(uidString); |
| 929 | int zoneId = Integer.parseInt(zoneString); |
| 930 | if (!ArrayUtils.contains(mCarAudioService.getAudioZoneIds(), zoneId)) { |
| 931 | return "zoneid " + zoneId + " not found"; |
| 932 | } |
| 933 | mCarAudioService.setZoneIdForUid(zoneId, uid); |
| 934 | return null; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 935 | } |
| 936 | |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 937 | public int exec(String[] args, PrintWriter writer) { |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 938 | String arg = args[0]; |
| 939 | switch (arg) { |
| 940 | case COMMAND_HELP: |
| 941 | dumpHelp(writer); |
| 942 | break; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 943 | case COMMAND_DAY_NIGHT_MODE: { |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 944 | String value = args.length < 2 ? "" : args[1]; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 945 | forceDayNightMode(value, writer); |
| 946 | break; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 947 | } |
| 948 | case COMMAND_GARAGE_MODE: { |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 949 | String value = args.length < 2 ? "" : args[1]; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 950 | forceGarageMode(value, writer); |
| 951 | break; |
| 952 | } |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 953 | case COMMAND_INJECT_VHAL_EVENT: |
| 954 | String zone = PARAM_VEHICLE_PROPERTY_AREA_GLOBAL; |
| 955 | String data; |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 956 | if (args.length != 3 && args.length != 4) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 957 | return dumpInvalidArguments(writer); |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 958 | } else if (args.length == 4) { |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 959 | // Zoned |
| 960 | zone = args[2]; |
| 961 | data = args[3]; |
| 962 | } else { |
| 963 | // Global |
| 964 | data = args[2]; |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 965 | } |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 966 | injectVhalEvent(args[1], zone, data, false, writer); |
| 967 | break; |
| 968 | case COMMAND_INJECT_ERROR_EVENT: |
| 969 | if (args.length != 4) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 970 | return dumpInvalidArguments(writer); |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 971 | } |
| 972 | String errorAreaId = args[2]; |
| 973 | String errorCode = args[3]; |
| 974 | injectVhalEvent(args[1], errorAreaId, errorCode, true, writer); |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 975 | break; |
Ram Periathiruvadi | bf0eab7 | 2018-02-06 12:32:43 -0800 | [diff] [blame] | 976 | case COMMAND_ENABLE_UXR: |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 977 | if (args.length != 2) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 978 | return dumpInvalidArguments(writer); |
Ram Periathiruvadi | bf0eab7 | 2018-02-06 12:32:43 -0800 | [diff] [blame] | 979 | } |
| 980 | boolean enableBlocking = Boolean.valueOf(args[1]); |
| 981 | if (mCarPackageManagerService != null) { |
| 982 | mCarPackageManagerService.setEnableActivityBlocking(enableBlocking); |
| 983 | } |
| 984 | break; |
Ram Periathiruvadi | 3838830 | 2018-02-22 16:42:49 -0800 | [diff] [blame] | 985 | case COMMAND_GET_DO_ACTIVITIES: |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 986 | if (args.length != 2) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 987 | return dumpInvalidArguments(writer); |
Ram Periathiruvadi | 3838830 | 2018-02-22 16:42:49 -0800 | [diff] [blame] | 988 | } |
| 989 | String pkgName = args[1].toLowerCase(); |
| 990 | if (mCarPackageManagerService != null) { |
| 991 | String[] doActivities = |
| 992 | mCarPackageManagerService.getDistractionOptimizedActivities( |
| 993 | pkgName); |
| 994 | if (doActivities != null) { |
| 995 | writer.println("DO Activities for " + pkgName); |
| 996 | for (String a : doActivities) { |
| 997 | writer.println(a); |
| 998 | } |
| 999 | } else { |
| 1000 | writer.println("No DO Activities for " + pkgName); |
| 1001 | } |
| 1002 | } |
| 1003 | break; |
Kai | dd4ef5a | 2019-03-04 14:07:26 -0800 | [diff] [blame] | 1004 | case COMMAND_GET_CARPROPERTYCONFIG: |
| 1005 | String propertyId = args.length < 2 ? "" : args[1]; |
| 1006 | mHal.dumpPropertyConfigs(writer, propertyId); |
| 1007 | break; |
Kai | 29fba11 | 2019-04-22 18:37:38 -0700 | [diff] [blame] | 1008 | case COMMAND_GET_PROPERTY_VALUE: |
| 1009 | String propId = args.length < 2 ? "" : args[1]; |
| 1010 | String areaId = args.length < 3 ? "" : args[2]; |
| 1011 | mHal.dumpPropertyValueByCommend(writer, propId, areaId); |
| 1012 | break; |
Pavel Maltsev | 48a3194 | 2019-03-03 22:08:28 -0800 | [diff] [blame] | 1013 | case COMMAND_PROJECTION_UI_MODE: |
| 1014 | if (args.length != 2) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1015 | return dumpInvalidArguments(writer); |
Pavel Maltsev | 48a3194 | 2019-03-03 22:08:28 -0800 | [diff] [blame] | 1016 | } |
| 1017 | mCarProjectionService.setUiMode(Integer.valueOf(args[1])); |
Pavel Maltsev | d6961f6 | 2019-03-26 10:22:31 -0700 | [diff] [blame] | 1018 | break; |
Pavel Maltsev | 371d97f | 2019-05-20 14:51:31 -0700 | [diff] [blame] | 1019 | case COMMAND_PROJECTION_AP_TETHERING: |
| 1020 | if (args.length != 2) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1021 | return dumpInvalidArguments(writer); |
Pavel Maltsev | 371d97f | 2019-05-20 14:51:31 -0700 | [diff] [blame] | 1022 | } |
| 1023 | mCarProjectionService.setAccessPointTethering(Boolean.valueOf(args[1])); |
| 1024 | break; |
Jim Kaye | d76c274 | 2019-04-02 11:33:27 -0700 | [diff] [blame] | 1025 | case COMMAND_RESUME: |
| 1026 | mCarPowerManagementService.forceSimulatedResume(); |
| 1027 | writer.println("Resume: Simulating resuming from Deep Sleep"); |
| 1028 | break; |
| 1029 | case COMMAND_SUSPEND: |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 1030 | mCarPowerManagementService.forceSuspendAndMaybeReboot(false); |
Jim Kaye | d76c274 | 2019-04-02 11:33:27 -0700 | [diff] [blame] | 1031 | writer.println("Resume: Simulating powering down to Deep Sleep"); |
| 1032 | break; |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 1033 | case COMMAND_ENABLE_TRUSTED_DEVICE: |
| 1034 | if (args.length != 2) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1035 | return dumpInvalidArguments(writer); |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 1036 | } |
| 1037 | mCarTrustedDeviceService.getCarTrustAgentEnrollmentService() |
| 1038 | .setTrustedDeviceEnrollmentEnabled(Boolean.valueOf(args[1])); |
| 1039 | mCarTrustedDeviceService.getCarTrustAgentUnlockService() |
| 1040 | .setTrustedDeviceUnlockEnabled(Boolean.valueOf(args[1])); |
| 1041 | break; |
| 1042 | case COMMAND_REMOVE_TRUSTED_DEVICES: |
| 1043 | mCarTrustedDeviceService.getCarTrustAgentEnrollmentService() |
Anthony Hugh | fbb6776 | 2019-10-15 12:54:54 -0700 | [diff] [blame] | 1044 | .removeAllTrustedDevices(ActivityManager.getCurrentUser()); |
Ram Periathiruvadi | d26a3fb | 2019-04-15 14:48:23 -0700 | [diff] [blame] | 1045 | break; |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 1046 | case COMMAND_SET_UID_TO_ZONE: |
| 1047 | if (args.length != 3) { |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1048 | return dumpInvalidArguments(writer); |
Oscar Azucena | 3f3a25e | 2019-07-12 14:28:24 -0700 | [diff] [blame] | 1049 | } |
| 1050 | String results = runSetZoneIdForUid(args[1], args[2]); |
| 1051 | if (results != null) { |
| 1052 | writer.println(results); |
| 1053 | dumpHelp(writer); |
| 1054 | } |
| 1055 | break; |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 1056 | case COMMAND_START_FIXED_ACTIVITY_MODE: |
| 1057 | handleStartFixedActivity(args, writer); |
| 1058 | break; |
| 1059 | case COMMAND_STOP_FIXED_ACTIVITY_MODE: |
| 1060 | handleStopFixedMode(args, writer); |
| 1061 | break; |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 1062 | case COMMAND_ENABLE_FEATURE: |
| 1063 | if (args.length != 2) { |
| 1064 | return dumpInvalidArguments(writer); |
| 1065 | } |
| 1066 | handleEnableDisableFeature(args, writer, /* enable= */ true); |
| 1067 | break; |
| 1068 | case COMMAND_DISABLE_FEATURE: |
| 1069 | if (args.length != 2) { |
| 1070 | return dumpInvalidArguments(writer); |
| 1071 | } |
| 1072 | handleEnableDisableFeature(args, writer, /* enable= */ false); |
| 1073 | break; |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 1074 | case COMMAND_INJECT_KEY: |
| 1075 | if (args.length < 2) { |
| 1076 | return dumpInvalidArguments(writer); |
| 1077 | } |
| 1078 | handleInjectKey(args, writer); |
| 1079 | break; |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 1080 | case COMMAND_GET_INITIAL_USER_INFO: |
| 1081 | handleGetInitialUserInfo(args, writer); |
| 1082 | break; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1083 | default: |
Jim Kaye | f10b7d8 | 2019-02-26 12:53:22 -0800 | [diff] [blame] | 1084 | writer.println("Unknown command: \"" + arg + "\""); |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1085 | dumpHelp(writer); |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1086 | return RESULT_ERROR; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1087 | } |
felipeal | 72bf642 | 2019-11-02 17:04:04 -0700 | [diff] [blame] | 1088 | return RESULT_OK; |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
Keun young Park | 09ca849 | 2019-10-15 10:34:11 -0700 | [diff] [blame] | 1091 | private void handleStartFixedActivity(String[] args, PrintWriter writer) { |
| 1092 | if (args.length != 4) { |
| 1093 | writer.println("Incorrect number of arguments"); |
| 1094 | dumpHelp(writer); |
| 1095 | return; |
| 1096 | } |
| 1097 | int displayId; |
| 1098 | try { |
| 1099 | displayId = Integer.parseInt(args[1]); |
| 1100 | } catch (NumberFormatException e) { |
| 1101 | writer.println("Wrong display id:" + args[1]); |
| 1102 | return; |
| 1103 | } |
| 1104 | String packageName = args[2]; |
| 1105 | String activityName = args[3]; |
| 1106 | Intent intent = new Intent(); |
| 1107 | intent.setComponent(new ComponentName(packageName, activityName)); |
| 1108 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 1109 | ActivityOptions options = ActivityOptions.makeBasic(); |
| 1110 | options.setLaunchDisplayId(displayId); |
| 1111 | if (!mFixedActivityService.startFixedActivityModeForDisplayAndUser(intent, options, |
| 1112 | displayId, ActivityManager.getCurrentUser())) { |
| 1113 | writer.println("Failed to start"); |
| 1114 | return; |
| 1115 | } |
| 1116 | writer.println("Succeeded"); |
| 1117 | } |
| 1118 | |
| 1119 | private void handleStopFixedMode(String[] args, PrintWriter writer) { |
| 1120 | if (args.length != 2) { |
| 1121 | writer.println("Incorrect number of arguments"); |
| 1122 | dumpHelp(writer); |
| 1123 | return; |
| 1124 | } |
| 1125 | int displayId; |
| 1126 | try { |
| 1127 | displayId = Integer.parseInt(args[1]); |
| 1128 | } catch (NumberFormatException e) { |
| 1129 | writer.println("Wrong display id:" + args[1]); |
| 1130 | return; |
| 1131 | } |
| 1132 | mFixedActivityService.stopFixedActivityMode(displayId); |
| 1133 | } |
| 1134 | |
Keun young Park | 9a91efb | 2019-11-15 18:10:47 -0800 | [diff] [blame] | 1135 | private void handleEnableDisableFeature(String[] args, PrintWriter writer, boolean enable) { |
| 1136 | if (Binder.getCallingUid() != Process.ROOT_UID) { |
| 1137 | writer.println("Only allowed to root/su"); |
| 1138 | return; |
| 1139 | } |
| 1140 | String featureName = args[1]; |
| 1141 | long id = Binder.clearCallingIdentity(); |
| 1142 | // no permission check here |
| 1143 | int r; |
| 1144 | if (enable) { |
| 1145 | r = mFeatureController.enableFeature(featureName); |
| 1146 | } else { |
| 1147 | r = mFeatureController.disableFeature(featureName); |
| 1148 | } |
| 1149 | switch (r) { |
| 1150 | case Car.FEATURE_REQUEST_SUCCESS: |
| 1151 | if (enable) { |
| 1152 | writer.println("Enabled feature:" + featureName); |
| 1153 | } else { |
| 1154 | writer.println("Disabled feature:" + featureName); |
| 1155 | } |
| 1156 | break; |
| 1157 | case Car.FEATURE_REQUEST_ALREADY_IN_THE_STATE: |
| 1158 | if (enable) { |
| 1159 | writer.println("Already enabled:" + featureName); |
| 1160 | } else { |
| 1161 | writer.println("Already disabled:" + featureName); |
| 1162 | } |
| 1163 | break; |
| 1164 | case Car.FEATURE_REQUEST_MANDATORY: |
| 1165 | writer.println("Cannot change mandatory feature:" + featureName); |
| 1166 | break; |
| 1167 | case Car.FEATURE_REQUEST_NOT_EXISTING: |
| 1168 | writer.println("Non-existing feature:" + featureName); |
| 1169 | break; |
| 1170 | default: |
| 1171 | writer.println("Unknown error:" + r); |
| 1172 | break; |
| 1173 | } |
| 1174 | Binder.restoreCallingIdentity(id); |
| 1175 | } |
| 1176 | |
Keun young Park | 313dfaf | 2019-12-19 11:32:38 -0800 | [diff] [blame] | 1177 | private void handleInjectKey(String[] args, PrintWriter writer) { |
| 1178 | int i = 1; // 0 is command itself |
| 1179 | int display = InputHalService.DISPLAY_MAIN; |
| 1180 | int delayMs = 0; |
| 1181 | int keyCode = KeyEvent.KEYCODE_UNKNOWN; |
| 1182 | try { |
| 1183 | while (i < args.length) { |
| 1184 | switch (args[i]) { |
| 1185 | case "-d": |
| 1186 | i++; |
| 1187 | display = Integer.parseInt(args[i]); |
| 1188 | break; |
| 1189 | case "-t": |
| 1190 | i++; |
| 1191 | delayMs = Integer.parseInt(args[i]); |
| 1192 | break; |
| 1193 | default: |
| 1194 | if (keyCode != KeyEvent.KEYCODE_UNKNOWN) { |
| 1195 | throw new IllegalArgumentException("key_code already set:" |
| 1196 | + keyCode); |
| 1197 | } |
| 1198 | keyCode = Integer.parseInt(args[i]); |
| 1199 | } |
| 1200 | i++; |
| 1201 | } |
| 1202 | } catch (Exception e) { |
| 1203 | writer.println("Invalid args:" + e); |
| 1204 | dumpHelp(writer); |
| 1205 | return; |
| 1206 | } |
| 1207 | if (keyCode == KeyEvent.KEYCODE_UNKNOWN) { |
| 1208 | writer.println("Missing key code or invalid keycode"); |
| 1209 | dumpHelp(writer); |
| 1210 | return; |
| 1211 | } |
| 1212 | if (display != InputHalService.DISPLAY_MAIN |
| 1213 | && display != InputHalService.DISPLAY_INSTRUMENT_CLUSTER) { |
| 1214 | writer.println("Invalid display:" + display); |
| 1215 | dumpHelp(writer); |
| 1216 | return; |
| 1217 | } |
| 1218 | if (delayMs < 0) { |
| 1219 | writer.println("Invalid delay:" + delayMs); |
| 1220 | dumpHelp(writer); |
| 1221 | return; |
| 1222 | } |
| 1223 | KeyEvent keyDown = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode); |
| 1224 | mCarInputService.onKeyEvent(keyDown, display); |
| 1225 | SystemClock.sleep(delayMs); |
| 1226 | KeyEvent keyUp = new KeyEvent(KeyEvent.ACTION_UP, keyCode); |
| 1227 | mCarInputService.onKeyEvent(keyUp, display); |
| 1228 | writer.println("Succeeded"); |
| 1229 | } |
| 1230 | |
Felipe Leme | a5e6938 | 2020-02-11 17:53:20 -0800 | [diff] [blame] | 1231 | private void handleGetInitialUserInfo(String[] args, PrintWriter writer) { |
| 1232 | if (args.length < 2) { |
| 1233 | writer.println("Insufficient number of args"); |
| 1234 | return; |
| 1235 | } |
| 1236 | |
| 1237 | // Gets the request type |
| 1238 | String typeArg = args[1]; |
| 1239 | int requestType = UserHalHelper.parseInitialUserInfoRequestType(typeArg); |
| 1240 | |
| 1241 | int timeout = 1_000; |
| 1242 | for (int i = 2; i < args.length; i++) { |
| 1243 | String arg = args[i]; |
| 1244 | switch (arg) { |
| 1245 | case "--timeout": |
| 1246 | timeout = Integer.parseInt(args[++i]); |
| 1247 | break; |
| 1248 | default: |
| 1249 | writer.println("Invalid option at index " + i + ": " + arg); |
| 1250 | return; |
| 1251 | |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | Log.d(TAG, "handleGetInitialUserInfo(): type=" + requestType + " (" + typeArg |
| 1256 | + "), timeout=" + timeout); |
| 1257 | |
| 1258 | UserHalService userHal = mHal.getUserHal(); |
| 1259 | // TODO(b/146207078): use UserHalHelper to populate it with current users |
| 1260 | UsersInfo usersInfo = new UsersInfo(); |
| 1261 | CountDownLatch latch = new CountDownLatch(1); |
| 1262 | |
| 1263 | userHal.getInitialUserInfo(requestType, timeout, usersInfo, (status, resp) -> { |
| 1264 | try { |
| 1265 | Log.d(TAG, "GetUserInfoResponse: status=" + status + ", resp=" + resp); |
| 1266 | writer.printf("Status: %s\n", UserHalHelper.halCallbackStatusToString(status)); |
| 1267 | if (status != HalCallback.STATUS_OK) { |
| 1268 | return; |
| 1269 | } |
| 1270 | writer.printf("Request id: %d\n", resp.requestId); |
| 1271 | writer.printf("Action: "); |
| 1272 | switch (resp.action) { |
| 1273 | case InitialUserInfoResponseAction.DEFAULT: |
| 1274 | writer.println("default"); |
| 1275 | break; |
| 1276 | case InitialUserInfoResponseAction.SWITCH: |
| 1277 | writer.printf("switch to user %d\n", resp.userToSwitchOrCreate.userId); |
| 1278 | break; |
| 1279 | case InitialUserInfoResponseAction.CREATE: |
| 1280 | writer.printf("create user: name=%s, flags=%d\n", resp.userNameToCreate, |
| 1281 | resp.userToSwitchOrCreate.flags); |
| 1282 | break; |
| 1283 | default: |
| 1284 | writer.printf("unknown (%d)\n", resp.action); |
| 1285 | break; |
| 1286 | } |
| 1287 | } finally { |
| 1288 | latch.countDown(); |
| 1289 | } |
| 1290 | }); |
| 1291 | |
| 1292 | try { |
| 1293 | if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { |
| 1294 | writer.printf("HAL didn't respond in %dms\n", timeout); |
| 1295 | } |
| 1296 | } catch (InterruptedException e) { |
| 1297 | Thread.currentThread().interrupt(); |
| 1298 | writer.println("Interrupted waiting for HAL"); |
| 1299 | } |
| 1300 | return; |
| 1301 | } |
| 1302 | |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1303 | private void forceDayNightMode(String arg, PrintWriter writer) { |
| 1304 | int mode; |
| 1305 | switch (arg) { |
| 1306 | case PARAM_DAY_MODE: |
| 1307 | mode = CarNightService.FORCED_DAY_MODE; |
| 1308 | break; |
| 1309 | case PARAM_NIGHT_MODE: |
| 1310 | mode = CarNightService.FORCED_NIGHT_MODE; |
| 1311 | break; |
| 1312 | case PARAM_SENSOR_MODE: |
| 1313 | mode = CarNightService.FORCED_SENSOR_MODE; |
| 1314 | break; |
| 1315 | default: |
| 1316 | writer.println("Unknown value. Valid argument: " + PARAM_DAY_MODE + "|" |
| 1317 | + PARAM_NIGHT_MODE + "|" + PARAM_SENSOR_MODE); |
| 1318 | return; |
| 1319 | } |
| 1320 | int current = mCarNightService.forceDayNightMode(mode); |
| 1321 | String currentMode = null; |
| 1322 | switch (current) { |
| 1323 | case UiModeManager.MODE_NIGHT_AUTO: |
| 1324 | currentMode = PARAM_SENSOR_MODE; |
| 1325 | break; |
| 1326 | case UiModeManager.MODE_NIGHT_YES: |
| 1327 | currentMode = PARAM_NIGHT_MODE; |
| 1328 | break; |
| 1329 | case UiModeManager.MODE_NIGHT_NO: |
| 1330 | currentMode = PARAM_DAY_MODE; |
| 1331 | break; |
| 1332 | } |
| 1333 | writer.println("DayNightMode changed to: " + currentMode); |
| 1334 | } |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1335 | |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1336 | private void forceGarageMode(String arg, PrintWriter writer) { |
| 1337 | switch (arg) { |
| 1338 | case PARAM_ON_MODE: |
Jim Kaye | 26fc7da | 2019-10-23 10:46:28 -0700 | [diff] [blame] | 1339 | mSystemInterface.setDisplayState(false); |
Serik Beketayev | e0e7ff2 | 2018-07-31 21:04:12 -0700 | [diff] [blame] | 1340 | mGarageModeService.forceStartGarageMode(); |
Jim Kaye | 1b5e618 | 2019-05-24 15:48:32 -0700 | [diff] [blame] | 1341 | writer.println("Garage mode: " + mGarageModeService.isGarageModeActive()); |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1342 | break; |
| 1343 | case PARAM_OFF_MODE: |
Jim Kaye | 26fc7da | 2019-10-23 10:46:28 -0700 | [diff] [blame] | 1344 | mSystemInterface.setDisplayState(true); |
Serik Beketayev | e0e7ff2 | 2018-07-31 21:04:12 -0700 | [diff] [blame] | 1345 | mGarageModeService.stopAndResetGarageMode(); |
Jim Kaye | 1b5e618 | 2019-05-24 15:48:32 -0700 | [diff] [blame] | 1346 | writer.println("Garage mode: " + mGarageModeService.isGarageModeActive()); |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1347 | break; |
| 1348 | case PARAM_QUERY_MODE: |
Jim Kaye | 1b5e618 | 2019-05-24 15:48:32 -0700 | [diff] [blame] | 1349 | mGarageModeService.dump(writer); |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1350 | break; |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 1351 | case PARAM_REBOOT: |
| 1352 | mCarPowerManagementService.forceSuspendAndMaybeReboot(true); |
| 1353 | writer.println("Entering Garage Mode. Will reboot when it completes."); |
| 1354 | break; |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1355 | default: |
| 1356 | writer.println("Unknown value. Valid argument: " + PARAM_ON_MODE + "|" |
Jim Kaye | 9a834ea | 2020-02-07 15:50:53 -0800 | [diff] [blame] | 1357 | + PARAM_OFF_MODE + "|" + PARAM_QUERY_MODE + "|" + PARAM_REBOOT); |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1358 | } |
Bryan Eyler | a32a7c1 | 2018-02-27 15:40:00 -0800 | [diff] [blame] | 1359 | } |
| 1360 | |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1361 | /** |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1362 | * Inject a fake VHAL event |
Ram Periathiruvadi | 49d5a5a | 2017-02-17 18:50:09 -0800 | [diff] [blame] | 1363 | * |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1364 | * @param property the Vehicle property Id as defined in the HAL |
| 1365 | * @param zone Zone that this event services |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 1366 | * @param isErrorEvent indicates the type of event |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1367 | * @param value Data value of the event |
| 1368 | * @param writer PrintWriter |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1369 | */ |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1370 | private void injectVhalEvent(String property, String zone, String value, |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 1371 | boolean isErrorEvent, PrintWriter writer) { |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1372 | if (zone != null && (zone.equalsIgnoreCase(PARAM_VEHICLE_PROPERTY_AREA_GLOBAL))) { |
| 1373 | if (!isPropertyAreaTypeGlobal(property)) { |
| 1374 | writer.println("Property area type inconsistent with given zone"); |
| 1375 | return; |
| 1376 | } |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1377 | } |
| 1378 | try { |
Kai | 4b098cf | 2019-06-05 15:03:28 -0700 | [diff] [blame] | 1379 | if (isErrorEvent) { |
| 1380 | mHal.injectOnPropertySetError(property, zone, value); |
| 1381 | } else { |
| 1382 | mHal.injectVhalEvent(property, zone, value); |
| 1383 | } |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1384 | } catch (NumberFormatException e) { |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1385 | writer.println("Invalid property Id zone Id or value" + e); |
| 1386 | dumpHelp(writer); |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1387 | } |
Ram Periathiruvadi | ee28c00 | 2017-02-07 21:35:01 -0800 | [diff] [blame] | 1388 | } |
| 1389 | |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1390 | // Check if the given property is global |
| 1391 | private boolean isPropertyAreaTypeGlobal(String property) { |
| 1392 | if (property == null) { |
| 1393 | return false; |
Ram Periathiruvadi | 49d5a5a | 2017-02-17 18:50:09 -0800 | [diff] [blame] | 1394 | } |
Ram Periathiruvadi | 5cd00cb | 2018-02-12 13:49:50 -0800 | [diff] [blame] | 1395 | return (Integer.decode(property) & VehicleArea.MASK) == VehicleArea.GLOBAL; |
Ram Periathiruvadi | 49d5a5a | 2017-02-17 18:50:09 -0800 | [diff] [blame] | 1396 | } |
Yao Chen | e33f07e | 2016-07-26 12:02:51 -0700 | [diff] [blame] | 1397 | } |
kevinjm | 55822c4 | 2018-08-15 11:26:00 -0700 | [diff] [blame] | 1398 | } |