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 | |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 19 | import android.car.Car; |
| 20 | import android.car.ICar; |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 21 | import android.car.cluster.renderer.IInstrumentClusterNavigation; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 22 | import android.content.Context; |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 23 | import android.content.pm.PackageManager; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 24 | import android.os.IBinder; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 25 | import android.util.Log; |
| 26 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 27 | import com.android.car.cluster.InstrumentClusterService; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 28 | import com.android.car.hal.VehicleHal; |
Keun-young Park | 4aeb4bf | 2015-12-08 18:31:33 -0800 | [diff] [blame] | 29 | import com.android.car.pm.CarPackageManagerService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 30 | import com.android.internal.annotations.GuardedBy; |
| 31 | |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 32 | import java.io.PrintWriter; |
| 33 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 34 | public class ICarImpl extends ICar.Stub { |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 35 | |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 36 | public static final String INTERNAL_INPUT_SERVICE = "internal_input"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 37 | public static final String INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE = |
| 38 | "system_activity_monitoring"; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 39 | |
| 40 | // load jni for all services here |
| 41 | static { |
| 42 | System.loadLibrary("jni_car_service"); |
| 43 | } |
| 44 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 45 | @GuardedBy("ICarImpl.class") |
| 46 | private static ICarImpl sInstance = null; |
| 47 | |
| 48 | private final Context mContext; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 49 | private final VehicleHal mHal; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 50 | |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 51 | private final SystemActivityMonitoringService mSystemActivityMonitoringService; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 52 | private final CarPowerManagementService mCarPowerManagementService; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 53 | private final CarPackageManagerService mCarPackageManagerService; |
| 54 | private final CarInputService mCarInputService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 55 | private final CarSensorService mCarSensorService; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 56 | private final CarInfoService mCarInfoService; |
keunyoung | d32f4e6 | 2015-09-21 11:33:06 -0700 | [diff] [blame] | 57 | private final CarAudioService mCarAudioService; |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 58 | private final CarProjectionService mCarProjectionService; |
Steve Paik | 875616c | 2016-02-05 10:55:59 -0800 | [diff] [blame] | 59 | private final CarCameraService mCarCameraService; |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 60 | private final CarHvacService mCarHvacService; |
Sanket Agarwal | 3cf096a | 2015-10-13 14:46:31 -0700 | [diff] [blame] | 61 | private final CarRadioService mCarRadioService; |
Joseph Pirozzo | 317343d | 2016-01-25 10:22:37 -0800 | [diff] [blame] | 62 | private final CarNightService mCarNightService; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 63 | private final AppFocusService mAppFocusService; |
Yao Chen | 3a7976d | 2016-01-20 17:27:08 -0800 | [diff] [blame] | 64 | private final GarageModeService mGarageModeService; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 65 | private final InstrumentClusterService mInstrumentClusterService; |
Keun-young Park | d73afae | 2016-04-08 20:03:32 -0700 | [diff] [blame] | 66 | private final SystemStateControllerService mSystemStateControllerService; |
keunyoung | a74b9ca | 2015-10-21 13:33:58 -0700 | [diff] [blame] | 67 | |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 68 | /** Test only service. Populate it only when necessary. */ |
| 69 | @GuardedBy("this") |
| 70 | private CarTestService mCarTestService; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 71 | private final CarServiceBase[] mAllServices; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 72 | |
| 73 | public synchronized static ICarImpl getInstance(Context serviceContext) { |
| 74 | if (sInstance == null) { |
| 75 | sInstance = new ICarImpl(serviceContext); |
| 76 | sInstance.init(); |
| 77 | } |
| 78 | return sInstance; |
| 79 | } |
| 80 | |
| 81 | public synchronized static void releaseInstance() { |
| 82 | if (sInstance == null) { |
| 83 | return; |
| 84 | } |
| 85 | sInstance.release(); |
| 86 | sInstance = null; |
| 87 | } |
| 88 | |
| 89 | public ICarImpl(Context serviceContext) { |
| 90 | mContext = serviceContext; |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 91 | mHal = VehicleHal.getInstance(); |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 92 | mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext); |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 93 | mCarPowerManagementService = new CarPowerManagementService(serviceContext); |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 94 | mCarSensorService = new CarSensorService(serviceContext); |
| 95 | mCarPackageManagerService = new CarPackageManagerService(serviceContext, mCarSensorService, |
| 96 | mSystemActivityMonitoringService); |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 97 | mCarInputService = new CarInputService(serviceContext); |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 98 | mCarProjectionService = new CarProjectionService(serviceContext, mCarInputService); |
Yao Chen | 3a7976d | 2016-01-20 17:27:08 -0800 | [diff] [blame] | 99 | mGarageModeService = new GarageModeService(mContext, mCarPowerManagementService); |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 100 | mCarInfoService = new CarInfoService(serviceContext); |
Vitalii Tomkiv | 8c7f297 | 2016-07-11 15:42:04 -0700 | [diff] [blame^] | 101 | mAppFocusService = new AppFocusService(serviceContext, mSystemActivityMonitoringService); |
Yao Chen | c4d442f | 2016-04-08 11:33:47 -0700 | [diff] [blame] | 102 | mCarAudioService = new CarAudioService(serviceContext, mCarInputService); |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 103 | mCarHvacService = new CarHvacService(serviceContext); |
Sanket Agarwal | 3cf096a | 2015-10-13 14:46:31 -0700 | [diff] [blame] | 104 | mCarRadioService = new CarRadioService(serviceContext); |
Steve Paik | 875616c | 2016-02-05 10:55:59 -0800 | [diff] [blame] | 105 | mCarCameraService = new CarCameraService(serviceContext); |
Joseph Pirozzo | 317343d | 2016-01-25 10:22:37 -0800 | [diff] [blame] | 106 | mCarNightService = new CarNightService(serviceContext); |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 107 | mInstrumentClusterService = new InstrumentClusterService(serviceContext, |
Pavel Maltsev | 03cf60c | 2016-06-27 15:11:51 -0700 | [diff] [blame] | 108 | mAppFocusService, mCarInputService); |
Keun-young Park | d73afae | 2016-04-08 20:03:32 -0700 | [diff] [blame] | 109 | mSystemStateControllerService = new SystemStateControllerService(serviceContext, |
Keun-young Park | 3cb8910 | 2016-05-05 13:16:03 -0700 | [diff] [blame] | 110 | mCarPowerManagementService, mCarAudioService, this); |
keunyoung | a74b9ca | 2015-10-21 13:33:58 -0700 | [diff] [blame] | 111 | |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 112 | // Be careful with order. Service depending on other service should be inited later. |
| 113 | mAllServices = new CarServiceBase[] { |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 114 | mSystemActivityMonitoringService, |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 115 | mCarPowerManagementService, |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 116 | mCarSensorService, |
Keun-young Park | 45fdcba | 2015-12-08 11:38:58 -0800 | [diff] [blame] | 117 | mCarPackageManagerService, |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 118 | mCarInputService, |
| 119 | mGarageModeService, |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 120 | mCarInfoService, |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 121 | mAppFocusService, |
Sanket Agarwal | 3cf096a | 2015-10-13 14:46:31 -0700 | [diff] [blame] | 122 | mCarAudioService, |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 123 | mCarHvacService, |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 124 | mCarRadioService, |
| 125 | mCarCameraService, |
Joseph Pirozzo | 317343d | 2016-01-25 10:22:37 -0800 | [diff] [blame] | 126 | mCarNightService, |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 127 | mInstrumentClusterService, |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 128 | mCarProjectionService, |
Keun-young Park | d73afae | 2016-04-08 20:03:32 -0700 | [diff] [blame] | 129 | mSystemStateControllerService |
keunyoung | a74b9ca | 2015-10-21 13:33:58 -0700 | [diff] [blame] | 130 | }; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | private void init() { |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 134 | for (CarServiceBase service: mAllServices) { |
| 135 | service.init(); |
| 136 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | private void release() { |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 140 | // release done in opposite order from init |
| 141 | for (int i = mAllServices.length - 1; i >= 0; i--) { |
| 142 | mAllServices[i].release(); |
| 143 | } |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 144 | VehicleHal.releaseInstance(); |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 145 | } |
| 146 | |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 147 | /** Only for CarTestService */ |
| 148 | void startMocking() { |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 149 | reinitServices(); |
| 150 | } |
| 151 | |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 152 | /** Only for CarTestService */ |
| 153 | void stopMocking() { |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 154 | reinitServices(); |
| 155 | } |
| 156 | |
keunyoung | 6b19769 | 2015-11-16 13:54:38 -0800 | [diff] [blame] | 157 | /** Reset all services when starting / stopping vehicle hal mocking */ |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 158 | private void reinitServices() { |
| 159 | for (int i = mAllServices.length - 1; i >= 0; i--) { |
| 160 | mAllServices[i].release(); |
| 161 | } |
Keun-young Park | 021310d | 2016-04-25 21:09:39 -0700 | [diff] [blame] | 162 | VehicleHal.getInstance().release(); |
| 163 | VehicleHal.getInstance().init(); |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 164 | for (CarServiceBase service: mAllServices) { |
| 165 | service.init(); |
| 166 | } |
| 167 | } |
| 168 | |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 169 | @Override |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 170 | public IBinder getCarService(String serviceName) { |
| 171 | switch (serviceName) { |
Keun-young Park | 5672e85 | 2016-02-09 19:53:48 -0800 | [diff] [blame] | 172 | case Car.AUDIO_SERVICE: |
| 173 | return mCarAudioService; |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 174 | case Car.SENSOR_SERVICE: |
| 175 | return mCarSensorService; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 176 | case Car.INFO_SERVICE: |
| 177 | return mCarInfoService; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 178 | case Car.APP_FOCUS_SERVICE: |
| 179 | return mAppFocusService; |
Keun-young Park | 45fdcba | 2015-12-08 11:38:58 -0800 | [diff] [blame] | 180 | case Car.PACKAGE_SERVICE: |
| 181 | return mCarPackageManagerService; |
Steve Paik | 875616c | 2016-02-05 10:55:59 -0800 | [diff] [blame] | 182 | case Car.CAMERA_SERVICE: |
| 183 | assertCameraPermission(mContext); |
| 184 | return mCarCameraService; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 185 | case Car.HVAC_SERVICE: |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 186 | assertHvacPermission(mContext); |
| 187 | return mCarHvacService; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 188 | case Car.RADIO_SERVICE: |
keunyoung | 6b19769 | 2015-11-16 13:54:38 -0800 | [diff] [blame] | 189 | assertRadioPermission(mContext); |
Sanket Agarwal | 3cf096a | 2015-10-13 14:46:31 -0700 | [diff] [blame] | 190 | return mCarRadioService; |
Pavel Maltsev | 7a948e5 | 2016-02-02 23:30:14 -0800 | [diff] [blame] | 191 | case Car.CAR_NAVIGATION_SERVICE: |
Keun-young Park | e31a8b2 | 2016-03-16 17:34:08 -0700 | [diff] [blame] | 192 | assertNavigationManagerPermission(mContext); |
Pavel Maltsev | 0477e29 | 2016-05-27 12:22:36 -0700 | [diff] [blame] | 193 | IInstrumentClusterNavigation navService = |
| 194 | mInstrumentClusterService.getNavigationService(); |
| 195 | return navService == null ? null : navService.asBinder(); |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 196 | case Car.PROJECTION_SERVICE: |
| 197 | assertProjectionPermission(mContext); |
| 198 | return mCarProjectionService; |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 199 | case Car.TEST_SERVICE: { |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 200 | assertVehicleHalMockPermission(mContext); |
| 201 | synchronized (this) { |
| 202 | if (mCarTestService == null) { |
| 203 | mCarTestService = new CarTestService(mContext, this); |
| 204 | } |
| 205 | return mCarTestService; |
| 206 | } |
| 207 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 208 | default: |
| 209 | Log.w(CarLog.TAG_SERVICE, "getCarService for unknown service:" + serviceName); |
| 210 | return null; |
| 211 | } |
| 212 | } |
| 213 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 214 | @Override |
| 215 | public int getCarConnectionType() { |
| 216 | if (!isInMocking()) { |
| 217 | return Car.CONNECTION_TYPE_EMBEDDED; |
| 218 | } else { |
| 219 | return Car.CONNECTION_TYPE_EMBEDDED_MOCKING; |
| 220 | } |
| 221 | } |
| 222 | |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 223 | public CarServiceBase getCarInternalService(String serviceName) { |
| 224 | switch (serviceName) { |
| 225 | case INTERNAL_INPUT_SERVICE: |
| 226 | return mCarInputService; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 227 | case INTERNAL_SYSTEM_ACTIVITY_MONITORING_SERVICE: |
| 228 | return mSystemActivityMonitoringService; |
Keun-young Park | a28d7b2 | 2016-02-29 16:54:29 -0800 | [diff] [blame] | 229 | default: |
| 230 | Log.w(CarLog.TAG_SERVICE, "getCarInternalService for unknown service:" + |
| 231 | serviceName); |
| 232 | return null; |
| 233 | } |
| 234 | } |
| 235 | |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 236 | /** |
| 237 | * Whether mocking underlying HAL or not. |
| 238 | * @return |
| 239 | */ |
| 240 | public synchronized boolean isInMocking() { |
| 241 | if (mCarTestService == null) { |
| 242 | return false; |
| 243 | } |
| 244 | return mCarTestService.isInMocking(); |
| 245 | } |
| 246 | |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 247 | public static void assertVehicleHalMockPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 248 | assertPermission(context, Car.PERMISSION_MOCK_VEHICLE_HAL); |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Steve Paik | 875616c | 2016-02-05 10:55:59 -0800 | [diff] [blame] | 251 | public static void assertCameraPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 252 | assertPermission(context, Car.PERMISSION_CAR_CAMERA); |
Steve Paik | 875616c | 2016-02-05 10:55:59 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Keun-young Park | e31a8b2 | 2016-03-16 17:34:08 -0700 | [diff] [blame] | 255 | public static void assertNavigationManagerPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 256 | assertPermission(context, Car.PERMISSION_CAR_NAVIGATION_MANAGER); |
Pavel Maltsev | ce4ffd9 | 2016-03-09 10:56:23 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 259 | public static void assertHvacPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 260 | assertPermission(context, Car.PERMISSION_CAR_HVAC); |
Steve Paik | 6648198 | 2015-10-27 15:22:38 -0700 | [diff] [blame] | 261 | } |
| 262 | |
keunyoung | 6b19769 | 2015-11-16 13:54:38 -0800 | [diff] [blame] | 263 | private static void assertRadioPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 264 | assertPermission(context, Car.PERMISSION_CAR_RADIO); |
Sanket Agarwal | 3cf096a | 2015-10-13 14:46:31 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 267 | public static void assertProjectionPermission(Context context) { |
Steve Paik | 461ecc6 | 2016-06-08 15:28:32 -0700 | [diff] [blame] | 268 | assertPermission(context, Car.PERMISSION_CAR_PROJECTION); |
| 269 | } |
| 270 | |
| 271 | public static void assertPermission(Context context, String permission) { |
| 272 | if (context.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { |
| 273 | throw new SecurityException("requires " + permission); |
Vitalii Tomkiv | 6e5ee61 | 2016-03-09 14:57:32 -0800 | [diff] [blame] | 274 | } |
| 275 | } |
| 276 | |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 277 | void dump(PrintWriter writer) { |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 278 | writer.println("*Dump all services*"); |
| 279 | for (CarServiceBase service: mAllServices) { |
| 280 | service.dump(writer); |
| 281 | } |
keunyoung | 1ab8e18 | 2015-09-24 09:25:22 -0700 | [diff] [blame] | 282 | CarTestService testService = mCarTestService; |
| 283 | if (testService != null) { |
| 284 | testService.dump(writer); |
| 285 | } |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 286 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 287 | } |