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

Commit 0be4f784 authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Apply DeviceEffects on rule activation/deactivation" into main

parents 087fcd5d 8a32f025
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1597,6 +1597,10 @@ package android.hardware.display {
    method public void restoreDozeSettings(int);
  }

  public final class ColorDisplayManager {
    method @FlaggedApi("android.app.modes_api") @RequiresPermission(android.Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS) public boolean isSaturationActivated();
  }

  public final class DisplayManager {
    method public boolean areUserDisabledHdrTypesAllowed();
    method @RequiresPermission(android.Manifest.permission.MODIFY_USER_PREFERRED_DISPLAY_MODE) public void clearGlobalUserPreferredDisplayMode();
+4 −0
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@
package android.hardware.display;

import android.Manifest;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.ContentResolver;
import android.content.Context;
import android.metrics.LogMaker;
@@ -397,6 +399,8 @@ public final class ColorDisplayManager {
     * @return {@code true} if the display is not at full saturation
     * @hide
     */
    @TestApi
    @FlaggedApi(android.app.Flags.FLAG_MODES_API)
    @RequiresPermission(Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS)
    public boolean isSaturationActivated() {
        return mManager.isSaturationActivated();
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.notification;

/**
 * Responsible for making any service calls needed to apply the set of {@link ZenDeviceEffects} that
 * make sense for the current platform.
 * @hide
 */
public interface DeviceEffectsApplier {
    /**
     * Applies the {@link ZenDeviceEffects} to the device.
     *
     * <p>The supplied {@code effects} represents the "consolidated" device effects, i.e. the
     * union of the effects of all the {@link ZenModeConfig.ZenRule} instances that are currently
     * active. If no rules are active (or no active rules specify custom effects) then {@code
     * effects} will be all-default (i.e. {@link ZenDeviceEffects#hasEffects} will return {@code
     * false}.
     *
     * <p>This will be called whenever the set of consolidated effects changes (normally through
     * the activation or deactivation of zen rules).
     */
    void apply(ZenDeviceEffects effects);
}
+22 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.service.notification;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Flags;
import android.os.Parcel;
import android.os.Parcelable;
@@ -359,6 +360,27 @@ public final class ZenDeviceEffects implements Parcelable {
            return this;
        }

        /**
         * Applies the effects that are {@code true} on the supplied {@link ZenDeviceEffects} to
         * this builder (essentially logically-ORing the effect set).
         * @hide
         */
        @NonNull
        public Builder add(@Nullable ZenDeviceEffects effects) {
            if (effects == null) return this;
            if (effects.shouldDisplayGrayscale()) setShouldDisplayGrayscale(true);
            if (effects.shouldSuppressAmbientDisplay()) setShouldSuppressAmbientDisplay(true);
            if (effects.shouldDimWallpaper()) setShouldDimWallpaper(true);
            if (effects.shouldUseNightMode()) setShouldUseNightMode(true);
            if (effects.shouldDisableAutoBrightness()) setShouldDisableAutoBrightness(true);
            if (effects.shouldDisableTapToWake()) setShouldDisableTapToWake(true);
            if (effects.shouldDisableTiltToWake()) setShouldDisableTiltToWake(true);
            if (effects.shouldDisableTouch()) setShouldDisableTouch(true);
            if (effects.shouldMinimizeRadioUsage()) setShouldMinimizeRadioUsage(true);
            if (effects.shouldMaximizeDoze()) setShouldMaximizeDoze(true);
            return this;
        }

        /** Builds a {@link ZenDeviceEffects} object based on the builder's state. */
        @NonNull
        public ZenDeviceEffects build() {
+2 −0
Original line number Diff line number Diff line
@@ -535,6 +535,8 @@ applications that come with the platform
        <!-- Permission required for CTS test IntentRedirectionTest -->
        <permission name="android.permission.QUERY_CLONED_APPS"/>
        <permission name="android.permission.GET_BINDING_UID_IMPORTANCE"/>
        <!-- Permission required for CTS test NotificationManagerZenTest -->
        <permission name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
    </privapp-permissions>

    <privapp-permissions package="com.android.statementservice">
Loading