Loading media/java/android/media/AudioManager.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -4982,6 +4982,20 @@ public class AudioManager { } } } } /** * @hide * Returns whether a client is currently holding audio focus. * @param pckgName the name of the package of the client */ @RequiresPermission("android.permission.QUERY_AUDIO_STATE") public boolean hasAudioFocus(@NonNull String pckgName) { try { return getService().hasAudioFocus(pckgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * @hide * @hide * Return the duration of the fade out applied when a player of the given AudioAttributes * Return the duration of the fade out applied when a player of the given AudioAttributes Loading services/core/java/com/android/server/pm/AppStateHelper.java +2 −5 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,7 @@ import android.app.usage.NetworkStatsManager; import android.content.Context; import android.content.Context; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManagerInternal; import android.media.AudioManager; import android.media.AudioManager; import android.media.IAudioService; import android.net.ConnectivityManager; import android.net.ConnectivityManager; import android.os.ServiceManager; import android.os.SystemProperties; import android.os.SystemProperties; import android.telecom.TelecomManager; import android.telecom.TelecomManager; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -74,10 +72,9 @@ public class AppStateHelper { * True if the app owns the audio focus. * True if the app owns the audio focus. */ */ private boolean hasAudioFocus(String packageName) { private boolean hasAudioFocus(String packageName) { var audioService = IAudioService.Stub.asInterface( var audioManager = mContext.getSystemService(AudioManager.class); ServiceManager.getService(Context.AUDIO_SERVICE)); try { try { return audioService.hasAudioFocus(packageName); return audioManager.hasAudioFocus(packageName); } catch (Exception ignore) { } catch (Exception ignore) { } } return false; return false; Loading Loading
media/java/android/media/AudioManager.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -4982,6 +4982,20 @@ public class AudioManager { } } } } /** * @hide * Returns whether a client is currently holding audio focus. * @param pckgName the name of the package of the client */ @RequiresPermission("android.permission.QUERY_AUDIO_STATE") public boolean hasAudioFocus(@NonNull String pckgName) { try { return getService().hasAudioFocus(pckgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * @hide * @hide * Return the duration of the fade out applied when a player of the given AudioAttributes * Return the duration of the fade out applied when a player of the given AudioAttributes Loading
services/core/java/com/android/server/pm/AppStateHelper.java +2 −5 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,7 @@ import android.app.usage.NetworkStatsManager; import android.content.Context; import android.content.Context; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManagerInternal; import android.media.AudioManager; import android.media.AudioManager; import android.media.IAudioService; import android.net.ConnectivityManager; import android.net.ConnectivityManager; import android.os.ServiceManager; import android.os.SystemProperties; import android.os.SystemProperties; import android.telecom.TelecomManager; import android.telecom.TelecomManager; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -74,10 +72,9 @@ public class AppStateHelper { * True if the app owns the audio focus. * True if the app owns the audio focus. */ */ private boolean hasAudioFocus(String packageName) { private boolean hasAudioFocus(String packageName) { var audioService = IAudioService.Stub.asInterface( var audioManager = mContext.getSystemService(AudioManager.class); ServiceManager.getService(Context.AUDIO_SERVICE)); try { try { return audioService.hasAudioFocus(packageName); return audioManager.hasAudioFocus(packageName); } catch (Exception ignore) { } catch (Exception ignore) { } } return false; return false; Loading