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

Commit 17418998 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[CEC Configuration] Rename getAvailableCecSettings to getUserCecSettings"

parents 922b08b6 b71636ad
Loading
Loading
Loading
Loading
+22 −20
Original line number Original line Diff line number Diff line
@@ -424,36 +424,37 @@ public final class HdmiControlManager {
     *
     *
     * @hide
     * @hide
     */
     */
    public static final String SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled";
    public static final String CEC_SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled";
    /**
    /**
     * Name of a setting deciding on the Standby message behaviour on sleep.
     * Name of a setting deciding on the Standby message behaviour on sleep.
     *
     *
     * @hide
     * @hide
     */
     */
    public static final String SETTING_NAME_SEND_STANDBY_ON_SLEEP = "send_standby_on_sleep";
    public static final String CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP = "send_standby_on_sleep";
    /**
    /**
     * Name of a setting deciding on power state action when losing Active Source.
     * Name of a setting deciding on power state action when losing Active Source.
     *
     *
     * @hide
     * @hide
     */
     */
    public static final String SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST =
    public static final String CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST =
            "power_state_change_on_active_source_lost";
            "power_state_change_on_active_source_lost";
    /**
    /**
     * Name of a setting deciding whether System Audio Muting is allowed.
     * Name of a setting deciding whether System Audio Muting is allowed.
     *
     *
     * @hide
     * @hide
     */
     */
    public static final String SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING = "system_audio_mode_muting";
    public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING =
            "system_audio_mode_muting";
    /**
    /**
     * @hide
     * @hide
     */
     */
    @StringDef({
    @StringDef({
        SETTING_NAME_HDMI_CEC_ENABLED,
        CEC_SETTING_NAME_HDMI_CEC_ENABLED,
        SETTING_NAME_SEND_STANDBY_ON_SLEEP,
        CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP,
        SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
        CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
    })
    })
    public @interface SettingName {}
    public @interface CecSettingName {}


    // True if we have a logical device of type playback hosted in the system.
    // True if we have a logical device of type playback hosted in the system.
    private final boolean mHasPlaybackDevice;
    private final boolean mHasPlaybackDevice;
@@ -1301,14 +1302,15 @@ public final class HdmiControlManager {
     * @hide
     * @hide
     */
     */
    @NonNull
    @NonNull
    @CecSettingName
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public List<String> getAvailableCecSettings() {
    public List<String> getUserCecSettings() {
        if (mService == null) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            return mService.getAvailableCecSettings();
            return mService.getUserCecSettings();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1326,7 +1328,7 @@ public final class HdmiControlManager {
     */
     */
    @NonNull
    @NonNull
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public List<String> getAllowedCecSettingValues(@NonNull String name) {
    public List<String> getAllowedCecSettingValues(@NonNull @CecSettingName String name) {
        if (mService == null) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
@@ -1354,7 +1356,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            mService.setCecSettingValue(SETTING_NAME_HDMI_CEC_ENABLED, value);
            mService.setCecSettingValue(CEC_SETTING_NAME_HDMI_CEC_ENABLED, value);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1377,7 +1379,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            return mService.getCecSettingValue(SETTING_NAME_HDMI_CEC_ENABLED);
            return mService.getCecSettingValue(CEC_SETTING_NAME_HDMI_CEC_ENABLED);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1399,7 +1401,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            mService.setCecSettingValue(SETTING_NAME_SEND_STANDBY_ON_SLEEP, value);
            mService.setCecSettingValue(CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP, value);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1422,7 +1424,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            return mService.getCecSettingValue(SETTING_NAME_SEND_STANDBY_ON_SLEEP);
            return mService.getCecSettingValue(CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1446,7 +1448,7 @@ public final class HdmiControlManager {
        }
        }
        try {
        try {
            mService.setCecSettingValue(
            mService.setCecSettingValue(
                    SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST, value);
                    CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST, value);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1470,7 +1472,7 @@ public final class HdmiControlManager {
        }
        }
        try {
        try {
            return mService.getCecSettingValue(
            return mService.getCecSettingValue(
                    SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST);
                    CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1492,7 +1494,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            mService.setCecSettingValue(SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING, value);
            mService.setCecSettingValue(CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING, value);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1515,7 +1517,7 @@ public final class HdmiControlManager {
            throw new RuntimeException("HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        }
        try {
        try {
            return mService.getCecSettingValue(SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING);
            return mService.getCecSettingValue(CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
+3 −3
Original line number Original line Diff line number Diff line
@@ -296,8 +296,8 @@ public final class HdmiControlServiceWrapper {
        }
        }


        @Override
        @Override
        public List<String> getAvailableCecSettings() {
        public List<String> getUserCecSettings() {
            return HdmiControlServiceWrapper.this.getAvailableCecSettings();
            return HdmiControlServiceWrapper.this.getUserCecSettings();
        }
        }


        @Override
        @Override
@@ -489,7 +489,7 @@ public final class HdmiControlServiceWrapper {
            IHdmiCecVolumeControlFeatureListener listener) {}
            IHdmiCecVolumeControlFeatureListener listener) {}


    /** @hide */
    /** @hide */
    public List<String> getAvailableCecSettings() {
    public List<String> getUserCecSettings() {
        return new ArrayList<>();
        return new ArrayList<>();
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -87,7 +87,7 @@ interface IHdmiControlService {
    boolean isHdmiCecVolumeControlEnabled();
    boolean isHdmiCecVolumeControlEnabled();
    void reportAudioStatus(int deviceType, int volume, int maxVolume, boolean isMute);
    void reportAudioStatus(int deviceType, int volume, int maxVolume, boolean isMute);
    void setSystemAudioModeOnForAudioOnlySource();
    void setSystemAudioModeOnForAudioOnlySource();
    List<String> getAvailableCecSettings();
    List<String> getUserCecSettings();
    List<String> getAllowedCecSettingValues(String name);
    List<String> getAllowedCecSettingValues(String name);
    String getCecSettingValue(String name);
    String getCecSettingValue(String name);
    void setCecSettingValue(String name, String value);
    void setCecSettingValue(String name, String value);
+1 −1
Original line number Original line Diff line number Diff line
@@ -376,7 +376,7 @@ public class HdmiAudioSystemClientTest {
        }
        }


        @Override
        @Override
        public List<String> getAvailableCecSettings() {
        public List<String> getUserCecSettings() {
            return new ArrayList<>();
            return new ArrayList<>();
        }
        }


+33 −19
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.server.hdmi;
package com.android.server.hdmi;


import static android.hardware.hdmi.HdmiControlManager.CecSettingName;

import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -179,13 +181,13 @@ public class HdmiCecConfig {
    @Storage
    @Storage
    private int getStorage(@NonNull Setting setting) {
    private int getStorage(@NonNull Setting setting) {
        switch (setting.getName()) {
        switch (setting.getName()) {
            case HdmiControlManager.SETTING_NAME_HDMI_CEC_ENABLED:
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
                return STORAGE_GLOBAL_SETTINGS;
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.SETTING_NAME_SEND_STANDBY_ON_SLEEP:
            case HdmiControlManager.CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP:
                return STORAGE_GLOBAL_SETTINGS;
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
                return STORAGE_SYSPROPS;
                return STORAGE_SYSPROPS;
            case HdmiControlManager.SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return STORAGE_SYSPROPS;
                return STORAGE_SYSPROPS;
            default:
            default:
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
@@ -195,13 +197,13 @@ public class HdmiCecConfig {


    private String getStorageKey(@NonNull Setting setting) {
    private String getStorageKey(@NonNull Setting setting) {
        switch (setting.getName()) {
        switch (setting.getName()) {
            case HdmiControlManager.SETTING_NAME_HDMI_CEC_ENABLED:
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
                return Global.HDMI_CONTROL_ENABLED;
                return Global.HDMI_CONTROL_ENABLED;
            case HdmiControlManager.SETTING_NAME_SEND_STANDBY_ON_SLEEP:
            case HdmiControlManager.CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP:
                return Global.HDMI_CONTROL_SEND_STANDBY_ON_SLEEP;
                return Global.HDMI_CONTROL_SEND_STANDBY_ON_SLEEP;
            case HdmiControlManager.SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
                return SYSPROP_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST;
                return SYSPROP_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST;
            case HdmiControlManager.SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return SYSPROP_SYSTEM_AUDIO_MODE_MUTING;
                return SYSPROP_SYSTEM_AUDIO_MODE_MUTING;
            default:
            default:
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
@@ -238,33 +240,44 @@ public class HdmiCecConfig {
    }
    }


    /**
    /**
     * Returns a list of currently available settings based on the XML metadata.
     * Returns a list of all settings based on the XML metadata.
     */
    public @CecSettingName List<String> getAllSettings() {
        List<String> allSettings = new ArrayList<String>();
        for (Setting setting : mProductConfig.getSetting()) {
            allSettings.add(setting.getName());
        }
        return allSettings;
    }

    /**
     * Returns a list of user-modifiable settings based on the XML metadata.
     */
     */
    public List<String> getAvailableSettings() {
    public @CecSettingName List<String> getUserSettings() {
        Set<String> availableSettings = new HashSet<String>();
        Set<String> userSettings = new HashSet<String>();
        // First read from the product config.
        // First read from the product config.
        for (Setting setting : mProductConfig.getSetting()) {
        for (Setting setting : mProductConfig.getSetting()) {
            if (setting.getUserConfigurable()) {
            if (setting.getUserConfigurable()) {
                availableSettings.add(setting.getName());
                userSettings.add(setting.getName());
            }
            }
        }
        }
        if (mVendorOverride != null) {
        if (mVendorOverride != null) {
            // Next either add or remove based on the vendor override.
            // Next either add or remove based on the vendor override.
            for (Setting setting : mVendorOverride.getSetting()) {
            for (Setting setting : mVendorOverride.getSetting()) {
                if (setting.getUserConfigurable()) {
                if (setting.getUserConfigurable()) {
                    availableSettings.add(setting.getName());
                    userSettings.add(setting.getName());
                } else {
                } else {
                    availableSettings.remove(setting.getName());
                    userSettings.remove(setting.getName());
                }
                }
            }
            }
        }
        }
        return new ArrayList(availableSettings);
        return new ArrayList(userSettings);
    }
    }


    /**
    /**
     * For a given setting name returns values that are allowed for that setting.
     * For a given setting name returns values that are allowed for that setting.
     */
     */
    public List<String> getAllowedValues(@NonNull String name) {
    public List<String> getAllowedValues(@NonNull @CecSettingName String name) {
        Setting setting = getSetting(name);
        Setting setting = getSetting(name);
        if (setting == null) {
        if (setting == null) {
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
@@ -279,7 +292,7 @@ public class HdmiCecConfig {
    /**
    /**
     * For a given setting name returns the default value for that setting.
     * For a given setting name returns the default value for that setting.
     */
     */
    public String getDefaultValue(@NonNull String name) {
    public String getDefaultValue(@NonNull @CecSettingName String name) {
        Setting setting = getSetting(name);
        Setting setting = getSetting(name);
        if (setting == null) {
        if (setting == null) {
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
@@ -290,7 +303,7 @@ public class HdmiCecConfig {
    /**
    /**
     * For a given setting name returns the current value of that setting.
     * For a given setting name returns the current value of that setting.
     */
     */
    public String getValue(@NonNull Context context, @NonNull String name) {
    public String getValue(@NonNull Context context, @NonNull @CecSettingName String name) {
        Setting setting = getSetting(name);
        Setting setting = getSetting(name);
        if (setting == null) {
        if (setting == null) {
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
@@ -302,7 +315,8 @@ public class HdmiCecConfig {
    /**
    /**
     * For a given setting name and value sets the current value of that setting.
     * For a given setting name and value sets the current value of that setting.
     */
     */
    public void setValue(@NonNull Context context, @NonNull String name, @NonNull String value) {
    public void setValue(@NonNull Context context, @NonNull @CecSettingName String name,
                         @NonNull String value) {
        Setting setting = getSetting(name);
        Setting setting = getSetting(name);
        if (setting == null) {
        if (setting == null) {
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
Loading