summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Yi2018-11-28 20:35:00 -0600
committerBill Yi2018-11-28 20:35:00 -0600
commit0f8320f6b95736ea4b703764a7d11a8a6ca13674 (patch)
treed7b300e81f05e45345ada1ffcaf39b2512dd8f6f
parentf02b56678700a4035d0ad8882f7d20371bb96ee2 (diff)
parent911e6566751a60c29eada6ad0679694bed11be4f (diff)
downloadplatform-packages-services-car-pie-cuttlefish-testing.tar.gz
platform-packages-services-car-pie-cuttlefish-testing.tar.xz
platform-packages-services-car-pie-cuttlefish-testing.zip
Merge pi-qpr1-release PQ1A.181105.017.A1 to pi-platform-releasepie-platform-releasepie-cuttlefish-testing
Change-Id: Ibafbc25e1d704d7e84a168b32d35a165dd41e06f
-rw-r--r--.gitignore1
-rw-r--r--TrustAgent/res/values/strings.xml2
-rw-r--r--TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java191
-rw-r--r--TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java68
-rw-r--r--TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java22
-rw-r--r--car-lib/api/current.txt124
-rw-r--r--car-lib/api/system-current.txt8
-rw-r--r--car-lib/src/android/car/Car.java8
-rw-r--r--car-lib/src/android/car/CarInfoManager.java56
-rw-r--r--car-lib/src/android/car/PortLocationType.java35
-rw-r--r--car-lib/src/android/car/VehicleLightState.java31
-rw-r--r--car-lib/src/android/car/VehicleLightSwitch.java31
-rw-r--r--car-lib/src/android/car/VehiclePropertyAccess.java35
-rw-r--r--car-lib/src/android/car/VehiclePropertyIds.java888
-rw-r--r--car-lib/src/android/car/drivingstate/CarUxRestrictions.java32
-rw-r--r--car-lib/src/android/car/hardware/CarSensorEvent.java43
-rw-r--r--car-lib/src/android/car/hardware/CarSensorManager.java15
-rw-r--r--car-lib/src/android/car/hardware/property/CarPropertyManager.java83
-rw-r--r--car-lib/src/android/car/media/CarAudioManager.java7
-rw-r--r--car-lib/src/android/car/settings/CarSettings.java30
-rw-r--r--car-lib/src/android/car/trust/ICarTrustAgentBleService.aidl3
-rw-r--r--car-lib/src/android/car/user/CarUserManagerHelper.java403
-rw-r--r--car-support-lib/proguard-release.flags8
-rw-r--r--car_product/overlay/frameworks/base/core/res/res/values/config.xml2
-rw-r--r--car_product/overlay/frameworks/base/packages/SystemUI/res-keyguard/layout-land/keyguard_pattern_view.xml85
-rw-r--r--car_product/overlay/frameworks/base/packages/SystemUI/res-keyguard/layout-land/keyguard_pin_view.xml104
-rw-r--r--car_product/overlay/frameworks/base/packages/SystemUI/res-keyguard/values/dimens.xml2
-rw-r--r--car_product/sepolicy/private/carservice_app.te2
-rw-r--r--evs/app/RenderDirectView.cpp3
-rw-r--r--evs/app/RenderTopView.cpp3
-rw-r--r--evs/sampleDriver/GlWrapper.cpp5
-rw-r--r--evs/sampleDriver/ServiceNames.h4
-rw-r--r--evs/sampleDriver/VideoCapture.h4
-rw-r--r--service/Android.mk6
-rw-r--r--service/AndroidManifest.xml5
-rw-r--r--service/res/values/config.xml6
-rw-r--r--service/src/com/android/car/CarAudioService.java44
-rw-r--r--service/src/com/android/car/CarInputService.java42
-rw-r--r--service/src/com/android/car/CarLocationService.java188
-rw-r--r--service/src/com/android/car/CarNightService.java39
-rw-r--r--service/src/com/android/car/CarPropertyService.java23
-rw-r--r--service/src/com/android/car/CarUxRestrictionsManagerService.java55
-rw-r--r--service/src/com/android/car/CarUxRestrictionsServiceHelper.java4
-rw-r--r--service/src/com/android/car/ICarImpl.java7
-rw-r--r--service/src/com/android/car/garagemode/GarageModePolicy.java157
-rw-r--r--service/src/com/android/car/garagemode/GarageModeService.java (renamed from service/src/com/android/car/GarageModeService.java)180
-rw-r--r--service/src/com/android/car/garagemode/WakeupInterval.java48
-rw-r--r--service/src/com/android/car/hal/CarPropertyUtils.java36
-rw-r--r--service/src/com/android/car/hal/PropertyHalServiceIds.java3
-rw-r--r--service/src/com/android/car/pm/CarPackageManagerService.java62
-rw-r--r--service/src/com/android/car/systeminterface/DisplayInterface.java44
-rw-r--r--service/src/com/android/car/user/CarUserService.java38
-rw-r--r--tests/CarTrustAgentClientApp/Android.mk15
-rw-r--r--tests/CarTrustAgentClientApp/AndroidManifest.xml34
-rw-r--r--tests/CarTrustAgentClientApp/README.txt2
-rw-r--r--tests/CarTrustAgentClientApp/res/layout/phone_enrolment_activity.xml54
-rw-r--r--tests/CarTrustAgentClientApp/res/values/strings.xml22
-rw-r--r--tests/CarTrustAgentClientApp/src/com/android/car/trust/client/PhoneEnrolmentActivity.java61
-rw-r--r--tests/CarTrustAgentClientApp/src/com/android/car/trust/client/PhoneEnrolmentController.java183
-rw-r--r--tests/CarTrustAgentClientApp/src/com/android/car/trust/client/PhoneUnlockController.java149
-rw-r--r--tests/CarTrustAgentClientApp/src/com/android/car/trust/client/SimpleBleClient.java355
-rw-r--r--tests/CarTrustAgentClientApp/src/com/android/car/trust/client/Utils.java46
-rw-r--r--tests/EmbeddedKitchenSinkApp/AndroidManifest.xml2
-rw-r--r--tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml55
-rw-r--r--tests/EmbeddedKitchenSinkApp/res/layout/list_item.xml22
-rw-r--r--tests/EmbeddedKitchenSinkApp/res/values/strings.xml5
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java70
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java154
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/hvac/HvacTestFragment.java141
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/power/PowerTestFragment.java23
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/property/PropertyTestFragment.java32
-rw-r--r--tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/sensor/SensorsTestFragment.java21
-rw-r--r--tests/carservice_test/AndroidManifest.xml5
-rw-r--r--tests/carservice_test/src/com/android/car/MockedCarTestBase.java4
-rw-r--r--tests/carservice_test/src/com/android/car/garagemode/GarageModeServiceTest.java (renamed from tests/carservice_test/src/com/android/car/GarageModeTest.java)143
-rw-r--r--tests/carservice_unit_test/src/com/android/car/CarLocationServiceTest.java52
-rw-r--r--tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java655
-rw-r--r--tests/carservice_unit_test/src/com/android/car/user/CarUserServiceTest.java136
-rw-r--r--tests/robotests/src/com/android/car/users/CarUserManagerHelperRoboTest.java2
79 files changed, 4817 insertions, 951 deletions
diff --git a/.gitignore b/.gitignore
index b2928471..697ef2da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
5gen/ 5gen/
6*.pyc 6*.pyc
7__pycache__ 7__pycache__
8.idea \ No newline at end of file
diff --git a/TrustAgent/res/values/strings.xml b/TrustAgent/res/values/strings.xml
index d0772621..192b7e4b 100644
--- a/TrustAgent/res/values/strings.xml
+++ b/TrustAgent/res/values/strings.xml
@@ -36,4 +36,6 @@
36 <string name="start_advertising">Start Advertising</string> 36 <string name="start_advertising">Start Advertising</string>
37 <string name="revoke_trust">Revoke Trust</string> 37 <string name="revoke_trust">Revoke Trust</string>
38 38
39 <string translatable="false" name="token_handle_shared_preferences">com.android.car.trust.TOKEN_HANDLE</string>
40
39</resources> 41</resources>
diff --git a/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java b/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java
index 227ea891..1dfbd504 100644
--- a/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java
+++ b/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java
@@ -16,27 +16,25 @@
16 16
17package com.android.car.trust; 17package com.android.car.trust;
18 18
19import android.bluetooth.BluetoothDevice; 19import android.annotation.Nullable;
20import android.bluetooth.BluetoothGattServer; 20import android.app.ActivityManager;
21import android.bluetooth.BluetoothGattServerCallback; 21import android.app.UserSwitchObserver;
22import android.bluetooth.BluetoothManager; 22import android.bluetooth.BluetoothAdapter;
23import android.car.trust.ICarTrustAgentBleService; 23import android.car.trust.ICarTrustAgentBleService;
24import android.car.trust.ICarTrustAgentTokenRequestDelegate; 24import android.car.trust.ICarTrustAgentTokenRequestDelegate;
25import android.car.trust.ICarTrustAgentUnlockCallback; 25import android.car.trust.ICarTrustAgentUnlockCallback;
26import android.content.BroadcastReceiver;
26import android.content.ComponentName; 27import android.content.ComponentName;
27import android.content.Context; 28import android.content.Context;
28import android.content.Intent; 29import android.content.Intent;
30import android.content.IntentFilter;
29import android.content.ServiceConnection; 31import android.content.ServiceConnection;
30import android.os.Handler;
31import android.os.IBinder; 32import android.os.IBinder;
32import android.os.RemoteException; 33import android.os.RemoteException;
33import android.os.UserHandle; 34import android.os.UserHandle;
34import android.os.UserManager;
35import android.service.trust.TrustAgentService; 35import android.service.trust.TrustAgentService;
36import android.util.Log; 36import android.util.Log;
37 37
38import java.util.concurrent.TimeUnit;
39
40/** 38/**
41 * A BluetoothLE (BLE) based {@link TrustAgentService} that uses the escrow token unlock APIs. </p> 39 * A BluetoothLE (BLE) based {@link TrustAgentService} that uses the escrow token unlock APIs. </p>
42 * 40 *
@@ -49,39 +47,44 @@ public class CarBleTrustAgent extends TrustAgentService {
49 47
50 private static final String TAG = CarBleTrustAgent.class.getSimpleName(); 48 private static final String TAG = CarBleTrustAgent.class.getSimpleName();
51 49
52 private static final long TRUST_DURATION_MS = TimeUnit.MINUTES.toMicros(5); 50 /**
53 private static final long BLE_RETRY_MS = TimeUnit.SECONDS.toMillis(1); 51 * {@link CarTrustAgentBleService} will callback this function when it receives both
54 52 * handle and token.
55 private Handler mHandler; 53 */
56 private BluetoothManager mBluetoothManager;
57 private ICarTrustAgentBleService mCarTrustAgentBleService;
58 private boolean mCarTrustAgentBleServiceBound;
59
60 private final ICarTrustAgentUnlockCallback mUnlockCallback = 54 private final ICarTrustAgentUnlockCallback mUnlockCallback =
61 new ICarTrustAgentUnlockCallback.Stub() { 55 new ICarTrustAgentUnlockCallback.Stub() {
62 @Override 56 @Override
63 public void onUnlockDataReceived(byte[] token, long handle) { 57 public void onUnlockDataReceived(byte[] token, long handle) throws RemoteException {
64 UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); 58 UserHandle userHandle = getUserHandleByTokenHandle(handle);
65 // TODO(b/77854782): get the actual user to unlock by token 59 if (userHandle == null) {
66 UserHandle userHandle = getForegroundUserHandle(); 60 Log.e(TAG, "Unable to find user by token handle " + handle);
67 61 return;
68 Log.d(TAG, "About to unlock user. Handle: " + handle 62 }
69 + " Time: " + System.currentTimeMillis());
70 unlockUserWithToken(handle, token, userHandle);
71
72 Log.d(TAG, "Attempted to unlock user, is user unlocked: "
73 + um.isUserUnlocked(userHandle)
74 + " Time: " + System.currentTimeMillis());
75 setManagingTrust(true);
76 63
77 if (um.isUserUnlocked(userHandle)) { 64 int uid = userHandle.getIdentifier();
78 Log.d(TAG, getString(R.string.trust_granted_explanation)); 65 if (ActivityManager.getCurrentUser() != uid) {
79 grantTrust("Granting trust from escrow token", 66 Log.d(TAG, "Switch to user: " + uid);
80 TRUST_DURATION_MS, FLAG_GRANT_TRUST_DISMISS_KEYGUARD); 67 // Try to unlock when user switch completes
68 ActivityManager.getService().registerUserSwitchObserver(
69 getUserSwitchObserver(uid, token, handle), TAG);
70 ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
71 am.switchUser(uid);
72 } else {
73 unlockUserInternally(uid, token, handle);
81 } 74 }
82 } 75 }
83 }; 76 };
84 77
78 /**
79 * Delegates the escrow token API calls from {@link CarTrustAgentBleService} to
80 * {@link TrustAgentService}. Due to the asynchronous nature, the results will be posted to
81 * {@link CarTrustAgentBleService} by the following calls
82 * <ul>
83 * <li>{@link #onEscrowTokenAdded(byte[], long, UserHandle)}</li>
84 * <li>{@link #onEscrowTokenRemoved(long, boolean)}</li>
85 * <li>{@link #onEscrowTokenStateReceived(long, int)}</li>
86 * </ul>
87 */
85 private final ICarTrustAgentTokenRequestDelegate mTokenRequestDelegate = 88 private final ICarTrustAgentTokenRequestDelegate mTokenRequestDelegate =
86 new ICarTrustAgentTokenRequestDelegate.Stub() { 89 new ICarTrustAgentTokenRequestDelegate.Stub() {
87 @Override 90 @Override
@@ -105,6 +108,9 @@ public class CarBleTrustAgent extends TrustAgentService {
105 } 108 }
106 }; 109 };
107 110
111 /**
112 * Service connection to {@link CarTrustAgentBleService}
113 */
108 private final ServiceConnection mServiceConnection = new ServiceConnection() { 114 private final ServiceConnection mServiceConnection = new ServiceConnection() {
109 @Override 115 @Override
110 public void onServiceConnected(ComponentName name, IBinder service) { 116 public void onServiceConnected(ComponentName name, IBinder service) {
@@ -114,7 +120,6 @@ public class CarBleTrustAgent extends TrustAgentService {
114 try { 120 try {
115 mCarTrustAgentBleService.registerUnlockCallback(mUnlockCallback); 121 mCarTrustAgentBleService.registerUnlockCallback(mUnlockCallback);
116 mCarTrustAgentBleService.setTokenRequestDelegate(mTokenRequestDelegate); 122 mCarTrustAgentBleService.setTokenRequestDelegate(mTokenRequestDelegate);
117 maybeStartBleUnlockService();
118 } catch (RemoteException e) { 123 } catch (RemoteException e) {
119 Log.e(TAG, "Error registerUnlockCallback", e); 124 Log.e(TAG, "Error registerUnlockCallback", e);
120 } 125 }
@@ -122,10 +127,12 @@ public class CarBleTrustAgent extends TrustAgentService {
122 127
123 @Override 128 @Override
124 public void onServiceDisconnected(ComponentName name) { 129 public void onServiceDisconnected(ComponentName name) {
130 Log.d(TAG, "CarTrustAgentBleService disconnected");
125 if (mCarTrustAgentBleService != null) { 131 if (mCarTrustAgentBleService != null) {
126 try { 132 try {
127 mCarTrustAgentBleService.unregisterUnlockCallback(mUnlockCallback); 133 mCarTrustAgentBleService.unregisterUnlockCallback(mUnlockCallback);
128 mCarTrustAgentBleService.setTokenRequestDelegate(null); 134 mCarTrustAgentBleService.setTokenRequestDelegate(null);
135 mCarTrustAgentBleService.stopUnlockAdvertising();
129 } catch (RemoteException e) { 136 } catch (RemoteException e) {
130 Log.e(TAG, "Error unregisterUnlockCallback", e); 137 Log.e(TAG, "Error unregisterUnlockCallback", e);
131 } 138 }
@@ -135,45 +142,57 @@ public class CarBleTrustAgent extends TrustAgentService {
135 } 142 }
136 }; 143 };
137 144
145 /**
146 * Receives the bluetooth state change broadcasts. Bluetooth is restarted when switching user,
147 * we need to ensure calling {@link ICarTrustAgentBleService#startUnlockAdvertising} after
148 * bluetooth is started.
149 */
150 private final BroadcastReceiver mBluetoothBroadcastReceiver = new BroadcastReceiver() {
151 @Override
152 public void onReceive(Context context, Intent intent) {
153 switch (intent.getAction()) {
154 case BluetoothAdapter.ACTION_STATE_CHANGED:
155 onBluetoothStateChanged(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1));
156 break;
157 }
158 }
159 };
160
161 private ICarTrustAgentBleService mCarTrustAgentBleService;
162 private boolean mCarTrustAgentBleServiceBound;
163
164 /**
165 * TODO: Currently it relies on {@link #onDeviceLocked()} and {@link #onDeviceUnlocked()}
166 * callback, and these callbacks won't happen if the user has unlocked once.
167 */
168 private boolean mIsOnLockScreen;
169
138 @Override 170 @Override
139 public void onCreate() { 171 public void onCreate() {
140 super.onCreate(); 172 super.onCreate();
141 173 setManagingTrust(true);
142 Log.d(TAG, "Bluetooth trust agent starting up"); 174 bindService(new Intent(this, CarTrustAgentBleService.class),
143 mHandler = new Handler(); 175 mServiceConnection, Context.BIND_AUTO_CREATE);
144 mBluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); 176 IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
145 177 registerReceiver(mBluetoothBroadcastReceiver, intentFilter);
146 // If the user is already unlocked, don't bother starting the BLE service.
147 UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
148 if (!um.isUserUnlocked(getForegroundUserHandle())) {
149 Log.d(TAG, "User locked, will now bind CarTrustAgentBleService");
150 Intent intent = new Intent(this, CarTrustAgentBleService.class);
151 bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
152 } else {
153 setManagingTrust(true);
154 }
155 } 178 }
156 179
157 @Override 180 @Override
158 public void onDestroy() { 181 public void onDestroy() {
159 Log.d(TAG, "Car Trust agent shutting down"); 182 Log.d(TAG, "Car Trust agent shutting down");
160 mHandler.removeCallbacks(null);
161
162 // Unbind the service to avoid leaks from BLE stack.
163 if (mCarTrustAgentBleServiceBound) { 183 if (mCarTrustAgentBleServiceBound) {
164 unbindService(mServiceConnection); 184 unbindService(mServiceConnection);
165 } 185 }
186 unregisterReceiver(mBluetoothBroadcastReceiver);
166 super.onDestroy(); 187 super.onDestroy();
167 } 188 }
168 189
169 @Override 190 @Override
170 public void onDeviceLocked() { 191 public void onDeviceLocked() {
171 super.onDeviceLocked(); 192 super.onDeviceLocked();
193 mIsOnLockScreen = true;
172 if (mCarTrustAgentBleServiceBound) { 194 if (mCarTrustAgentBleServiceBound) {
173 try { 195 try {
174 // Only one BLE advertising is allowed, ensure enrolment advertising is stopped
175 // before start unlock advertising.
176 mCarTrustAgentBleService.stopEnrolmentAdvertising();
177 mCarTrustAgentBleService.startUnlockAdvertising(); 196 mCarTrustAgentBleService.startUnlockAdvertising();
178 } catch (RemoteException e) { 197 } catch (RemoteException e) {
179 Log.e(TAG, "Error startUnlockAdvertising", e); 198 Log.e(TAG, "Error startUnlockAdvertising", e);
@@ -184,36 +203,47 @@ public class CarBleTrustAgent extends TrustAgentService {
184 @Override 203 @Override
185 public void onDeviceUnlocked() { 204 public void onDeviceUnlocked() {
186 super.onDeviceUnlocked(); 205 super.onDeviceUnlocked();
206 mIsOnLockScreen = false;
187 if (mCarTrustAgentBleServiceBound) { 207 if (mCarTrustAgentBleServiceBound) {
188 try { 208 try {
189 // Only one BLE advertising is allowed, ensure unlock advertising is stopped.
190 mCarTrustAgentBleService.stopUnlockAdvertising(); 209 mCarTrustAgentBleService.stopUnlockAdvertising();
191 } catch (RemoteException e) { 210 } catch (RemoteException e) {
192 Log.e(TAG, "Error stopUnlockAdvertising", e); 211 Log.e(TAG, "Error stopUnlockAdvertising", e);
193 } 212 }
194 } 213 }
214 // Revoke trust right after to enable keyguard when switching user
215 revokeTrust();
195 } 216 }
196 217
197 private void maybeStartBleUnlockService() { 218 private UserSwitchObserver getUserSwitchObserver(int uid,
198 Log.d(TAG, "Trying to open a Ble GATT server"); 219 byte[] token, long handle) {
199 BluetoothGattServer gattServer = mBluetoothManager.openGattServer( 220 return new UserSwitchObserver() {
200 this, new BluetoothGattServerCallback() { 221 @Override
222 public void onUserSwitchComplete(int newUserId) throws RemoteException {
223 if (uid != newUserId) return;
224 unlockUserInternally(uid, token, handle);
225 ActivityManager.getService().unregisterUserSwitchObserver(this);
226 }
227
201 @Override 228 @Override
202 public void onConnectionStateChange(BluetoothDevice device, int status, int newState) { 229 public void onLockedBootComplete(int newUserId) {
203 super.onConnectionStateChange(device, status, newState); 230 // ignored.
204 } 231 }
205 }); 232 };
233 }
234
235 private void unlockUserInternally(int uid, byte[] token, long handle) {
236 Log.d(TAG, "About to unlock user: " + uid);
237 unlockUserWithToken(handle, token, UserHandle.of(uid));
238 grantTrust("Granting trust from escrow token",
239 0, FLAG_GRANT_TRUST_DISMISS_KEYGUARD);
240 }
206 241
207 // The BLE stack is started up before the trust agent service, however Gatt capabilities 242 private void onBluetoothStateChanged(int state) {
208 // might not be ready just yet. Keep trying until a GattServer can open up before proceeding 243 Log.d(TAG, "onBluetoothStateChanged: " + state);
209 // to start the rest of the BLE services. 244 if ((state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON)
210 if (gattServer == null) { 245 && mCarTrustAgentBleServiceBound
211 Log.e(TAG, "Gatt not available, will try again...in " + BLE_RETRY_MS + "ms"); 246 && mIsOnLockScreen) {
212 mHandler.postDelayed(this::maybeStartBleUnlockService, BLE_RETRY_MS);
213 } else {
214 mHandler.removeCallbacks(null);
215 gattServer.close();
216 Log.d(TAG, "GATT available, starting up UnlockService");
217 try { 247 try {
218 mCarTrustAgentBleService.startUnlockAdvertising(); 248 mCarTrustAgentBleService.startUnlockAdvertising();
219 } catch (RemoteException e) { 249 } catch (RemoteException e) {
@@ -259,12 +289,15 @@ public class CarBleTrustAgent extends TrustAgentService {
259 } 289 }
260 } 290 }
261 291
262 /** 292 private @Nullable UserHandle getUserHandleByTokenHandle(long tokenHandle) {
263 * TODO(b/77854782): return the {@link UserHandle} of foreground user. 293 if (mCarTrustAgentBleServiceBound) {
264 * CarBleTrustAgent itself runs as user-0 294 try {
265 */ 295 int userId = mCarTrustAgentBleService.getUserIdByEscrowTokenHandle(tokenHandle);
266 private UserHandle getForegroundUserHandle() { 296 return userId < 0 ? null : UserHandle.of(userId);
267 Log.d(TAG, "getForegroundUserHandle for " + UserHandle.myUserId()); 297 } catch (RemoteException e) {
268 return UserHandle.of(UserHandle.myUserId()); 298 Log.e(TAG, "Error getUserHandleByTokenHandle");
299 }
300 }
301 return null;
269 } 302 }
270} 303}
diff --git a/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java b/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java
index d7160e34..4b587d14 100644
--- a/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java
+++ b/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java
@@ -46,13 +46,16 @@ public class CarEnrolmentActivity extends Activity {
46 private static final String SP_HANDLE_KEY = "sp-test"; 46 private static final String SP_HANDLE_KEY = "sp-test";
47 private static final int FINE_LOCATION_REQUEST_CODE = 42; 47 private static final int FINE_LOCATION_REQUEST_CODE = 42;
48 48
49 /**
50 * Receives escrow token callbacks, registered on {@link CarTrustAgentBleService}
51 */
49 private final ICarTrustAgentTokenResponseCallback mCarTrustAgentTokenResponseCallback = 52 private final ICarTrustAgentTokenResponseCallback mCarTrustAgentTokenResponseCallback =
50 new ICarTrustAgentTokenResponseCallback.Stub() { 53 new ICarTrustAgentTokenResponseCallback.Stub() {
51 @Override 54 @Override
52 public void onEscrowTokenAdded(byte[] token, long handle, int uid) { 55 public void onEscrowTokenAdded(byte[] token, long handle, int uid) {
53 runOnUiThread(() -> { 56 runOnUiThread(() -> {
54 mPrefs.edit().putLong(SP_HANDLE_KEY, handle).apply(); 57 mPrefs.edit().putLong(SP_HANDLE_KEY, handle).apply();
55 Log.d(TAG, "stored new handle"); 58 Log.d(TAG, "stored new handle for user: " + uid);
56 }); 59 });
57 60
58 if (mBluetoothDevice == null) { 61 if (mBluetoothDevice == null) {
@@ -81,6 +84,9 @@ public class CarEnrolmentActivity extends Activity {
81 } 84 }
82 }; 85 };
83 86
87 /**
88 * Receives BLE state change callbacks, registered on {@link CarTrustAgentBleService}
89 */
84 private final ICarTrustAgentBleCallback mBleConnectionCallback = 90 private final ICarTrustAgentBleCallback mBleConnectionCallback =
85 new ICarTrustAgentBleCallback.Stub() { 91 new ICarTrustAgentBleCallback.Stub() {
86 @Override 92 @Override
@@ -108,6 +114,12 @@ public class CarEnrolmentActivity extends Activity {
108 } 114 }
109 }; 115 };
110 116
117 /**
118 * {@link CarTrustAgentBleService} will callback this when receives enrolment data.
119 *
120 * Here is the place we can prompt to the user on HU whether or not to add this
121 * {@link #mBluetoothDevice} as a trust device.
122 */
111 private final ICarTrustAgentEnrolmentCallback mEnrolmentCallback = 123 private final ICarTrustAgentEnrolmentCallback mEnrolmentCallback =
112 new ICarTrustAgentEnrolmentCallback.Stub() { 124 new ICarTrustAgentEnrolmentCallback.Stub() {
113 @Override 125 @Override
@@ -121,6 +133,9 @@ public class CarEnrolmentActivity extends Activity {
121 } 133 }
122 }; 134 };
123 135
136 /**
137 * Service connection to {@link CarTrustAgentBleService}
138 */
124 private final ServiceConnection mServiceConnection = new ServiceConnection() { 139 private final ServiceConnection mServiceConnection = new ServiceConnection() {
125 @Override 140 @Override
126 public void onServiceConnected(ComponentName name, IBinder service) { 141 public void onServiceConnected(ComponentName name, IBinder service) {
@@ -135,6 +150,7 @@ public class CarEnrolmentActivity extends Activity {
135 } catch (RemoteException e) { 150 } catch (RemoteException e) {
136 Log.e(TAG, "Error startEnrolmentAdvertising", e); 151 Log.e(TAG, "Error startEnrolmentAdvertising", e);
137 } 152 }
153 checkTokenHandle();
138 } 154 }
139 155
140 @Override 156 @Override
@@ -169,8 +185,10 @@ public class CarEnrolmentActivity extends Activity {
169 mPrefs = PreferenceManager.getDefaultSharedPreferences(this /* context */); 185 mPrefs = PreferenceManager.getDefaultSharedPreferences(this /* context */);
170 186
171 findViewById(R.id.start_button).setOnClickListener((view) -> { 187 findViewById(R.id.start_button).setOnClickListener((view) -> {
172 Intent bindIntent = new Intent(this, CarTrustAgentBleService.class); 188 if (!mCarTrustAgentBleServiceBound) {
173 bindService(bindIntent, mServiceConnection, Context.BIND_AUTO_CREATE); 189 Intent bindIntent = new Intent(this, CarTrustAgentBleService.class);
190 bindService(bindIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
191 }
174 }); 192 });
175 193
176 findViewById(R.id.revoke_trust_button).setOnClickListener((view) -> { 194 findViewById(R.id.revoke_trust_button).setOnClickListener((view) -> {
@@ -193,33 +211,17 @@ public class CarEnrolmentActivity extends Activity {
193 requestPermissions( 211 requestPermissions(
194 new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, 212 new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION },
195 FINE_LOCATION_REQUEST_CODE); 213 FINE_LOCATION_REQUEST_CODE);
196 } else {
197 long tokenHandle = getTokenHandle();
198 if (tokenHandle != -1) {
199 Log.d(TAG, "onResume, checking handle active: " + tokenHandle);
200 if (mCarTrustAgentBleServiceBound) {
201 try {
202 // Due to the asynchronous nature of isEscrowTokenActive in
203 // TrustAgentService, query result will be delivered via
204 // {@link #mCarTrustAgentTokenResponseCallback}
205 mCarTrustAgentBleService.isEscrowTokenActive(tokenHandle,
206 UserHandle.myUserId());
207 } catch (RemoteException e) {
208 Log.e(TAG, "Error isEscrowTokenActive", e);
209 }
210 }
211 } else {
212 appendOutputText("No handles found");
213 }
214 } 214 }
215 } 215 }
216 216
217 @Override 217 @Override
218 protected void onDestroy() { 218 protected void onStop() {
219 super.onStop();
220
219 if (mCarTrustAgentBleServiceBound) { 221 if (mCarTrustAgentBleServiceBound) {
220 unbindService(mServiceConnection); 222 unbindService(mServiceConnection);
223 mCarTrustAgentBleServiceBound = false;
221 } 224 }
222 super.onDestroy();
223 } 225 }
224 226
225 private void appendOutputText(final String text) { 227 private void appendOutputText(final String text) {
@@ -234,7 +236,23 @@ public class CarEnrolmentActivity extends Activity {
234 mCarTrustAgentBleService.addEscrowToken(token, UserHandle.myUserId()); 236 mCarTrustAgentBleService.addEscrowToken(token, UserHandle.myUserId());
235 } 237 }
236 238
237 private long getTokenHandle() { 239 private void checkTokenHandle() {
238 return mPrefs.getLong(SP_HANDLE_KEY, -1); 240 long tokenHandle = mPrefs.getLong(SP_HANDLE_KEY, -1);
241 if (tokenHandle != -1) {
242 Log.d(TAG, "Checking handle active: " + tokenHandle);
243 if (mCarTrustAgentBleServiceBound) {
244 try {
245 // Due to the asynchronous nature of isEscrowTokenActive in
246 // TrustAgentService, query result will be delivered via
247 // {@link #mCarTrustAgentTokenResponseCallback}
248 mCarTrustAgentBleService.isEscrowTokenActive(tokenHandle,
249 UserHandle.myUserId());
250 } catch (RemoteException e) {
251 Log.e(TAG, "Error isEscrowTokenActive", e);
252 }
253 }
254 } else {
255 appendOutputText("No handles found");
256 }
239 } 257 }
240} 258}
diff --git a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java b/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java
index f8ba90f3..2cc20800 100644
--- a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java
+++ b/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java
@@ -25,6 +25,7 @@ import android.car.trust.ICarTrustAgentTokenRequestDelegate;
25import android.car.trust.ICarTrustAgentTokenResponseCallback; 25import android.car.trust.ICarTrustAgentTokenResponseCallback;
26import android.car.trust.ICarTrustAgentUnlockCallback; 26import android.car.trust.ICarTrustAgentUnlockCallback;
27import android.content.Intent; 27import android.content.Intent;
28import android.content.SharedPreferences;
28import android.os.IBinder; 29import android.os.IBinder;
29import android.os.ParcelUuid; 30import android.os.ParcelUuid;
30import android.os.RemoteCallbackList; 31import android.os.RemoteCallbackList;
@@ -62,6 +63,8 @@ public class CarTrustAgentBleService extends SimpleBleServer {
62 private byte[] mCurrentUnlockToken; 63 private byte[] mCurrentUnlockToken;
63 private Long mCurrentUnlockHandle; 64 private Long mCurrentUnlockHandle;
64 65
66 private SharedPreferences mTokenHandleSharedPreferences;
67
65 @Override 68 @Override
66 public void onCreate() { 69 public void onCreate() {
67 super.onCreate(); 70 super.onCreate();
@@ -72,6 +75,10 @@ public class CarTrustAgentBleService extends SimpleBleServer {
72 75
73 setupEnrolmentBleServer(); 76 setupEnrolmentBleServer();
74 setupUnlockBleServer(); 77 setupUnlockBleServer();
78
79 mTokenHandleSharedPreferences = getSharedPreferences(
80 getString(R.string.token_handle_shared_preferences),
81 MODE_PRIVATE);
75 } 82 }
76 83
77 @Override 84 @Override
@@ -260,8 +267,8 @@ public class CarTrustAgentBleService extends SimpleBleServer {
260 267
261 @Override 268 @Override
262 public void startEnrolmentAdvertising() { 269 public void startEnrolmentAdvertising() {
263 Log.d(TAG, "startEnrolmentAdvertising");
264 stopUnlockAdvertising(); 270 stopUnlockAdvertising();
271 Log.d(TAG, "startEnrolmentAdvertising");
265 startAdvertising(mEnrolmentUuid, mEnrolmentGattServer); 272 startAdvertising(mEnrolmentUuid, mEnrolmentGattServer);
266 } 273 }
267 274
@@ -290,8 +297,8 @@ public class CarTrustAgentBleService extends SimpleBleServer {
290 297
291 @Override 298 @Override
292 public void startUnlockAdvertising() { 299 public void startUnlockAdvertising() {
293 Log.d(TAG, "startUnlockAdvertising");
294 stopEnrolmentAdvertising(); 300 stopEnrolmentAdvertising();
301 Log.d(TAG, "startUnlockAdvertising");
295 startAdvertising(mUnlockUuid, mUnlockGattServer); 302 startAdvertising(mUnlockUuid, mUnlockGattServer);
296 } 303 }
297 304
@@ -353,6 +360,9 @@ public class CarTrustAgentBleService extends SimpleBleServer {
353 public void onEscrowTokenAdded(byte[] token, long handle, int uid) 360 public void onEscrowTokenAdded(byte[] token, long handle, int uid)
354 throws RemoteException { 361 throws RemoteException {
355 Log.d(TAG, "onEscrowTokenAdded handle:" + handle + " uid:" + uid); 362 Log.d(TAG, "onEscrowTokenAdded handle:" + handle + " uid:" + uid);
363 mTokenHandleSharedPreferences.edit()
364 .putInt(String.valueOf(handle), uid)
365 .apply();
356 if (mTokenResponseCallback != null) { 366 if (mTokenResponseCallback != null) {
357 mTokenResponseCallback.onEscrowTokenAdded(token, handle, uid); 367 mTokenResponseCallback.onEscrowTokenAdded(token, handle, uid);
358 } 368 }
@@ -361,6 +371,9 @@ public class CarTrustAgentBleService extends SimpleBleServer {
361 @Override 371 @Override
362 public void onEscrowTokenRemoved(long handle, boolean successful) throws RemoteException { 372 public void onEscrowTokenRemoved(long handle, boolean successful) throws RemoteException {
363 Log.d(TAG, "onEscrowTokenRemoved handle:" + handle); 373 Log.d(TAG, "onEscrowTokenRemoved handle:" + handle);
374 mTokenHandleSharedPreferences.edit()
375 .remove(String.valueOf(handle))
376 .apply();
364 if (mTokenResponseCallback != null) { 377 if (mTokenResponseCallback != null) {
365 mTokenResponseCallback.onEscrowTokenRemoved(handle, successful); 378 mTokenResponseCallback.onEscrowTokenRemoved(handle, successful);
366 } 379 }
@@ -373,5 +386,10 @@ public class CarTrustAgentBleService extends SimpleBleServer {
373 mTokenResponseCallback.onEscrowTokenActiveStateChanged(handle, active); 386 mTokenResponseCallback.onEscrowTokenActiveStateChanged(handle, active);
374 } 387 }
375 } 388 }
389
390 @Override
391 public int getUserIdByEscrowTokenHandle(long tokenHandle) {
392 return mTokenHandleSharedPreferences.getInt(String.valueOf(tokenHandle), -1);
393 }
376 } 394 }
377} 395}
diff --git a/car-lib/api/current.txt b/car-lib/api/current.txt
index 9cd2e4c3..57975a2c 100644
--- a/car-lib/api/current.txt
+++ b/car-lib/api/current.txt
@@ -73,6 +73,126 @@ package android.car {
73 ctor public CarNotConnectedException(java.lang.Exception); 73 ctor public CarNotConnectedException(java.lang.Exception);
74 } 74 }
75 75
76 public final class VehiclePropertyIds {
77 ctor public VehiclePropertyIds();
78 method public static java.lang.String toString(int);
79 field public static final int ABS_ACTIVE = 287310858; // 0x1120040a
80 field public static final int AP_POWER_BOOTUP_REASON = 289409538; // 0x11400a02
81 field public static final int AP_POWER_STATE_REPORT = 289475073; // 0x11410a01
82 field public static final int AP_POWER_STATE_REQ = 289475072; // 0x11410a00
83 field public static final int CURRENT_GEAR = 289408001; // 0x11400401
84 field public static final int DISPLAY_BRIGHTNESS = 289409539; // 0x11400a03
85 field public static final int DOOR_LOCK = 371198722; // 0x16200b02
86 field public static final int DOOR_MOVE = 373295873; // 0x16400b01
87 field public static final int DOOR_POS = 373295872; // 0x16400b00
88 field public static final int ENGINE_COOLANT_TEMP = 291504897; // 0x11600301
89 field public static final int ENGINE_OIL_LEVEL = 289407747; // 0x11400303
90 field public static final int ENGINE_OIL_TEMP = 291504900; // 0x11600304
91 field public static final int ENGINE_RPM = 291504901; // 0x11600305
92 field public static final int ENV_OUTSIDE_TEMPERATURE = 291505923; // 0x11600703
93 field public static final int EV_BATTERY_INSTANTANEOUS_CHARGE_RATE = 291504908; // 0x1160030c
94 field public static final int EV_BATTERY_LEVEL = 291504905; // 0x11600309
95 field public static final int EV_CHARGE_PORT_CONNECTED = 287310603; // 0x1120030b
96 field public static final int EV_CHARGE_PORT_OPEN = 287310602; // 0x1120030a
97 field public static final int FOG_LIGHTS_STATE = 289410562; // 0x11400e02
98 field public static final int FOG_LIGHTS_SWITCH = 289410578; // 0x11400e12
99 field public static final int FUEL_DOOR_OPEN = 287310600; // 0x11200308
100 field public static final int FUEL_LEVEL = 291504903; // 0x11600307
101 field public static final int FUEL_LEVEL_LOW = 287310853; // 0x11200405
102 field public static final int GEAR_SELECTION = 289408000; // 0x11400400
103 field public static final int HAZARD_LIGHTS_STATE = 289410563; // 0x11400e03
104 field public static final int HAZARD_LIGHTS_SWITCH = 289410579; // 0x11400e13
105 field public static final int HEADLIGHTS_STATE = 289410560; // 0x11400e00
106 field public static final int HEADLIGHTS_SWITCH = 289410576; // 0x11400e10
107 field public static final int HIGH_BEAM_LIGHTS_STATE = 289410561; // 0x11400e01
108 field public static final int HIGH_BEAM_LIGHTS_SWITCH = 289410577; // 0x11400e11
109 field public static final int HVAC_ACTUAL_FAN_SPEED_RPM = 356517135; // 0x1540050f
110 field public static final int HVAC_AC_ON = 354419973; // 0x15200505
111 field public static final int HVAC_AUTO_ON = 354419978; // 0x1520050a
112 field public static final int HVAC_AUTO_RECIRC_ON = 354419986; // 0x15200512
113 field public static final int HVAC_DEFROSTER = 320865540; // 0x13200504
114 field public static final int HVAC_DUAL_ON = 354419977; // 0x15200509
115 field public static final int HVAC_FAN_DIRECTION = 356517121; // 0x15400501
116 field public static final int HVAC_FAN_DIRECTION_AVAILABLE = 356582673; // 0x15410511
117 field public static final int HVAC_FAN_SPEED = 356517120; // 0x15400500
118 field public static final int HVAC_MAX_AC_ON = 354419974; // 0x15200506
119 field public static final int HVAC_MAX_DEFROST_ON = 354419975; // 0x15200507
120 field public static final int HVAC_POWER_ON = 354419984; // 0x15200510
121 field public static final int HVAC_RECIRC_ON = 354419976; // 0x15200508
122 field public static final int HVAC_SEAT_TEMPERATURE = 356517131; // 0x1540050b
123 field public static final int HVAC_SEAT_VENTILATION = 356517139; // 0x15400513
124 field public static final int HVAC_SIDE_MIRROR_HEAT = 339739916; // 0x1440050c
125 field public static final int HVAC_STEERING_WHEEL_HEAT = 289408269; // 0x1140050d
126 field public static final int HVAC_TEMPERATURE_CURRENT = 358614274; // 0x15600502
127 field public static final int HVAC_TEMPERATURE_DISPLAY_UNITS = 289408270; // 0x1140050e
128 field public static final int HVAC_TEMPERATURE_SET = 358614275; // 0x15600503
129 field public static final int HW_KEY_INPUT = 289475088; // 0x11410a10
130 field public static final int IGNITION_STATE = 289408009; // 0x11400409
131 field public static final int INFO_DRIVER_SEAT = 356516106; // 0x1540010a
132 field public static final int INFO_EV_BATTERY_CAPACITY = 291504390; // 0x11600106
133 field public static final int INFO_EV_CONNECTOR_TYPE = 289472775; // 0x11410107
134 field public static final int INFO_EV_PORT_LOCATION = 289407241; // 0x11400109
135 field public static final int INFO_FUEL_CAPACITY = 291504388; // 0x11600104
136 field public static final int INFO_FUEL_DOOR_LOCATION = 289407240; // 0x11400108
137 field public static final int INFO_FUEL_TYPE = 289472773; // 0x11410105
138 field public static final int INFO_MAKE = 286261505; // 0x11100101
139 field public static final int INFO_MODEL = 286261506; // 0x11100102
140 field public static final int INFO_MODEL_YEAR = 289407235; // 0x11400103
141 field public static final int INFO_VIN = 286261504; // 0x11100100
142 field public static final int INVALID = 0; // 0x0
143 field public static final int MIRROR_FOLD = 287312709; // 0x11200b45
144 field public static final int MIRROR_LOCK = 287312708; // 0x11200b44
145 field public static final int MIRROR_Y_MOVE = 339741507; // 0x14400b43
146 field public static final int MIRROR_Y_POS = 339741506; // 0x14400b42
147 field public static final int MIRROR_Z_MOVE = 339741505; // 0x14400b41
148 field public static final int MIRROR_Z_POS = 339741504; // 0x14400b40
149 field public static final int NIGHT_MODE = 287310855; // 0x11200407
150 field public static final int OBD2_FREEZE_FRAME = 299896065; // 0x11e00d01
151 field public static final int OBD2_FREEZE_FRAME_CLEAR = 299896067; // 0x11e00d03
152 field public static final int OBD2_FREEZE_FRAME_INFO = 299896066; // 0x11e00d02
153 field public static final int OBD2_LIVE_FRAME = 299896064; // 0x11e00d00
154 field public static final int PARKING_BRAKE_AUTO_APPLY = 287310851; // 0x11200403
155 field public static final int PARKING_BRAKE_ON = 287310850; // 0x11200402
156 field public static final int PERF_ODOMETER = 291504644; // 0x11600204
157 field public static final int PERF_VEHICLE_SPEED = 291504647; // 0x11600207
158 field public static final int RANGE_REMAINING = 291504904; // 0x11600308
159 field public static final int SEAT_BACKREST_ANGLE_1_MOVE = 356518792; // 0x15400b88
160 field public static final int SEAT_BACKREST_ANGLE_1_POS = 356518791; // 0x15400b87
161 field public static final int SEAT_BACKREST_ANGLE_2_MOVE = 356518794; // 0x15400b8a
162 field public static final int SEAT_BACKREST_ANGLE_2_POS = 356518793; // 0x15400b89
163 field public static final int SEAT_BELT_BUCKLED = 354421634; // 0x15200b82
164 field public static final int SEAT_BELT_HEIGHT_MOVE = 356518788; // 0x15400b84
165 field public static final int SEAT_BELT_HEIGHT_POS = 356518787; // 0x15400b83
166 field public static final int SEAT_DEPTH_MOVE = 356518798; // 0x15400b8e
167 field public static final int SEAT_DEPTH_POS = 356518797; // 0x15400b8d
168 field public static final int SEAT_FORE_AFT_MOVE = 356518790; // 0x15400b86
169 field public static final int SEAT_FORE_AFT_POS = 356518789; // 0x15400b85
170 field public static final int SEAT_HEADREST_ANGLE_MOVE = 356518808; // 0x15400b98
171 field public static final int SEAT_HEADREST_ANGLE_POS = 356518807; // 0x15400b97
172 field public static final int SEAT_HEADREST_FORE_AFT_MOVE = 356518810; // 0x15400b9a
173 field public static final int SEAT_HEADREST_FORE_AFT_POS = 356518809; // 0x15400b99
174 field public static final int SEAT_HEADREST_HEIGHT_MOVE = 356518806; // 0x15400b96
175 field public static final int SEAT_HEADREST_HEIGHT_POS = 289409941; // 0x11400b95
176 field public static final int SEAT_HEIGHT_MOVE = 356518796; // 0x15400b8c
177 field public static final int SEAT_HEIGHT_POS = 356518795; // 0x15400b8b
178 field public static final int SEAT_LUMBAR_FORE_AFT_MOVE = 356518802; // 0x15400b92
179 field public static final int SEAT_LUMBAR_FORE_AFT_POS = 356518801; // 0x15400b91
180 field public static final int SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 356518804; // 0x15400b94
181 field public static final int SEAT_LUMBAR_SIDE_SUPPORT_POS = 356518803; // 0x15400b93
182 field public static final int SEAT_MEMORY_SELECT = 356518784; // 0x15400b80
183 field public static final int SEAT_MEMORY_SET = 356518785; // 0x15400b81
184 field public static final int SEAT_TILT_MOVE = 356518800; // 0x15400b90
185 field public static final int SEAT_TILT_POS = 356518799; // 0x15400b8f
186 field public static final int TIRE_PRESSURE = 392168201; // 0x17600309
187 field public static final int TRACTION_CONTROL_ACTIVE = 287310859; // 0x1120040b
188 field public static final int TURN_SIGNAL_STATE = 289408008; // 0x11400408
189 field public static final int VEHICLE_MAP_SERVICE = 299895808; // 0x11e00c00
190 field public static final int WHEEL_TICK = 290521862; // 0x11510306
191 field public static final int WINDOW_LOCK = 320867268; // 0x13200bc4
192 field public static final int WINDOW_MOVE = 322964417; // 0x13400bc1
193 field public static final int WINDOW_POS = 322964416; // 0x13400bc0
194 }
195
76} 196}
77 197
78package android.car.app.menu { 198package android.car.app.menu {
@@ -265,7 +385,6 @@ package android.car.hardware {
265 field public static final int IGNITION_STATE_ON = 4; // 0x4 385 field public static final int IGNITION_STATE_ON = 4; // 0x4
266 field public static final int IGNITION_STATE_START = 5; // 0x5 386 field public static final int IGNITION_STATE_START = 5; // 0x5
267 field public static final int IGNITION_STATE_UNDEFINED = 0; // 0x0 387 field public static final int IGNITION_STATE_UNDEFINED = 0; // 0x0
268 field public static final int INDEX_ENVIRONMENT_PRESSURE = 1; // 0x1
269 field public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0; // 0x0 388 field public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0; // 0x0
270 field public static final int INDEX_WHEEL_DISTANCE_FRONT_LEFT = 1; // 0x1 389 field public static final int INDEX_WHEEL_DISTANCE_FRONT_LEFT = 1; // 0x1
271 field public static final int INDEX_WHEEL_DISTANCE_FRONT_RIGHT = 2; // 0x2 390 field public static final int INDEX_WHEEL_DISTANCE_FRONT_RIGHT = 2; // 0x2
@@ -280,7 +399,6 @@ package android.car.hardware {
280 } 399 }
281 400
282 public static class CarSensorEvent.EnvironmentData { 401 public static class CarSensorEvent.EnvironmentData {
283 field public float pressure;
284 field public float temperature; 402 field public float temperature;
285 field public long timestamp; 403 field public long timestamp;
286 } 404 }
@@ -300,7 +418,7 @@ package android.car.hardware {
300 field public static final int SENSOR_RATE_UI = 5; // 0x5 418 field public static final int SENSOR_RATE_UI = 5; // 0x5
301 field public static final int SENSOR_TYPE_ABS_ACTIVE = 287310858; // 0x1120040a 419 field public static final int SENSOR_TYPE_ABS_ACTIVE = 287310858; // 0x1120040a
302 field public static final int SENSOR_TYPE_CAR_SPEED = 291504647; // 0x11600207 420 field public static final int SENSOR_TYPE_CAR_SPEED = 291504647; // 0x11600207
303 field public static final int SENSOR_TYPE_ENVIRONMENT = 12; // 0xc 421 field public static final int SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE = 291505923; // 0x11600703
304 field public static final int SENSOR_TYPE_EV_BATTERY_CHARGE_RATE = 291504908; // 0x1160030c 422 field public static final int SENSOR_TYPE_EV_BATTERY_CHARGE_RATE = 291504908; // 0x1160030c
305 field public static final int SENSOR_TYPE_EV_BATTERY_LEVEL = 291504905; // 0x11600309 423 field public static final int SENSOR_TYPE_EV_BATTERY_LEVEL = 291504905; // 0x11600309
306 field public static final int SENSOR_TYPE_EV_CHARGE_PORT_CONNECTED = 287310603; // 0x1120030b 424 field public static final int SENSOR_TYPE_EV_CHARGE_PORT_CONNECTED = 287310603; // 0x1120030b
diff --git a/car-lib/api/system-current.txt b/car-lib/api/system-current.txt
index d6119326..df6b85ed 100644
--- a/car-lib/api/system-current.txt
+++ b/car-lib/api/system-current.txt
@@ -5,7 +5,6 @@ package android.car {
5 field public static final java.lang.String CAR_DRIVING_STATE_SERVICE = "drivingstate"; 5 field public static final java.lang.String CAR_DRIVING_STATE_SERVICE = "drivingstate";
6 field public static final java.lang.String DIAGNOSTIC_SERVICE = "diagnostic"; 6 field public static final java.lang.String DIAGNOSTIC_SERVICE = "diagnostic";
7 field public static final java.lang.String HVAC_SERVICE = "hvac"; 7 field public static final java.lang.String HVAC_SERVICE = "hvac";
8 field public static final java.lang.String PERMISSION_ADJUST_CAR_CABIN = "android.car.permission.ADJUST_CAR_CABIN";
9 field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_CLEAR = "android.car.permission.CLEAR_CAR_DIAGNOSTICS"; 8 field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_CLEAR = "android.car.permission.CLEAR_CAR_DIAGNOSTICS";
10 field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_READ_ALL = "android.car.permission.CAR_DIAGNOSTICS"; 9 field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_READ_ALL = "android.car.permission.CAR_DIAGNOSTICS";
11 field public static final java.lang.String PERMISSION_CAR_DRIVING_STATE = "android.car.permission.CAR_DRIVING_STATE"; 10 field public static final java.lang.String PERMISSION_CAR_DRIVING_STATE = "android.car.permission.CAR_DRIVING_STATE";
@@ -112,6 +111,13 @@ package android.car {
112 field public static final int WINDOW_ROW_3_RIGHT = 16384; // 0x4000 111 field public static final int WINDOW_ROW_3_RIGHT = 16384; // 0x4000
113 } 112 }
114 113
114 public final class VehiclePropertyAccess {
115 field public static final int NONE = 0; // 0x0
116 field public static final int READ = 1; // 0x1
117 field public static final int READ_WRITE = 3; // 0x3
118 field public static final int WRITE = 2; // 0x2
119 }
120
115} 121}
116 122
117package android.car.cluster { 123package android.car.cluster {
diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java
index 738a4238..c1bf5027 100644
--- a/car-lib/src/android/car/Car.java
+++ b/car-lib/src/android/car/Car.java
@@ -281,14 +281,6 @@ public final class Car {
281 "android.car.permission.CONTROL_APP_BLOCKING"; 281 "android.car.permission.CONTROL_APP_BLOCKING";
282 282
283 /** 283 /**
284 * Permission necessary to access Car Cabin APIs.
285 * @hide
286 */
287 @SystemApi
288 public static final String PERMISSION_ADJUST_CAR_CABIN =
289 "android.car.permission.ADJUST_CAR_CABIN";
290
291 /**
292 * Permission necessary to access car's engine information. 284 * Permission necessary to access car's engine information.
293 * @hide 285 * @hide
294 */ 286 */
diff --git a/car-lib/src/android/car/CarInfoManager.java b/car-lib/src/android/car/CarInfoManager.java
index b228ca7c..d90883b6 100644
--- a/car-lib/src/android/car/CarInfoManager.java
+++ b/car-lib/src/android/car/CarInfoManager.java
@@ -16,16 +16,12 @@
16 16
17package android.car; 17package android.car;
18 18
19import static java.lang.Integer.toHexString;
20
21import android.annotation.Nullable; 19import android.annotation.Nullable;
22import android.car.annotation.ValueTypeDef; 20import android.car.annotation.ValueTypeDef;
23import android.car.hardware.CarPropertyValue; 21import android.car.hardware.CarPropertyValue;
24import android.car.hardware.property.ICarProperty; 22import android.car.hardware.property.CarPropertyManager;
25import android.os.Bundle; 23import android.os.Bundle;
26import android.os.IBinder; 24import android.os.IBinder;
27import android.os.RemoteException;
28import android.util.Log;
29 25
30 26
31/** 27/**
@@ -36,6 +32,7 @@ public final class CarInfoManager implements CarManagerBase{
36 32
37 private static final boolean DBG = false; 33 private static final boolean DBG = false;
38 private static final String TAG = "CarInfoManager"; 34 private static final String TAG = "CarInfoManager";
35 private final CarPropertyManager mCarPropertyMgr;
39 /** 36 /**
40 * Key for manufacturer of the car. Passed in basic info Bundle. 37 * Key for manufacturer of the car. Passed in basic info Bundle.
41 * @hide 38 * @hide
@@ -112,17 +109,15 @@ public final class CarInfoManager implements CarManagerBase{
112 * Passed in basic info Bundle. 109 * Passed in basic info Bundle.
113 * @hide 110 * @hide
114 */ 111 */
115 @ValueTypeDef(type = Integer.class) 112 @ValueTypeDef(type = Integer[].class)
116 public static final int BASIC_INFO_EV_CONNECTOR_TYPES = 0x11410107; 113 public static final int BASIC_INFO_EV_CONNECTOR_TYPES = 0x11410107;
117 114
118 private final ICarProperty mService;
119
120 /** 115 /**
121 * @return Manufacturer of the car. Null if not available. 116 * @return Manufacturer of the car. Null if not available.
122 */ 117 */
123 @Nullable 118 @Nullable
124 public String getManufacturer() throws CarNotConnectedException { 119 public String getManufacturer() throws CarNotConnectedException {
125 CarPropertyValue<String> carProp = getProperty(String.class, 120 CarPropertyValue<String> carProp = mCarPropertyMgr.getProperty(String.class,
126 BASIC_INFO_KEY_MANUFACTURER, 0); 121 BASIC_INFO_KEY_MANUFACTURER, 0);
127 return carProp != null ? carProp.getValue() : null; 122 return carProp != null ? carProp.getValue() : null;
128 } 123 }
@@ -134,7 +129,8 @@ public final class CarInfoManager implements CarManagerBase{
134 */ 129 */
135 @Nullable 130 @Nullable
136 public String getModel() throws CarNotConnectedException { 131 public String getModel() throws CarNotConnectedException {
137 CarPropertyValue<String> carProp = getProperty(String.class, BASIC_INFO_KEY_MODEL, 0); 132 CarPropertyValue<String> carProp = mCarPropertyMgr.getProperty(
133 String.class, BASIC_INFO_KEY_MODEL, 0);
138 return carProp != null ? carProp.getValue() : null; 134 return carProp != null ? carProp.getValue() : null;
139 } 135 }
140 136
@@ -143,7 +139,7 @@ public final class CarInfoManager implements CarManagerBase{
143 */ 139 */
144 @Nullable 140 @Nullable
145 public String getModelYear() throws CarNotConnectedException { 141 public String getModelYear() throws CarNotConnectedException {
146 CarPropertyValue<String> carProp = getProperty(String.class, 142 CarPropertyValue<String> carProp = mCarPropertyMgr.getProperty(String.class,
147 BASIC_INFO_KEY_MODEL_YEAR, 0); 143 BASIC_INFO_KEY_MODEL_YEAR, 0);
148 return carProp != null ? carProp.getValue() : null; 144 return carProp != null ? carProp.getValue() : null;
149 } 145 }
@@ -163,7 +159,7 @@ public final class CarInfoManager implements CarManagerBase{
163 * fuel. 159 * fuel.
164 */ 160 */
165 public float getFuelCapacity() throws CarNotConnectedException { 161 public float getFuelCapacity() throws CarNotConnectedException {
166 CarPropertyValue<Float> carProp = getProperty(Float.class, 162 CarPropertyValue<Float> carProp = mCarPropertyMgr.getProperty(Float.class,
167 BASIC_INFO_FUEL_CAPACITY, 0); 163 BASIC_INFO_FUEL_CAPACITY, 0);
168 return carProp != null ? carProp.getValue() : 0f; 164 return carProp != null ? carProp.getValue() : 0f;
169 } 165 }
@@ -173,8 +169,7 @@ public final class CarInfoManager implements CarManagerBase{
173 * types available. 169 * types available.
174 */ 170 */
175 public @FuelType.Enum int[] getFuelTypes() throws CarNotConnectedException { 171 public @FuelType.Enum int[] getFuelTypes() throws CarNotConnectedException {
176 CarPropertyValue<int[]> carProp = getProperty(int[].class, BASIC_INFO_FUEL_TYPES, 0); 172 return mCarPropertyMgr.getIntArrayProperty(BASIC_INFO_FUEL_TYPES, 0);
177 return carProp != null ? carProp.getValue() : new int[0];
178 } 173 }
179 174
180 /** 175 /**
@@ -182,7 +177,7 @@ public final class CarInfoManager implements CarManagerBase{
182 * battery. 177 * battery.
183 */ 178 */
184 public float getEvBatteryCapacity() throws CarNotConnectedException { 179 public float getEvBatteryCapacity() throws CarNotConnectedException {
185 CarPropertyValue<Float> carProp = getProperty(Float.class, 180 CarPropertyValue<Float> carProp = mCarPropertyMgr.getProperty(Float.class,
186 BASIC_INFO_EV_BATTERY_CAPACITY, 0); 181 BASIC_INFO_EV_BATTERY_CAPACITY, 0);
187 return carProp != null ? carProp.getValue() : 0f; 182 return carProp != null ? carProp.getValue() : 0f;
188 } 183 }
@@ -192,42 +187,17 @@ public final class CarInfoManager implements CarManagerBase{
192 * no connector types available. 187 * no connector types available.
193 */ 188 */
194 public @EvConnectorType.Enum int[] getEvConnectorTypes() throws CarNotConnectedException { 189 public @EvConnectorType.Enum int[] getEvConnectorTypes() throws CarNotConnectedException {
195 CarPropertyValue<int[]> carProp = getProperty(int[].class, 190 return mCarPropertyMgr.getIntArrayProperty(BASIC_INFO_EV_CONNECTOR_TYPES, 0);
196 BASIC_INFO_EV_CONNECTOR_TYPES, 0);
197 return carProp != null ? carProp.getValue() : new int[0];
198 } 191 }
199 192
200 /** @hide */ 193 /** @hide */
201 CarInfoManager(IBinder service) { 194 CarInfoManager(IBinder service) {
202 mService = ICarProperty.Stub.asInterface(service); 195 mCarPropertyMgr = new CarPropertyManager(service, null, DBG, TAG);
203 } 196 }
204 197
205 /** @hide */ 198 /** @hide */
206 public void onCarDisconnected() { 199 public void onCarDisconnected() {
200 mCarPropertyMgr.onCarDisconnected();
207 } 201 }
208 202
209 private <E> CarPropertyValue<E> getProperty(Class<E> clazz, int propId, int area)
210 throws CarNotConnectedException {
211 if (DBG) {
212 Log.d(TAG, "getProperty, propId: 0x" + toHexString(propId)
213 + ", area: 0x" + toHexString(area) + ", class: " + clazz);
214 }
215 try {
216 CarPropertyValue<E> propVal = mService.getProperty(propId, area);
217 if (propVal != null && propVal.getValue() != null) {
218 Class<?> actualClass = propVal.getValue().getClass();
219 if (actualClass != clazz) {
220 throw new IllegalArgumentException("Invalid property type. " + "Expected: "
221 + clazz + ", but was: " + actualClass);
222 }
223 }
224 return propVal;
225 } catch (RemoteException e) {
226 Log.e(TAG, "getProperty failed with " + e.toString()
227 + ", propId: 0x" + toHexString(propId) + ", area: 0x" + toHexString(area), e);
228 throw new CarNotConnectedException(e);
229 } catch (IllegalArgumentException e) {
230 return null;
231 }
232 }
233} 203}
diff --git a/car-lib/src/android/car/PortLocationType.java b/car-lib/src/android/car/PortLocationType.java
new file mode 100644
index 00000000..3006a296
--- /dev/null
+++ b/car-lib/src/android/car/PortLocationType.java
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2018 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 */
16package android.car;
17
18/**
19 * Used by INFO_FUEL_DOOR_LOCATION/INFO_CHARGE_PORT_LOCATION to enumerate fuel door or
20 * ev port location.
21 * Use getProperty and setProperty in {@link android.car.hardware.property.CarPropertyManager} to
22 * set and get this VHAL property.
23 * @hide
24 */
25public final class PortLocationType {
26 public static final int UNKNOWN = 0;
27 public static final int FRONT_LEFT = 1;
28 public static final int FRONT_RIGHT = 2;
29 public static final int REAR_RIGHT = 3;
30 public static final int REAR_LEFT = 4;
31 public static final int FRONT = 5;
32 public static final int REAR = 6;
33
34 private PortLocationType() {}
35}
diff --git a/car-lib/src/android/car/VehicleLightState.java b/car-lib/src/android/car/VehicleLightState.java
new file mode 100644
index 00000000..55f74f9e
--- /dev/null
+++ b/car-lib/src/android/car/VehicleLightState.java
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2018 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 */
16package android.car;
17
18/**
19 * Used by Lights state properties to enumerate the current state of the lights.
20 * Use getProperty and setProperty in {@link android.car.hardware.property.CarPropertyManager} to
21 * set and get this VHAL property.
22 * @hide
23 */
24public final class VehicleLightState {
25 public static final int OFF = 0;
26 public static final int ON = 1;
27 public static final int DAYTIME_RUNNING = 2;
28
29 private VehicleLightState() {}
30
31}
diff --git a/car-lib/src/android/car/VehicleLightSwitch.java b/car-lib/src/android/car/VehicleLightSwitch.java
new file mode 100644
index 00000000..03780bb6
--- /dev/null
+++ b/car-lib/src/android/car/VehicleLightSwitch.java
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2018 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 */
16package android.car;
17
18/**
19 * Used by lights switch properties to enumerate user selected switch setting.
20 * Use getProperty and setProperty in {@link android.car.hardware.property.CarPropertyManager} to
21 * set and get this VHAL property.
22 * @hide
23 */
24public final class VehicleLightSwitch {
25 public static final int OFF = 0;
26 public static final int ON = 1;
27 public static final int DAYTIME_RUNNING = 2;
28 public static final int AUTOMATIC = 0x100;
29
30 private VehicleLightSwitch() {}
31}
diff --git a/car-lib/src/android/car/VehiclePropertyAccess.java b/car-lib/src/android/car/VehiclePropertyAccess.java
new file mode 100644
index 00000000..22801de4
--- /dev/null
+++ b/car-lib/src/android/car/VehiclePropertyAccess.java
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2018 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 */
16package android.car;
17
18import android.annotation.SystemApi;
19
20/**
21 * Define value for getAccess() in {@link android.car.hardware.CarPropertyConfig}
22 * @hide
23 */
24@SystemApi
25public final class VehiclePropertyAccess {
26 /**
27 * List of VehiclePropertyAccess from VHAL
28 */
29 public static final int NONE = 0x00;
30 public static final int READ = 0x01;
31 public static final int WRITE = 0x02;
32 public static final int READ_WRITE = 0x03;
33
34 private VehiclePropertyAccess() {}
35}
diff --git a/car-lib/src/android/car/VehiclePropertyIds.java b/car-lib/src/android/car/VehiclePropertyIds.java
new file mode 100644
index 00000000..12d2698d
--- /dev/null
+++ b/car-lib/src/android/car/VehiclePropertyIds.java
@@ -0,0 +1,888 @@
1/*
2 * Copyright (C) 2018 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
17package android.car;
18
19/**
20 * Copy from android.hardware.automotive.vehicle-V2.0-java_gen_java/gen/android/hardware/automotive
21 * /vehicle/V2_0. Need to update this file when vehicle propertyId is changed in VHAL.
22 * Use it as PorpertyId in getProperty() and setProperty() in
23 * {@link android.car.hardware.property.CarPropertyManager}
24 */
25public final class VehiclePropertyIds {
26 /**
27 * Undefined property. */
28 public static final int INVALID = 0;
29 /**
30 * VIN of vehicle
31 */
32 public static final int INFO_VIN = 286261504;
33 /**
34 * Manufacturer of vehicle
35 */
36 public static final int INFO_MAKE = 286261505;
37 /**
38 * Model of vehicle
39 */
40 public static final int INFO_MODEL = 286261506;
41 /**
42 * Model year of vehicle.
43 */
44 public static final int INFO_MODEL_YEAR = 289407235;
45 /**
46 * Fuel capacity of the vehicle in milliliters
47 */
48 public static final int INFO_FUEL_CAPACITY = 291504388;
49 /**
50 * List of fuels the vehicle may use
51 */
52 public static final int INFO_FUEL_TYPE = 289472773;
53 /**
54 * Battery capacity of the vehicle, if EV or hybrid. This is the nominal
55 * battery capacity when the vehicle is new.
56 */
57 public static final int INFO_EV_BATTERY_CAPACITY = 291504390;
58 /**
59 * List of connectors this EV may use
60 */
61 public static final int INFO_EV_CONNECTOR_TYPE = 289472775;
62 /**
63 * Fuel door location
64 */
65 public static final int INFO_FUEL_DOOR_LOCATION = 289407240;
66 /**
67 * EV port location
68 */
69 public static final int INFO_EV_PORT_LOCATION = 289407241;
70 /**
71 * Driver's seat location
72 */
73 public static final int INFO_DRIVER_SEAT = 356516106;
74 /**
75 * Current odometer value of the vehicle
76 */
77 public static final int PERF_ODOMETER = 291504644;
78 /**
79 * Speed of the vehicle
80 */
81 public static final int PERF_VEHICLE_SPEED = 291504647;
82 /**
83 * Temperature of engine coolant
84 */
85 public static final int ENGINE_COOLANT_TEMP = 291504897;
86 /**
87 * Engine oil level
88 */
89 public static final int ENGINE_OIL_LEVEL = 289407747;
90 /**
91 * Temperature of engine oil
92 */
93 public static final int ENGINE_OIL_TEMP = 291504900;
94 /**
95 * Engine rpm
96 */
97 public static final int ENGINE_RPM = 291504901;
98 /**
99 * Reports wheel ticks
100 */
101 public static final int WHEEL_TICK = 290521862;
102 /**
103 * Fuel remaining in the the vehicle, in milliliters
104 */
105 public static final int FUEL_LEVEL = 291504903;
106 /**
107 * Fuel door open
108 */
109 public static final int FUEL_DOOR_OPEN = 287310600;
110 /**
111 * EV battery level in WH, if EV or hybrid
112 */
113 public static final int EV_BATTERY_LEVEL = 291504905;
114 /**
115 * EV charge port open
116 */
117 public static final int EV_CHARGE_PORT_OPEN = 287310602;
118 /**
119 * EV charge port connected
120 */
121 public static final int EV_CHARGE_PORT_CONNECTED = 287310603;
122 /**
123 * EV instantaneous charge rate in milliwatts
124 */
125 public static final int EV_BATTERY_INSTANTANEOUS_CHARGE_RATE = 291504908;
126 /**
127 * Range remaining
128 */
129 public static final int RANGE_REMAINING = 291504904;
130 /**
131 * Tire pressure
132 *
133 * min/max value indicates tire pressure sensor range. Each tire will have a separate min/max
134 * value denoted by its areaConfig.areaId.
135 */
136 public static final int TIRE_PRESSURE = 392168201;
137 /**
138 * Currently selected gear
139 *
140 * This is the gear selected by the user.
141 */
142 public static final int GEAR_SELECTION = 289408000;
143 /**
144 * Current gear. In non-manual case, selected gear may not
145 * match the current gear. For example, if the selected gear is GEAR_DRIVE,
146 * the current gear will be one of GEAR_1, GEAR_2 etc, which reflects
147 * the actual gear the transmission is currently running in.
148 */
149 public static final int CURRENT_GEAR = 289408001;
150 /**
151 * Parking brake state.
152 */
153 public static final int PARKING_BRAKE_ON = 287310850;
154 /**
155 * Auto-apply parking brake.
156 */
157 public static final int PARKING_BRAKE_AUTO_APPLY = 287310851;
158 /**
159 * Warning for fuel low level.
160 */
161 public static final int FUEL_LEVEL_LOW = 287310853;
162 /**
163 * Night mode
164 */
165 public static final int NIGHT_MODE = 287310855;
166 /**
167 * State of the vehicles turn signals
168 */
169 public static final int TURN_SIGNAL_STATE = 289408008;
170 /**
171 * Represents ignition state
172 */
173 public static final int IGNITION_STATE = 289408009;
174 /**
175 * ABS is active
176 */
177 public static final int ABS_ACTIVE = 287310858;
178 /**
179 * Traction Control is active
180 */
181 public static final int TRACTION_CONTROL_ACTIVE = 287310859;
182 /**
183 * Fan speed setting
184 */
185 public static final int HVAC_FAN_SPEED = 356517120;
186 /**
187 * Fan direction setting
188 */
189 public static final int HVAC_FAN_DIRECTION = 356517121;
190 /**
191 * HVAC current temperature.
192 */
193 public static final int HVAC_TEMPERATURE_CURRENT = 358614274;
194 /**
195 * HVAC, target temperature set.
196 */
197 public static final int HVAC_TEMPERATURE_SET = 358614275;
198 /**
199 * On/off defrost for designated window
200 */
201 public static final int HVAC_DEFROSTER = 320865540;
202 /**
203 * On/off AC for designated areaId
204 */
205 public static final int HVAC_AC_ON = 354419973;
206 /**
207 * On/off max AC
208 */
209 public static final int HVAC_MAX_AC_ON = 354419974;
210 /**
211 * On/off max defrost
212 */
213 public static final int HVAC_MAX_DEFROST_ON = 354419975;
214 /**
215 * Recirculation on/off
216 */
217 public static final int HVAC_RECIRC_ON = 354419976;
218 /**
219 * Enable temperature coupling between areas.
220 */
221 public static final int HVAC_DUAL_ON = 354419977;
222 /**
223 * On/off automatic mode
224 */
225 public static final int HVAC_AUTO_ON = 354419978;
226 /**
227 * Seat heating/cooling
228 *
229 */
230 public static final int HVAC_SEAT_TEMPERATURE = 356517131;
231 /**
232 * Side Mirror Heat
233 */
234 public static final int HVAC_SIDE_MIRROR_HEAT = 339739916;
235 /**
236 * Steering Wheel Heating/Cooling
237 */
238 public static final int HVAC_STEERING_WHEEL_HEAT = 289408269;
239 /**
240 * Temperature units for display
241 */
242 public static final int HVAC_TEMPERATURE_DISPLAY_UNITS = 289408270;
243 /**
244 * Actual fan speed
245 */
246 public static final int HVAC_ACTUAL_FAN_SPEED_RPM = 356517135;
247 /**
248 * Represents global power state for HVAC. Setting this property to false
249 * MAY mark some properties that control individual HVAC features/subsystems
250 * to UNAVAILABLE state. Setting this property to true MAY mark some
251 * properties that control individual HVAC features/subsystems to AVAILABLE
252 * state (unless any/all of them are UNAVAILABLE on their own individual
253 * merits).
254 */
255 public static final int HVAC_POWER_ON = 354419984;
256 /**
257 * Fan Positions Available
258 */
259 public static final int HVAC_FAN_DIRECTION_AVAILABLE = 356582673;
260 /**
261 * Automatic recirculation on/off
262 */
263 public static final int HVAC_AUTO_RECIRC_ON = 354419986;
264 /**
265 * Seat ventilation
266 */
267 public static final int HVAC_SEAT_VENTILATION = 356517139;
268 /**
269 * Outside temperature
270 */
271 public static final int ENV_OUTSIDE_TEMPERATURE = 291505923;
272 /**
273 * Property to control power state of application processor
274 *
275 * It is assumed that AP's power state is controller by separate power
276 * controller.
277 */
278 public static final int AP_POWER_STATE_REQ = 289475072;
279 /**
280 * Property to report power state of application processor
281 *
282 * It is assumed that AP's power state is controller by separate power
283 * controller.
284 */
285 public static final int AP_POWER_STATE_REPORT = 289475073;
286 /**
287 * Property to report bootup reason for the current power on. This is a
288 * static property that will not change for the whole duration until power
289 * off. For example, even if user presses power on button after automatic
290 * power on with door unlock, bootup reason must stay with
291 * VehicleApPowerBootupReason#USER_UNLOCK.
292 */
293 public static final int AP_POWER_BOOTUP_REASON = 289409538;
294 /**
295 * Property to represent brightness of the display. Some cars have single
296 * control for the brightness of all displays and this property is to share
297 * change in that control.
298 */
299 public static final int DISPLAY_BRIGHTNESS = 289409539;
300 /**
301 * Property to feed H/W input events to android
302 */
303 public static final int HW_KEY_INPUT = 289475088;
304 /**
305 * Door position
306 *
307 * This is an integer in case a door may be set to a particular position.
308 * Max value indicates fully open, min value (0) indicates fully closed.
309 */
310 public static final int DOOR_POS = 373295872;
311 /**
312 * Door move
313 */
314 public static final int DOOR_MOVE = 373295873;
315 /**
316 * Door lock
317 */
318 public static final int DOOR_LOCK = 371198722;
319 /**
320 * Mirror Z Position
321 */
322 public static final int MIRROR_Z_POS = 339741504;
323 /**
324 * Mirror Z Move
325 */
326 public static final int MIRROR_Z_MOVE = 339741505;
327 /**
328 * Mirror Y Position
329 */
330 public static final int MIRROR_Y_POS = 339741506;
331 /**
332 * Mirror Y Move
333 */
334 public static final int MIRROR_Y_MOVE = 339741507;
335 /**
336 * Mirror Lock
337 */
338 public static final int MIRROR_LOCK = 287312708;
339 /**
340 * Mirror Fold
341 */
342 public static final int MIRROR_FOLD = 287312709;
343 /**
344 * Seat memory select
345 *
346 * This parameter selects the memory preset to use to select the seat
347 * position. The minValue is always 0, and the maxValue determines the
348 * number of seat positions available.
349 */
350 public static final int SEAT_MEMORY_SELECT = 356518784;
351 /**
352 * Seat memory set
353 *
354 * This setting allows the user to save the current seat position settings
355 * into the selected preset slot. The maxValue for each seat position
356 * must match the maxValue for SEAT_MEMORY_SELECT.
357 */
358 public static final int SEAT_MEMORY_SET = 356518785;
359 /**
360 * Seatbelt buckled
361 *
362 * True indicates belt is buckled.
363 */
364 public static final int SEAT_BELT_BUCKLED = 354421634;
365 /**
366 * Seatbelt height position
367 */
368 public static final int SEAT_BELT_HEIGHT_POS = 356518787;
369 /**
370 * Seatbelt height move
371 */
372 public static final int SEAT_BELT_HEIGHT_MOVE = 356518788;
373 /**
374 * Seat fore/aft position
375 */
376 public static final int SEAT_FORE_AFT_POS = 356518789;
377 /**
378 * Seat fore/aft move
379 */
380 public static final int SEAT_FORE_AFT_MOVE = 356518790;
381 /**
382 * Seat backrest angle 1 position
383 */
384 public static final int SEAT_BACKREST_ANGLE_1_POS = 356518791;
385 /**
386 * Seat backrest angle 1 move
387 *
388 * Moves the backrest forward or recline.
389 */
390 public static final int SEAT_BACKREST_ANGLE_1_MOVE = 356518792;
391 /**
392 * Seat backrest angle 2 position
393 */
394 public static final int SEAT_BACKREST_ANGLE_2_POS = 356518793;
395 /**
396 * Seat backrest angle 2 move
397 */
398 public static final int SEAT_BACKREST_ANGLE_2_MOVE = 356518794;
399 /**
400 * Seat height position
401 */
402 public static final int SEAT_HEIGHT_POS = 356518795;
403 /**
404 * Seat height move
405 */
406 public static final int SEAT_HEIGHT_MOVE = 356518796;
407 /**
408 * Seat depth position
409 */
410 public static final int SEAT_DEPTH_POS = 356518797;
411 /**
412 * Seat depth move
413 */
414 public static final int SEAT_DEPTH_MOVE = 356518798;
415 /**
416 * Seat tilt position
417 */
418 public static final int SEAT_TILT_POS = 356518799;
419 /**
420 * Seat tilt move
421 */
422 public static final int SEAT_TILT_MOVE = 356518800;
423 /**
424 * Lumber fore/aft position
425 */
426 public static final int SEAT_LUMBAR_FORE_AFT_POS = 356518801;
427 /**
428 * Lumbar fore/aft move
429 */
430 public static final int SEAT_LUMBAR_FORE_AFT_MOVE = 356518802;
431 /**
432 * Lumbar side support position
433 */
434 public static final int SEAT_LUMBAR_SIDE_SUPPORT_POS = 356518803;
435 /**
436 * Lumbar side support move
437 */
438 public static final int SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 356518804;
439 /**
440 * Headrest height position
441 */
442 public static final int SEAT_HEADREST_HEIGHT_POS = 289409941;
443 /**
444 * Headrest height move
445 */
446 public static final int SEAT_HEADREST_HEIGHT_MOVE = 356518806;
447 /**
448 * Headrest angle position
449 */
450 public static final int SEAT_HEADREST_ANGLE_POS = 356518807;
451 /**
452 * Headrest angle move
453 */
454 public static final int SEAT_HEADREST_ANGLE_MOVE = 356518808;
455 /**
456 * Headrest fore/aft position
457 */
458 public static final int SEAT_HEADREST_FORE_AFT_POS = 356518809;
459 /**
460 * Headrest fore/aft move
461 */
462 public static final int SEAT_HEADREST_FORE_AFT_MOVE = 356518810;
463 /**
464 * Window Position
465 */
466 public static final int WINDOW_POS = 322964416;
467 /**
468 * Window Move
469 */
470 public static final int WINDOW_MOVE = 322964417;
471 /**
472 * Window Lock
473 */
474 public static final int WINDOW_LOCK = 320867268;
475 /**
476 * Vehicle Maps Service (VMS) message
477 */
478 public static final int VEHICLE_MAP_SERVICE = 299895808;
479 /**
480 * OBD2 Live Sensor Data
481 *
482 * Reports a snapshot of the current (live) values of the OBD2 sensors available.
483 */
484 public static final int OBD2_LIVE_FRAME = 299896064;
485 /**
486 * OBD2 Freeze Frame Sensor Data
487 *
488 * Reports a snapshot of the value of the OBD2 sensors available at the time that a fault
489 * occurred and was detected.
490 */
491 public static final int OBD2_FREEZE_FRAME = 299896065;
492 /**
493 * OBD2 Freeze Frame Information
494 */
495 public static final int OBD2_FREEZE_FRAME_INFO = 299896066;
496 /**
497 * OBD2 Freeze Frame Clear
498 *
499 * This property allows deletion of any of the freeze frames stored in
500 * vehicle memory, as described by OBD2_FREEZE_FRAME_INFO.
501 */
502 public static final int OBD2_FREEZE_FRAME_CLEAR = 299896067;
503 /**
504 * Headlights State
505 */
506 public static final int HEADLIGHTS_STATE = 289410560;
507 /**
508 * High beam lights state
509 */
510 public static final int HIGH_BEAM_LIGHTS_STATE = 289410561;
511 /**
512 * Fog light state
513 */
514 public static final int FOG_LIGHTS_STATE = 289410562;
515 /**
516 * Hazard light status
517 */
518 public static final int HAZARD_LIGHTS_STATE = 289410563;
519 /**
520 * Headlight switch
521 */
522 public static final int HEADLIGHTS_SWITCH = 289410576;
523 /**
524 * High beam light switch
525 */
526 public static final int HIGH_BEAM_LIGHTS_SWITCH = 289410577;
527 /**
528 * Fog light switch
529 */
530 public static final int FOG_LIGHTS_SWITCH = 289410578;
531 /**
532 * Hazard light switch
533 */
534 public static final int HAZARD_LIGHTS_SWITCH = 289410579;
535
536 /**
537 * @param o Integer
538 * @return String
539 */
540 public static String toString(int o) {
541 if (o == INVALID) {
542 return "INVALID";
543 }
544 if (o == INFO_VIN) {
545 return "INFO_VIN";
546 }
547 if (o == INFO_MAKE) {
548 return "INFO_MAKE";
549 }
550 if (o == INFO_MODEL) {
551 return "INFO_MODEL";
552 }
553 if (o == INFO_MODEL_YEAR) {
554 return "INFO_MODEL_YEAR";
555 }
556 if (o == INFO_FUEL_CAPACITY) {
557 return "INFO_FUEL_CAPACITY";
558 }
559 if (o == INFO_FUEL_TYPE) {
560 return "INFO_FUEL_TYPE";
561 }
562 if (o == INFO_EV_BATTERY_CAPACITY) {
563 return "INFO_EV_BATTERY_CAPACITY";
564 }
565 if (o == INFO_EV_CONNECTOR_TYPE) {
566 return "INFO_EV_CONNECTOR_TYPE";
567 }
568 if (o == INFO_FUEL_DOOR_LOCATION) {
569 return "INFO_FUEL_DOOR_LOCATION";
570 }
571 if (o == INFO_EV_PORT_LOCATION) {
572 return "INFO_EV_PORT_LOCATION";
573 }
574 if (o == INFO_DRIVER_SEAT) {
575 return "INFO_DRIVER_SEAT";
576 }
577 if (o == PERF_ODOMETER) {
578 return "PERF_ODOMETER";
579 }
580 if (o == PERF_VEHICLE_SPEED) {
581 return "PERF_VEHICLE_SPEED";
582 }
583 if (o == ENGINE_COOLANT_TEMP) {
584 return "ENGINE_COOLANT_TEMP";
585 }
586 if (o == ENGINE_OIL_LEVEL) {
587 return "ENGINE_OIL_LEVEL";
588 }
589 if (o == ENGINE_OIL_TEMP) {
590 return "ENGINE_OIL_TEMP";
591 }
592 if (o == ENGINE_RPM) {
593 return "ENGINE_RPM";
594 }
595 if (o == WHEEL_TICK) {
596 return "WHEEL_TICK";
597 }
598 if (o == FUEL_LEVEL) {
599 return "FUEL_LEVEL";
600 }
601 if (o == FUEL_DOOR_OPEN) {
602 return "FUEL_DOOR_OPEN";
603 }
604 if (o == EV_BATTERY_LEVEL) {
605 return "EV_BATTERY_LEVEL";
606 }
607 if (o == EV_CHARGE_PORT_OPEN) {
608 return "EV_CHARGE_PORT_OPEN";
609 }
610 if (o == EV_CHARGE_PORT_CONNECTED) {
611 return "EV_CHARGE_PORT_CONNECTED";
612 }
613 if (o == EV_BATTERY_INSTANTANEOUS_CHARGE_RATE) {
614 return "EV_BATTERY_INSTANTANEOUS_CHARGE_RATE";
615 }
616 if (o == RANGE_REMAINING) {
617 return "RANGE_REMAINING";
618 }
619 if (o == TIRE_PRESSURE) {
620 return "TIRE_PRESSURE";
621 }
622 if (o == GEAR_SELECTION) {
623 return "GEAR_SELECTION";
624 }
625 if (o == CURRENT_GEAR) {
626 return "CURRENT_GEAR";
627 }
628 if (o == PARKING_BRAKE_ON) {
629 return "PARKING_BRAKE_ON";
630 }
631 if (o == PARKING_BRAKE_AUTO_APPLY) {
632 return "PARKING_BRAKE_AUTO_APPLY";
633 }
634 if (o == FUEL_LEVEL_LOW) {
635 return "FUEL_LEVEL_LOW";
636 }
637 if (o == NIGHT_MODE) {
638 return "NIGHT_MODE";
639 }
640 if (o == TURN_SIGNAL_STATE) {
641 return "TURN_SIGNAL_STATE";
642 }
643 if (o == IGNITION_STATE) {
644 return "IGNITION_STATE";
645 }
646 if (o == ABS_ACTIVE) {
647 return "ABS_ACTIVE";
648 }
649 if (o == TRACTION_CONTROL_ACTIVE) {
650 return "TRACTION_CONTROL_ACTIVE";
651 }
652 if (o == HVAC_FAN_SPEED) {
653 return "HVAC_FAN_SPEED";
654 }
655 if (o == HVAC_FAN_DIRECTION) {
656 return "HVAC_FAN_DIRECTION";
657 }
658 if (o == HVAC_TEMPERATURE_CURRENT) {
659 return "HVAC_TEMPERATURE_CURRENT";
660 }
661 if (o == HVAC_TEMPERATURE_SET) {
662 return "HVAC_TEMPERATURE_SET";
663 }
664 if (o == HVAC_DEFROSTER) {
665 return "HVAC_DEFROSTER";
666 }
667 if (o == HVAC_AC_ON) {
668 return "HVAC_AC_ON";
669 }
670 if (o == HVAC_MAX_AC_ON) {
671 return "HVAC_MAX_AC_ON";
672 }
673 if (o == HVAC_MAX_DEFROST_ON) {
674 return "HVAC_MAX_DEFROST_ON";
675 }
676 if (o == HVAC_RECIRC_ON) {
677 return "HVAC_RECIRC_ON";
678 }
679 if (o == HVAC_DUAL_ON) {
680 return "HVAC_DUAL_ON";
681 }
682 if (o == HVAC_AUTO_ON) {
683 return "HVAC_AUTO_ON";
684 }
685 if (o == HVAC_SEAT_TEMPERATURE) {
686 return "HVAC_SEAT_TEMPERATURE";
687 }
688 if (o == HVAC_SIDE_MIRROR_HEAT) {
689 return "HVAC_SIDE_MIRROR_HEAT";
690 }
691 if (o == HVAC_STEERING_WHEEL_HEAT) {
692 return "HVAC_STEERING_WHEEL_HEAT";
693 }
694 if (o == HVAC_TEMPERATURE_DISPLAY_UNITS) {
695 return "HVAC_TEMPERATURE_DISPLAY_UNITS";
696 }
697 if (o == HVAC_ACTUAL_FAN_SPEED_RPM) {
698 return "HVAC_ACTUAL_FAN_SPEED_RPM";
699 }
700 if (o == HVAC_POWER_ON) {
701 return "HVAC_POWER_ON";
702 }
703 if (o == HVAC_FAN_DIRECTION_AVAILABLE) {
704 return "HVAC_FAN_DIRECTION_AVAILABLE";
705 }
706 if (o == HVAC_AUTO_RECIRC_ON) {
707 return "HVAC_AUTO_RECIRC_ON";
708 }
709 if (o == HVAC_SEAT_VENTILATION) {
710 return "HVAC_SEAT_VENTILATION";
711 }
712 if (o == ENV_OUTSIDE_TEMPERATURE) {
713 return "ENV_OUTSIDE_TEMPERATURE";
714 }
715 if (o == AP_POWER_STATE_REQ) {
716 return "AP_POWER_STATE_REQ";
717 }
718 if (o == AP_POWER_STATE_REPORT) {
719 return "AP_POWER_STATE_REPORT";
720 }
721 if (o == AP_POWER_BOOTUP_REASON) {
722 return "AP_POWER_BOOTUP_REASON";
723 }
724 if (o == DISPLAY_BRIGHTNESS) {
725 return "DISPLAY_BRIGHTNESS";
726 }
727 if (o == HW_KEY_INPUT) {
728 return "HW_KEY_INPUT";
729 }
730 if (o == DOOR_POS) {
731 return "DOOR_POS";
732 }
733 if (o == DOOR_MOVE) {
734 return "DOOR_MOVE";
735 }
736 if (o == DOOR_LOCK) {
737 return "DOOR_LOCK";
738 }
739 if (o == MIRROR_Z_POS) {
740 return "MIRROR_Z_POS";
741 }
742 if (o == MIRROR_Z_MOVE) {
743 return "MIRROR_Z_MOVE";
744 }
745 if (o == MIRROR_Y_POS) {
746 return "MIRROR_Y_POS";
747 }
748 if (o == MIRROR_Y_MOVE) {
749 return "MIRROR_Y_MOVE";
750 }
751 if (o == MIRROR_LOCK) {
752 return "MIRROR_LOCK";
753 }
754 if (o == MIRROR_FOLD) {
755 return "MIRROR_FOLD";
756 }
757 if (o == SEAT_MEMORY_SELECT) {
758 return "SEAT_MEMORY_SELECT";
759 }
760 if (o == SEAT_MEMORY_SET) {
761 return "SEAT_MEMORY_SET";
762 }
763 if (o == SEAT_BELT_BUCKLED) {
764 return "SEAT_BELT_BUCKLED";
765 }
766 if (o == SEAT_BELT_HEIGHT_POS) {
767 return "SEAT_BELT_HEIGHT_POS";
768 }
769 if (o == SEAT_BELT_HEIGHT_MOVE) {
770 return "SEAT_BELT_HEIGHT_MOVE";
771 }
772 if (o == SEAT_FORE_AFT_POS) {
773 return "SEAT_FORE_AFT_POS";
774 }
775 if (o == SEAT_FORE_AFT_MOVE) {
776 return "SEAT_FORE_AFT_MOVE";
777 }
778 if (o == SEAT_BACKREST_ANGLE_1_POS) {
779 return "SEAT_BACKREST_ANGLE_1_POS";
780 }
781 if (o == SEAT_BACKREST_ANGLE_1_MOVE) {
782 return "SEAT_BACKREST_ANGLE_1_MOVE";
783 }
784 if (o == SEAT_BACKREST_ANGLE_2_POS) {
785 return "SEAT_BACKREST_ANGLE_2_POS";
786 }
787 if (o == SEAT_BACKREST_ANGLE_2_MOVE) {
788 return "SEAT_BACKREST_ANGLE_2_MOVE";
789 }
790 if (o == SEAT_HEIGHT_POS) {
791 return "SEAT_HEIGHT_POS";
792 }
793 if (o == SEAT_HEIGHT_MOVE) {
794 return "SEAT_HEIGHT_MOVE";
795 }
796 if (o == SEAT_DEPTH_POS) {
797 return "SEAT_DEPTH_POS";
798 }
799 if (o == SEAT_DEPTH_MOVE) {
800 return "SEAT_DEPTH_MOVE";
801 }
802 if (o == SEAT_TILT_POS) {
803 return "SEAT_TILT_POS";
804 }
805 if (o == SEAT_TILT_MOVE) {
806 return "SEAT_TILT_MOVE";
807 }
808 if (o == SEAT_LUMBAR_FORE_AFT_POS) {
809 return "SEAT_LUMBAR_FORE_AFT_POS";
810 }
811 if (o == SEAT_LUMBAR_FORE_AFT_MOVE) {
812 return "SEAT_LUMBAR_FORE_AFT_MOVE";
813 }
814 if (o == SEAT_LUMBAR_SIDE_SUPPORT_POS) {
815 return "SEAT_LUMBAR_SIDE_SUPPORT_POS";
816 }
817 if (o == SEAT_LUMBAR_SIDE_SUPPORT_MOVE) {
818 return "SEAT_LUMBAR_SIDE_SUPPORT_MOVE";
819 }
820 if (o == SEAT_HEADREST_HEIGHT_POS) {
821 return "SEAT_HEADREST_HEIGHT_POS";
822 }
823 if (o == SEAT_HEADREST_HEIGHT_MOVE) {
824 return "SEAT_HEADREST_HEIGHT_MOVE";
825 }
826 if (o == SEAT_HEADREST_ANGLE_POS) {
827 return "SEAT_HEADREST_ANGLE_POS";
828 }
829 if (o == SEAT_HEADREST_ANGLE_MOVE) {
830 return "SEAT_HEADREST_ANGLE_MOVE";
831 }
832 if (o == SEAT_HEADREST_FORE_AFT_POS) {
833 return "SEAT_HEADREST_FORE_AFT_POS";
834 }
835 if (o == SEAT_HEADREST_FORE_AFT_MOVE) {
836 return "SEAT_HEADREST_FORE_AFT_MOVE";
837 }
838 if (o == WINDOW_POS) {
839 return "WINDOW_POS";
840 }
841 if (o == WINDOW_MOVE) {
842 return "WINDOW_MOVE";
843 }
844 if (o == WINDOW_LOCK) {
845 return "WINDOW_LOCK";
846 }
847 if (o == VEHICLE_MAP_SERVICE) {
848 return "VEHICLE_MAP_SERVICE";
849 }
850 if (o == OBD2_LIVE_FRAME) {
851 return "OBD2_LIVE_FRAME";
852 }
853 if (o == OBD2_FREEZE_FRAME) {
854 return "OBD2_FREEZE_FRAME";
855 }
856 if (o == OBD2_FREEZE_FRAME_INFO) {
857 return "OBD2_FREEZE_FRAME_INFO";
858 }
859 if (o == OBD2_FREEZE_FRAME_CLEAR) {
860 return "OBD2_FREEZE_FRAME_CLEAR";
861 }
862 if (o == HEADLIGHTS_STATE) {
863 return "HEADLIGHTS_STATE";
864 }
865 if (o == HIGH_BEAM_LIGHTS_STATE) {
866 return "HIGH_BEAM_LIGHTS_STATE";
867 }
868 if (o == FOG_LIGHTS_STATE) {
869 return "FOG_LIGHTS_STATE";
870 }
871 if (o == HAZARD_LIGHTS_STATE) {
872 return "HAZARD_LIGHTS_STATE";
873 }
874 if (o == HEADLIGHTS_SWITCH) {
875 return "HEADLIGHTS_SWITCH";
876 }
877 if (o == HIGH_BEAM_LIGHTS_SWITCH) {
878 return "HIGH_BEAM_LIGHTS_SWITCH";
879 }
880 if (o == FOG_LIGHTS_SWITCH) {
881 return "FOG_LIGHTS_SWITCH";
882 }
883 if (o == HAZARD_LIGHTS_SWITCH) {
884 return "HAZARD_LIGHTS_SWITCH";
885 }
886 return "0x" + Integer.toHexString(o);
887 }
888}
diff --git a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
index c6c22bc3..87dfa3aa 100644
--- a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
+++ b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
@@ -24,30 +24,32 @@ import java.lang.annotation.Retention;
24import java.lang.annotation.RetentionPolicy; 24import java.lang.annotation.RetentionPolicy;
25 25
26/** 26/**
27 * Car UX Restrictions event. This contains information on the set of UX restrictions 27 * Car UX Restrictions event. This contains information on the set of UX restrictions that is in
28 * that is in place due to the car's driving state. 28 * place due to the car's driving state.
29 * <p> 29 * <p>
30 * The restriction information is organized as follows: 30 * The restriction information is organized as follows:
31 * <ul> 31 * <ul>
32 * <li> When there are no restrictions in place, for example when the car is parked, 32 * <li> When there are no restrictions in place, for example when the car is parked,
33 * <ul> 33 * <ul>
34 * <li> {@link #mRequiresDistractionOptimization} is set to false. Apps can display activities 34 * <li> {@link #isRequiresDistractionOptimization()} returns false. Apps can display activities
35 * that are not distraction optimized. 35 * that are not distraction optimized.
36 * <li> {@link #mActiveRestrictions} should contain UX_RESTRICTIONS_UNRESTRICTED. Apps don't 36 * <li> When {@link #isRequiresDistractionOptimization()} returns false, apps don't have to call
37 * have to check for this since {@code mRequiresDistractionOptimization} is false. 37 * {@link #getActiveRestrictions()}, since there is no distraction optimization required.
38 * </ul> 38 * </ul>
39 * <li> When the driving state changes, causing the UX restrictions to come in effect, 39 * <li> When the driving state changes, causing the UX restrictions to come in effect,
40 * <ul> 40 * <ul>
41 * <li> {@code mRequiresDistractionOptimization} is set to true. Apps can only display 41 * <li> {@link #isRequiresDistractionOptimization()} returns true. Apps can only display activities
42 * activities that are distraction optimized. Distraction optimized activities follow the base 42 * that are distraction optimized. Distraction optimized activities must follow the base design
43 * design guidelines that provide a distraction free driving user experience. 43 * guidelines to ensure a distraction free driving experience for the user.
44 * <li> In addition, apps will have to check for the content of mActiveRestrictions. 44 * <li> When {@link #isRequiresDistractionOptimization()} returns true, apps must call
45 * {@code mActiveRestrictions} will have additional granular information on the set of UX 45 * {@link #getActiveRestrictions()}, to get the currently active UX restrictions to adhere to.
46 * restrictions that are in place for the current driving state. The content of 46 * {@link #getActiveRestrictions()} provides additional information on the set of UX
47 * {@code mActiveRestrictions}, for the same driving state of the vehicle, could vary depending 47 * restrictions that are in place for the current driving state.
48 * on the car maker and the market. For example, when the car is idling, the set of active 48 * <p>
49 * UX restrictions contained in the {@code mActiveRestrictions} will depend on the car maker 49 * The UX restrictions returned by {@link #getActiveRestrictions()}, for the same driving state of
50 * and the safety standards of the market that the vehicle is deployed in. 50 * the vehicle, could vary depending on the OEM and the market. For example, when the car is
51 * idling, the set of active UX restrictions will depend on the car maker and the safety standards
52 * of the market that the vehicle is deployed in.
51 * </ul> 53 * </ul>
52 * </ul> 54 * </ul>
53 * <p> 55 * <p>
diff --git a/car-lib/src/android/car/hardware/CarSensorEvent.java b/car-lib/src/android/car/hardware/CarSensorEvent.java
index 86af0637..8cba0a27 100644
--- a/car-lib/src/android/car/hardware/CarSensorEvent.java
+++ b/car-lib/src/android/car/hardware/CarSensorEvent.java
@@ -92,15 +92,11 @@ public class CarSensorEvent implements Parcelable {
92 public static final int IGNITION_STATE_START = 5; 92 public static final int IGNITION_STATE_START = 5;
93 93
94 /** 94 /**
95 * Index for {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT} in floatValues. 95 * Index for {@link CarSensorManager#SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE} in floatValues.
96 * Temperature in Celsius degrees. 96 * Temperature in Celsius degrees.
97 */ 97 */
98 public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0; 98 public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0;
99 /** 99
100 * Index for {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT} in floatValues.
101 * Pressure in kPa.
102 */
103 public static final int INDEX_ENVIRONMENT_PRESSURE = 1;
104 /** 100 /**
105 * Index for {@link CarSensorManager#SENSOR_TYPE_WHEEL_TICK_DISTANCE} in longValues. RESET_COUNT 101 * Index for {@link CarSensorManager#SENSOR_TYPE_WHEEL_TICK_DISTANCE} in longValues. RESET_COUNT
106 * is incremented whenever the HAL detects that a sensor reset has occurred. It represents to 102 * is incremented whenever the HAL detects that a sensor reset has occurred. It represents to
@@ -208,8 +204,6 @@ public class CarSensorEvent implements Parcelable {
208 public long timestamp; 204 public long timestamp;
209 /** If unsupported by the car, this value is NaN. */ 205 /** If unsupported by the car, this value is NaN. */
210 public float temperature; 206 public float temperature;
211 /** If unsupported by the car, this value is NaN. */
212 public float pressure;
213 207
214 /** @hide */ 208 /** @hide */
215 private EnvironmentData() {}; 209 private EnvironmentData() {};
@@ -217,7 +211,7 @@ public class CarSensorEvent implements Parcelable {
217 211
218 /** 212 /**
219 * Convenience method for obtaining an {@link EnvironmentData} object from a CarSensorEvent 213 * Convenience method for obtaining an {@link EnvironmentData} object from a CarSensorEvent
220 * object with type {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT}. 214 * object with type {@link CarSensorManager#SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE}.
221 * 215 *
222 * @param data an optional output parameter which, if non-null, will be used by this method 216 * @param data an optional output parameter which, if non-null, will be used by this method
223 * instead of a newly created object. 217 * instead of a newly created object.
@@ -225,13 +219,40 @@ public class CarSensorEvent implements Parcelable {
225 * @hide 219 * @hide
226 */ 220 */
227 public EnvironmentData getEnvironmentData(EnvironmentData data) { 221 public EnvironmentData getEnvironmentData(EnvironmentData data) {
228 checkType(CarSensorManager.SENSOR_TYPE_ENVIRONMENT); 222 checkType(CarSensorManager.SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE);
229 if (data == null) { 223 if (data == null) {
230 data = new EnvironmentData(); 224 data = new EnvironmentData();
231 } 225 }
232 data.timestamp = timestamp; 226 data.timestamp = timestamp;
233 data.temperature = floatValues[INDEX_ENVIRONMENT_TEMPERATURE]; 227 data.temperature = floatValues[INDEX_ENVIRONMENT_TEMPERATURE];
234 data.pressure = floatValues[INDEX_ENVIRONMENT_PRESSURE]; 228 return data;
229 }
230
231 /** @hide*/
232 public static class IgnitionStateData {
233 public long timestamp;
234 public int ignitionState;
235
236 /** @hide */
237 private IgnitionStateData() {};
238 }
239
240 /**
241 * Convenience method for obtaining a {@link IgnitionStateData} object from a CarSensorEvent
242 * object with type {@link CarSensorManager#SENSOR_TYPE_IGNITION_STATE}.
243 *
244 * @param data an optional output parameter which, if non-null, will be used by this method
245 * instead of a newly created object.
246 * @return a IgnitionStateData object corresponding to the data contained in the CarSensorEvent.
247 * @hide
248 */
249 public IgnitionStateData getIgnitionStateData(IgnitionStateData data) {
250 checkType(CarSensorManager.SENSOR_TYPE_IGNITION_STATE);
251 if (data == null) {
252 data = new IgnitionStateData();
253 }
254 data.timestamp = timestamp;
255 data.ignitionState = intValues[0];
235 return data; 256 return data;
236 } 257 }
237 258
diff --git a/car-lib/src/android/car/hardware/CarSensorManager.java b/car-lib/src/android/car/hardware/CarSensorManager.java
index 25366046..338d74f4 100644
--- a/car-lib/src/android/car/hardware/CarSensorManager.java
+++ b/car-lib/src/android/car/hardware/CarSensorManager.java
@@ -91,14 +91,17 @@ public final class CarSensorManager implements CarManagerBase {
91 * Day/night sensor. Sensor data is intValues[0]. 91 * Day/night sensor. Sensor data is intValues[0].
92 */ 92 */
93 public static final int SENSOR_TYPE_NIGHT = 0x11200407; 93 public static final int SENSOR_TYPE_NIGHT = 0x11200407;
94 /**
95 * Outside Environment like temperature.
96 * This requires {@link Car#PERMISSION_EXTERIOR_ENVIRONMENT} permission.
97 */
98 public static final int SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE = 0x11600703;
94 /** @hide */ 99 /** @hide */
95 public static final int SENSOR_TYPE_RESERVED10 = 10; 100 public static final int SENSOR_TYPE_RESERVED10 = 10;
96 /** @hide */ 101 /** @hide */
97 public static final int SENSOR_TYPE_RESERVED11 = 11; 102 public static final int SENSOR_TYPE_RESERVED11 = 11;
98 /** 103 /** @hide */
99 * Environment like temperature and pressure. 104 public static final int SENSOR_TYPE_RESERVED12 = 12;
100 */
101 public static final int SENSOR_TYPE_ENVIRONMENT = 12;
102 /** @hide */ 105 /** @hide */
103 public static final int SENSOR_TYPE_RESERVED13 = 13; 106 public static final int SENSOR_TYPE_RESERVED13 = 13;
104 /** @hide */ 107 /** @hide */
@@ -186,7 +189,7 @@ public final class CarSensorManager implements CarManagerBase {
186 SENSOR_TYPE_PARKING_BRAKE, 189 SENSOR_TYPE_PARKING_BRAKE,
187 SENSOR_TYPE_GEAR, 190 SENSOR_TYPE_GEAR,
188 SENSOR_TYPE_NIGHT, 191 SENSOR_TYPE_NIGHT,
189 SENSOR_TYPE_ENVIRONMENT, 192 SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE,
190 SENSOR_TYPE_IGNITION_STATE, 193 SENSOR_TYPE_IGNITION_STATE,
191 SENSOR_TYPE_WHEEL_TICK_DISTANCE, 194 SENSOR_TYPE_WHEEL_TICK_DISTANCE,
192 SENSOR_TYPE_ABS_ACTIVE, 195 SENSOR_TYPE_ABS_ACTIVE,
@@ -209,7 +212,7 @@ public final class CarSensorManager implements CarManagerBase {
209 SENSOR_TYPE_PARKING_BRAKE, 212 SENSOR_TYPE_PARKING_BRAKE,
210 SENSOR_TYPE_GEAR, 213 SENSOR_TYPE_GEAR,
211 SENSOR_TYPE_NIGHT, 214 SENSOR_TYPE_NIGHT,
212 SENSOR_TYPE_ENVIRONMENT, 215 SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE,
213 SENSOR_TYPE_IGNITION_STATE, 216 SENSOR_TYPE_IGNITION_STATE,
214 SENSOR_TYPE_WHEEL_TICK_DISTANCE, 217 SENSOR_TYPE_WHEEL_TICK_DISTANCE,
215 SENSOR_TYPE_ABS_ACTIVE, 218 SENSOR_TYPE_ABS_ACTIVE,
diff --git a/car-lib/src/android/car/hardware/property/CarPropertyManager.java b/car-lib/src/android/car/hardware/property/CarPropertyManager.java
index 5c094e75..373c23a7 100644
--- a/car-lib/src/android/car/hardware/property/CarPropertyManager.java
+++ b/car-lib/src/android/car/hardware/property/CarPropertyManager.java
@@ -18,6 +18,7 @@ package android.car.hardware.property;
18 18
19import static java.lang.Integer.toHexString; 19import static java.lang.Integer.toHexString;
20 20
21import android.annotation.Nullable;
21import android.car.CarApiUtil; 22import android.car.CarApiUtil;
22import android.car.CarManagerBase; 23import android.car.CarManagerBase;
23import android.car.CarNotConnectedException; 24import android.car.CarNotConnectedException;
@@ -44,6 +45,7 @@ import java.util.function.Consumer;
44 * @hide 45 * @hide
45 */ 46 */
46public class CarPropertyManager implements CarManagerBase { 47public class CarPropertyManager implements CarManagerBase {
48 private final List<CarPropertyConfig> mConfigs;
47 private final boolean mDbg; 49 private final boolean mDbg;
48 private final SingleMessageHandler<CarPropertyEvent> mHandler; 50 private final SingleMessageHandler<CarPropertyEvent> mHandler;
49 private final ICarProperty mService; 51 private final ICarProperty mService;
@@ -69,10 +71,20 @@ public class CarPropertyManager implements CarManagerBase {
69 /** 71 /**
70 * Get an instance of the CarPropertyManager. 72 * Get an instance of the CarPropertyManager.
71 */ 73 */
72 public CarPropertyManager(IBinder service, Handler handler, boolean dbg, String tag) { 74 public CarPropertyManager(IBinder service, @Nullable Handler handler, boolean dbg, String tag) {
73 mDbg = dbg; 75 mDbg = dbg;
74 mTag = tag; 76 mTag = tag;
75 mService = ICarProperty.Stub.asInterface(service); 77 mService = ICarProperty.Stub.asInterface(service);
78 try {
79 mConfigs = mService.getPropertyList();
80 } catch (Exception e) {
81 Log.e(mTag, "getPropertyList exception ", e);
82 throw new RuntimeException(e);
83 }
84 if (handler == null) {
85 mHandler = null;
86 return;
87 }
76 mHandler = new SingleMessageHandler<CarPropertyEvent>(handler.getLooper(), 88 mHandler = new SingleMessageHandler<CarPropertyEvent>(handler.getLooper(),
77 MSG_GENERIC_EVENT) { 89 MSG_GENERIC_EVENT) {
78 @Override 90 @Override
@@ -154,7 +166,9 @@ public class CarPropertyManager implements CarManagerBase {
154 } 166 }
155 167
156 private void handleEvent(List<CarPropertyEvent> events) { 168 private void handleEvent(List<CarPropertyEvent> events) {
157 mHandler.sendEvents(events); 169 if (mHandler != null) {
170 mHandler.sendEvents(events);
171 }
158 } 172 }
159 173
160 /** 174 /**
@@ -164,8 +178,12 @@ public class CarPropertyManager implements CarManagerBase {
164 */ 178 */
165 public void unregisterListener(CarPropertyEventListener listener) { 179 public void unregisterListener(CarPropertyEventListener listener) {
166 synchronized (mActivePropertyListener) { 180 synchronized (mActivePropertyListener) {
181 int [] propertyIds = new int[mActivePropertyListener.size()];
167 for (int i = 0; i < mActivePropertyListener.size(); i++) { 182 for (int i = 0; i < mActivePropertyListener.size(); i++) {
168 doUnregisterListenerLocked(listener, mActivePropertyListener.keyAt(i)); 183 propertyIds[i] = mActivePropertyListener.keyAt(i);
184 }
185 for (int prop : propertyIds) {
186 doUnregisterListenerLocked(listener, prop);
169 } 187 }
170 } 188 }
171 } 189 }
@@ -207,41 +225,24 @@ public class CarPropertyManager implements CarManagerBase {
207 } 225 }
208 226
209 /** 227 /**
210 * Returns the list of properties implemented by this car. 228 * @return List of properties implemented by this car that the application may access.
211 *
212 * @return Caller must check the property type and typecast to the appropriate subclass
213 * (CarPropertyBooleanProperty, CarPropertyFloatProperty, CarrPropertyIntProperty)
214 */ 229 */
215 public List<CarPropertyConfig> getPropertyList() throws CarNotConnectedException { 230 public List<CarPropertyConfig> getPropertyList() {
216 try { 231 return mConfigs;
217 return mService.getPropertyList();
218 } catch (RemoteException e) {
219 Log.e(mTag, "getPropertyList exception ", e);
220 throw new CarNotConnectedException(e);
221 }
222 } 232 }
223 233
224 /** 234 /**
225 * Returns the list of properties implemented by this car in given property id list. 235 * @return List of properties implemented by this car in given property ID list that application
226 * 236 * may access.
227 * @return Caller must check the property type and typecast to the appropriate subclass
228 * (CarPropertyBooleanProperty, CarPropertyFloatProperty, CarrPropertyIntProperty)
229 */ 237 */
230 public List<CarPropertyConfig> getPropertyList(ArraySet<Integer> propertyIds) 238 public List<CarPropertyConfig> getPropertyList(ArraySet<Integer> propertyIds) {
231 throws CarNotConnectedException { 239 List<CarPropertyConfig> configs = new ArrayList<>();
232 try { 240 for (CarPropertyConfig c : mConfigs) {
233 List<CarPropertyConfig> configs = new ArrayList<>(); 241 if (propertyIds.contains(c.getPropertyId())) {
234 for (CarPropertyConfig c : mService.getPropertyList()) { 242 configs.add(c);
235 if (propertyIds.contains(c.getPropertyId())) {
236 configs.add(c);
237 }
238 } 243 }
239 return configs;
240 } catch (RemoteException e) {
241 Log.e(mTag, "getPropertyList exception ", e);
242 throw new CarNotConnectedException(e);
243 } 244 }
244 245 return configs;
245 } 246 }
246 247
247 /** 248 /**
@@ -294,6 +295,26 @@ public class CarPropertyManager implements CarManagerBase {
294 return carProp != null ? carProp.getValue() : 0; 295 return carProp != null ? carProp.getValue() : 0;
295 } 296 }
296 297
298 /**
299 * Returns value of a integer array property
300 *
301 * @param prop Property ID to get
302 * @param area Zone of the property to get
303 */
304 public int[] getIntArrayProperty(int prop, int area) throws CarNotConnectedException {
305 CarPropertyValue<Integer[]> carProp = getProperty(Integer[].class, prop, area);
306 return carProp != null ? toIntArray(carProp.getValue()) : new int[0];
307 }
308
309 private static int[] toIntArray(Integer[] input) {
310 int len = input.length;
311 int[] arr = new int[len];
312 for (int i = 0; i < len; i++) {
313 arr[i] = input[i];
314 }
315 return arr;
316 }
317
297 /** Return CarPropertyValue */ 318 /** Return CarPropertyValue */
298 @SuppressWarnings("unchecked") 319 @SuppressWarnings("unchecked")
299 public <E> CarPropertyValue<E> getProperty(Class<E> clazz, int propId, int area) 320 public <E> CarPropertyValue<E> getProperty(Class<E> clazz, int propId, int area)
diff --git a/car-lib/src/android/car/media/CarAudioManager.java b/car-lib/src/android/car/media/CarAudioManager.java
index c9aef749..7257255c 100644
--- a/car-lib/src/android/car/media/CarAudioManager.java
+++ b/car-lib/src/android/car/media/CarAudioManager.java
@@ -47,6 +47,13 @@ public final class CarAudioManager implements CarManagerBase {
47 return VOLUME_SETTINGS_KEY_FOR_GROUP_PREFIX + groupId; 47 return VOLUME_SETTINGS_KEY_FOR_GROUP_PREFIX + groupId;
48 } 48 }
49 49
50 /**
51 * Key to persist master mute state in {@link Settings.Global}
52 *
53 * @hide
54 */
55 public static final String VOLUME_SETTINGS_KEY_MASTER_MUTE = "android.car.MASTER_MUTE";
56
50 private final ContentResolver mContentResolver; 57 private final ContentResolver mContentResolver;
51 private final ICarAudio mService; 58 private final ICarAudio mService;
52 59
diff --git a/car-lib/src/android/car/settings/CarSettings.java b/car-lib/src/android/car/settings/CarSettings.java
index d7402b26..f5e10378 100644
--- a/car-lib/src/android/car/settings/CarSettings.java
+++ b/car-lib/src/android/car/settings/CarSettings.java
@@ -45,6 +45,22 @@ public class CarSettings {
45 */ 45 */
46 public static final String KEY_GARAGE_MODE_MAINTENANCE_WINDOW = 46 public static final String KEY_GARAGE_MODE_MAINTENANCE_WINDOW =
47 "android.car.GARAGE_MODE_MAINTENANCE_WINDOW"; 47 "android.car.GARAGE_MODE_MAINTENANCE_WINDOW";
48
49 /**
50 * Key for default user id to boot into.
51 *
52 * @hide
53 */
54 public static final String DEFAULT_USER_ID_TO_BOOT_INTO =
55 "android.car.DEFAULT_BOOT_INTO_USER_ID";
56
57 /**
58 * Key for user id that is last logged in to.
59 *
60 * @hide
61 */
62 public static final String LAST_ACTIVE_USER_ID =
63 "android.car.LAST_ACTIVE_USER_ID";
48 } 64 }
49 65
50 /** 66 /**
@@ -62,20 +78,6 @@ public class CarSettings {
62 public static final int DEFAULT_GARAGE_MODE_MAINTENANCE_WINDOW = 10 * 60 * 1000; // 10 mins 78 public static final int DEFAULT_GARAGE_MODE_MAINTENANCE_WINDOW = 10 * 60 * 1000; // 10 mins
63 79
64 /** 80 /**
65 * Id for user that is set as default to boot into.
66 *
67 * @hide
68 */
69 public static final int DEFAULT_USER_ID_TO_BOOT_INTO = 10; // Default to first created user.
70
71 /**
72 * Id for user that is last logged in to.
73 *
74 * @hide
75 */
76 public static final int LAST_ACTIVE_USER_ID = 10; // Default to first created user.
77
78 /**
79 * @hide 81 * @hide
80 */ 82 */
81 public static final class Secure { 83 public static final class Secure {
diff --git a/car-lib/src/android/car/trust/ICarTrustAgentBleService.aidl b/car-lib/src/android/car/trust/ICarTrustAgentBleService.aidl
index 8b50fd37..4dec6a0a 100644
--- a/car-lib/src/android/car/trust/ICarTrustAgentBleService.aidl
+++ b/car-lib/src/android/car/trust/ICarTrustAgentBleService.aidl
@@ -58,4 +58,7 @@ interface ICarTrustAgentBleService {
58 void onEscrowTokenAdded(in byte[] token, long handle, int uid); 58 void onEscrowTokenAdded(in byte[] token, long handle, int uid);
59 void onEscrowTokenRemoved(long handle, boolean successful); 59 void onEscrowTokenRemoved(long handle, boolean successful);
60 void onEscrowTokenActiveStateChanged(long handle, boolean active); 60 void onEscrowTokenActiveStateChanged(long handle, boolean active);
61
62 /** Management */
63 int getUserIdByEscrowTokenHandle(long tokenHandle);
61} 64}
diff --git a/car-lib/src/android/car/user/CarUserManagerHelper.java b/car-lib/src/android/car/user/CarUserManagerHelper.java
index 4a69f0b7..ce509436 100644
--- a/car-lib/src/android/car/user/CarUserManagerHelper.java
+++ b/car-lib/src/android/car/user/CarUserManagerHelper.java
@@ -15,7 +15,9 @@
15 */ 15 */
16package android.car.user; 16package android.car.user;
17 17
18import android.Manifest;
18import android.annotation.Nullable; 19import android.annotation.Nullable;
20import android.annotation.RequiresPermission;
19import android.app.ActivityManager; 21import android.app.ActivityManager;
20import android.car.settings.CarSettings; 22import android.car.settings.CarSettings;
21import android.content.BroadcastReceiver; 23import android.content.BroadcastReceiver;
@@ -26,15 +28,21 @@ import android.content.pm.UserInfo;
26import android.graphics.Bitmap; 28import android.graphics.Bitmap;
27import android.graphics.drawable.BitmapDrawable; 29import android.graphics.drawable.BitmapDrawable;
28import android.graphics.drawable.Drawable; 30import android.graphics.drawable.Drawable;
31import android.os.Bundle;
29import android.os.SystemProperties; 32import android.os.SystemProperties;
30import android.os.UserHandle; 33import android.os.UserHandle;
31import android.os.UserManager; 34import android.os.UserManager;
35import android.provider.Settings;
32import android.util.Log; 36import android.util.Log;
33 37
34import com.android.internal.util.UserIcons; 38import com.android.internal.util.UserIcons;
35 39
40import com.google.android.collect.Sets;
41
42import java.util.ArrayList;
36import java.util.Iterator; 43import java.util.Iterator;
37import java.util.List; 44import java.util.List;
45import java.util.Set;
38 46
39/** 47/**
40 * Helper class for {@link UserManager}, this is meant to be used by builds that support 48 * Helper class for {@link UserManager}, this is meant to be used by builds that support
@@ -49,19 +57,47 @@ import java.util.List;
49public class CarUserManagerHelper { 57public class CarUserManagerHelper {
50 private static final String TAG = "CarUserManagerHelper"; 58 private static final String TAG = "CarUserManagerHelper";
51 private static final String HEADLESS_SYSTEM_USER = "android.car.systemuser.headless"; 59 private static final String HEADLESS_SYSTEM_USER = "android.car.systemuser.headless";
60 /**
61 * Default set of restrictions for Non-Admin users.
62 */
63 private static final Set<String> DEFAULT_NON_ADMIN_RESTRICTIONS = Sets.newArraySet(
64 UserManager.DISALLOW_FACTORY_RESET
65 );
66 /**
67 * Default set of restrictions for Guest users.
68 */
69 private static final Set<String> DEFAULT_GUEST_RESTRICTIONS = Sets.newArraySet(
70 UserManager.DISALLOW_FACTORY_RESET,
71 UserManager.DISALLOW_REMOVE_USER,
72 UserManager.DISALLOW_MODIFY_ACCOUNTS,
73 UserManager.DISALLOW_OUTGOING_CALLS,
74 UserManager.DISALLOW_SMS,
75 UserManager.DISALLOW_INSTALL_APPS,
76 UserManager.DISALLOW_UNINSTALL_APPS
77 );
78
52 private final Context mContext; 79 private final Context mContext;
53 private final UserManager mUserManager; 80 private final UserManager mUserManager;
54 private final ActivityManager mActivityManager; 81 private final ActivityManager mActivityManager;
82 private int mLastActiveUser = UserHandle.USER_SYSTEM;
55 private Bitmap mDefaultGuestUserIcon; 83 private Bitmap mDefaultGuestUserIcon;
56 private OnUsersUpdateListener mUpdateListener; 84 private ArrayList<OnUsersUpdateListener> mUpdateListeners;
57 private final BroadcastReceiver mUserChangeReceiver = new BroadcastReceiver() { 85 private final BroadcastReceiver mUserChangeReceiver = new BroadcastReceiver() {
58 @Override 86 @Override
59 public void onReceive(Context context, Intent intent) { 87 public void onReceive(Context context, Intent intent) {
60 mUpdateListener.onUsersUpdate(); 88 ArrayList<OnUsersUpdateListener> copyOfUpdateListeners;
89 synchronized (mUpdateListeners) {
90 copyOfUpdateListeners = new ArrayList(mUpdateListeners);
91 }
92
93 for (OnUsersUpdateListener listener : copyOfUpdateListeners) {
94 listener.onUsersUpdate();
95 }
61 } 96 }
62 }; 97 };
63 98
64 public CarUserManagerHelper(Context context) { 99 public CarUserManagerHelper(Context context) {
100 mUpdateListeners = new ArrayList<>();
65 mContext = context.getApplicationContext(); 101 mContext = context.getApplicationContext();
66 mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); 102 mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
67 mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); 103 mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
@@ -70,24 +106,139 @@ public class CarUserManagerHelper {
70 /** 106 /**
71 * Registers a listener for updates to all users - removing, adding users or changing user info. 107 * Registers a listener for updates to all users - removing, adding users or changing user info.
72 * 108 *
73 * <p> Best practise is to keep one listener per helper.
74 *
75 * @param listener Instance of {@link OnUsersUpdateListener}. 109 * @param listener Instance of {@link OnUsersUpdateListener}.
76 */ 110 */
77 public void registerOnUsersUpdateListener(OnUsersUpdateListener listener) { 111 public void registerOnUsersUpdateListener(OnUsersUpdateListener listener) {
78 if (mUpdateListener != null) { 112 if (listener == null) {
79 unregisterOnUsersUpdateListener(); 113 return;
114 }
115
116 synchronized (mUpdateListeners) {
117 if (mUpdateListeners.isEmpty()) {
118 // First listener being added, register receiver.
119 registerReceiver();
120 }
121
122 if (!mUpdateListeners.contains(listener)) {
123 mUpdateListeners.add(listener);
124 }
125 }
126 }
127
128 /**
129 * Unregisters on user update listener.
130 * Unregisters {@code BroadcastReceiver} if no listeners remain.
131 *
132 * @param listener Instance of {@link OnUsersUpdateListener} to unregister.
133 */
134 public void unregisterOnUsersUpdateListener(OnUsersUpdateListener listener) {
135 synchronized (mUpdateListeners) {
136 if (mUpdateListeners.contains(listener)) {
137 mUpdateListeners.remove(listener);
138
139 if (mUpdateListeners.isEmpty()) {
140 // No more listeners, unregister broadcast receiver.
141 unregisterReceiver();
142 }
143 }
80 } 144 }
145 }
81 146
82 mUpdateListener = listener; 147 /**
83 registerReceiver(); 148 * Set default boot into user.
149 *
150 * @param userId default user id to boot into.
151 */
152 public void setDefaultBootUser(int userId) {
153 Settings.Global.putInt(
154 mContext.getContentResolver(),
155 CarSettings.Global.DEFAULT_USER_ID_TO_BOOT_INTO, userId);
156 }
157
158 /**
159 * Set last active user.
160 *
161 * @param userId last active user id.
162 * @param skipGlobalSetting whether to skip set the global settings value.
163 */
164 public void setLastActiveUser(int userId, boolean skipGlobalSetting) {
165 mLastActiveUser = userId;
166 if (!skipGlobalSetting) {
167 Settings.Global.putInt(
168 mContext.getContentResolver(), CarSettings.Global.LAST_ACTIVE_USER_ID, userId);
169 }
84 } 170 }
85 171
86 /** 172 /**
87 * Unregisters on user update listener by unregistering {@code BroadcastReceiver}. 173 * Get user id for the default boot into user.
174 *
175 * @return user id of the default boot into user
176 */
177 public int getDefaultBootUser() {
178 // Make user 10 the original default boot user.
179 return Settings.Global.getInt(
180 mContext.getContentResolver(), CarSettings.Global.DEFAULT_USER_ID_TO_BOOT_INTO,
181 /* default user id= */ 10);
182 }
183
184 /**
185 * Get user id for the last active user.
186 *
187 * @return user id of the last active user.
88 */ 188 */
89 public void unregisterOnUsersUpdateListener() { 189 public int getLastActiveUser() {
90 unregisterReceiver(); 190 if (mLastActiveUser != UserHandle.USER_SYSTEM) {
191 return mLastActiveUser;
192 }
193 return Settings.Global.getInt(
194 mContext.getContentResolver(), CarSettings.Global.LAST_ACTIVE_USER_ID,
195 /* default user id= */ UserHandle.USER_SYSTEM);
196 }
197
198 /**
199 * Get user id for the initial user to boot into. This is only applicable for headless
200 * system user model.
201 *
202 * <p>If failed to retrieve the id stored in global settings or the retrieved id does not
203 * exist on device, then return the user with smallest user id.
204 *
205 * @return user id of the last active user or the smallest user id on the device.
206 */
207 public int getInitialUser() {
208 int lastActiveUserId = getLastActiveUser();
209
210 boolean isUserExist = false;
211 List<UserInfo> allUsers = getAllPersistentUsers();
212 int smallestUserId = Integer.MAX_VALUE;
213 for (UserInfo user : allUsers) {
214 if (user.id == lastActiveUserId) {
215 isUserExist = true;
216 }
217 smallestUserId = Math.min(user.id, smallestUserId);
218 }
219
220 // If the last active user is system user or the user id doesn't exist on device,
221 // return the smallest id or all users.
222 if (lastActiveUserId == UserHandle.USER_SYSTEM || !isUserExist) {
223 Log.e(TAG, "Can't get last active user id or the user no longer exist, user id: ."
224 + lastActiveUserId);
225 lastActiveUserId = smallestUserId;
226 }
227
228 return lastActiveUserId;
229 }
230
231 /**
232 * Sets default guest restrictions that will be applied every time a Guest user is created.
233 *
234 * <p> Restrictions are written to disk and persistent across boots.
235 */
236 public void initDefaultGuestRestrictions() {
237 Bundle defaultGuestRestrictions = new Bundle();
238 for (String restriction : DEFAULT_GUEST_RESTRICTIONS) {
239 defaultGuestRestrictions.putBoolean(restriction, true);
240 }
241 mUserManager.setDefaultGuestRestrictions(defaultGuestRestrictions);
91 } 242 }
92 243
93 /** 244 /**
@@ -151,8 +302,9 @@ public class CarUserManagerHelper {
151 } 302 }
152 303
153 /** 304 /**
154 * Gets all the existing foreground users on the system that are not currently running as 305 * Gets all the existing users on the system that are not currently running as
155 * the foreground user. 306 * the foreground user.
307 * These are all the users that can be switched to from the foreground user.
156 * 308 *
157 * @return List of {@code UserInfo} for each user that is not the foreground user. 309 * @return List of {@code UserInfo} for each user that is not the foreground user.
158 */ 310 */
@@ -173,8 +325,61 @@ public class CarUserManagerHelper {
173 if (isHeadlessSystemUser()) { 325 if (isHeadlessSystemUser()) {
174 return getAllUsersExceptSystemUserAndSpecifiedUser(UserHandle.USER_SYSTEM); 326 return getAllUsersExceptSystemUserAndSpecifiedUser(UserHandle.USER_SYSTEM);
175 } else { 327 } else {
176 return mUserManager.getUsers(/* excludeDying= */true); 328 return mUserManager.getUsers(/* excludeDying= */ true);
329 }
330 }
331
332 /**
333 * Gets all the users that are non-ephemeral and can be brought to the foreground on the system.
334 *
335 * @return List of {@code UserInfo} for non-ephemeral users that associated with a real person.
336 */
337 public List<UserInfo> getAllPersistentUsers() {
338 List<UserInfo> users = getAllUsers();
339 for (Iterator<UserInfo> iterator = users.iterator(); iterator.hasNext(); ) {
340 UserInfo userInfo = iterator.next();
341 if (userInfo.isEphemeral()) {
342 // Remove user that is ephemeral.
343 iterator.remove();
344 }
345 }
346 return users;
347 }
348
349 /**
350 * Gets all the users that can be brought to the foreground on the system that have admin roles.
351 *
352 * @return List of {@code UserInfo} for admin users that associated with a real person.
353 */
354 public List<UserInfo> getAllAdminUsers() {
355 List<UserInfo> users = getAllUsers();
356
357 for (Iterator<UserInfo> iterator = users.iterator(); iterator.hasNext(); ) {
358 UserInfo userInfo = iterator.next();
359 if (!userInfo.isAdmin()) {
360 // Remove user that is not admin.
361 iterator.remove();
362 }
363 }
364 return users;
365 }
366
367 /**
368 * Gets all users that are not guests.
369 *
370 * @return List of {@code UserInfo} for all users who are not guest users.
371 */
372 public List<UserInfo> getAllUsersExceptGuests() {
373 List<UserInfo> users = getAllUsers();
374
375 for (Iterator<UserInfo> iterator = users.iterator(); iterator.hasNext(); ) {
376 UserInfo userInfo = iterator.next();
377 if (userInfo.isGuest()) {
378 // Remove guests.
379 iterator.remove();
380 }
177 } 381 }
382 return users;
178 } 383 }
179 384
180 /** 385 /**
@@ -215,6 +420,62 @@ public class CarUserManagerHelper {
215 return users; 420 return users;
216 } 421 }
217 422
423 /**
424 * Maximum number of users allowed on the device. This includes real users, managed profiles
425 * and restricted users, but excludes guests.
426 *
427 * <p> It excludes system user in headless system user model.
428 *
429 * @return Maximum number of users that can be present on the device.
430 */
431 public int getMaxSupportedUsers() {
432 if (isHeadlessSystemUser()) {
433 return UserManager.getMaxSupportedUsers() - 1;
434 }
435 return UserManager.getMaxSupportedUsers();
436 }
437
438 /**
439 * Get the maximum number of real (non-guest, non-managed profile) users that can be created on
440 * the device. This is a dynamic value and it decreases with the increase of the number of
441 * managed profiles on the device.
442 *
443 * <p> It excludes system user in headless system user model.
444 *
445 * @return Maximum number of real users that can be created.
446 */
447 public int getMaxSupportedRealUsers() {
448 return getMaxSupportedUsers() - getManagedProfilesCount();
449 }
450
451 /**
452 * Returns true if the maximum number of users on the device has been reached, false otherwise.
453 */
454 public boolean isUserLimitReached() {
455 int countNonGuestUsers = getAllUsersExceptGuests().size();
456 int maxSupportedUsers = getMaxSupportedUsers();
457
458 if (countNonGuestUsers > maxSupportedUsers) {
459 Log.e(TAG, "There are more users on the device than allowed.");
460 return true;
461 }
462
463 return getAllUsersExceptGuests().size() == maxSupportedUsers;
464 }
465
466 private int getManagedProfilesCount() {
467 List<UserInfo> users = getAllUsers();
468
469 // Count all users that are managed profiles of another user.
470 int managedProfilesCount = 0;
471 for (UserInfo user : users) {
472 if (user.isManagedProfile()) {
473 managedProfilesCount++;
474 }
475 }
476 return managedProfilesCount;
477 }
478
218 // User information accessors 479 // User information accessors
219 480
220 /** 481 /**
@@ -234,7 +495,17 @@ public class CarUserManagerHelper {
234 * @return {@code true} if is default user, {@code false} otherwise. 495 * @return {@code true} if is default user, {@code false} otherwise.
235 */ 496 */
236 public boolean isDefaultUser(UserInfo userInfo) { 497 public boolean isDefaultUser(UserInfo userInfo) {
237 return userInfo.id == CarSettings.DEFAULT_USER_ID_TO_BOOT_INTO; 498 return userInfo.id == getDefaultBootUser();
499 }
500
501 /**
502 * Checks whether the user is last active user.
503 *
504 * @param userInfo User to check against last active user.
505 * @return {@code true} if is last active user, {@code false} otherwise.
506 */
507 public boolean isLastActiveUser(UserInfo userInfo) {
508 return userInfo.id == getLastActiveUser();
238 } 509 }
239 510
240 /** 511 /**
@@ -267,6 +538,24 @@ public class CarUserManagerHelper {
267 } 538 }
268 539
269 /** 540 /**
541 * Checks if the foreground user is ephemeral.
542 */
543 public boolean isForegroundUserEphemeral() {
544 return getCurrentForegroundUserInfo().isEphemeral();
545 }
546
547 /**
548 * Checks if the given user is non-ephemeral.
549 *
550 * @param userId User to check
551 * @return {@code true} if given user is persistent user.
552 */
553 public boolean isPersistentUser(int userId) {
554 UserInfo user = mUserManager.getUserInfo(userId);
555 return !user.isEphemeral();
556 }
557
558 /**
270 * Returns whether this user can be removed from the system. 559 * Returns whether this user can be removed from the system.
271 * 560 *
272 * @param userInfo User to be removed 561 * @param userInfo User to be removed
@@ -311,6 +600,13 @@ public class CarUserManagerHelper {
311 } 600 }
312 601
313 /** 602 /**
603 * Checks if the calling app is running as an admin user.
604 */
605 public boolean isCurrentProcessAdminUser() {
606 return mUserManager.isAdminUser();
607 }
608
609 /**
314 * Checks if the calling app is running as a guest user. 610 * Checks if the calling app is running as a guest user.
315 */ 611 */
316 public boolean isCurrentProcessGuestUser() { 612 public boolean isCurrentProcessGuestUser() {
@@ -369,17 +665,44 @@ public class CarUserManagerHelper {
369 } 665 }
370 666
371 /** 667 /**
668 * Assigns admin privileges to the user.
669 *
670 * @param user User to be upgraded to Admin status.
671 */
672 @RequiresPermission(allOf = {
673 Manifest.permission.INTERACT_ACROSS_USERS_FULL,
674 Manifest.permission.MANAGE_USERS
675 })
676 public void assignAdminPrivileges(UserInfo user) {
677 if (!isCurrentProcessAdminUser()) {
678 Log.w(TAG, "Only admin users can assign admin privileges.");
679 return;
680 }
681
682 mUserManager.setUserAdmin(user.id);
683
684 // Remove restrictions imposed on non-admins.
685 setDefaultNonAdminRestrictions(user, /* enable= */ false);
686 }
687
688 /**
372 * Creates a new user on the system, the created user would be granted admin role. 689 * Creates a new user on the system, the created user would be granted admin role.
690 * Only admins can create other admins.
373 * 691 *
374 * @param userName Name to give to the newly created user. 692 * @param userName Name to give to the newly created user.
375 * @return Newly created admin user, null if failed to create a user. 693 * @return Newly created admin user, null if failed to create a user.
376 */ 694 */
377 @Nullable 695 @Nullable
378 public UserInfo createNewAdminUser(String userName) { 696 public UserInfo createNewAdminUser(String userName) {
697 if (!(isCurrentProcessAdminUser() || isCurrentProcessSystemUser())) {
698 // Only Admins or System user can create other privileged users.
699 Log.e(TAG, "Only admin users and system user can create other admins.");
700 return null;
701 }
702
379 UserInfo user = mUserManager.createUser(userName, UserInfo.FLAG_ADMIN); 703 UserInfo user = mUserManager.createUser(userName, UserInfo.FLAG_ADMIN);
380 if (user == null) { 704 if (user == null) {
381 // Couldn't create user, most likely because there are too many, but we haven't 705 // Couldn't create user, most likely because there are too many.
382 // been able to reload the list yet.
383 Log.w(TAG, "can't create admin user."); 706 Log.w(TAG, "can't create admin user.");
384 return null; 707 return null;
385 } 708 }
@@ -397,16 +720,47 @@ public class CarUserManagerHelper {
397 public UserInfo createNewNonAdminUser(String userName) { 720 public UserInfo createNewNonAdminUser(String userName) {
398 UserInfo user = mUserManager.createUser(userName, 0); 721 UserInfo user = mUserManager.createUser(userName, 0);
399 if (user == null) { 722 if (user == null) {
400 // Couldn't create user, most likely because there are too many, but we haven't 723 // Couldn't create user, most likely because there are too many.
401 // been able to reload the list yet.
402 Log.w(TAG, "can't create non-admin user."); 724 Log.w(TAG, "can't create non-admin user.");
403 return null; 725 return null;
404 } 726 }
727 setDefaultNonAdminRestrictions(user, /* enable= */ true);
728
729 // Each non-admin has sms and outgoing call restrictions applied by the UserManager on
730 // creation. We want to enable these permissions by default in the car.
731 setUserRestriction(user, UserManager.DISALLOW_SMS, /* enable= */ false);
732 setUserRestriction(user, UserManager.DISALLOW_OUTGOING_CALLS, /* enable= */ false);
733
405 assignDefaultIcon(user); 734 assignDefaultIcon(user);
406 return user; 735 return user;
407 } 736 }
408 737
409 /** 738 /**
739 * Sets the values of default Non-Admin restrictions to the passed in value.
740 *
741 * @param userInfo User to set restrictions on.
742 * @param enable If true, restriction is ON, If false, restriction is OFF.
743 */
744 private void setDefaultNonAdminRestrictions(UserInfo userInfo, boolean enable) {
745 for (String restriction : DEFAULT_NON_ADMIN_RESTRICTIONS) {
746 setUserRestriction(userInfo, restriction, enable);
747 }
748 }
749
750 /**
751 * Sets the value of the specified restriction for the specified user.
752 *
753 * @param userInfo the user whose restriction is to be changed
754 * @param restriction the key of the restriction
755 * @param enable the value for the restriction. if true, turns the restriction ON, if false,
756 * turns the restriction OFF.
757 */
758 public void setUserRestriction(UserInfo userInfo, String restriction, boolean enable) {
759 UserHandle userHandle = UserHandle.of(userInfo.id);
760 mUserManager.setUserRestriction(restriction, enable, userHandle);
761 }
762
763 /**
410 * Tries to remove the user that's passed in. System user cannot be removed. 764 * Tries to remove the user that's passed in. System user cannot be removed.
411 * If the user to be removed is user currently running the process, 765 * If the user to be removed is user currently running the process,
412 * it switches to the guest user first, and then removes the user. 766 * it switches to the guest user first, and then removes the user.
@@ -420,10 +774,15 @@ public class CarUserManagerHelper {
420 return false; 774 return false;
421 } 775 }
422 776
423 // Not allow to delete the default user for now. Since default user is the one to 777 // Not allow to delete the last admin user on the device for now.
424 // boot into. 778 if (userInfo.isAdmin() && getAllAdminUsers().size() <= 1) {
425 if (isHeadlessSystemUser() && isDefaultUser(userInfo)) { 779 Log.w(TAG, "User " + userInfo.id + " is the last admin user on device.");
426 Log.w(TAG, "User " + userInfo.id + " is the default user, could not be removed."); 780 return false;
781 }
782
783 if (!isCurrentProcessAdminUser() && !isCurrentProcessUser(userInfo)) {
784 // If the caller is non-admin, they can only delete themselves.
785 Log.e(TAG, "Non-admins cannot remove other users.");
427 return false; 786 return false;
428 } 787 }
429 788
diff --git a/car-support-lib/proguard-release.flags b/car-support-lib/proguard-release.flags
index 91cab7ea..4f5f9178 100644
--- a/car-support-lib/proguard-release.flags
+++ b/car-support-lib/proguard-release.flags
@@ -7201,6 +7201,7 @@
7201 public int enabledSetting; 7201 public int enabledSetting;
7202 public int flags; 7202 public int flags;
7203 public int fullBackupContent; 7203 public int fullBackupContent;
7204 public boolean hiddenUntilInstalled;
7204 public int installLocation; 7205 public int installLocation;
7205 public int largestWidthLimitDp; 7206 public int largestWidthLimitDp;
7206 public long longVersionCode; 7207 public long longVersionCode;
@@ -7646,6 +7647,8 @@
7646 public abstract java.lang.String[] setPackagesSuspendedAsUser(java.lang.String[], boolean, android.os.PersistableBundle, android.os.PersistableBundle, java.lang.String, java.lang.String, int); 7647 public abstract java.lang.String[] setPackagesSuspendedAsUser(java.lang.String[], boolean, android.os.PersistableBundle, android.os.PersistableBundle, java.lang.String, java.lang.String, int);
7647 public abstract void setPermissionEnforced(java.lang.String, boolean); 7648 public abstract void setPermissionEnforced(java.lang.String, boolean);
7648 public abstract boolean setRequiredForSystemUser(java.lang.String, boolean); 7649 public abstract boolean setRequiredForSystemUser(java.lang.String, boolean);
7650 public abstract void setSystemAppHiddenUntilInstalled(java.lang.String, boolean);
7651 public abstract boolean setSystemAppInstallState(java.lang.String, boolean, int);
7649 public abstract void setUpdateAvailable(java.lang.String, boolean); 7652 public abstract void setUpdateAvailable(java.lang.String, boolean);
7650 public abstract boolean shouldShowRequestPermissionRationale(java.lang.String, java.lang.String, int); 7653 public abstract boolean shouldShowRequestPermissionRationale(java.lang.String, java.lang.String, int);
7651 public abstract void systemReady(); 7654 public abstract void systemReady();
@@ -8589,6 +8592,7 @@
8589 public static int MATCH_DISABLED_UNTIL_USED_COMPONENTS; 8592 public static int MATCH_DISABLED_UNTIL_USED_COMPONENTS;
8590 public static int MATCH_EXPLICITLY_VISIBLE_ONLY; 8593 public static int MATCH_EXPLICITLY_VISIBLE_ONLY;
8591 public static int MATCH_FACTORY_ONLY; 8594 public static int MATCH_FACTORY_ONLY;
8595 public static int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS;
8592 public static int MATCH_INSTANT; 8596 public static int MATCH_INSTANT;
8593 public static int MATCH_KNOWN_PACKAGES; 8597 public static int MATCH_KNOWN_PACKAGES;
8594 public static int MATCH_STATIC_SHARED_LIBRARIES; 8598 public static int MATCH_STATIC_SHARED_LIBRARIES;
@@ -17003,8 +17007,8 @@
17003 17007
17004 public boolean equals(java.lang.Object); 17008 public boolean equals(java.lang.Object);
17005 public static android.view.DisplayCutout fromBoundingRect(int, int, int, int);