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

Commit f1537f53 authored by Dave Mankoff's avatar Dave Mankoff Committed by Automerger Merge Worker
Browse files

Add permissions to FeatureFlagService and override api. am: c25fd5ae

parents ffa8030c c25fd5ae
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -24,4 +24,8 @@ package android.flags;
 * @hide
 */
public interface DynamicFlag<T> extends Flag<T> {
    @Override
    default boolean isDynamic() {
        return true;
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -250,7 +250,13 @@ public class FeatureFlags {
        return flag;
    }

    protected void sync() {
    /**
     * Sync any known flags that have not yet been synced.
     *
     * This is called implicitly when any flag is read, and is not generally needed except in
     * exceptional circumstances.
     */
    public void sync() {
        synchronized (FeatureFlags.class) {
            if (mDirtyFlags.isEmpty()) {
                return;
+5 −0
Original line number Diff line number Diff line
@@ -37,4 +37,9 @@ public interface Flag<T> {
    /** The value of this flag if no override has been set. Null values are not supported. */
    @NonNull
    T getDefault();

    /** Returns true if the value of this flag can change at runtime. */
    default boolean isDynamic() {
        return false;
    }
}
+24 −0
Original line number Diff line number Diff line
@@ -62,4 +62,28 @@ interface IFeatureFlags {
     * {@link #registerCallback}.
     */
    void unregisterCallback(IFeatureFlagsCallback callback);

    /**
     * Query the {@link com.android.server.flags.FeatureFlagsService} for flags, but don't
     * cache them. See {@link #syncFlags}.
     *
     * You almost certainly don't want this method. This is intended for the Flag Flipper
     * application that needs to query the state of system but doesn't want to affect it by
     * doing so. All other clients should use {@link syncFlags}.
     */
    List<SyncableFlag> queryFlags(in List<SyncableFlag> flagList);

    /**
     * Change a flags value in the system.
     *
     * This is intended for use by the Flag Flipper application.
     */
    void overrideFlag(in SyncableFlag flag);

    /**
     * Restore a flag to its default value.
     *
     * This is intended for use by the Flag Flipper application.
     */
    void resetFlag(in SyncableFlag flag);
}
 No newline at end of file
+22 −2
Original line number Diff line number Diff line
@@ -28,16 +28,28 @@ public final class SyncableFlag implements Parcelable {
    private final String mName;
    private final String mValue;
    private final boolean mDynamic;
    private final boolean mOverridden;

    public SyncableFlag(
            @NonNull String namespace,
            @NonNull String name,
            @NonNull String value,
            boolean dynamic) {
        this(namespace, name, value, dynamic, false);
    }

    public SyncableFlag(
            @NonNull String namespace,
            @NonNull String name,
            @NonNull String value,
            boolean dynamic,
            boolean overridden
    ) {
        mNamespace = namespace;
        mName = name;
        mValue = value;
        mDynamic = dynamic;
        mOverridden = overridden;
    }

    @NonNull
@@ -55,16 +67,23 @@ public final class SyncableFlag implements Parcelable {
        return mValue;
    }

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

    public boolean isOverridden() {
        return mOverridden;
    }

    @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());
                    in.readString(),
                    in.readString(),
                    in.readString(),
                    in.readBoolean(),
                    in.readBoolean());
        }

        public SyncableFlag[] newArray(int size) {
@@ -83,6 +102,7 @@ public final class SyncableFlag implements Parcelable {
        dest.writeString(mName);
        dest.writeString(mValue);
        dest.writeBoolean(mDynamic);
        dest.writeBoolean(mOverridden);
    }

    @Override
Loading