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

Commit 4f7ccd42 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Define FeatureFlagsService.

This service acts as a central coordinator to ensure that all
cross-process, stable flags maintain the same value, as well as
providing a central mechanism for overriding flags locally on a
device.

This cl contains a the service wholly defined and functional, though
the FeatureFlags class in core, meant to communicate with it, is not
yet implemented.

See http://go/android-flagging-dd for more details.

Test: build && flash && `adb shell cmd flags`.
Bug: 279054964
Change-Id: I930152682f98f3f299e763522e5c7e6b1a550e32
parent 27f4ca52
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -33,6 +33,15 @@ filegroup {
    srcs: ["com/android/internal/os/IBinaryTransparencyService.aidl"],
}

filegroup {
    name: "feature_flags_aidl",
    srcs: [
        "android/flags/IFeatureFlags.aidl",
        "android/flags/IFeatureFlagsCallback.aidl",
        "android/flags/SyncableFlag.aidl",
    ],
}

filegroup {
    name: "ITracingServiceProxy.aidl",
    srcs: ["android/tracing/ITracingServiceProxy.aidl"],
+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
Loading