Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -23500,6 +23500,7 @@ package android.media { method @Deprecated public boolean isBluetoothA2dpOn(); method public boolean isBluetoothScoAvailableOffCall(); method public boolean isBluetoothScoOn(); method public boolean isCallScreeningModeSupported(); method public static boolean isHapticPlaybackSupported(); method public boolean isMicrophoneMute(); method public boolean isMusicActive(); Loading Loading @@ -23598,6 +23599,7 @@ package android.media { field public static final int GET_DEVICES_ALL = 3; // 0x3 field public static final int GET_DEVICES_INPUTS = 1; // 0x1 field public static final int GET_DEVICES_OUTPUTS = 2; // 0x2 field public static final int MODE_CALL_SCREENING = 4; // 0x4 field public static final int MODE_CURRENT = -1; // 0xffffffff field public static final int MODE_INVALID = -2; // 0xfffffffe field public static final int MODE_IN_CALL = 2; // 0x2 core/jni/android_media_AudioSystem.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -2264,6 +2264,12 @@ android_media_AudioSystem_setAudioHalPids(JNIEnv *env, jobject clazz, jintArray return jStatus; } static jboolean android_media_AudioSystem_isCallScreeningModeSupported(JNIEnv *env, jobject thiz) { return AudioSystem::isCallScreenModeSupported(); } // ---------------------------------------------------------------------------- static const JNINativeMethod gMethods[] = { Loading Loading @@ -2343,6 +2349,7 @@ static const JNINativeMethod gMethods[] = { {"setAllowedCapturePolicy", "(II)I", (void *)android_media_AudioSystem_setAllowedCapturePolicy}, {"setRttEnabled", "(Z)I", (void *)android_media_AudioSystem_setRttEnabled}, {"setAudioHalPids", "([I)I", (void *)android_media_AudioSystem_setAudioHalPids}, {"isCallScreeningModeSupported", "()Z", (void *)android_media_AudioSystem_isCallScreeningModeSupported}, }; static const JNINativeMethod gEventHandlerMethods[] = { Loading media/java/android/media/AudioManager.java +56 −7 Original line number Diff line number Diff line /* /* * Copyright (C) 2007 The Android Open Source Project * Loading Loading @@ -1931,12 +1932,11 @@ public class AudioManager { * application when it places a phone call, as it will cause signals from the radio layer * to feed the platform mixer. * * @param mode the requested audio mode ({@link #MODE_NORMAL}, {@link #MODE_RINGTONE}, * {@link #MODE_IN_CALL} or {@link #MODE_IN_COMMUNICATION}). * @param mode the requested audio mode. * Informs the HAL about the current audio state so that * it can route the audio appropriately. */ public void setMode(int mode) { public void setMode(@AudioMode int mode) { final IAudioService service = getService(); try { service.setMode(mode, mICallBack, mApplicationContext.getOpPackageName()); Loading @@ -1948,14 +1948,47 @@ public class AudioManager { /** * Returns the current audio mode. * * @return the current audio mode ({@link #MODE_NORMAL}, {@link #MODE_RINGTONE}, * {@link #MODE_IN_CALL} or {@link #MODE_IN_COMMUNICATION}). * Returns the current current audio state from the HAL. * @return the current audio mode. */ @AudioMode public int getMode() { final IAudioService service = getService(); try { return service.getMode(); int mode = service.getMode(); int sdk; try { sdk = getContext().getApplicationInfo().targetSdkVersion; } catch (NullPointerException e) { // some tests don't have a Context sdk = Build.VERSION.SDK_INT; } if (mode == MODE_CALL_SCREENING && sdk <= Build.VERSION_CODES.Q) { mode = MODE_IN_CALL; } return mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indicates if the platform supports a special call screening and call monitoring mode. * <p> * When this mode is supported, it is possible to perform call screening and monitoring * functions while other use cases like music or movie playback are active. * <p> * Use {@link #setMode(int)} with mode {@link #MODE_CALL_SCREENING} to place the platform in * call screening mode. * <p> * If call screening mode is not supported, setting mode to * MODE_CALL_SCREENING will be ignored and will not change current mode reported by * {@link #getMode()}. * @return true if call screening mode is supported, false otherwise. */ public boolean isCallScreeningModeSupported() { final IAudioService service = getService(); try { return service.isCallScreeningModeSupported(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1989,6 +2022,22 @@ public class AudioManager { * In communication audio mode. An audio/video chat or VoIP call is established. */ public static final int MODE_IN_COMMUNICATION = AudioSystem.MODE_IN_COMMUNICATION; /** * Call screening in progress. Call is connected and audio is accessible to call * screening applications but other audio use cases are still possible. */ public static final int MODE_CALL_SCREENING = AudioSystem.MODE_CALL_SCREENING; /** @hide */ @IntDef(flag = false, prefix = "MODE_", value = { MODE_NORMAL, MODE_RINGTONE, MODE_IN_CALL, MODE_IN_COMMUNICATION, MODE_CALL_SCREENING } ) @Retention(RetentionPolicy.SOURCE) public @interface AudioMode {} /* Routing bits for setRouting/getRouting API */ /** Loading media/java/android/media/AudioSystem.java +8 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,8 @@ public class AudioSystem public static final int MODE_RINGTONE = 1; public static final int MODE_IN_CALL = 2; public static final int MODE_IN_COMMUNICATION = 3; public static final int NUM_MODES = 4; public static final int MODE_CALL_SCREENING = 4; public static final int NUM_MODES = 5; public static String modeToString(int mode) { switch (mode) { Loading @@ -142,6 +143,7 @@ public class AudioSystem case MODE_INVALID: return "MODE_INVALID"; case MODE_NORMAL: return "MODE_NORMAL"; case MODE_RINGTONE: return "MODE_RINGTONE"; case MODE_CALL_SCREENING: return "MODE_CALL_SCREENING"; default: return "unknown mode (" + mode + ")"; } } Loading Loading @@ -1130,6 +1132,11 @@ public class AudioSystem */ public static native int setAudioHalPids(int[] pids); /** * @see AudioManager#isCallScreeningModeSupported() */ public static native boolean isCallScreeningModeSupported(); // Items shared with audio service /** Loading media/java/android/media/IAudioService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -263,6 +263,8 @@ interface IAudioService { boolean hasHapticChannels(in Uri uri); boolean isCallScreeningModeSupported(); // WARNING: read warning at top of file, new methods that need to be used by native // code via IAudioManager.h need to be added to the top section. } Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -23500,6 +23500,7 @@ package android.media { method @Deprecated public boolean isBluetoothA2dpOn(); method public boolean isBluetoothScoAvailableOffCall(); method public boolean isBluetoothScoOn(); method public boolean isCallScreeningModeSupported(); method public static boolean isHapticPlaybackSupported(); method public boolean isMicrophoneMute(); method public boolean isMusicActive(); Loading Loading @@ -23598,6 +23599,7 @@ package android.media { field public static final int GET_DEVICES_ALL = 3; // 0x3 field public static final int GET_DEVICES_INPUTS = 1; // 0x1 field public static final int GET_DEVICES_OUTPUTS = 2; // 0x2 field public static final int MODE_CALL_SCREENING = 4; // 0x4 field public static final int MODE_CURRENT = -1; // 0xffffffff field public static final int MODE_INVALID = -2; // 0xfffffffe field public static final int MODE_IN_CALL = 2; // 0x2
core/jni/android_media_AudioSystem.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -2264,6 +2264,12 @@ android_media_AudioSystem_setAudioHalPids(JNIEnv *env, jobject clazz, jintArray return jStatus; } static jboolean android_media_AudioSystem_isCallScreeningModeSupported(JNIEnv *env, jobject thiz) { return AudioSystem::isCallScreenModeSupported(); } // ---------------------------------------------------------------------------- static const JNINativeMethod gMethods[] = { Loading Loading @@ -2343,6 +2349,7 @@ static const JNINativeMethod gMethods[] = { {"setAllowedCapturePolicy", "(II)I", (void *)android_media_AudioSystem_setAllowedCapturePolicy}, {"setRttEnabled", "(Z)I", (void *)android_media_AudioSystem_setRttEnabled}, {"setAudioHalPids", "([I)I", (void *)android_media_AudioSystem_setAudioHalPids}, {"isCallScreeningModeSupported", "()Z", (void *)android_media_AudioSystem_isCallScreeningModeSupported}, }; static const JNINativeMethod gEventHandlerMethods[] = { Loading
media/java/android/media/AudioManager.java +56 −7 Original line number Diff line number Diff line /* /* * Copyright (C) 2007 The Android Open Source Project * Loading Loading @@ -1931,12 +1932,11 @@ public class AudioManager { * application when it places a phone call, as it will cause signals from the radio layer * to feed the platform mixer. * * @param mode the requested audio mode ({@link #MODE_NORMAL}, {@link #MODE_RINGTONE}, * {@link #MODE_IN_CALL} or {@link #MODE_IN_COMMUNICATION}). * @param mode the requested audio mode. * Informs the HAL about the current audio state so that * it can route the audio appropriately. */ public void setMode(int mode) { public void setMode(@AudioMode int mode) { final IAudioService service = getService(); try { service.setMode(mode, mICallBack, mApplicationContext.getOpPackageName()); Loading @@ -1948,14 +1948,47 @@ public class AudioManager { /** * Returns the current audio mode. * * @return the current audio mode ({@link #MODE_NORMAL}, {@link #MODE_RINGTONE}, * {@link #MODE_IN_CALL} or {@link #MODE_IN_COMMUNICATION}). * Returns the current current audio state from the HAL. * @return the current audio mode. */ @AudioMode public int getMode() { final IAudioService service = getService(); try { return service.getMode(); int mode = service.getMode(); int sdk; try { sdk = getContext().getApplicationInfo().targetSdkVersion; } catch (NullPointerException e) { // some tests don't have a Context sdk = Build.VERSION.SDK_INT; } if (mode == MODE_CALL_SCREENING && sdk <= Build.VERSION_CODES.Q) { mode = MODE_IN_CALL; } return mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indicates if the platform supports a special call screening and call monitoring mode. * <p> * When this mode is supported, it is possible to perform call screening and monitoring * functions while other use cases like music or movie playback are active. * <p> * Use {@link #setMode(int)} with mode {@link #MODE_CALL_SCREENING} to place the platform in * call screening mode. * <p> * If call screening mode is not supported, setting mode to * MODE_CALL_SCREENING will be ignored and will not change current mode reported by * {@link #getMode()}. * @return true if call screening mode is supported, false otherwise. */ public boolean isCallScreeningModeSupported() { final IAudioService service = getService(); try { return service.isCallScreeningModeSupported(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1989,6 +2022,22 @@ public class AudioManager { * In communication audio mode. An audio/video chat or VoIP call is established. */ public static final int MODE_IN_COMMUNICATION = AudioSystem.MODE_IN_COMMUNICATION; /** * Call screening in progress. Call is connected and audio is accessible to call * screening applications but other audio use cases are still possible. */ public static final int MODE_CALL_SCREENING = AudioSystem.MODE_CALL_SCREENING; /** @hide */ @IntDef(flag = false, prefix = "MODE_", value = { MODE_NORMAL, MODE_RINGTONE, MODE_IN_CALL, MODE_IN_COMMUNICATION, MODE_CALL_SCREENING } ) @Retention(RetentionPolicy.SOURCE) public @interface AudioMode {} /* Routing bits for setRouting/getRouting API */ /** Loading
media/java/android/media/AudioSystem.java +8 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,8 @@ public class AudioSystem public static final int MODE_RINGTONE = 1; public static final int MODE_IN_CALL = 2; public static final int MODE_IN_COMMUNICATION = 3; public static final int NUM_MODES = 4; public static final int MODE_CALL_SCREENING = 4; public static final int NUM_MODES = 5; public static String modeToString(int mode) { switch (mode) { Loading @@ -142,6 +143,7 @@ public class AudioSystem case MODE_INVALID: return "MODE_INVALID"; case MODE_NORMAL: return "MODE_NORMAL"; case MODE_RINGTONE: return "MODE_RINGTONE"; case MODE_CALL_SCREENING: return "MODE_CALL_SCREENING"; default: return "unknown mode (" + mode + ")"; } } Loading Loading @@ -1130,6 +1132,11 @@ public class AudioSystem */ public static native int setAudioHalPids(int[] pids); /** * @see AudioManager#isCallScreeningModeSupported() */ public static native boolean isCallScreeningModeSupported(); // Items shared with audio service /** Loading
media/java/android/media/IAudioService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -263,6 +263,8 @@ interface IAudioService { boolean hasHapticChannels(in Uri uri); boolean isCallScreeningModeSupported(); // WARNING: read warning at top of file, new methods that need to be used by native // code via IAudioManager.h need to be added to the top section. }