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

Commit 2a7d5831 authored by Richard Ho's avatar Richard Ho Committed by Automerger Merge Worker
Browse files

Merge changes from topic "nearby-streaming-policy" into sc-dev am: 2335acd9

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

Change-Id: I2dbe281b81b87ecf394977da3e66e42dd4ac10dc
parents 5829c6d4 2335acd9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7134,6 +7134,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(@Nullable android.content.ComponentName);
    method public long getMaximumTimeToLock(@Nullable android.content.ComponentName);
    method @NonNull public java.util.List<java.lang.String> getMeteredDataDisabledPackages(@NonNull android.content.ComponentName);
    method public int getNearbyAppStreamingPolicy();
    method public int getNearbyNotificationStreamingPolicy();
    method @Deprecated @ColorInt public int getOrganizationColor(@NonNull android.content.ComponentName);
    method @Nullable public CharSequence getOrganizationName(@NonNull android.content.ComponentName);
@@ -7278,6 +7279,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(@NonNull android.content.ComponentName, int);
    method public void setMaximumTimeToLock(@NonNull android.content.ComponentName, long);
    method @NonNull public java.util.List<java.lang.String> setMeteredDataDisabledPackages(@NonNull android.content.ComponentName, @NonNull java.util.List<java.lang.String>);
    method public void setNearbyAppStreamingPolicy(int);
    method public void setNearbyNotificationStreamingPolicy(int);
    method public void setNetworkLoggingEnabled(@Nullable android.content.ComponentName, boolean);
    method @Deprecated public void setOrganizationColor(@NonNull android.content.ComponentName, int);
+36 −0
Original line number Diff line number Diff line
@@ -7220,6 +7220,42 @@ public class DevicePolicyManager {
        }
    }
    /**
     * Called by a device/profile owner to set nearby app streaming policy. App streaming is when
     * the device starts an app on a virtual display and sends a video stream of the app to nearby
     * devices.
     *
     * @param policy One of the {@code NearbyStreamingPolicy} constants.
     * @throws SecurityException if caller is not a device or profile owner.
     */
    public void setNearbyAppStreamingPolicy(@NearbyStreamingPolicy int policy) {
        throwIfParentInstance("setNearbyAppStreamingPolicy");
        if (mService == null) {
            return;
        }
        try {
            mService.setNearbyAppStreamingPolicy(policy);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    /**
     * 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() {
        throwIfParentInstance("getNearbyAppStreamingPolicy");
        if (mService == null) {
            return NEARBY_STREAMING_DISABLED;
        }
        try {
            return mService.getNearbyAppStreamingPolicy();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }
    /**
     * Called by a device owner, or alternatively a profile owner from Android 8.0 (API level 26) or
     * higher, to set whether auto time is required. If auto time is required, no user will be able
+3 −0
Original line number Diff line number Diff line
@@ -135,6 +135,9 @@ interface IDevicePolicyManager {
    void setNearbyNotificationStreamingPolicy(int policy);
    int getNearbyNotificationStreamingPolicy();

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

    void setKeyguardDisabledFeatures(in ComponentName who, int which, boolean parent);
    int getKeyguardDisabledFeatures(in ComponentName who, int userHandle, boolean parent);

+14 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ class ActiveAdmin {
    private static final String TAG_DISABLE_ACCOUNT_MANAGEMENT = "disable-account-management";
    private static final String TAG_NEARBY_NOTIFICATION_STREAMING_POLICY =
            "nearby-notification-streaming-policy";
    private static final String TAG_NEARBY_APP_STREAMING_POLICY =
            "nearby-app-streaming-policy";
    private static final String TAG_REQUIRE_AUTO_TIME = "require_auto_time";
    private static final String TAG_FORCE_EPHEMERAL_USERS = "force_ephemeral_users";
    private static final String TAG_IS_NETWORK_LOGGING_ENABLED = "is_network_logging_enabled";
@@ -165,6 +167,9 @@ class ActiveAdmin {
    @DevicePolicyManager.NearbyStreamingPolicy
    int mNearbyNotificationStreamingPolicy = NEARBY_STREAMING_DISABLED;

    @DevicePolicyManager.NearbyStreamingPolicy
    int mNearbyAppStreamingPolicy = NEARBY_STREAMING_DISABLED;

    @Nullable
    FactoryResetProtectionPolicy mFactoryResetProtectionPolicy = null;

@@ -559,6 +564,10 @@ class ActiveAdmin {
            writeAttributeValueToXml(out, TAG_NEARBY_NOTIFICATION_STREAMING_POLICY,
                    mNearbyNotificationStreamingPolicy);
        }
        if (mNearbyAppStreamingPolicy != NEARBY_STREAMING_DISABLED) {
            writeAttributeValueToXml(out, TAG_NEARBY_APP_STREAMING_POLICY,
                    mNearbyAppStreamingPolicy);
        }
        if (!TextUtils.isEmpty(mOrganizationId)) {
            writeTextToXml(out, TAG_ORGANIZATION_ID, mOrganizationId);
        }
@@ -806,6 +815,8 @@ class ActiveAdmin {
                mPasswordComplexity = parser.getAttributeInt(null, ATTR_VALUE);
            } else if (TAG_NEARBY_NOTIFICATION_STREAMING_POLICY.equals(tag)) {
                mNearbyNotificationStreamingPolicy = parser.getAttributeInt(null, ATTR_VALUE);
            } else if (TAG_NEARBY_APP_STREAMING_POLICY.equals(tag)) {
                mNearbyAppStreamingPolicy = parser.getAttributeInt(null, ATTR_VALUE);
            } else if (TAG_ORGANIZATION_ID.equals(tag)) {
                type = parser.next();
                if (type == TypedXmlPullParser.TEXT) {
@@ -1169,6 +1180,9 @@ class ActiveAdmin {
        pw.print("mNearbyNotificationStreamingPolicy=");
        pw.println(mNearbyNotificationStreamingPolicy);

        pw.print("mNearbyAppStreamingPolicy=");
        pw.println(mNearbyAppStreamingPolicy);

        if (!TextUtils.isEmpty(mOrganizationId)) {
            pw.print("mOrganizationId=");
            pw.println(mOrganizationId);
+36 −0
Original line number Diff line number Diff line
@@ -7509,6 +7509,42 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
    }
    @Override
    public void setNearbyAppStreamingPolicy(int policy) {
        if (!mHasFeature) {
            return;
        }
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(isDeviceOwner(caller) || isProfileOwner(caller));
        synchronized (getLockObject()) {
            final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller);
            if (admin.mNearbyAppStreamingPolicy != policy) {
                admin.mNearbyAppStreamingPolicy = policy;
                saveSettingsLocked(caller.getUserId());
            }
        }
    }
    @Override
    public int getNearbyAppStreamingPolicy() {
        if (!mHasFeature) {
            return NEARBY_STREAMING_DISABLED;
        }
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(
                isDeviceOwner(caller)
                    || isProfileOwner(caller)
                    || hasCallingOrSelfPermission(permission.READ_NEARBY_STREAMING_POLICY));
        synchronized (getLockObject()) {
            final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller);
            return admin.mNearbyAppStreamingPolicy;
        }
    }
    /**
     * Set whether auto time is required by the specified admin (must be device or profile owner).
     */