Merge "Add a test API to query audio HAL version." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d3672e192a
@@ -1466,6 +1466,7 @@ package android.media {
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.CALL_AUDIO_INTERCEPTION) public android.media.AudioTrack getCallUplinkInjectionAudioTrack(@NonNull android.media.AudioFormat);
|
||||
method @Nullable public static android.media.AudioDeviceInfo getDeviceInfoFromType(int);
|
||||
method @IntRange(from=0) @RequiresPermission("android.permission.QUERY_AUDIO_STATE") public long getFadeOutDurationOnFocusLossMillis(@NonNull android.media.AudioAttributes);
|
||||
method @Nullable public static String getHalVersion();
|
||||
method public static final int[] getPublicStreamTypes();
|
||||
method @NonNull public java.util.List<java.lang.Integer> getReportedSurroundFormats();
|
||||
method public int getStreamMinVolumeInt(int);
|
||||
|
||||
@@ -8450,6 +8450,22 @@ public class AudioManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the audio HAL version in the form MAJOR.MINOR. If there is no audio HAL found, null
|
||||
* will be returned.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static @Nullable String getHalVersion() {
|
||||
try {
|
||||
return getService().getHalVersion();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error querying getHalVersion", e);
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
private final Object mMuteAwaitConnectionListenerLock = new Object();
|
||||
|
||||
@GuardedBy("mMuteAwaitConnectionListenerLock")
|
||||
|
||||
@@ -480,7 +480,6 @@ interface IAudioService {
|
||||
|
||||
boolean sendFocusLoss(in AudioFocusInfo focusLoser, in IAudioPolicyCallback apcb);
|
||||
|
||||
|
||||
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)")
|
||||
void addAssistantServicesUids(in int[] assistantUID);
|
||||
|
||||
@@ -501,4 +500,6 @@ interface IAudioService {
|
||||
in IAudioDeviceVolumeDispatcher cb,
|
||||
in String packageName,
|
||||
in AudioDeviceAttributes device, in List<VolumeInfo> volumes);
|
||||
|
||||
String getHalVersion();
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HwBinder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -10471,6 +10472,25 @@ public class AudioService extends IAudioService.Stub
|
||||
return mMediaFocusControl.sendFocusLoss(focusLoser);
|
||||
}
|
||||
|
||||
private static final String[] HAL_VERSIONS = new String[] {"7.1", "7.0", "6.0", "4.0", "2.0"};
|
||||
|
||||
/** @see AudioManager#getHalVersion */
|
||||
public @Nullable String getHalVersion() {
|
||||
for (String version : HAL_VERSIONS) {
|
||||
try {
|
||||
HwBinder.getService(
|
||||
String.format("android.hardware.audio@%s::IDevicesFactory", version),
|
||||
"default");
|
||||
return version;
|
||||
} catch (NoSuchElementException e) {
|
||||
// Ignore, the specified HAL interface is not found.
|
||||
} catch (RemoteException re) {
|
||||
Log.e(TAG, "Remote exception when getting hardware audio service:", re);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** see AudioManager.hasRegisteredDynamicPolicy */
|
||||
public boolean hasRegisteredDynamicPolicy() {
|
||||
synchronized (mAudioPolicies) {
|
||||
|
||||
Reference in New Issue
Block a user