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

Commit 071f28de authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert the mandatory backups feature."

parents d1cf264e 3b6e0877
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -15605,7 +15605,6 @@ HSPLandroid/app/admin/IDevicePolicyManager;->getLockTaskFeatures(Landroid/conten
HSPLandroid/app/admin/IDevicePolicyManager;->getLockTaskPackages(Landroid/content/ComponentName;)[Ljava/lang/String;
HSPLandroid/app/admin/IDevicePolicyManager;->getLongSupportMessage(Landroid/content/ComponentName;)Ljava/lang/CharSequence;
HSPLandroid/app/admin/IDevicePolicyManager;->getLongSupportMessageForUser(Landroid/content/ComponentName;I)Ljava/lang/CharSequence;
HSPLandroid/app/admin/IDevicePolicyManager;->getMandatoryBackupTransport()Landroid/content/ComponentName;
HSPLandroid/app/admin/IDevicePolicyManager;->getMaximumFailedPasswordsForWipe(Landroid/content/ComponentName;IZ)I
HSPLandroid/app/admin/IDevicePolicyManager;->getMaximumTimeToLock(Landroid/content/ComponentName;IZ)J
HSPLandroid/app/admin/IDevicePolicyManager;->getMeteredDataDisabledPackages(Landroid/content/ComponentName;)Ljava/util/List;
@@ -15747,7 +15746,6 @@ HSPLandroid/app/admin/IDevicePolicyManager;->setLockTaskFeatures(Landroid/conten
HSPLandroid/app/admin/IDevicePolicyManager;->setLockTaskPackages(Landroid/content/ComponentName;[Ljava/lang/String;)V
HSPLandroid/app/admin/IDevicePolicyManager;->setLogoutEnabled(Landroid/content/ComponentName;Z)V
HSPLandroid/app/admin/IDevicePolicyManager;->setLongSupportMessage(Landroid/content/ComponentName;Ljava/lang/CharSequence;)V
HSPLandroid/app/admin/IDevicePolicyManager;->setMandatoryBackupTransport(Landroid/content/ComponentName;Landroid/content/ComponentName;)Z
HSPLandroid/app/admin/IDevicePolicyManager;->setMasterVolumeMuted(Landroid/content/ComponentName;Z)V
HSPLandroid/app/admin/IDevicePolicyManager;->setMaximumFailedPasswordsForWipe(Landroid/content/ComponentName;IZ)V
HSPLandroid/app/admin/IDevicePolicyManager;->setMaximumTimeToLock(Landroid/content/ComponentName;JZ)V
+2 −60
Original line number Diff line number Diff line
@@ -1182,14 +1182,6 @@ public class DevicePolicyManager {
     */
    public static final String POLICY_DISABLE_SCREEN_CAPTURE = "policy_disable_screen_capture";

    /**
     * Constant to indicate the feature of mandatory backups. Used as argument to
     * {@link #createAdminSupportIntent(String)}.
     * @see #setMandatoryBackupTransport(ComponentName, ComponentName)
     * @hide
     */
    public static final String POLICY_MANDATORY_BACKUPS = "policy_mandatory_backups";

    /**
     * Constant to indicate the feature of suspending app. Use it as the value of
     * {@link #EXTRA_RESTRICTION}.
@@ -1200,8 +1192,7 @@ public class DevicePolicyManager {
    /**
     * A String indicating a specific restricted feature. Can be a user restriction from the
     * {@link UserManager}, e.g. {@link UserManager#DISALLOW_ADJUST_VOLUME}, or one of the values
     * {@link #POLICY_DISABLE_CAMERA}, {@link #POLICY_DISABLE_SCREEN_CAPTURE} or
     * {@link #POLICY_MANDATORY_BACKUPS}.
     * {@link #POLICY_DISABLE_CAMERA} or {@link #POLICY_DISABLE_SCREEN_CAPTURE}.
     * @see #createAdminSupportIntent(String)
     * @hide
     */
@@ -6919,7 +6910,7 @@ public class DevicePolicyManager {
     * @param restriction Indicates for which feature the dialog should be displayed. Can be a
     *            user restriction from {@link UserManager}, e.g.
     *            {@link UserManager#DISALLOW_ADJUST_VOLUME}, or one of the constants
     *            {@link #POLICY_DISABLE_CAMERA}, {@link #POLICY_DISABLE_SCREEN_CAPTURE}.
     *            {@link #POLICY_DISABLE_CAMERA} or {@link #POLICY_DISABLE_SCREEN_CAPTURE}.
     * @return Intent An intent to be used to start the dialog-activity if the restriction is
     *            set by an admin, or null if the restriction does not exist or no admin set it.
     */
@@ -8916,55 +8907,6 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Makes backups mandatory and enforces the usage of the specified backup transport.
     *
     * <p>When a {@code null} backup transport is specified, backups are made optional again.
     * <p>Only device owner can call this method.
     * <p>If backups were disabled and a non-null backup transport {@link ComponentName} is
     * specified, backups will be enabled.
     * <p> If the backup service is disabled after the mandatory backup transport has been set, the
     * mandatory backup transport is cleared.
     *
     * <p>NOTE: The method shouldn't be called on the main thread.
     *
     * @param admin admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param backupTransportComponent The backup transport layer to be used for mandatory backups.
     * @return {@code true} if the backup transport was successfully set; {@code false} otherwise.
     * @throws SecurityException if {@code admin} is not a device owner.
     * @hide
     */
    @WorkerThread
    public boolean setMandatoryBackupTransport(
            @NonNull ComponentName admin,
            @Nullable ComponentName backupTransportComponent) {
        throwIfParentInstance("setMandatoryBackupTransport");
        try {
            return mService.setMandatoryBackupTransport(admin, backupTransportComponent);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the backup transport which has to be used for backups if backups are mandatory or
     * {@code null} if backups are not mandatory.
     *
     * @return a {@link ComponentName} of the backup transport layer to be used if backups are
     *         mandatory or {@code null} if backups are not mandatory.
     * @hide
     */
    @UnsupportedAppUsage
    public ComponentName getMandatoryBackupTransport() {
        throwIfParentInstance("getMandatoryBackupTransport");
        try {
            return mService.getMandatoryBackupTransport();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }


    /**
     * Called by a device owner to control the network logging feature.
     *
+0 −2
Original line number Diff line number Diff line
@@ -362,8 +362,6 @@ interface IDevicePolicyManager {

    void setBackupServiceEnabled(in ComponentName admin, boolean enabled);
    boolean isBackupServiceEnabled(in ComponentName admin);
    boolean setMandatoryBackupTransport(in ComponentName admin, in ComponentName backupTransportComponent);
    ComponentName getMandatoryBackupTransport();

    void setNetworkLoggingEnabled(in ComponentName admin, boolean enabled);
    boolean isNetworkLoggingEnabled(in ComponentName admin);
+1 −2
Original line number Diff line number Diff line
@@ -299,8 +299,7 @@ interface IBackupManager {
     *
     * @param transport ComponentName of the service hosting the transport. This is different from
     *                  the transport's name that is returned by {@link BackupTransport#name()}.
     * @param listener A listener object to get a callback on the transport being selected. It may
     *                 be {@code null}.
     * @param listener A listener object to get a callback on the transport being selected.
     */
    void selectBackupTransportAsync(in ComponentName transport, ISelectBackupTransportCallback listener);

+6 −64
Original line number Diff line number Diff line
@@ -698,8 +698,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
    @GuardedBy("mQueueLock")
    private ArrayList<FullBackupEntry> mFullBackupQueue;

    private BackupPolicyEnforcer mBackupPolicyEnforcer;

    // Utility: build a new random integer token. The low bits are the ordinal of the
    // operation for near-time uniqueness, and the upper bits are random for app-
    // side unpredictability.
@@ -899,8 +897,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {

        // Power management
        mWakelock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*backup*");

        mBackupPolicyEnforcer = new BackupPolicyEnforcer(context);
    }

    private void initPackageTracking() {
@@ -2827,10 +2823,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
    public void setBackupEnabled(boolean enable) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
                "setBackupEnabled");
        if (!enable && mBackupPolicyEnforcer.getMandatoryBackupTransport() != null) {
            Slog.w(TAG, "Cannot disable backups when the mandatory backups policy is active.");
            return;
        }

        Slog.i(TAG, "Backup enabled => " + enable);

@@ -3085,12 +3077,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.BACKUP, "selectBackupTransport");

        if (!isAllowedByMandatoryBackupTransportPolicy(transportName)) {
            // Don't change the transport if it is not allowed.
            Slog.w(TAG, "Failed to select transport - disallowed by device owner policy.");
            return mTransportManager.getCurrentTransportName();
        }

        final long oldId = Binder.clearCallingIdentity();
        try {
            String previousTransportName = mTransportManager.selectTransport(transportName);
@@ -3105,20 +3091,10 @@ public class BackupManagerService implements BackupManagerServiceInterface {

    @Override
    public void selectBackupTransportAsync(
            ComponentName transportComponent, @Nullable ISelectBackupTransportCallback listener) {
            ComponentName transportComponent, ISelectBackupTransportCallback listener) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.BACKUP, "selectBackupTransportAsync");
        if (!isAllowedByMandatoryBackupTransportPolicy(transportComponent)) {
            try {
                if (listener != null) {
                    Slog.w(TAG, "Failed to select transport - disallowed by device owner policy.");
                    listener.onFailure(BackupManager.ERROR_BACKUP_NOT_ALLOWED);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "ISelectBackupTransportCallback listener not available");
            }
            return;
        }

        final long oldId = Binder.clearCallingIdentity();
        try {
            String transportString = transportComponent.flattenToShortString();
@@ -3140,13 +3116,11 @@ public class BackupManagerService implements BackupManagerServiceInterface {
                        }

                        try {
                            if (listener != null) {
                            if (transportName != null) {
                                listener.onSuccess(transportName);
                            } else {
                                listener.onFailure(result);
                            }
                            }
                        } catch (RemoteException e) {
                            Slog.e(TAG, "ISelectBackupTransportCallback listener not available");
                        }
@@ -3156,38 +3130,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
        }
    }

    /**
     * Returns if the specified transport can be set as the current transport without violating the
     * mandatory backup transport policy.
     */
    private boolean isAllowedByMandatoryBackupTransportPolicy(String transportName) {
        ComponentName mandatoryBackupTransport = mBackupPolicyEnforcer.getMandatoryBackupTransport();
        if (mandatoryBackupTransport == null) {
            return true;
        }
        final String mandatoryBackupTransportName;
        try {
            mandatoryBackupTransportName =
                    mTransportManager.getTransportName(mandatoryBackupTransport);
        } catch (TransportNotRegisteredException e) {
            Slog.e(TAG, "mandatory backup transport not registered!");
            return false;
        }
        return TextUtils.equals(mandatoryBackupTransportName, transportName);
    }

    /**
     * Returns if the specified transport can be set as the current transport without violating the
     * mandatory backup transport policy.
     */
    private boolean isAllowedByMandatoryBackupTransportPolicy(ComponentName transport) {
        ComponentName mandatoryBackupTransport = mBackupPolicyEnforcer.getMandatoryBackupTransport();
        if (mandatoryBackupTransport == null) {
            return true;
        }
        return mandatoryBackupTransport.equals(transport);
    }

    private void updateStateForTransport(String newTransportName) {
        // Publish the name change
        Settings.Secure.putString(mContext.getContentResolver(),
Loading