Merge "Refactoring VmsHalService into VmsBrokerService and VmsHalService."
diff --git a/car-lib/api/current.txt b/car-lib/api/current.txt
index 7f509df..f520acc 100644
--- a/car-lib/api/current.txt
+++ b/car-lib/api/current.txt
@@ -394,28 +394,8 @@
package android.car.media {
public final class CarAudioManager {
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) public android.car.media.CarAudioPatchHandle createAudioPatch(String, int, int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) @NonNull public String[] getExternalSources();
- method public int getGroupMaxVolume(int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMaxVolume(int, int);
- method public int getGroupMinVolume(int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMinVolume(int, int);
- method public int getGroupVolume(int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupVolume(int, int);
- method @NonNull public int[] getUsagesForVolumeGroupId(int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) @NonNull public int[] getUsagesForVolumeGroupId(int, int);
- method public int getVolumeGroupCount();
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupCount(int);
- method public int getVolumeGroupIdForUsage(int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupIdForUsage(int, int);
method public void registerCarVolumeCallback(@NonNull android.car.media.CarAudioManager.CarVolumeCallback);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) public void releaseAudioPatch(android.car.media.CarAudioPatchHandle);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setBalanceTowardRight(float);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setFadeTowardFront(float);
- method public void setGroupVolume(int, int, int);
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setGroupVolume(int, int, int, int);
method public void unregisterCarVolumeCallback(@NonNull android.car.media.CarAudioManager.CarVolumeCallback);
- field public static final int PRIMARY_AUDIO_ZONE = 0; // 0x0
}
public abstract static class CarAudioManager.CarVolumeCallback {
@@ -424,13 +404,6 @@
method public void onMasterMuteChanged(int, int);
}
- public final class CarAudioPatchHandle implements android.os.Parcelable {
- ctor public CarAudioPatchHandle(android.media.AudioPatch);
- method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.car.media.CarAudioPatchHandle> CREATOR;
- }
-
}
package android.car.navigation {
diff --git a/car-lib/api/system-current.txt b/car-lib/api/system-current.txt
index 3459e1f..ff4f8d1 100644
--- a/car-lib/api/system-current.txt
+++ b/car-lib/api/system-current.txt
@@ -736,6 +736,40 @@
}
+package android.car.media {
+
+ public final class CarAudioManager {
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) public android.car.media.CarAudioPatchHandle createAudioPatch(String, int, int);
+ method @NonNull @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) public String[] getExternalSources();
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMaxVolume(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMaxVolume(int, int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMinVolume(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupMinVolume(int, int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupVolume(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getGroupVolume(int, int);
+ method @NonNull @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int[] getUsagesForVolumeGroupId(int);
+ method @NonNull @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int[] getUsagesForVolumeGroupId(int, int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupCount();
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupCount(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupIdForUsage(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public int getVolumeGroupIdForUsage(int, int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS) public void releaseAudioPatch(android.car.media.CarAudioPatchHandle);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setBalanceTowardRight(float);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setFadeTowardFront(float);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setGroupVolume(int, int, int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME) public void setGroupVolume(int, int, int, int);
+ field public static final int PRIMARY_AUDIO_ZONE = 0; // 0x0
+ }
+
+ public final class CarAudioPatchHandle implements android.os.Parcelable {
+ ctor public CarAudioPatchHandle(android.media.AudioPatch);
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.car.media.CarAudioPatchHandle> CREATOR;
+ }
+
+}
+
package android.car.navigation {
public class CarNavigationInstrumentCluster implements android.os.Parcelable {
@@ -896,10 +930,10 @@
package android.car.trust {
public final class CarTrustAgentEnrollmentManager {
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void activateToken(long);
method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void enrollmentHandshakeAccepted();
- method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public java.util.List<java.lang.Integer> getEnrollmentHandlesForUser(int);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) @NonNull public java.util.List<java.lang.Long> getEnrollmentHandlesForUser(int);
method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void initiateEnrollmentHandshake(android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public boolean isEscrowTokenActive(long, int);
method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void revokeTrust(long);
method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void setBleCallback(@Nullable android.car.trust.CarTrustAgentEnrollmentManager.CarTrustAgentBleCallback);
method @RequiresPermission(android.car.Car.PERMISSION_CAR_ENROLL_TRUST) public void setEnrollmentCallback(@Nullable android.car.trust.CarTrustAgentEnrollmentManager.CarTrustAgentEnrollmentCallback);
diff --git a/car-lib/src/android/car/media/CarAudioManager.java b/car-lib/src/android/car/media/CarAudioManager.java
index d3fb4bd..9fb1fa5 100644
--- a/car-lib/src/android/car/media/CarAudioManager.java
+++ b/car-lib/src/android/car/media/CarAudioManager.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.car.Car;
import android.car.CarLibLog;
@@ -52,7 +53,9 @@
/**
* Zone id of the primary audio zone.
+ * @hide
*/
+ @SystemApi
public static final int PRIMARY_AUDIO_ZONE = 0x0;
private final ICarAudio mService;
@@ -91,7 +94,10 @@
* Sets the volume index for a volume group in primary zone.
*
* @see {@link #setGroupVolume(int, int, int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public void setGroupVolume(int groupId, int index, int flags) {
setGroupVolume(PRIMARY_AUDIO_ZONE, groupId, index, flags);
}
@@ -105,7 +111,9 @@
* {@link #getGroupMaxVolume(int, int)} for the largest valid value.
* @param flags One or more flags (e.g., {@link android.media.AudioManager#FLAG_SHOW_UI},
* {@link android.media.AudioManager#FLAG_PLAY_SOUND})
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public void setGroupVolume(int zoneId, int groupId, int index, int flags) {
try {
@@ -119,7 +127,10 @@
* Returns the maximum volume index for a volume group in primary zone.
*
* @see {@link #getGroupMaxVolume(int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupMaxVolume(int groupId) {
return getGroupMaxVolume(PRIMARY_AUDIO_ZONE, groupId);
}
@@ -130,7 +141,9 @@
* @param zoneId The zone id whose volume group is queried.
* @param groupId The volume group id whose maximum volume index is returned.
* @return The maximum valid volume index for the given group.
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupMaxVolume(int zoneId, int groupId) {
try {
@@ -144,7 +157,10 @@
* Returns the minimum volume index for a volume group in primary zone.
*
* @see {@link #getGroupMinVolume(int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupMinVolume(int groupId) {
return getGroupMinVolume(PRIMARY_AUDIO_ZONE, groupId);
}
@@ -155,7 +171,9 @@
* @param zoneId The zone id whose volume group is queried.
* @param groupId The volume group id whose minimum volume index is returned.
* @return The minimum valid volume index for the given group, non-negative
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupMinVolume(int zoneId, int groupId) {
try {
@@ -169,7 +187,10 @@
* Returns the current volume index for a volume group in primary zone.
*
* @see {@link #getGroupVolume(int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupVolume(int groupId) {
return getGroupVolume(PRIMARY_AUDIO_ZONE, groupId);
}
@@ -183,7 +204,9 @@
*
* @see #getGroupMaxVolume(int, int)
* @see #setGroupVolume(int, int, int, int)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getGroupVolume(int zoneId, int groupId) {
try {
@@ -200,7 +223,9 @@
* fully toward the front. 0.0 means evenly balanced.
*
* @see #setBalanceTowardRight(float)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public void setFadeTowardFront(float value) {
try {
@@ -217,7 +242,9 @@
* fully toward the right. 0.0 means evenly balanced.
*
* @see #setFadeTowardFront(float)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public void setBalanceTowardRight(float value) {
try {
@@ -237,7 +264,9 @@
*
* @see #createAudioPatch(String, int, int)
* @see #releaseAudioPatch(CarAudioPatchHandle)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS)
public @NonNull String[] getExternalSources() {
try {
@@ -264,7 +293,9 @@
*
* @see #getExternalSources()
* @see #releaseAudioPatch(CarAudioPatchHandle)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS)
public CarAudioPatchHandle createAudioPatch(String sourceAddress,
@AudioAttributes.AttributeUsage int usage, int gainInMillibels) {
@@ -283,7 +314,9 @@
*
* @see #getExternalSources()
* @see #createAudioPatch(String, int, int)
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS)
public void releaseAudioPatch(CarAudioPatchHandle patch) {
try {
@@ -297,7 +330,10 @@
* Gets the count of available volume groups in primary zone.
*
* @see {@link #getVolumeGroupCount(int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getVolumeGroupCount() {
return getVolumeGroupCount(PRIMARY_AUDIO_ZONE);
}
@@ -307,7 +343,9 @@
*
* @param zoneId The zone id whois count of volume groups is queried.
* @return Count of volume groups
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getVolumeGroupCount(int zoneId) {
try {
@@ -321,7 +359,10 @@
* Gets the volume group id for a given {@link AudioAttributes} usage in primary zone.
*
* @see {@link #getVolumeGroupIdForUsage(int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getVolumeGroupIdForUsage(@AudioAttributes.AttributeUsage int usage) {
return getVolumeGroupIdForUsage(PRIMARY_AUDIO_ZONE, usage);
}
@@ -332,7 +373,9 @@
* @param zoneId The zone id whose volume group is queried.
* @param usage The {@link AudioAttributes} usage to get a volume group from.
* @return The volume group id where the usage belongs to
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public int getVolumeGroupIdForUsage(int zoneId, @AudioAttributes.AttributeUsage int usage) {
try {
@@ -346,7 +389,10 @@
* Gets array of {@link AudioAttributes} usages for a volume group in primary zone.
*
* @see {@link #getUsagesForVolumeGroupId(int, int)}
+ * @hide
*/
+ @SystemApi
+ @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public @NonNull int[] getUsagesForVolumeGroupId(int groupId) {
return getUsagesForVolumeGroupId(PRIMARY_AUDIO_ZONE, groupId);
}
@@ -357,7 +403,9 @@
* @param zoneId The zone id whose volume group is queried.
* @param groupId The volume group id whose associated audio usages is returned.
* @return Array of {@link AudioAttributes} usages for a given volume group id
+ * @hide
*/
+ @SystemApi
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
public @NonNull int[] getUsagesForVolumeGroupId(int zoneId, int groupId) {
try {
diff --git a/car-lib/src/android/car/media/CarAudioPatchHandle.java b/car-lib/src/android/car/media/CarAudioPatchHandle.java
index bbcc791..77dfc23 100644
--- a/car-lib/src/android/car/media/CarAudioPatchHandle.java
+++ b/car-lib/src/android/car/media/CarAudioPatchHandle.java
@@ -16,6 +16,7 @@
package android.car.media;
+import android.annotation.SystemApi;
import android.media.AudioDevicePort;
import android.media.AudioPatch;
import android.os.Parcel;
@@ -27,7 +28,9 @@
* A class to encapsulate the handle for a system level audio patch. This is used
* to provide a "safe" way for permitted applications to route automotive audio sources
* outside of android.
+ * @hide
*/
+@SystemApi
public final class CarAudioPatchHandle implements Parcelable {
// This is enough information to uniquely identify a patch to the system
diff --git a/car-lib/src/android/car/trust/CarTrustAgentEnrollmentManager.java b/car-lib/src/android/car/trust/CarTrustAgentEnrollmentManager.java
index 1bb3ba0..e10c280 100644
--- a/car-lib/src/android/car/trust/CarTrustAgentEnrollmentManager.java
+++ b/car-lib/src/android/car/trust/CarTrustAgentEnrollmentManager.java
@@ -18,6 +18,7 @@
import static android.car.Car.PERMISSION_CAR_ENROLL_TRUST;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
@@ -172,14 +173,21 @@
}
/**
- * Activate the newly added escrow token.
+ * Returns {@code true} if the escrow token associated with the given handle is active.
+ * <p>
+ * When a new escrow token has been added as part of the Trusted device enrollment, the client
+ * will receive {@link CarTrustAgentEnrollmentCallback#onEscrowTokenAdded(long)} and
+ * {@link CarTrustAgentEnrollmentCallback#onEscrowTokenActiveStateChanged(long, boolean)}
+ * callbacks. This method provides a way to query for the token state at a later point of time.
*
* @param handle the handle corresponding to the escrow token
+ * @param uid user id associated with the token
+ * @return true if the token is active, false if not
*/
@RequiresPermission(PERMISSION_CAR_ENROLL_TRUST)
- public void activateToken(long handle) {
+ public boolean isEscrowTokenActive(long handle, int uid) {
try {
- mEnrollmentService.activateToken(handle);
+ return mEnrollmentService.isEscrowTokenActive(handle, uid);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -281,17 +289,19 @@
/**
* Provides a list of enrollment handles for the given user id.
+ * <p>
* Each enrollment handle corresponds to a trusted device for the given user.
*
* @param uid user id.
* @return list of the Enrollment handles for the user id.
*/
@RequiresPermission(PERMISSION_CAR_ENROLL_TRUST)
- public List<Integer> getEnrollmentHandlesForUser(int uid) {
+ @NonNull
+ public List<Long> getEnrollmentHandlesForUser(int uid) {
try {
- return Arrays.stream(
- mEnrollmentService.getEnrollmentHandlesForUser(uid)).boxed().collect(
- Collectors.toList());
+ return Arrays.stream(mEnrollmentService.getEnrollmentHandlesForUser(uid))
+ .boxed()
+ .collect(Collectors.toList());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -346,7 +356,6 @@
* @param active True if token has been activated, false if not.
*/
void onEscrowTokenActiveStateChanged(long handle, boolean active);
-
}
/**
diff --git a/car-lib/src/android/car/trust/ICarTrustAgentEnrollment.aidl b/car-lib/src/android/car/trust/ICarTrustAgentEnrollment.aidl
index 0476f70..5606c06 100644
--- a/car-lib/src/android/car/trust/ICarTrustAgentEnrollment.aidl
+++ b/car-lib/src/android/car/trust/ICarTrustAgentEnrollment.aidl
@@ -32,9 +32,9 @@
void initiateEnrollmentHandshake(in BluetoothDevice device);
void enrollmentHandshakeAccepted();
void terminateEnrollmentHandshake();
- void activateToken(in long handle);
+ boolean isEscrowTokenActive(in long handle, int uid);
void revokeTrust(in long handle);
- int[] getEnrollmentHandlesForUser(in int uid);
+ long[] getEnrollmentHandlesForUser(in int uid);
void registerEnrollmentCallback(in ICarTrustAgentEnrollmentCallback callback);
void unregisterEnrollmentCallback(in ICarTrustAgentEnrollmentCallback callback);
void registerBleCallback(in ICarTrustAgentBleCallback callback);
diff --git a/car_product/init/init.bootstat.rc b/car_product/init/init.bootstat.rc
index 430a96b..5c5e796 100644
--- a/car_product/init/init.bootstat.rc
+++ b/car_product/init/init.bootstat.rc
@@ -3,31 +3,5 @@
# IMPORTANT: Do not create world writable files or directories.
# This is a common source of Android security bugs.
#
-on post-fs-data
- mkdir /data/misc/bootstat 0700 root root
-
-# Record the time at which the user has successfully entered the pin to decrypt
-# the device, /data is decrypted, and the system is entering the main boot phase.
-#
-# post-fs-data: /data is writable
-# property:init.svc.bootanim=running: The boot animation is running
-on post-fs-data && property:init.svc.bootanim=running
- exec - root root -- /system/bin/bootstat -r post_decrypt_time_elapsed
-
-# Boot animation stopped, is considered the point at which
-# the user may interact with the device, so it is a good proxy for the boot
-# complete signal.
-on property:init.svc.bootanim=stopped
- # Record boot_complete and related stats (decryption, etc).
- exec - root root -- /system/bin/bootstat --record_boot_complete
-
-on property:dev.bootcomplete=1
- exec - root root -- /system/bin/bootstat -r dev_bootcomplete
- # Log all boot events.
- exec - root root -- /system/bin/bootstat -l
-
on property:boot.car_service_created=1
exec - root root -- /system/bin/bootstat -r car_service_created
-
-on property:init.svc.zygote=running
- exec - root root -- /system/bin/bootstat -r zygote_running
diff --git a/car_product/overlay/frameworks/base/core/res/res/values/styles.xml b/car_product/overlay/frameworks/base/core/res/res/values/styles.xml
index 1362b97..20d6b49 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values/styles.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values/styles.xml
@@ -24,7 +24,7 @@
<!-- Override the default activity transitions. We have to do a full copy and not just inherit
and override because we're replacing the default style across the system.
-->
- <style name="Animation.DeviceDefault.Activity" parent="*android:Animation.Material.Activity">
+ <style name="Animation.Activity" parent="*android:Animation.Material.Activity">
<item name="android:activityOpenEnterAnimation">@*android:anim/fade_in</item>
<item name="android:activityOpenExitAnimation">@*android:anim/fade_out</item>
<item name="android:activityCloseEnterAnimation">@*android:anim/fade_in</item>
diff --git a/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java b/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
index 5d7fc0e..6b2169a 100644
--- a/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
+++ b/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
@@ -33,18 +33,24 @@
import android.bluetooth.BluetoothPbapClient;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
+import android.car.Car;
import android.car.CarBluetoothManager;
+import android.car.CarNotConnectedException;
import android.car.ICarBluetoothUserService;
import android.car.ICarUserService;
import android.car.drivingstate.CarUxRestrictions;
import android.car.drivingstate.ICarUxRestrictionsChangeListener;
import android.car.hardware.CarPropertyValue;
+import android.car.hardware.power.CarPowerManager;
+import android.car.hardware.power.CarPowerManager.CarPowerStateListener;
import android.car.hardware.property.CarPropertyEvent;
import android.car.hardware.property.ICarPropertyEventListener;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.ServiceConnection;
import android.hardware.automotive.vehicle.V2_0.VehicleIgnitionState;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.os.Binder;
@@ -71,10 +77,10 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
-
/**
* A Bluetooth Device Connection policy that is specific to the use cases of a Car. A car's
* bluetooth capabilities in terms of the profiles it supports and its use cases are unique.
@@ -112,12 +118,15 @@
// The main data structure that holds on to the {profile:list of known and connectible devices}
HashMap<Integer, BluetoothDevicesInfo> mProfileToConnectableDevicesMap;
- /// TODO(vnori): fix this. b/70029056
- private static final int NUM_SUPPORTED_PHONE_CONNECTIONS = 4; // num of HFP and PBAP connections
- private static final int NUM_SUPPORTED_MSG_CONNECTIONS = 4; // num of MAP connections
- private static final int NUM_SUPPORTED_MUSIC_CONNECTIONS = 1; // num of A2DP connections
- private static final int NUM_SUPPORTED_NETWORK_CONNECTIONS = 1; // num of PAN connections
- private Map<Integer, Integer> mNumSupportedActiveConnections;
+ // Keep a map of the maximum number of connections allowed for any profile we plan to support.
+ private static final Map<Integer, Integer> sNumSupportedActiveConnections = new HashMap<>();
+ static {
+ sNumSupportedActiveConnections.put(BluetoothProfile.HEADSET_CLIENT, 4);
+ sNumSupportedActiveConnections.put(BluetoothProfile.PBAP_CLIENT, 4);
+ sNumSupportedActiveConnections.put(BluetoothProfile.A2DP_SINK, 1);
+ sNumSupportedActiveConnections.put(BluetoothProfile.MAP_CLIENT, 4);
+ sNumSupportedActiveConnections.put(BluetoothProfile.PAN, 1);
+ }
private BluetoothAutoConnectStateMachine mBluetoothAutoConnectStateMachine;
private final BluetoothAdapter mBluetoothAdapter;
@@ -133,6 +142,63 @@
private final CarPropertyService mCarPropertyService;
private final CarPropertyListener mPropertyEventListener;
+ // Car service binder to setup listening for power manager updates
+ private final Car mCar;
+ private CarPowerManager mCarPowerManager;
+ private final CarPowerStateListener mCarPowerStateListener = new CarPowerStateListener() {
+ @Override
+ public void onStateChanged(int state, CompletableFuture<Void> future) {
+ if (DBG) Log.d(TAG, "Car power state has changed to " + state);
+
+ // ON is the state when user turned on the car (it can be either ignition or
+ // door unlock) the policy for ON is defined by OEMs and we can rely on that.
+ if (state == CarPowerManager.CarPowerStateListener.ON) {
+ Log.i(TAG, "Car is powering on. Enable Bluetooth and auto-connect to devices.");
+ if (isBluetoothPersistedOn()) {
+ enabledBluetooth();
+ }
+ initiateConnection();
+ return;
+ }
+
+ // Since we're appearing to be off after shutdown prepare, but may stay on in idle mode,
+ // we'll turn off Bluetooth to disconnect devices and better the "off" illusion
+ if (state == CarPowerManager.CarPowerStateListener.SHUTDOWN_PREPARE) {
+ Log.i(TAG, "Car is preparing for shutdown. Disable bluetooth adapter.");
+ disableBluetooth();
+
+ // Let CPMS know we're ready to shutdown. Otherwise, CPMS will get stuck for
+ // up to an hour.
+ if (future != null) {
+ future.complete(null);
+ }
+ return;
+ }
+ }
+ };
+
+
+ private final ServiceConnection mCarServiceConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.i(TAG, "Car is now connected, getting CarPowerManager service");
+ try {
+ mCarPowerManager = (CarPowerManager) mCar.getCarManager(Car.POWER_SERVICE);
+ mCarPowerManager.setListener(mCarPowerStateListener);
+ } catch (CarNotConnectedException e) {
+ Log.e(TAG, "Failed to get CarPowerManager instance", e);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.i(TAG, "Car is now disconnected");
+ if (mCarPowerManager != null) {
+ mCarPowerManager.clearListener();
+ }
+ }
+ };
+
// PerUserCarService related listeners
private final UserServiceConnectionCallback mServiceCallback;
@@ -193,33 +259,6 @@
CarBluetoothManager.BLUETOOTH_DEVICE_CONNECTION_PRIORITY_0,
CarBluetoothManager.BLUETOOTH_DEVICE_CONNECTION_PRIORITY_1
);
- // mNumSupportedActiveConnections is a HashMap of mProfilesToConnect and the number of
- // connections each profile supports currently.
- mNumSupportedActiveConnections = new HashMap<>(mProfilesToConnect.size());
- for (Integer profile : mProfilesToConnect) {
- switch (profile) {
- case BluetoothProfile.HEADSET_CLIENT:
- mNumSupportedActiveConnections.put(BluetoothProfile.HEADSET_CLIENT,
- NUM_SUPPORTED_PHONE_CONNECTIONS);
- break;
- case BluetoothProfile.PBAP_CLIENT:
- mNumSupportedActiveConnections.put(BluetoothProfile.PBAP_CLIENT,
- NUM_SUPPORTED_PHONE_CONNECTIONS);
- break;
- case BluetoothProfile.A2DP_SINK:
- mNumSupportedActiveConnections.put(BluetoothProfile.A2DP_SINK,
- NUM_SUPPORTED_MUSIC_CONNECTIONS);
- break;
- case BluetoothProfile.MAP_CLIENT:
- mNumSupportedActiveConnections.put(BluetoothProfile.MAP_CLIENT,
- NUM_SUPPORTED_MSG_CONNECTIONS);
- break;
- case BluetoothProfile.PAN:
- mNumSupportedActiveConnections.put(BluetoothProfile.PAN,
- NUM_SUPPORTED_NETWORK_CONNECTIONS);
- break;
- }
- }
// Listen to events for triggering auto connect
mPropertyEventListener = new CarPropertyListener();
@@ -232,6 +271,10 @@
Log.w(TAG, "No Bluetooth Adapter Available");
}
mFastPairProvider = new FastPairProvider(mContext);
+
+ // Connect to car
+ mCar = Car.createCar(context, mCarServiceConnection);
+ mCar.connect();
}
/**
@@ -746,7 +789,7 @@
for (Integer profile : mProfilesToConnect) {
// Build the BluetoothDevicesInfo for this profile.
BluetoothDevicesInfo devicesInfo = new BluetoothDevicesInfo(profile,
- mNumSupportedActiveConnections.get(profile));
+ sNumSupportedActiveConnections.get(profile));
mProfileToConnectableDevicesMap.put(profile, devicesInfo);
}
if (DBG) {
@@ -851,6 +894,7 @@
writeDeviceInfoToSettings();
cleanupUserSpecificInfo();
closeEventListeners();
+ mCar.disconnect();
}
/**
@@ -1796,6 +1840,41 @@
}
/**
+ * Get the persisted Bluetooth state from Settings
+ */
+ private boolean isBluetoothPersistedOn() {
+ return (Settings.Global.getInt(
+ mContext.getContentResolver(), Settings.Global.BLUETOOTH_ON, -1) != 0);
+ }
+
+ /**
+ * Turn on the Bluetooth Adapter.
+ */
+ private void enabledBluetooth() {
+ if (DBG) Log.d(TAG, "Enable bluetooth adapter");
+ if (mBluetoothAdapter == null) {
+ Log.e(TAG, "Cannot enable Bluetooth adapter. The object is null.");
+ return;
+ }
+ mBluetoothAdapter.enable();
+ }
+
+ /**
+ * Turn off the Bluetooth Adapter.
+ *
+ * Tells BluetoothAdapter to shut down _without_ persisting the off state as the desired state
+ * of the Bluetooth adapter for next start up.
+ */
+ private void disableBluetooth() {
+ if (DBG) Log.d(TAG, "Disable bluetooth, do not persist state across reboot");
+ if (mBluetoothAdapter == null) {
+ Log.e(TAG, "Cannot disable Bluetooth adapter. The object is null.");
+ return;
+ }
+ mBluetoothAdapter.disable(false);
+ }
+
+ /**
* Write the device list for all bluetooth profiles that connected.
*
* @return true if the write was successful, false otherwise
diff --git a/service/src/com/android/car/trust/CarTrustAgentEnrollmentService.java b/service/src/com/android/car/trust/CarTrustAgentEnrollmentService.java
index e6aeeac..cd421e7 100644
--- a/service/src/com/android/car/trust/CarTrustAgentEnrollmentService.java
+++ b/service/src/com/android/car/trust/CarTrustAgentEnrollmentService.java
@@ -86,7 +86,8 @@
}
@Override
- public void activateToken(long handle) {
+ public boolean isEscrowTokenActive(long handle, int uid) {
+ return false;
}
@Override
@@ -94,9 +95,8 @@
}
@Override
- public int[] getEnrollmentHandlesForUser(int uid) {
- int[] handles = {};
- return handles;
+ public long[] getEnrollmentHandlesForUser(int uid) {
+ return new long[0];
}
/**