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

Commit f712e742 authored by Shubang Lu's avatar Shubang Lu
Browse files

[MQ] Support ambient backlight

Test: mmm
Flag: android.media.tv.flags.media_quality_fw
Bug: 377079429
Change-Id: I27358f64435f70128a8e5de492dbd389b274781b
parent 7ed58e66
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.media.quality;

parcelable AmbientBacklightEvent;
+136 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.media.quality;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;

/**
 * @hide
 */
public final class AmbientBacklightEvent implements Parcelable {

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({AMBIENT_BACKLIGHT_EVENT_ENABLED, AMBIENT_BACKLIGHT_EVENT_DISABLED,
            AMBIENT_BACKLIGHT_EVENT_METADATA,
            AMBIENT_BACKLIGHT_EVENT_INTERRUPTED})
    public @interface AmbientBacklightEventTypes {}

    /**
     * Event type for ambient backlight events. The ambient backlight is enabled.
     */
    public static final int AMBIENT_BACKLIGHT_EVENT_ENABLED = 1;

    /**
     * Event type for ambient backlight events. The ambient backlight is disabled.
     */
    public static final int AMBIENT_BACKLIGHT_EVENT_DISABLED = 2;

    /**
     * Event type for ambient backlight events. The ambient backlight metadata is
     * available.
     */
    public static final int AMBIENT_BACKLIGHT_EVENT_METADATA = 3;

    /**
     * Event type for ambient backlight events. The ambient backlight event is preempted by another
     * application.
     */
    public static final int AMBIENT_BACKLIGHT_EVENT_INTERRUPTED = 4;

    private final int mEventType;
    @Nullable
    private final AmbientBacklightMetadata mMetadata;

    public AmbientBacklightEvent(int eventType,
            @Nullable AmbientBacklightMetadata metadata) {
        mEventType = eventType;
        mMetadata = metadata;
    }

    private AmbientBacklightEvent(Parcel in) {
        mEventType = in.readInt();
        mMetadata = in.readParcelable(AmbientBacklightMetadata.class.getClassLoader());
    }

    public int getEventType() {
        return mEventType;
    }

    @Nullable
    public AmbientBacklightMetadata getMetadata() {
        return mMetadata;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mEventType);
        dest.writeParcelable(mMetadata, flags);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final @NonNull Parcelable.Creator<AmbientBacklightEvent> CREATOR =
            new Parcelable.Creator<AmbientBacklightEvent>() {
                public AmbientBacklightEvent createFromParcel(Parcel in) {
                    return new AmbientBacklightEvent(in);
                }

                public AmbientBacklightEvent[] newArray(int size) {
                    return new AmbientBacklightEvent[size];
                }
            };

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof AmbientBacklightEvent)) {
            return false;
        }

        AmbientBacklightEvent other = (AmbientBacklightEvent) obj;
        return mEventType == other.mEventType
                && Objects.equals(mMetadata, other.mMetadata);
    }

    @Override
    public int hashCode() {
        return mEventType * 31 + (mMetadata != null ? mMetadata.hashCode() : 0);
    }

    @Override
    public String toString() {
        return "AmbientBacklightEvent{"
                + "mEventType=" + mEventType
                + ", mMetadata=" + mMetadata
                + '}';
    }
}
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.media.quality;

parcelable AmbientBacklightMetadata;
 No newline at end of file
+127 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.media.quality;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import java.util.Arrays;

/**
 * @hide
 */
public class AmbientBacklightMetadata implements Parcelable {
    @NonNull
    private final String mPackageName;
    private final int mCompressAlgorithm;
    private final int mSource;
    private final int mColorFormat;
    private final int mHorizontalZonesNumber;
    private final int mVerticalZonesNumber;
    @NonNull
    private final int[] mZonesColors;

    public AmbientBacklightMetadata(@NonNull String packageName, int compressAlgorithm,
            int source, int colorFormat, int horizontalZonesNumber, int verticalZonesNumber,
            @NonNull int[] zonesColors) {
        mPackageName = packageName;
        mCompressAlgorithm = compressAlgorithm;
        mSource = source;
        mColorFormat = colorFormat;
        mHorizontalZonesNumber = horizontalZonesNumber;
        mVerticalZonesNumber = verticalZonesNumber;
        mZonesColors = zonesColors;
    }

    private AmbientBacklightMetadata(Parcel in) {
        mPackageName = in.readString();
        mCompressAlgorithm = in.readInt();
        mSource = in.readInt();
        mColorFormat = in.readInt();
        mHorizontalZonesNumber = in.readInt();
        mVerticalZonesNumber = in.readInt();
        mZonesColors = in.createIntArray();
    }

    @NonNull
    public String getPackageName() {
        return mPackageName;
    }

    public int getCompressAlgorithm() {
        return mCompressAlgorithm;
    }

    public int getSource() {
        return mSource;
    }

    public int getColorFormat() {
        return mColorFormat;
    }

    public int getHorizontalZonesNumber() {
        return mHorizontalZonesNumber;
    }

    public int getVerticalZonesNumber() {
        return mVerticalZonesNumber;
    }

    @NonNull
    public int[] getZonesColors() {
        return mZonesColors;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(mPackageName);
        dest.writeInt(mCompressAlgorithm);
        dest.writeInt(mSource);
        dest.writeInt(mColorFormat);
        dest.writeInt(mHorizontalZonesNumber);
        dest.writeInt(mVerticalZonesNumber);
        dest.writeIntArray(mZonesColors);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final @NonNull Parcelable.Creator<AmbientBacklightMetadata> CREATOR =
            new Parcelable.Creator<AmbientBacklightMetadata>() {
                public AmbientBacklightMetadata createFromParcel(Parcel in) {
                    return new AmbientBacklightMetadata(in);
                }

                public AmbientBacklightMetadata[] newArray(int size) {
                    return new AmbientBacklightMetadata[size];
                }
            };

    @Override
    public String toString() {
        return "AmbientBacklightMetadata{packageName=" + mPackageName
                + ", compressAlgorithm=" + mCompressAlgorithm + ", source=" + mSource
                + ", colorFormat=" + mColorFormat + ", horizontalZonesNumber="
                + mHorizontalZonesNumber + ", verticalZonesNumber=" + mVerticalZonesNumber
                + ", zonesColors=" + Arrays.toString(mZonesColors) + "}";
    }
}
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.media.quality;

parcelable AmbientBacklightSettings;
Loading