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

Commit 39713ce0 authored by Kholoud Mohamed's avatar Kholoud Mohamed
Browse files

Migrate application restrictions to policy engine

Bug: 232918480
Test: btest -sw android.devicepolicy.cts.ApplicationRestrictionsTest
Change-Id: I03f307c956ac4df5ca028239e47931c398d61096
parent 50568294
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -8190,6 +8190,7 @@ package android.app.admin {
    method public int getResultCode();
    method public int getResultCode();
    field public static final int RESULT_FAILURE_CONFLICTING_ADMIN_POLICY = 1; // 0x1
    field public static final int RESULT_FAILURE_CONFLICTING_ADMIN_POLICY = 1; // 0x1
    field public static final int RESULT_FAILURE_UNKNOWN = -1; // 0xffffffff
    field public static final int RESULT_FAILURE_UNKNOWN = -1; // 0xffffffff
    field public static final int RESULT_POLICY_CLEARED = 2; // 0x2
    field public static final int RESULT_SUCCESS = 0; // 0x0
    field public static final int RESULT_SUCCESS = 0; // 0x0
  }
  }
+7 −0
Original line number Original line Diff line number Diff line
@@ -599,6 +599,13 @@ package android.app.admin {
    field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.FlagUnion> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.FlagUnion> CREATOR;
  }
  }


  public final class MostRecent<V> extends android.app.admin.ResolutionMechanism<V> {
    ctor public MostRecent();
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.MostRecent> CREATOR;
  }

  public final class MostRestrictive<V> extends android.app.admin.ResolutionMechanism<V> {
  public final class MostRestrictive<V> extends android.app.admin.ResolutionMechanism<V> {
    method public int describeContents();
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
+80 −0
Original line number Original line 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.app.admin;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.Parcel;

import java.util.Objects;

/**
 * @hide
 */
public final class BundlePolicyValue extends PolicyValue<Bundle> {

    public BundlePolicyValue(Bundle value) {
        super(value);
    }

    private BundlePolicyValue(Parcel source) {
        this(source.readBundle());
    }

    @Override
    public boolean equals(@Nullable Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BundlePolicyValue other = (BundlePolicyValue) o;
        return Objects.equals(getValue(), other.getValue());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getValue());
    }

    @Override
    public String toString() {
        return "BundlePolicyValue { mValue= " + getValue() + " }";
    }

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

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeBundle(getValue());
    }

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

                @Override
                public BundlePolicyValue[] newArray(int size) {
                    return new BundlePolicyValue[size];
                }
            };
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -4051,6 +4051,12 @@ public class DevicePolicyManager {
     */
     */
    public static final String PACKAGE_UNINSTALL_BLOCKED_POLICY = "packageUninstallBlocked";
    public static final String PACKAGE_UNINSTALL_BLOCKED_POLICY = "packageUninstallBlocked";
    // TODO: Expose this as SystemAPI once we add the query API
    /**
     * @hide
     */
    public static final String APPLICATION_RESTRICTIONS_POLICY = "applicationRestrictions";
    /**
    /**
     * This object is a single place to tack on invalidation and disable calls.  All
     * This object is a single place to tack on invalidation and disable calls.  All
     * binder caches in this class derive from this Config, so all can be invalidated or
     * binder caches in this class derive from this Config, so all can be invalidated or
+8 −0
Original line number Original line Diff line number Diff line
@@ -21,9 +21,11 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Intent;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserHandle;


import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Set;


/**
/**
@@ -309,4 +311,10 @@ public abstract class DevicePolicyManagerInternal {
     * Returns whether the application exemptions feature flag is enabled.
     * Returns whether the application exemptions feature flag is enabled.
     */
     */
    public abstract boolean isApplicationExemptionsFlagEnabled();
    public abstract boolean isApplicationExemptionsFlagEnabled();

    /**
    * Returns the application restrictions set by each admin for the given {@code packageName}.
     */
    public abstract Map<String, Bundle> getApplicationRestrictionsPerAdmin(
            String packageName, int userId);
}
}
Loading