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

Commit f04b84d4 authored by Andy Hung's avatar Andy Hung
Browse files

Add setMasterMono and getMasterMono

Bug: 15283594
Bug: 22700363
Change-Id: I5d0552938ec2a54be4450512974d92ff8c77b1e9
parent 46ca2828
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2591,6 +2591,15 @@ public final class Settings {

        private static final Validator MICROPHONE_MUTE_VALIDATOR = sBooleanValidator;

        /**
         * Master mono (int 1 = mono, 0 = normal).
         *
         * @hide
         */
        public static final String MASTER_MONO = "master_mono";

        private static final Validator MASTER_MONO_VALIDATOR = sBooleanValidator;

        /**
         * Whether the notifications should use the ring volume (value of 1) or
         * a separate notification volume (value of 0). In most cases, users
@@ -3357,6 +3366,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(VOLUME_MASTER);
            PRIVATE_SETTINGS.add(VOLUME_MASTER_MUTE);
            PRIVATE_SETTINGS.add(MICROPHONE_MUTE);
            PRIVATE_SETTINGS.add(MASTER_MONO);
            PRIVATE_SETTINGS.add(NOTIFICATIONS_USE_RING_VOLUME);
            PRIVATE_SETTINGS.add(VIBRATE_IN_SILENT);
            PRIVATE_SETTINGS.add(MEDIA_BUTTON_RECEIVER);
@@ -3435,6 +3445,7 @@ public final class Settings {
            VALIDATORS.put(VIBRATE_INPUT_DEVICES, VIBRATE_INPUT_DEVICES_VALIDATOR);
            VALIDATORS.put(VOLUME_MASTER_MUTE, VOLUME_MASTER_MUTE_VALIDATOR);
            VALIDATORS.put(MICROPHONE_MUTE, MICROPHONE_MUTE_VALIDATOR);
            VALIDATORS.put(MASTER_MONO, MASTER_MONO_VALIDATOR);
            VALIDATORS.put(NOTIFICATIONS_USE_RING_VOLUME, NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR);
            VALIDATORS.put(VIBRATE_IN_SILENT, VIBRATE_IN_SILENT_VALIDATOR);
            VALIDATORS.put(MEDIA_BUTTON_RECEIVER, MEDIA_BUTTON_RECEIVER_VALIDATOR);
+18 −0
Original line number Diff line number Diff line
@@ -497,6 +497,22 @@ android_media_AudioSystem_getMasterMute(JNIEnv *env, jobject thiz)
    return mute;
}

static jint
android_media_AudioSystem_setMasterMono(JNIEnv *env, jobject thiz, jboolean mono)
{
    return (jint) check_AudioSystem_Command(AudioSystem::setMasterMono(mono));
}

static jboolean
android_media_AudioSystem_getMasterMono(JNIEnv *env, jobject thiz)
{
    bool mono;
    if (AudioSystem::getMasterMono(&mono) != NO_ERROR) {
        mono = false;
    }
    return mono;
}

static jint
android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint stream)
{
@@ -1637,6 +1653,8 @@ static const JNINativeMethod gMethods[] = {
    {"getMasterVolume",     "()F",      (void *)android_media_AudioSystem_getMasterVolume},
    {"setMasterMute",       "(Z)I",     (void *)android_media_AudioSystem_setMasterMute},
    {"getMasterMute",       "()Z",      (void *)android_media_AudioSystem_getMasterMute},
    {"setMasterMono",       "(Z)I",     (void *)android_media_AudioSystem_setMasterMono},
    {"getMasterMono",       "()Z",      (void *)android_media_AudioSystem_getMasterMono},
    {"getDevicesForStream", "(I)I",     (void *)android_media_AudioSystem_getDevicesForStream},
    {"getPrimaryOutputSamplingRate", "()I", (void *)android_media_AudioSystem_getPrimaryOutputSamplingRate},
    {"getPrimaryOutputFrameCount",   "()I", (void *)android_media_AudioSystem_getPrimaryOutputFrameCount},
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@
    <protected-broadcast android:name="android.media.VOLUME_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.MASTER_VOLUME_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.MASTER_MUTE_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.MASTER_MONO_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.SCO_AUDIO_STATE_CHANGED" />
    <protected-broadcast android:name="android.media.ACTION_SCO_AUDIO_STATE_UPDATED" />

+43 −0
Original line number Diff line number Diff line
@@ -175,6 +175,16 @@ public class AudioManager {
    public static final String MASTER_MUTE_CHANGED_ACTION =
        "android.media.MASTER_MUTE_CHANGED_ACTION";

    /**
     * @hide Broadcast intent when the master mono state changes.
     * Includes the new mono state
     *
     * @see #EXTRA_MASTER_MONO
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String MASTER_MONO_CHANGED_ACTION =
        "android.media.MASTER_MONO_CHANGED_ACTION";

    /**
     * The new vibrate setting for a particular type.
     *
@@ -253,6 +263,13 @@ public class AudioManager {
    public static final String EXTRA_STREAM_VOLUME_MUTED =
        "android.media.EXTRA_STREAM_VOLUME_MUTED";

    /**
     * @hide The new master mono state for the master mono changed intent.
     * Value is boolean
     */
    public static final String EXTRA_MASTER_MONO =
        "android.media.EXTRA_MASTER_MONO";

    /**
     * Broadcast Action: Wired Headset plugged in or unplugged.
     *
@@ -880,6 +897,17 @@ public class AudioManager {
        }
    }

    /** @hide */
    public void setMasterMono(boolean mono) {
        IAudioService service = getService();
        try {
            service.setMasterMono(mono, getContext().getOpPackageName(),
                    UserHandle.getCallingUserId());
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in setMasterMono", e);
        }
    }

    /**
     * Returns the current ringtone mode.
     *
@@ -1141,6 +1169,21 @@ public class AudioManager {
        }
    }

    /**
     * get master mono state.
     *
     * @hide
     */
    public boolean isMasterMono() {
        IAudioService service = getService();
        try {
            return service.isMasterMono();
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in isMasterMono", e);
            return false;
        }
    }

    /**
     * forces the stream controlled by hard volume keys
     * specifying streamType == -1 releases control to the
+5 −0
Original line number Diff line number Diff line
@@ -624,6 +624,11 @@ public class AudioSystem
    public static native boolean getMasterMute();
    public static native int getDevicesForStream(int stream);

    /** @hide returns true if master mono is enabled. */
    public static native boolean getMasterMono();
    /** @hide enables or disables the master mono mode. */
    public static native int setMasterMono(boolean mono);

    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
    public static native int getPrimaryOutputSamplingRate();
    public static native int getPrimaryOutputFrameCount();
Loading