Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d5723fe authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Define stream type for accessibility volume control"

parents fdd3cb50 3f0945a6
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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_CONNECTING = 2; // 0x2
    field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
    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 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_ALARM = 4; // 0x4
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_MUSIC = 3; // 0x3
    field public static final int STREAM_MUSIC = 3; // 0x3
+1 −0
Original line number Original line Diff line number Diff line
@@ -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_CONNECTING = 2; // 0x2
    field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
    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 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_ALARM = 4; // 0x4
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_MUSIC = 3; // 0x3
    field public static final int STREAM_MUSIC = 3; // 0x3
+1 −0
Original line number Original line Diff line number Diff line
@@ -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_CONNECTING = 2; // 0x2
    field public static final int SCO_AUDIO_STATE_DISCONNECTED = 0; // 0x0
    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 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_ALARM = 4; // 0x4
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_DTMF = 8; // 0x8
    field public static final int STREAM_MUSIC = 3; // 0x3
    field public static final int STREAM_MUSIC = 3; // 0x3
+11 −1
Original line number Original line Diff line number Diff line
@@ -240,7 +240,9 @@ public class AppOpsManager {
    /** @hide Control whether an application is allowed to run in the background. */
    /** @hide Control whether an application is allowed to run in the background. */
    public static final int OP_RUN_IN_BACKGROUND = 63;
    public static final int OP_RUN_IN_BACKGROUND = 63;
    /** @hide */
    /** @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. */
    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -452,6 +454,7 @@ public class AppOpsManager {
            OP_TURN_SCREEN_ON,
            OP_TURN_SCREEN_ON,
            OP_GET_ACCOUNTS,
            OP_GET_ACCOUNTS,
            OP_RUN_IN_BACKGROUND,
            OP_RUN_IN_BACKGROUND,
            OP_AUDIO_ACCESSIBILITY_VOLUME,
    };
    };


    /**
    /**
@@ -523,6 +526,7 @@ public class AppOpsManager {
            null,
            null,
            OPSTR_GET_ACCOUNTS,
            OPSTR_GET_ACCOUNTS,
            null,
            null,
            null, // OP_AUDIO_ACCESSIBILITY_VOLUME
    };
    };


    /**
    /**
@@ -594,6 +598,7 @@ public class AppOpsManager {
            "TURN_ON_SCREEN",
            "TURN_ON_SCREEN",
            "GET_ACCOUNTS",
            "GET_ACCOUNTS",
            "RUN_IN_BACKGROUND",
            "RUN_IN_BACKGROUND",
            "AUDIO_ACCESSIBILITY_VOLUME",
    };
    };


    /**
    /**
@@ -665,6 +670,7 @@ public class AppOpsManager {
            null, // no permission for turning the screen on
            null, // no permission for turning the screen on
            Manifest.permission.GET_ACCOUNTS,
            Manifest.permission.GET_ACCOUNTS,
            null, // no permission for running in background
            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, // TURN_ON_SCREEN
            null, // GET_ACCOUNTS
            null, // GET_ACCOUNTS
            null, // RUN_IN_BACKGROUND
            null, // RUN_IN_BACKGROUND
            UserManager.DISALLOW_ADJUST_VOLUME, //AUDIO_ACCESSIBILITY_VOLUME
    };
    };


    /**
    /**
@@ -808,6 +815,7 @@ public class AppOpsManager {
            false, // TURN_ON_SCREEN
            false, // TURN_ON_SCREEN
            false, // GET_ACCOUNTS
            false, // GET_ACCOUNTS
            false, // RUN_IN_BACKGROUND
            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,  // OP_TURN_ON_SCREEN
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,  // OP_RUN_IN_BACKGROUND
            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,
            false,
            false,
            false, // OP_AUDIO_ACCESSIBILITY_VOLUME
    };
    };


    /**
    /**
+13 −5
Original line number Original line Diff line number Diff line
@@ -584,6 +584,10 @@ public final class AudioAttributes implements Parcelable {
         * @return the same Builder instance.
         * @return the same Builder instance.
         */
         */
        public Builder setLegacyStreamType(int streamType) {
        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);
            return setInternalLegacyStreamType(streamType);
        }
        }


@@ -624,12 +628,15 @@ public final class AudioAttributes implements Parcelable {
                    mContentType = CONTENT_TYPE_SONIFICATION;
                    mContentType = CONTENT_TYPE_SONIFICATION;
                    break;
                    break;
                case AudioSystem.STREAM_TTS:
                case AudioSystem.STREAM_TTS:
                    mContentType = CONTENT_TYPE_SONIFICATION;
                    break;
                case AudioSystem.STREAM_ACCESSIBILITY:
                    mContentType = CONTENT_TYPE_SPEECH;
                    mContentType = CONTENT_TYPE_SPEECH;
                    break;
                    break;
                default:
                default:
                    Log.e(TAG, "Invalid stream type " + streamType + " for AudioAttributes");
                    Log.e(TAG, "Invalid stream type " + streamType + " for AudioAttributes");
            }
            }
            mUsage = usageForLegacyStreamType(streamType);
            mUsage = usageForStreamType(streamType);
            return this;
            return this;
        }
        }


@@ -842,8 +849,7 @@ public final class AudioAttributes implements Parcelable {
        }
        }
    }
    }


    /** @hide */
    private static int usageForStreamType(int streamType) {
    public static int usageForLegacyStreamType(int streamType) {
        switch(streamType) {
        switch(streamType) {
            case AudioSystem.STREAM_VOICE_CALL:
            case AudioSystem.STREAM_VOICE_CALL:
                return USAGE_VOICE_COMMUNICATION;
                return USAGE_VOICE_COMMUNICATION;
@@ -862,8 +868,9 @@ public final class AudioAttributes implements Parcelable {
                return USAGE_VOICE_COMMUNICATION;
                return USAGE_VOICE_COMMUNICATION;
            case AudioSystem.STREAM_DTMF:
            case AudioSystem.STREAM_DTMF:
                return USAGE_VOICE_COMMUNICATION_SIGNALLING;
                return USAGE_VOICE_COMMUNICATION_SIGNALLING;
            case AudioSystem.STREAM_TTS:
            case AudioSystem.STREAM_ACCESSIBILITY:
                return USAGE_ASSISTANCE_ACCESSIBILITY;
                return USAGE_ASSISTANCE_ACCESSIBILITY;
            case AudioSystem.STREAM_TTS:
            default:
            default:
                return USAGE_UNKNOWN;
                return USAGE_UNKNOWN;
        }
        }
@@ -915,7 +922,6 @@ public final class AudioAttributes implements Parcelable {
        switch (aa.getUsage()) {
        switch (aa.getUsage()) {
            case USAGE_MEDIA:
            case USAGE_MEDIA:
            case USAGE_GAME:
            case USAGE_GAME:
            case USAGE_ASSISTANCE_ACCESSIBILITY:
            case USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
            case USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
                return AudioSystem.STREAM_MUSIC;
                return AudioSystem.STREAM_MUSIC;
            case USAGE_ASSISTANCE_SONIFICATION:
            case USAGE_ASSISTANCE_SONIFICATION:
@@ -935,6 +941,8 @@ public final class AudioAttributes implements Parcelable {
            case USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
            case USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
            case USAGE_NOTIFICATION_EVENT:
            case USAGE_NOTIFICATION_EVENT:
                return AudioSystem.STREAM_NOTIFICATION;
                return AudioSystem.STREAM_NOTIFICATION;
            case USAGE_ASSISTANCE_ACCESSIBILITY:
                return AudioSystem.STREAM_ACCESSIBILITY;
            case USAGE_UNKNOWN:
            case USAGE_UNKNOWN:
                return fromGetVolumeControlStream ?
                return fromGetVolumeControlStream ?
                        AudioManager.USE_DEFAULT_STREAM_TYPE : AudioSystem.STREAM_MUSIC;
                        AudioManager.USE_DEFAULT_STREAM_TYPE : AudioSystem.STREAM_MUSIC;
Loading