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