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

Commit 0c72a321 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Revert^2 "Define FeatureFlagsService."

This revert contains one small fix: The prior change included
changes in core/java/Android.bp and a corresponding line in
services/flags/Android.bp that causes problems in
StrictJavaPackagesTest
#testBootClasspathAndSystemServerClasspath_nonDuplicateClasses

Specifically resulting in this bug being filed: http://b/290929382


de960774

Bug: 279054964
Change-Id: Ia2ac95bb22144ff8be84c711604db72d039a814d
parent 25846953
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -5297,6 +5297,13 @@ public abstract class Context {
    @SystemApi
    public static final String APP_PREDICTION_SERVICE = "app_prediction";

    /**
     * Used for reading system-wide, overridable flags.
     *
     * @hide
     */
    public static final String FEATURE_FLAGS_SERVICE = "feature_flags";

    /**
     * Official published name of the search ui service.
     *
+65 −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.flags;

import android.flags.IFeatureFlagsCallback;
import android.flags.SyncableFlag;

/**
 * Binder interface for communicating with {@link com.android.server.flags.FeatureFlagsService}.
 *
 * This interface is used by {@link android.flags.FeatureFlags} and developers should use that to
 * interface with the service. FeatureFlags is the "client" in this documentation.
 *
 * The methods allow client apps to communicate what flags they care about, and receive back
 * current values for those flags. For stable flags, this is the finalized value until the device
 * restarts. For {@link DynamicFlag}s, this is the last known value, though it may change in the
 * future. Clients can listen for changes to flag values so that it can react accordingly.
 * @hide
 */
interface IFeatureFlags {
    /**
     * Synchronize with the {@link com.android.server.flags.FeatureFlagsService} about flags of
     * interest.
     *
     * The client should pass in a list of flags that it is using as {@link SyncableFlag}s, which
     * includes what it thinks the default values of the flags are.
     *
     * The response will contain a list of matching SyncableFlags, whose values are set to what the
     * value of the flags actually are. The client should update its internal state flag data to
     * match.
     *
     * Generally speaking, if a flag that is passed in is new to the FeatureFlagsService, the
     * service will cache the passed-in value, and return it back out. If, however, a different
     * client has synced that flag with the service previously, FeatureFlagsService will return the
     * existing cached value, which may or may not be what the current client passed in. This allows
     * FeatureFlagsService to keep clients in agreement with one another.
     */
    List<SyncableFlag> syncFlags(in List<SyncableFlag> flagList);

    /**
     * Pass in an {@link IFeatureFlagsCallback} that will be called whenever a {@link DymamicFlag}
     * changes.
     */
    void registerCallback(IFeatureFlagsCallback callback);

    /**
     * Remove a {@link IFeatureFlagsCallback} that was previously registered with
     * {@link #registerCallback}.
     */
    void unregisterCallback(IFeatureFlagsCallback callback);
}
 No newline at end of file
+31 −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.flags;

import android.flags.SyncableFlag;

/**
 * Callback for {@link IFeatureFlags#registerCallback} to get alerts when a {@link DynamicFlag}
 * changes.
 *
 * DynamicFlags can change at run time. Stable flags will never result in a call to this method.
 *
 * @hide
 */
oneway interface IFeatureFlagsCallback {
    void onFlagChange(in SyncableFlag flag);
}
 No newline at end of file
+22 −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.flags;

/**
 * A parcelable data class for serializing {@link Flag} across a Binder.
 */
parcelable SyncableFlag;
 No newline at end of file
+99 −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.flags;

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

import com.android.internal.annotations.VisibleForTesting;

/**
 * @hide
 */
public final class SyncableFlag implements Parcelable {
    private final String mNamespace;
    private final String mName;
    private String mValue;
    private final boolean mDynamic;

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public SyncableFlag(
            @NonNull String namespace,
            @NonNull String name,
            @NonNull String value,
            boolean dynamic) {
        mNamespace = namespace;
        mName = name;
        mValue = value;
        mDynamic = dynamic;
    }

    public void setValue(@NonNull String value) {
        mValue = value;
    }

    @NonNull
    public String getNamespace() {
        return mNamespace;
    }

    @NonNull
    public String getName() {
        return mName;
    }

    @NonNull
    public String getValue() {
        return mValue;
    }

    @NonNull
    public boolean isDynamic() {
        return mDynamic;
    }

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

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

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

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(mNamespace);
        dest.writeString(mName);
        dest.writeString(mValue);
        dest.writeBoolean(mDynamic);
    }

    @Override
    public String toString() {
        return getNamespace() + "." + getName() + "[" + getValue() + "]";
    }
}
Loading