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

Commit b22aabbb authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Introduce condition provider services."

parents 2be1f8c3 7340fc86
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ LOCAL_SRC_FILES += \
	core/java/android/os/IUserManager.aidl \
	core/java/android/os/IVibratorService.aidl \
	core/java/android/service/notification/INotificationListener.aidl \
	core/java/android/service/notification/IConditionProvider.aidl \
	core/java/android/print/ILayoutResultCallback.aidl \
	core/java/android/print/IPrinterDiscoveryObserver.aidl \
	core/java/android/print/IPrintDocumentAdapter.aidl \
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.service.notification.StatusBarNotification;
import android.app.Notification;
import android.content.ComponentName;
import android.content.Intent;
import android.service.notification.Condition;
import android.service.notification.IConditionProvider;
import android.service.notification.INotificationListener;
import android.service.notification.ZenModeConfig;

@@ -53,4 +55,5 @@ interface INotificationManager

    ZenModeConfig getZenModeConfig();
    boolean setZenModeConfig(in ZenModeConfig config);
    void notifyCondition(in IConditionProvider provider, in Condition condition);
}
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
@@ -722,6 +722,13 @@ public final class Settings {
    public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS
            = "android.settings.NOTIFICATION_LISTENER_SETTINGS";

    /**
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_CONDITION_PROVIDER_SETTINGS
            = "android.settings.ACTION_CONDITION_PROVIDER_SETTINGS";

    /**
     * Activity Action: Show settings for video captioning.
     * <p>
@@ -4516,6 +4523,11 @@ public final class Settings {
         */
        public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";

        /**
         * @hide
         */
        public static final String ENABLED_CONDITION_PROVIDERS = "enabled_condition_providers";

        /** @hide */
        public static final String BAR_SERVICE_COMPONENT = "bar_service_component";

+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, 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;

parcelable Condition;
+119 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2014, 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;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * Condition information from condition providers.
 *
 * @hide
 */
public class Condition implements Parcelable {

    public static final int FLAG_RELEVANT_NOW = 1 << 0;
    public static final int FLAG_RELEVANT_ALWAYS = 1 << 1;

    public final Uri id;
    public String caption;
    public boolean state;
    public int flags;


    public Condition(Uri id, String caption, boolean state, int flags) {
        if (id == null) throw new IllegalArgumentException("id is required");
        if (caption == null) throw new IllegalArgumentException("caption is required");
        this.id = id;
        this.caption = caption;
        this.state = state;
        this.flags = flags;
    }

    private Condition(Parcel source) {
        id = Uri.CREATOR.createFromParcel(source);
        caption = source.readString();
        state = source.readInt() == 1;
        flags = source.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(id, 0);
        dest.writeString(caption);
        dest.writeInt(state ? 1 : 0);
        dest.writeInt(flags);
    }

    @Override
    public String toString() {
        return new StringBuilder(Condition.class.getSimpleName()).append('[')
            .append("id=").append(id)
            .append(",caption=").append(caption)
            .append(",state=").append(state)
            .append(",flags=").append(flags)
            .append(']').toString();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Condition)) return false;
        if (o == this) return true;
        final Condition other = (Condition) o;
        return Objects.equals(other.id, id)
                && Objects.equals(other.caption, caption)
                && other.state == state
                && other.flags == flags;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, caption, state, flags);
    }

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

    public Condition copy() {
        final Parcel parcel = Parcel.obtain();
        try {
            writeToParcel(parcel, 0);
            parcel.setDataPosition(0);
            return new Condition(parcel);
        } finally {
            parcel.recycle();
        }
    }

    public static final Parcelable.Creator<Condition> CREATOR
            = new Parcelable.Creator<Condition>() {
        @Override
        public Condition createFromParcel(Parcel source) {
            return new Condition(source);
        }

        @Override
        public Condition[] newArray(int size) {
            return new Condition[size];
        }
    };
}
Loading