Merge "Define stream type for accessibility volume control"
This commit is contained in:
committed by
Android (Google) Code Review
commit
6d5723fe4e
@@ -19914,6 +19914,7 @@ package android.media {
|
||||
field public static final int SCO_AUDIO_STATE_CONNECTING = 2; // 0x2
|
||||
field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
|
||||
field public static final int SCO_AUDIO_STATE_ERROR = -1; // 0xffffffff
|
||||
field public static final int STREAM_ACCESSIBILITY = 10; // 0xa
|
||||
field public static final int STREAM_ALARM = 4; // 0x4
|
||||
field public static final int STREAM_DTMF = 8; // 0x8
|
||||
field public static final int STREAM_MUSIC = 3; // 0x3
|
||||
|
||||
@@ -21476,6 +21476,7 @@ package android.media {
|
||||
field public static final int SCO_AUDIO_STATE_CONNECTING = 2; // 0x2
|
||||
field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
|
||||
field public static final int SCO_AUDIO_STATE_ERROR = -1; // 0xffffffff
|
||||
field public static final int STREAM_ACCESSIBILITY = 10; // 0xa
|
||||
field public static final int STREAM_ALARM = 4; // 0x4
|
||||
field public static final int STREAM_DTMF = 8; // 0x8
|
||||
field public static final int STREAM_MUSIC = 3; // 0x3
|
||||
|
||||
@@ -19995,6 +19995,7 @@ package android.media {
|
||||
field public static final int SCO_AUDIO_STATE_CONNECTING = 2; // 0x2
|
||||
field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
|
||||
field public static final int SCO_AUDIO_STATE_ERROR = -1; // 0xffffffff
|
||||
field public static final int STREAM_ACCESSIBILITY = 10; // 0xa
|
||||
field public static final int STREAM_ALARM = 4; // 0x4
|
||||
field public static final int STREAM_DTMF = 8; // 0x8
|
||||
field public static final int STREAM_MUSIC = 3; // 0x3
|
||||
|
||||
@@ -240,7 +240,9 @@ public class AppOpsManager {
|
||||
/** @hide Control whether an application is allowed to run in the background. */
|
||||
public static final int OP_RUN_IN_BACKGROUND = 63;
|
||||
/** @hide */
|
||||
public static final int _NUM_OP = 64;
|
||||
public static final int OP_AUDIO_ACCESSIBILITY_VOLUME = 64;
|
||||
/** @hide */
|
||||
public static final int _NUM_OP = 65;
|
||||
|
||||
/** Access to coarse location information. */
|
||||
public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
|
||||
@@ -452,6 +454,7 @@ public class AppOpsManager {
|
||||
OP_TURN_SCREEN_ON,
|
||||
OP_GET_ACCOUNTS,
|
||||
OP_RUN_IN_BACKGROUND,
|
||||
OP_AUDIO_ACCESSIBILITY_VOLUME,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -523,6 +526,7 @@ public class AppOpsManager {
|
||||
null,
|
||||
OPSTR_GET_ACCOUNTS,
|
||||
null,
|
||||
null, // OP_AUDIO_ACCESSIBILITY_VOLUME
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -594,6 +598,7 @@ public class AppOpsManager {
|
||||
"TURN_ON_SCREEN",
|
||||
"GET_ACCOUNTS",
|
||||
"RUN_IN_BACKGROUND",
|
||||
"AUDIO_ACCESSIBILITY_VOLUME",
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -665,6 +670,7 @@ public class AppOpsManager {
|
||||
null, // no permission for turning the screen on
|
||||
Manifest.permission.GET_ACCOUNTS,
|
||||
null, // no permission for running in background
|
||||
null, // no permission for changing accessibility volume
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -737,6 +743,7 @@ public class AppOpsManager {
|
||||
null, // TURN_ON_SCREEN
|
||||
null, // GET_ACCOUNTS
|
||||
null, // RUN_IN_BACKGROUND
|
||||
UserManager.DISALLOW_ADJUST_VOLUME, //AUDIO_ACCESSIBILITY_VOLUME
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -808,6 +815,7 @@ public class AppOpsManager {
|
||||
false, // TURN_ON_SCREEN
|
||||
false, // GET_ACCOUNTS
|
||||
false, // RUN_IN_BACKGROUND
|
||||
false, // AUDIO_ACCESSIBILITY_VOLUME
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -878,6 +886,7 @@ public class AppOpsManager {
|
||||
AppOpsManager.MODE_ALLOWED, // OP_TURN_ON_SCREEN
|
||||
AppOpsManager.MODE_ALLOWED,
|
||||
AppOpsManager.MODE_ALLOWED, // OP_RUN_IN_BACKGROUND
|
||||
AppOpsManager.MODE_ALLOWED, // OP_AUDIO_ACCESSIBILITY_VOLUME
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -952,6 +961,7 @@ public class AppOpsManager {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // OP_AUDIO_ACCESSIBILITY_VOLUME
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -584,6 +584,10 @@ public final class AudioAttributes implements Parcelable {
|
||||
* @return the same Builder instance.
|
||||
*/
|
||||
public Builder setLegacyStreamType(int streamType) {
|
||||
if (streamType == AudioManager.STREAM_ACCESSIBILITY) {
|
||||
throw new IllegalArgumentException("STREAM_ACCESSIBILITY is not a legacy stream "
|
||||
+ "type that was used for audio playback");
|
||||
}
|
||||
return setInternalLegacyStreamType(streamType);
|
||||
}
|
||||
|
||||
@@ -624,12 +628,15 @@ public final class AudioAttributes implements Parcelable {
|
||||
mContentType = CONTENT_TYPE_SONIFICATION;
|
||||
break;
|
||||
case AudioSystem.STREAM_TTS:
|
||||
mContentType = CONTENT_TYPE_SONIFICATION;
|
||||
break;
|
||||
case AudioSystem.STREAM_ACCESSIBILITY:
|
||||
mContentType = CONTENT_TYPE_SPEECH;
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Invalid stream type " + streamType + " for AudioAttributes");
|
||||
}
|
||||
mUsage = usageForLegacyStreamType(streamType);
|
||||
mUsage = usageForStreamType(streamType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -842,8 +849,7 @@ public final class AudioAttributes implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static int usageForLegacyStreamType(int streamType) {
|
||||
private static int usageForStreamType(int streamType) {
|
||||
switch(streamType) {
|
||||
case AudioSystem.STREAM_VOICE_CALL:
|
||||
return USAGE_VOICE_COMMUNICATION;
|
||||
@@ -862,8 +868,9 @@ public final class AudioAttributes implements Parcelable {
|
||||
return USAGE_VOICE_COMMUNICATION;
|
||||
case AudioSystem.STREAM_DTMF:
|
||||
return USAGE_VOICE_COMMUNICATION_SIGNALLING;
|
||||
case AudioSystem.STREAM_TTS:
|
||||
case AudioSystem.STREAM_ACCESSIBILITY:
|
||||
return USAGE_ASSISTANCE_ACCESSIBILITY;
|
||||
case AudioSystem.STREAM_TTS:
|
||||
default:
|
||||
return USAGE_UNKNOWN;
|
||||
}
|
||||
@@ -915,7 +922,6 @@ public final class AudioAttributes implements Parcelable {
|
||||
switch (aa.getUsage()) {
|
||||
case USAGE_MEDIA:
|
||||
case USAGE_GAME:
|
||||
case USAGE_ASSISTANCE_ACCESSIBILITY:
|
||||
case USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
|
||||
return AudioSystem.STREAM_MUSIC;
|
||||
case USAGE_ASSISTANCE_SONIFICATION:
|
||||
@@ -935,6 +941,8 @@ public final class AudioAttributes implements Parcelable {
|
||||
case USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
|
||||
case USAGE_NOTIFICATION_EVENT:
|
||||
return AudioSystem.STREAM_NOTIFICATION;
|
||||
case USAGE_ASSISTANCE_ACCESSIBILITY:
|
||||
return AudioSystem.STREAM_ACCESSIBILITY;
|
||||
case USAGE_UNKNOWN:
|
||||
return fromGetVolumeControlStream ?
|
||||
AudioManager.USE_DEFAULT_STREAM_TYPE : AudioSystem.STREAM_MUSIC;
|
||||
|
||||
@@ -335,6 +335,9 @@ public class AudioManager {
|
||||
/** @hide Used to identify the volume of audio streams exclusively transmitted through the
|
||||
* speaker (TTS) of the device */
|
||||
public static final int STREAM_TTS = AudioSystem.STREAM_TTS;
|
||||
/** Used to identify the volume of audio streams for accessibility prompts */
|
||||
public static final int STREAM_ACCESSIBILITY = AudioSystem.STREAM_ACCESSIBILITY;
|
||||
|
||||
/** Number of audio streams */
|
||||
/**
|
||||
* @deprecated Do not iterate on volume stream type values.
|
||||
|
||||
@@ -63,13 +63,15 @@ public class AudioSystem
|
||||
/** Used to identify the volume of audio streams exclusively transmitted through the
|
||||
* speaker (TTS) of the device */
|
||||
public static final int STREAM_TTS = 9;
|
||||
/** Used to identify the volume of audio streams for accessibility prompts */
|
||||
public static final int STREAM_ACCESSIBILITY = 10;
|
||||
/**
|
||||
* @deprecated Use {@link #numStreamTypes() instead}
|
||||
*/
|
||||
public static final int NUM_STREAMS = 5;
|
||||
|
||||
// Expose only the getter method publicly so we can change it in the future
|
||||
private static final int NUM_STREAM_TYPES = 10;
|
||||
private static final int NUM_STREAM_TYPES = 11;
|
||||
public static final int getNumStreamTypes() { return NUM_STREAM_TYPES; }
|
||||
|
||||
public static final String[] STREAM_NAMES = new String[] {
|
||||
@@ -82,7 +84,8 @@ public class AudioSystem
|
||||
"STREAM_BLUETOOTH_SCO",
|
||||
"STREAM_SYSTEM_ENFORCED",
|
||||
"STREAM_DTMF",
|
||||
"STREAM_TTS"
|
||||
"STREAM_TTS",
|
||||
"STREAM_ACCESSIBILITY"
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -773,7 +776,8 @@ public class AudioSystem
|
||||
7, // STREAM_BLUETOOTH_SCO
|
||||
7, // STREAM_SYSTEM_ENFORCED
|
||||
11, // STREAM_DTMF
|
||||
11 // STREAM_TTS
|
||||
11, // STREAM_TTS
|
||||
11, // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
public static String streamToString(int stream) {
|
||||
|
||||
@@ -272,7 +272,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
15, // STREAM_BLUETOOTH_SCO
|
||||
7, // STREAM_SYSTEM_ENFORCED
|
||||
15, // STREAM_DTMF
|
||||
15 // STREAM_TTS
|
||||
15, // STREAM_TTS
|
||||
15 // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
/** Minimum volume index values for audio streams */
|
||||
@@ -286,7 +287,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
0, // STREAM_BLUETOOTH_SCO
|
||||
0, // STREAM_SYSTEM_ENFORCED
|
||||
0, // STREAM_DTMF
|
||||
0 // STREAM_TTS
|
||||
0, // STREAM_TTS
|
||||
0 // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
/* mStreamVolumeAlias[] indicates for each stream if it uses the volume settings
|
||||
@@ -308,7 +310,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
AudioSystem.STREAM_BLUETOOTH_SCO, // STREAM_BLUETOOTH_SCO
|
||||
AudioSystem.STREAM_RING, // STREAM_SYSTEM_ENFORCED
|
||||
AudioSystem.STREAM_RING, // STREAM_DTMF
|
||||
AudioSystem.STREAM_MUSIC // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC // STREAM_ACCESSIBILITY
|
||||
};
|
||||
private final int[] STREAM_VOLUME_ALIAS_TELEVISION = new int[] {
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_VOICE_CALL
|
||||
@@ -320,7 +323,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_BLUETOOTH_SCO
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_SYSTEM_ENFORCED
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_DTMF
|
||||
AudioSystem.STREAM_MUSIC // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC // STREAM_ACCESSIBILITY
|
||||
};
|
||||
private final int[] STREAM_VOLUME_ALIAS_DEFAULT = new int[] {
|
||||
AudioSystem.STREAM_VOICE_CALL, // STREAM_VOICE_CALL
|
||||
@@ -332,7 +336,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
AudioSystem.STREAM_BLUETOOTH_SCO, // STREAM_BLUETOOTH_SCO
|
||||
AudioSystem.STREAM_RING, // STREAM_SYSTEM_ENFORCED
|
||||
AudioSystem.STREAM_RING, // STREAM_DTMF
|
||||
AudioSystem.STREAM_MUSIC // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC, // STREAM_TTS
|
||||
AudioSystem.STREAM_MUSIC // STREAM_ACCESSIBILITY
|
||||
};
|
||||
private int[] mStreamVolumeAlias;
|
||||
|
||||
@@ -351,6 +356,7 @@ public class AudioService extends IAudioService.Stub {
|
||||
AppOpsManager.OP_AUDIO_MEDIA_VOLUME, // STREAM_SYSTEM_ENFORCED
|
||||
AppOpsManager.OP_AUDIO_MEDIA_VOLUME, // STREAM_DTMF
|
||||
AppOpsManager.OP_AUDIO_MEDIA_VOLUME, // STREAM_TTS
|
||||
AppOpsManager.OP_AUDIO_ACCESSIBILITY_VOLUME, // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
private final boolean mUseFixedVolume;
|
||||
|
||||
Reference in New Issue
Block a user