AudioManager: fix implementation of isMusicActive()
Implementation of isMusicActive() should go through AudioService as AudioSystem.isStreamActive() can only be called from system service. Bug: 175084989 Bug: 162423060 Test: atest AudioManagerTest Change-Id: I15b3f7cd082a7497f857e6bf261f933224da853e
This commit is contained in:
@@ -2881,7 +2881,12 @@ public class AudioManager {
|
||||
* @return true if any music tracks are active.
|
||||
*/
|
||||
public boolean isMusicActive() {
|
||||
return AudioSystem.isStreamActive(STREAM_MUSIC, 0);
|
||||
final IAudioService service = getService();
|
||||
try {
|
||||
return service.isMusicActive();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -334,4 +334,6 @@ interface IAudioService {
|
||||
oneway void setStreamVolumeForUid(int streamType, int direction, int flags,
|
||||
in String packageName, int uid, int pid, in UserHandle userHandle,
|
||||
int targetSdkVersion);
|
||||
|
||||
boolean isMusicActive();
|
||||
}
|
||||
|
||||
@@ -2108,6 +2108,12 @@ public class AudioService extends IAudioService.Stub
|
||||
return getDevicesForAttributesInt(attributes);
|
||||
}
|
||||
|
||||
/** @see AudioManager#isMusicActive() */
|
||||
public boolean isMusicActive() {
|
||||
// no permission required
|
||||
return AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0);
|
||||
}
|
||||
|
||||
protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt(
|
||||
@NonNull AudioAttributes attributes) {
|
||||
Objects.requireNonNull(attributes);
|
||||
|
||||
Reference in New Issue
Block a user