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

Commit 5208561d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Change streaming policy implementations" into sc-dev am: 78a91deb am: b3e8ce35

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14121961

Change-Id: Ie1f01258c3f9811ea85111f81dfe42cddd4d02ce
parents 2983f47e b3e8ce35
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -7466,9 +7466,10 @@ package android.app.admin {
    field public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1; // 0x1
    field public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1; // 0x1
    field public static final int MAKE_USER_EPHEMERAL = 2; // 0x2
    field public static final int MAKE_USER_EPHEMERAL = 2; // 0x2
    field public static final String MIME_TYPE_PROVISIONING_NFC = "application/com.android.managedprovisioning";
    field public static final String MIME_TYPE_PROVISIONING_NFC = "application/com.android.managedprovisioning";
    field public static final int NEARBY_STREAMING_DISABLED = 0; // 0x0
    field public static final int NEARBY_STREAMING_DISABLED = 1; // 0x1
    field public static final int NEARBY_STREAMING_ENABLED = 1; // 0x1
    field public static final int NEARBY_STREAMING_ENABLED = 2; // 0x2
    field public static final int NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY = 2; // 0x2
    field public static final int NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY = 0; // 0x0
    field public static final int NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY = 3; // 0x3
    field public static final int OPERATION_SAFETY_REASON_DRIVING_DISTRACTION = 1; // 0x1
    field public static final int OPERATION_SAFETY_REASON_DRIVING_DISTRACTION = 1; // 0x1
    field public static final int PASSWORD_COMPLEXITY_HIGH = 327680; // 0x50000
    field public static final int PASSWORD_COMPLEXITY_HIGH = 327680; // 0x50000
    field public static final int PASSWORD_COMPLEXITY_LOW = 65536; // 0x10000
    field public static final int PASSWORD_COMPLEXITY_LOW = 65536; // 0x10000
+25 −9
Original line number Original line Diff line number Diff line
@@ -1678,23 +1678,30 @@ public class DevicePolicyManager {
    })
    })
    public @interface PasswordComplexity {}
    public @interface PasswordComplexity {}
    /**
     * Indicates that nearby streaming is not controlled by policy, which means nearby streaming is
     * allowed.
     */
    public static final int NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY = 0;
    /** Indicates that nearby streaming is disabled. */
    /** Indicates that nearby streaming is disabled. */
    public static final int NEARBY_STREAMING_DISABLED = 0;
    public static final int NEARBY_STREAMING_DISABLED = 1;
    /** Indicates that nearby streaming is enabled. */
    /** Indicates that nearby streaming is enabled. */
    public static final int NEARBY_STREAMING_ENABLED = 1;
    public static final int NEARBY_STREAMING_ENABLED = 2;
    /**
    /**
     * Indicates that nearby streaming is enabled only to devices offering a comparable level of
     * Indicates that nearby streaming is enabled only to devices offering a comparable level of
     * security, with the same authenticated managed account.
     * security, with the same authenticated managed account.
     */
     */
    public static final int NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY = 2;
    public static final int NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY = 3;
    /**
    /**
     * @hide
     * @hide
     */
     */
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"NEARBY_STREAMING_"}, value = {
    @IntDef(prefix = {"NEARBY_STREAMING_"}, value = {
        NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY,
        NEARBY_STREAMING_DISABLED,
        NEARBY_STREAMING_DISABLED,
        NEARBY_STREAMING_ENABLED,
        NEARBY_STREAMING_ENABLED,
        NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
        NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
@@ -7199,15 +7206,20 @@ public class DevicePolicyManager {
    /**
    /**
     * Returns the current runtime nearby notification streaming policy set by the device or profile
     * Returns the current runtime nearby notification streaming policy set by the device or profile
     * owner. The default is {@link #NEARBY_STREAMING_DISABLED}.
     * owner.
     */
     */
    public @NearbyStreamingPolicy int getNearbyNotificationStreamingPolicy() {
    public @NearbyStreamingPolicy int getNearbyNotificationStreamingPolicy() {
        return getNearbyNotificationStreamingPolicy(myUserId());
    }
    /** @hide per-user version */
    public @NearbyStreamingPolicy int getNearbyNotificationStreamingPolicy(int userId) {
        throwIfParentInstance("getNearbyNotificationStreamingPolicy");
        throwIfParentInstance("getNearbyNotificationStreamingPolicy");
        if (mService == null) {
        if (mService == null) {
            return NEARBY_STREAMING_DISABLED;
            return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
        }
        }
        try {
        try {
            return mService.getNearbyNotificationStreamingPolicy();
            return mService.getNearbyNotificationStreamingPolicy(userId);
        } catch (RemoteException re) {
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
            throw re.rethrowFromSystemServer();
        }
        }
@@ -7235,15 +7247,19 @@ public class DevicePolicyManager {
    /**
    /**
     * Returns the current runtime nearby app streaming policy set by the device or profile owner.
     * Returns the current runtime nearby app streaming policy set by the device or profile owner.
     * The default is {@link #NEARBY_STREAMING_DISABLED}.
     */
     */
    public @NearbyStreamingPolicy int getNearbyAppStreamingPolicy() {
    public @NearbyStreamingPolicy int getNearbyAppStreamingPolicy() {
        return getNearbyAppStreamingPolicy(myUserId());
    }
    /** @hide per-user version */
    public @NearbyStreamingPolicy int getNearbyAppStreamingPolicy(int userId) {
        throwIfParentInstance("getNearbyAppStreamingPolicy");
        throwIfParentInstance("getNearbyAppStreamingPolicy");
        if (mService == null) {
        if (mService == null) {
            return NEARBY_STREAMING_DISABLED;
            return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
        }
        }
        try {
        try {
            return mService.getNearbyAppStreamingPolicy();
            return mService.getNearbyAppStreamingPolicy(userId);
        } catch (RemoteException re) {
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
            throw re.rethrowFromSystemServer();
        }
        }
+2 −2
Original line number Original line Diff line number Diff line
@@ -134,10 +134,10 @@ interface IDevicePolicyManager {
    boolean getScreenCaptureDisabled(in ComponentName who, int userHandle, boolean parent);
    boolean getScreenCaptureDisabled(in ComponentName who, int userHandle, boolean parent);


    void setNearbyNotificationStreamingPolicy(int policy);
    void setNearbyNotificationStreamingPolicy(int policy);
    int getNearbyNotificationStreamingPolicy();
    int getNearbyNotificationStreamingPolicy(int userId);


    void setNearbyAppStreamingPolicy(int policy);
    void setNearbyAppStreamingPolicy(int policy);
    int getNearbyAppStreamingPolicy();
    int getNearbyAppStreamingPolicy(int userId);


    void setKeyguardDisabledFeatures(in ComponentName who, int which, boolean parent);
    void setKeyguardDisabledFeatures(in ComponentName who, int which, boolean parent);
    int getKeyguardDisabledFeatures(in ComponentName who, int userHandle, boolean parent);
    int getKeyguardDisabledFeatures(in ComponentName who, int userHandle, boolean parent);
+23 −15
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ import static android.app.admin.DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLE
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_HOME;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_HOME;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_NOTIFICATIONS;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_NOTIFICATIONS;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW;
import static android.app.admin.DevicePolicyManager.NEARBY_STREAMING_DISABLED;
import static android.app.admin.DevicePolicyManager.NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
import static android.app.admin.DevicePolicyManager.NON_ORG_OWNED_PROFILE_KEYGUARD_FEATURES_AFFECT_OWNER;
import static android.app.admin.DevicePolicyManager.NON_ORG_OWNED_PROFILE_KEYGUARD_FEATURES_AFFECT_OWNER;
import static android.app.admin.DevicePolicyManager.OPERATION_SAFETY_REASON_NONE;
import static android.app.admin.DevicePolicyManager.OPERATION_SAFETY_REASON_NONE;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_HIGH;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_HIGH;
@@ -7548,23 +7548,27 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    }
    @Override
    @Override
    public int getNearbyNotificationStreamingPolicy() {
    public int getNearbyNotificationStreamingPolicy(final int userId) {
        if (!mHasFeature) {
        if (!mHasFeature) {
            return NEARBY_STREAMING_DISABLED;
            return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
        }
        }
        final CallerIdentity caller = getCallerIdentity();
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(
        Preconditions.checkCallAuthorization(
                isDeviceOwner(caller)
                isProfileOwner(caller)
                    || isProfileOwner(caller)
                        || isDeviceOwner(caller)
                        || hasCallingOrSelfPermission(permission.READ_NEARBY_STREAMING_POLICY));
                        || hasCallingOrSelfPermission(permission.READ_NEARBY_STREAMING_POLICY));
        synchronized (getLockObject()) {
        synchronized (getLockObject()) {
            final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller);
            if (mOwners.hasProfileOwner(userId) || mOwners.hasDeviceOwner()) {
                final ActiveAdmin admin = getDeviceOrProfileOwnerAdminLocked(userId);
                return admin.mNearbyNotificationStreamingPolicy;
                return admin.mNearbyNotificationStreamingPolicy;
            }
            }
        }
        }
        return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
    }
    @Override
    @Override
    public void setNearbyAppStreamingPolicy(int policy) {
    public void setNearbyAppStreamingPolicy(int policy) {
        if (!mHasFeature) {
        if (!mHasFeature) {
@@ -7584,23 +7588,27 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    }
    @Override
    @Override
    public int getNearbyAppStreamingPolicy() {
    public int getNearbyAppStreamingPolicy(final int userId) {
        if (!mHasFeature) {
        if (!mHasFeature) {
            return NEARBY_STREAMING_DISABLED;
            return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
        }
        }
        final CallerIdentity caller = getCallerIdentity();
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(
        Preconditions.checkCallAuthorization(
                isDeviceOwner(caller)
                isProfileOwner(caller)
                    || isProfileOwner(caller)
                        || isDeviceOwner(caller)
                        || hasCallingOrSelfPermission(permission.READ_NEARBY_STREAMING_POLICY));
                        || hasCallingOrSelfPermission(permission.READ_NEARBY_STREAMING_POLICY));
        synchronized (getLockObject()) {
        synchronized (getLockObject()) {
            final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller);
            if (mOwners.hasProfileOwner(userId) || mOwners.hasDeviceOwner()) {
                final ActiveAdmin admin = getDeviceOrProfileOwnerAdminLocked(userId);
                return admin.mNearbyAppStreamingPolicy;
                return admin.mNearbyAppStreamingPolicy;
            }
            }
        }
        }
        return NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY;
    }
    /**
    /**
     * Set whether auto time is required by the specified admin (must be device or profile owner).
     * Set whether auto time is required by the specified admin (must be device or profile owner).
     */
     */