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

Commit ee9629f6 authored by Haofan Wang's avatar Haofan Wang
Browse files

Add APIs for Auto picture/sound quality and Auto super resolution

Test: atest VtsHalMediaQualityTargetTest
Flag: android.media.tv.flags.media_quality_fw
Bug: 375472716

Change-Id: Iaf2704f882e4f19c6e6233c052fa87e27093c3b1
parent e47dc591
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,15 @@ interface IMediaQuality {
  void setAmbientBacklightDetector(in android.hardware.tv.mediaquality.AmbientBacklightSettings settings);
  void setAmbientBacklightDetector(in android.hardware.tv.mediaquality.AmbientBacklightSettings settings);
  void setAmbientBacklightDetectionEnabled(in boolean enabled);
  void setAmbientBacklightDetectionEnabled(in boolean enabled);
  boolean getAmbientBacklightDetectionEnabled();
  boolean getAmbientBacklightDetectionEnabled();
  boolean isAutoPqSupported();
  boolean getAutoPqEnabled();
  void setAutoPqEnabled(boolean enable);
  boolean isAutoSrSupported();
  boolean getAutoSrEnabled();
  void setAutoSrEnabled(boolean enable);
  boolean isAutoAqSupported();
  boolean getAutoAqEnabled();
  void setAutoAqEnabled(boolean enable);
  android.hardware.tv.mediaquality.IPictureProfileChangedListener getPictureProfileListener();
  android.hardware.tv.mediaquality.IPictureProfileChangedListener getPictureProfileListener();
  void setPictureProfileAdjustmentListener(android.hardware.tv.mediaquality.IPictureProfileAdjustmentListener listener);
  void setPictureProfileAdjustmentListener(android.hardware.tv.mediaquality.IPictureProfileAdjustmentListener listener);
  android.hardware.tv.mediaquality.PictureParameters getPictureParameters(long pictureProfileId);
  android.hardware.tv.mediaquality.PictureParameters getPictureParameters(long pictureProfileId);
+72 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,78 @@ interface IMediaQuality {
     */
     */
    boolean getAmbientBacklightDetectionEnabled();
    boolean getAmbientBacklightDetectionEnabled();


    /**
     * Check if auto picture quality feature is supported on the current TV device.
     *
     * @return true when the device supports the auto picture quality, false when the device does
     * not supports the auto picture quality.
     */
    boolean isAutoPqSupported();

    /**
     * Get the current state of auto picture quality.
     *
     * @return true when auto picture quality is enabled, false when auto picture quality is
     * disabled.
     */
    boolean getAutoPqEnabled();

    /**
     * Set the auto picture quality enable/disable. Auto picture quality is to adjust the Picture
     * parameters depends on the current content playing.
     *
     * @param enable True to enable, false to disable.
     */
    void setAutoPqEnabled(boolean enable);

    /**
     * Check if auto super resolution feature is supported on the current TV device.
     *
     * @return true when the device supports the super resolution feature, false when the device
     * does not support super resolution.
     */
    boolean isAutoSrSupported();

    /**
     * Get the current state of auto super resolution.
     *
     * @return true when auto super resolution is enabled, false when auto super resolution is
     * disabled.
     */
    boolean getAutoSrEnabled();

    /**
     * Set the auto super resolution enable/disable. Auto super resolution is to analyze the
     * lower resolution image and invent the missing pixel to make the image looks sharper.
     *
     * @param enable True to enable, false to disable.
     */
    void setAutoSrEnabled(boolean enable);

    /**
     * Check if auto sound/audio quality feature is supported on the current TV device.
     *
     * @return true when the device supports the auto sound/audio quality, false when
     * the device does not supports the auto sound/audio quality.
     */
    boolean isAutoAqSupported();

    /**
     * Get the current state of auto sound/audio quality.
     *
     * @return true when auto sound/audio quality is enabled, false when auto sound/audio
     * quality is disabled.
     */
    boolean getAutoAqEnabled();

    /**
     * Set the auto sound/audio quality enable/disable. Auto sound/audio quality is to
     * adjust the sound parameters depends on the current content playing.
     *
     * @param enable True to enable, false to disable.
     */
    void setAutoAqEnabled(boolean enable);

    /**
    /**
     * Get picture profile changed listener.
     * Get picture profile changed listener.
     *
     *
+75 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,12 @@ pub struct MediaQualityService {
    callback: Arc<Mutex<Option<Strong<dyn IMediaQualityCallback>>>>,
    callback: Arc<Mutex<Option<Strong<dyn IMediaQualityCallback>>>>,
    ambient_backlight_enabled: Arc<Mutex<bool>>,
    ambient_backlight_enabled: Arc<Mutex<bool>>,
    ambient_backlight_detector_settings: Arc<Mutex<AmbientBacklightSettings>>,
    ambient_backlight_detector_settings: Arc<Mutex<AmbientBacklightSettings>>,
    auto_pq_supported: Arc<Mutex<bool>>,
    auto_pq_enabled: Arc<Mutex<bool>>,
    auto_sr_supported: Arc<Mutex<bool>>,
    auto_sr_enabled: Arc<Mutex<bool>>,
    auto_aq_supported: Arc<Mutex<bool>>,
    auto_aq_enabled: Arc<Mutex<bool>>,
    picture_profile_adjustment_listener:
    picture_profile_adjustment_listener:
            Arc<Mutex<Option<Strong<dyn IPictureProfileAdjustmentListener>>>>,
            Arc<Mutex<Option<Strong<dyn IPictureProfileAdjustmentListener>>>>,
    sound_profile_adjustment_listener:
    sound_profile_adjustment_listener:
@@ -55,6 +61,12 @@ impl MediaQualityService {
            ambient_backlight_enabled: Arc::new(Mutex::new(true)),
            ambient_backlight_enabled: Arc::new(Mutex::new(true)),
            ambient_backlight_detector_settings:
            ambient_backlight_detector_settings:
                    Arc::new(Mutex::new(AmbientBacklightSettings::default())),
                    Arc::new(Mutex::new(AmbientBacklightSettings::default())),
            auto_pq_supported: Arc::new(Mutex::new(false)),
            auto_pq_enabled: Arc::new(Mutex::new(false)),
            auto_sr_supported: Arc::new(Mutex::new(false)),
            auto_sr_enabled: Arc::new(Mutex::new(false)),
            auto_aq_supported: Arc::new(Mutex::new(false)),
            auto_aq_enabled: Arc::new(Mutex::new(false)),
            picture_profile_adjustment_listener: Arc::new(Mutex::new(None)),
            picture_profile_adjustment_listener: Arc::new(Mutex::new(None)),
            sound_profile_adjustment_listener: Arc::new(Mutex::new(None)),
            sound_profile_adjustment_listener: Arc::new(Mutex::new(None)),
            picture_profile_changed_listener: Arc::new(Mutex::new(None)),
            picture_profile_changed_listener: Arc::new(Mutex::new(None)),
@@ -129,6 +141,69 @@ impl IMediaQuality for MediaQualityService {
        Ok(*ambient_backlight_enabled)
        Ok(*ambient_backlight_enabled)
    }
    }


    fn isAutoPqSupported(&self) -> binder::Result<bool> {
        let auto_pq_supported = self.auto_pq_supported.lock().unwrap();
        Ok(*auto_pq_supported)
    }

    fn getAutoPqEnabled(&self) -> binder::Result<bool> {
        let auto_pq_enabled = self.auto_pq_enabled.lock().unwrap();
        Ok(*auto_pq_enabled)
    }

    fn setAutoPqEnabled(&self, enabled: bool) -> binder::Result<()> {
        let mut auto_pq_enabled = self.auto_pq_enabled.lock().unwrap();
        *auto_pq_enabled = enabled;
        if enabled {
            println!("Enable auto picture quality");
        } else {
            println!("Disable auto picture quality");
        }
        Ok(())
    }

    fn isAutoSrSupported(&self) -> binder::Result<bool> {
        let auto_sr_supported = self.auto_sr_supported.lock().unwrap();
        Ok(*auto_sr_supported)
    }

    fn getAutoSrEnabled(&self) -> binder::Result<bool> {
        let auto_sr_enabled = self.auto_sr_enabled.lock().unwrap();
        Ok(*auto_sr_enabled)
    }

    fn setAutoSrEnabled(&self, enabled: bool) -> binder::Result<()> {
        let mut auto_sr_enabled = self.auto_sr_enabled.lock().unwrap();
        *auto_sr_enabled = enabled;
        if enabled {
            println!("Enable auto super resolution");
        } else {
            println!("Disable auto super resolution");
        }
        Ok(())
    }

    fn isAutoAqSupported(&self) -> binder::Result<bool> {
        let auto_aq_supported = self.auto_aq_supported.lock().unwrap();
        Ok(*auto_aq_supported)
    }

    fn getAutoAqEnabled(&self) -> binder::Result<bool> {
        let auto_aq_enabled = self.auto_aq_enabled.lock().unwrap();
        Ok(*auto_aq_enabled)
    }

    fn setAutoAqEnabled(&self, enabled: bool) -> binder::Result<()> {
        let mut auto_aq_enabled = self.auto_aq_enabled.lock().unwrap();
        *auto_aq_enabled = enabled;
        if enabled {
            println!("Enable auto audio quality");
        } else {
            println!("Disable auto audio quality");
        }
        Ok(())
    }

    fn getPictureProfileListener(&self) -> binder::Result<binder::Strong<dyn IPictureProfileChangedListener>> {
    fn getPictureProfileListener(&self) -> binder::Result<binder::Strong<dyn IPictureProfileChangedListener>> {
        println!("getPictureProfileListener");
        println!("getPictureProfileListener");
        let listener = self.picture_profile_changed_listener.lock().unwrap();
        let listener = self.picture_profile_changed_listener.lock().unwrap();
+42 −0
Original line number Original line Diff line number Diff line
@@ -176,6 +176,48 @@ TEST_P(MediaQualityAidl, TestSetAmbientBacklightDetector) {
    ASSERT_OK(mediaquality->setAmbientBacklightDetector(in_settings));
    ASSERT_OK(mediaquality->setAmbientBacklightDetector(in_settings));
}
}


TEST_P(MediaQualityAidl, TestIsAutoPqSupported) {
    bool supported;
    ASSERT_OK(mediaquality->isAutoPqSupported(&supported));
}

TEST_P(MediaQualityAidl, TestGetAutoPqEnabled) {
    bool enabled;
    ASSERT_OK(mediaquality->getAutoPqEnabled(&enabled));
}

TEST_P(MediaQualityAidl, TestSetAutoPqEnabled) {
    ASSERT_OK(mediaquality->setAutoPqEnabled(true));
}

TEST_P(MediaQualityAidl, TestIsAutoSrSupported) {
    bool supported;
    ASSERT_OK(mediaquality->isAutoSrSupported(&supported));
}

TEST_P(MediaQualityAidl, TestGetAutoSrEnabled) {
    bool enabled;
    ASSERT_OK(mediaquality->getAutoSrEnabled(&enabled));
}

TEST_P(MediaQualityAidl, TestSetAutoSrEnabled) {
    ASSERT_OK(mediaquality->setAutoSrEnabled(true));
}

TEST_P(MediaQualityAidl, TestIsAutoAqSupported) {
    bool supported;
    ASSERT_OK(mediaquality->isAutoAqSupported(&supported));
}

TEST_P(MediaQualityAidl, TestGetAutoAqEnabled) {
    bool enabled;
    ASSERT_OK(mediaquality->getAutoAqEnabled(&enabled));
}

TEST_P(MediaQualityAidl, TestSetAutoAqEnabled) {
    ASSERT_OK(mediaquality->setAutoAqEnabled(true));
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaQualityAidl);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaQualityAidl);


INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(