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

Commit ca19e6e3 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Move AmbientDisplayConfiguration class out of internal package.

Test: m droid (run full build), atest SystemUITests
Bug: 126327497
Change-Id: Ife8303924bd02e9639008293bf9028f4871a9b16
parent 5412ada5
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -742,6 +742,13 @@ package android.hardware.display {
    field public static final android.os.Parcelable.Creator<android.hardware.display.AmbientBrightnessDayStats> CREATOR;
    field public static final android.os.Parcelable.Creator<android.hardware.display.AmbientBrightnessDayStats> CREATOR;
  }
  }


  public class AmbientDisplayConfiguration {
    ctor public AmbientDisplayConfiguration(android.content.Context);
    method public boolean alwaysOnAvailable();
    method public boolean alwaysOnAvailableForUser(int);
    method public boolean alwaysOnEnabled(int);
  }

  public final class BrightnessChangeEvent implements android.os.Parcelable {
  public final class BrightnessChangeEvent implements android.os.Parcelable {
    method public int describeContents();
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
@@ -1992,6 +1999,7 @@ package android.provider {
    field public static final String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH = "autofill_user_data_min_value_length";
    field public static final String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH = "autofill_user_data_min_value_length";
    field public static final String CONTENT_CAPTURE_ENABLED = "content_capture_enabled";
    field public static final String CONTENT_CAPTURE_ENABLED = "content_capture_enabled";
    field public static final String DISABLED_PRINT_SERVICES = "disabled_print_services";
    field public static final String DISABLED_PRINT_SERVICES = "disabled_print_services";
    field public static final String DOZE_ALWAYS_ON = "doze_always_on";
    field @Deprecated public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages";
    field @Deprecated public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages";
    field public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
    field public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
    field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis";
    field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis";
+50 −4
Original line number Original line Diff line number Diff line
@@ -11,11 +11,12 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * See the License for the specific language governing permissions and
 * limitations under the License
 * limitations under the License.
 */
 */


package com.android.internal.hardware;
package android.hardware.display;


import android.annotation.TestApi;
import android.content.Context;
import android.content.Context;
import android.os.Build;
import android.os.Build;
import android.os.SystemProperties;
import android.os.SystemProperties;
@@ -24,16 +25,25 @@ import android.text.TextUtils;


import com.android.internal.R;
import com.android.internal.R;


/**
 * AmbientDisplayConfiguration encapsulates reading access to the configuration of ambient display.
 *
 * {@hide}
 */
@TestApi
public class AmbientDisplayConfiguration {
public class AmbientDisplayConfiguration {


    private final Context mContext;
    private final Context mContext;
    private final boolean mAlwaysOnByDefault;
    private final boolean mAlwaysOnByDefault;


    /** {@hide} */
    @TestApi
    public AmbientDisplayConfiguration(Context context) {
    public AmbientDisplayConfiguration(Context context) {
        mContext = context;
        mContext = context;
        mAlwaysOnByDefault = mContext.getResources().getBoolean(R.bool.config_dozeAlwaysOnEnabled);
        mAlwaysOnByDefault = mContext.getResources().getBoolean(R.bool.config_dozeAlwaysOnEnabled);
    }
    }


    /** {@hide} */
    public boolean enabled(int user) {
    public boolean enabled(int user) {
        return pulseOnNotificationEnabled(user)
        return pulseOnNotificationEnabled(user)
                || pulseOnLongPressEnabled(user)
                || pulseOnLongPressEnabled(user)
@@ -41,67 +51,83 @@ public class AmbientDisplayConfiguration {
                || wakeScreenGestureEnabled(user);
                || wakeScreenGestureEnabled(user);
    }
    }


    /** {@hide} */
    public boolean pulseOnNotificationEnabled(int user) {
    public boolean pulseOnNotificationEnabled(int user) {
        return boolSettingDefaultOn(Settings.Secure.DOZE_ENABLED, user) && pulseOnNotificationAvailable();
        return boolSettingDefaultOn(Settings.Secure.DOZE_ENABLED, user)
                && pulseOnNotificationAvailable();
    }
    }


    /** {@hide} */
    public boolean pulseOnNotificationAvailable() {
    public boolean pulseOnNotificationAvailable() {
        return ambientDisplayAvailable();
        return ambientDisplayAvailable();
    }
    }


    /** {@hide} */
    public boolean pickupGestureEnabled(int user) {
    public boolean pickupGestureEnabled(int user) {
        return boolSettingDefaultOn(Settings.Secure.DOZE_PICK_UP_GESTURE, user)
        return boolSettingDefaultOn(Settings.Secure.DOZE_PICK_UP_GESTURE, user)
                && dozePickupSensorAvailable();
                && dozePickupSensorAvailable();
    }
    }


    /** {@hide} */
    public boolean dozePickupSensorAvailable() {
    public boolean dozePickupSensorAvailable() {
        return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
        return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
    }
    }


    /** {@hide} */
    public boolean tapGestureEnabled(int user) {
    public boolean tapGestureEnabled(int user) {
        return boolSettingDefaultOn(Settings.Secure.DOZE_TAP_SCREEN_GESTURE, user)
        return boolSettingDefaultOn(Settings.Secure.DOZE_TAP_SCREEN_GESTURE, user)
                && tapSensorAvailable();
                && tapSensorAvailable();
    }
    }


    /** {@hide} */
    public boolean tapSensorAvailable() {
    public boolean tapSensorAvailable() {
        return !TextUtils.isEmpty(tapSensorType());
        return !TextUtils.isEmpty(tapSensorType());
    }
    }


    /** {@hide} */
    public boolean doubleTapGestureEnabled(int user) {
    public boolean doubleTapGestureEnabled(int user) {
        return boolSettingDefaultOn(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, user)
        return boolSettingDefaultOn(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, user)
                && doubleTapSensorAvailable();
                && doubleTapSensorAvailable();
    }
    }


    /** {@hide} */
    public boolean doubleTapSensorAvailable() {
    public boolean doubleTapSensorAvailable() {
        return !TextUtils.isEmpty(doubleTapSensorType());
        return !TextUtils.isEmpty(doubleTapSensorType());
    }
    }


    /** {@hide} */
    public boolean wakeScreenGestureAvailable() {
    public boolean wakeScreenGestureAvailable() {
        return mContext.getResources()
        return mContext.getResources()
                .getBoolean(R.bool.config_dozeWakeLockScreenSensorAvailable);
                .getBoolean(R.bool.config_dozeWakeLockScreenSensorAvailable);
    }
    }


    /** {@hide} */
    public boolean wakeScreenGestureEnabled(int user) {
    public boolean wakeScreenGestureEnabled(int user) {
        return boolSettingDefaultOn(Settings.Secure.DOZE_WAKE_SCREEN_GESTURE, user)
        return boolSettingDefaultOn(Settings.Secure.DOZE_WAKE_SCREEN_GESTURE, user)
                && wakeScreenGestureAvailable();
                && wakeScreenGestureAvailable();
    }
    }


    /** {@hide} */
    public long getWakeLockScreenDebounce() {
    public long getWakeLockScreenDebounce() {
        return mContext.getResources().getInteger(R.integer.config_dozeWakeLockScreenDebounce);
        return mContext.getResources().getInteger(R.integer.config_dozeWakeLockScreenDebounce);
    }
    }


    /** {@hide} */
    public String doubleTapSensorType() {
    public String doubleTapSensorType() {
        return mContext.getResources().getString(R.string.config_dozeDoubleTapSensorType);
        return mContext.getResources().getString(R.string.config_dozeDoubleTapSensorType);
    }
    }


    /** {@hide} */
    public String tapSensorType() {
    public String tapSensorType() {
        return mContext.getResources().getString(R.string.config_dozeTapSensorType);
        return mContext.getResources().getString(R.string.config_dozeTapSensorType);
    }
    }


    /** {@hide} */
    public String longPressSensorType() {
    public String longPressSensorType() {
        return mContext.getResources().getString(R.string.config_dozeLongPressSensorType);
        return mContext.getResources().getString(R.string.config_dozeLongPressSensorType);
    }
    }


    /** {@hide} */
    public boolean pulseOnLongPressEnabled(int user) {
    public boolean pulseOnLongPressEnabled(int user) {
        return pulseOnLongPressAvailable() && boolSettingDefaultOff(
        return pulseOnLongPressAvailable() && boolSettingDefaultOff(
                Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, user);
                Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, user);
@@ -111,28 +137,49 @@ public class AmbientDisplayConfiguration {
        return !TextUtils.isEmpty(longPressSensorType());
        return !TextUtils.isEmpty(longPressSensorType());
    }
    }


    /**
     * Returns if Always-on-Display functionality is enabled on the display for a specified user.
     *
     * {@hide}
     */
    @TestApi
    public boolean alwaysOnEnabled(int user) {
    public boolean alwaysOnEnabled(int user) {
        return boolSetting(Settings.Secure.DOZE_ALWAYS_ON, user, mAlwaysOnByDefault ? 1 : 0)
        return boolSetting(Settings.Secure.DOZE_ALWAYS_ON, user, mAlwaysOnByDefault ? 1 : 0)
                && alwaysOnAvailable() && !accessibilityInversionEnabled(user);
                && alwaysOnAvailable() && !accessibilityInversionEnabled(user);
    }
    }


    /**
     * Returns if Always-on-Display functionality is available on the display.
     *
     * {@hide}
     */
    @TestApi
    public boolean alwaysOnAvailable() {
    public boolean alwaysOnAvailable() {
        return (alwaysOnDisplayDebuggingEnabled() || alwaysOnDisplayAvailable())
        return (alwaysOnDisplayDebuggingEnabled() || alwaysOnDisplayAvailable())
                && ambientDisplayAvailable();
                && ambientDisplayAvailable();
    }
    }


    /**
     * Returns if Always-on-Display functionality is available on the display for a specified user.
     *
     *  {@hide}
     */
    @TestApi
    public boolean alwaysOnAvailableForUser(int user) {
    public boolean alwaysOnAvailableForUser(int user) {
        return alwaysOnAvailable() && !accessibilityInversionEnabled(user);
        return alwaysOnAvailable() && !accessibilityInversionEnabled(user);
    }
    }


    /** {@hide} */
    public String ambientDisplayComponent() {
    public String ambientDisplayComponent() {
        return mContext.getResources().getString(R.string.config_dozeComponent);
        return mContext.getResources().getString(R.string.config_dozeComponent);
    }
    }


    /** {@hide} */
    public boolean accessibilityInversionEnabled(int user) {
    public boolean accessibilityInversionEnabled(int user) {
        return boolSettingDefaultOff(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, user);
        return boolSettingDefaultOff(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, user);
    }
    }


    /** {@hide} */
    public boolean ambientDisplayAvailable() {
    public boolean ambientDisplayAvailable() {
        return !TextUtils.isEmpty(ambientDisplayComponent());
        return !TextUtils.isEmpty(ambientDisplayComponent());
    }
    }
@@ -145,7 +192,6 @@ public class AmbientDisplayConfiguration {
        return SystemProperties.getBoolean("debug.doze.aod", false) && Build.IS_DEBUGGABLE;
        return SystemProperties.getBoolean("debug.doze.aod", false) && Build.IS_DEBUGGABLE;
    }
    }



    private boolean boolSettingDefaultOn(String name, int user) {
    private boolean boolSettingDefaultOn(String name, int user) {
        return boolSetting(name, user, 1);
        return boolSetting(name, user, 1);
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -7483,6 +7483,7 @@ public final class Settings {
         * @hide
         * @hide
         */
         */
        @SystemApi
        @SystemApi
        @TestApi
        public static final String DOZE_ALWAYS_ON = "doze_always_on";
        public static final String DOZE_ALWAYS_ON = "doze_always_on";
        private static final Validator DOZE_ALWAYS_ON_VALIDATOR = BOOLEAN_VALIDATOR;
        private static final Validator DOZE_ALWAYS_ON_VALIDATOR = BOOLEAN_VALIDATOR;
+1 −1
Original line number Original line Diff line number Diff line
@@ -17,11 +17,11 @@
package com.android.systemui.doze;
package com.android.systemui.doze;


import android.content.Context;
import android.content.Context;
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.Handler;
import android.os.Handler;
import android.os.UserHandle;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;


import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeMachine.State;
import com.android.systemui.doze.DozeMachine.State;


+1 −1
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@ import android.app.Application;
import android.content.Context;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.SensorManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.Handler;
import android.os.Handler;


import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R;
Loading