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

Commit 153edfc3 authored by Annie Meng's avatar Annie Meng Committed by Android (Google) Code Review
Browse files

Merge "API Review: Make dataManagementLabel a CharSequence"

parents 966e0623 4eb4efc4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -744,7 +744,8 @@ package android.app.backup {
    method @RequiresPermission(android.Manifest.permission.BACKUP) public String getCurrentTransport();
    method @Nullable @RequiresPermission(android.Manifest.permission.BACKUP) public android.content.ComponentName getCurrentTransportComponent();
    method @RequiresPermission(android.Manifest.permission.BACKUP) public android.content.Intent getDataManagementIntent(String);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public String getDataManagementLabel(String);
    method @Nullable @RequiresPermission(android.Manifest.permission.BACKUP) public CharSequence getDataManagementIntentLabel(@NonNull String);
    method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.BACKUP) public String getDataManagementLabel(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public String getDestinationString(String);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public boolean isAppEligibleForBackup(String);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public boolean isBackupEnabled();
@@ -758,7 +759,8 @@ package android.app.backup {
    method @RequiresPermission(android.Manifest.permission.BACKUP) public void setAncestralSerialNumber(long);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public void setAutoRestore(boolean);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public void setBackupEnabled(boolean);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public void updateTransportAttributes(android.content.ComponentName, String, @Nullable android.content.Intent, String, @Nullable android.content.Intent, @Nullable String);
    method @Deprecated @RequiresPermission(android.Manifest.permission.BACKUP) public void updateTransportAttributes(@NonNull android.content.ComponentName, @NonNull String, @Nullable android.content.Intent, @NonNull String, @Nullable android.content.Intent, @Nullable String);
    method @RequiresPermission(android.Manifest.permission.BACKUP) public void updateTransportAttributes(@NonNull android.content.ComponentName, @NonNull String, @Nullable android.content.Intent, @NonNull String, @Nullable android.content.Intent, @Nullable CharSequence);
    field public static final int ERROR_AGENT_FAILURE = -1003; // 0xfffffc15
    field public static final int ERROR_BACKUP_CANCELLED = -2003; // 0xfffff82d
    field public static final int ERROR_BACKUP_NOT_ALLOWED = -2001; // 0xfffff82f
@@ -863,7 +865,8 @@ package android.app.backup {
    method public android.content.Intent configurationIntent();
    method public String currentDestinationString();
    method public android.content.Intent dataManagementIntent();
    method public String dataManagementLabel();
    method @Nullable public CharSequence dataManagementIntentLabel();
    method @Deprecated @Nullable public String dataManagementLabel();
    method public int finishBackup();
    method public void finishRestore();
    method public android.app.backup.RestoreSet[] getAvailableRestoreSets();
+2 −1
Original line number Diff line number Diff line
@@ -420,7 +420,8 @@ package android.app.backup {
  public class BackupManager {
    method @RequiresPermission("android.permission.BACKUP") public android.content.Intent getConfigurationIntent(String);
    method @RequiresPermission("android.permission.BACKUP") public android.content.Intent getDataManagementIntent(String);
    method @RequiresPermission("android.permission.BACKUP") public String getDataManagementLabel(String);
    method @Nullable @RequiresPermission("android.permission.BACKUP") public CharSequence getDataManagementIntentLabel(@NonNull String);
    method @Deprecated @Nullable @RequiresPermission("android.permission.BACKUP") public String getDataManagementLabel(@NonNull String);
    method @RequiresPermission("android.permission.BACKUP") public String getDestinationString(String);
  }

+86 −21
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app.backup;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
@@ -502,32 +503,76 @@ public class BackupManager {
     * @param transportComponent The identity of the transport being described.
     * @param name A {@link String} with the new name for the transport. This is NOT for
     *     identification. MUST NOT be {@code null}.
     * @param configurationIntent An {@link Intent} that can be passed to
     *     {@link Context#startActivity} in order to launch the transport's configuration UI. It may
     *     be {@code null} if the transport does not offer any user-facing configuration UI.
     * @param configurationIntent An {@link Intent} that can be passed to {@link
     *     Context#startActivity} in order to launch the transport's configuration UI. It may be
     *     {@code null} if the transport does not offer any user-facing configuration UI.
     * @param currentDestinationString A {@link String} describing the destination to which the
     *     transport is currently sending data. MUST NOT be {@code null}.
     * @param dataManagementIntent An {@link Intent} that can be passed to
     *     {@link Context#startActivity} in order to launch the transport's data-management UI. It
     *     may be {@code null} if the transport does not offer any user-facing data
     *     management UI.
     * @param dataManagementIntent An {@link Intent} that can be passed to {@link
     *     Context#startActivity} in order to launch the transport's data-management UI. It may be
     *     {@code null} if the transport does not offer any user-facing data management UI.
     * @param dataManagementLabel A {@link String} to be used as the label for the transport's data
     *     management affordance. This MUST be {@code null} when dataManagementIntent is
     *     {@code null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
     *     management affordance. This MUST be {@code null} when dataManagementIntent is {@code
     *     null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
     * @throws SecurityException If the UID of the calling process differs from the package UID of
     *     {@code transportComponent} or if the caller does NOT have BACKUP permission.
     *
     * @deprecated Since Android Q, please use the variant {@link
     *     #updateTransportAttributes(ComponentName, String, Intent, String, Intent, CharSequence)}
     *     instead.
     * @hide
     */
    @Deprecated
    @SystemApi
    @RequiresPermission(android.Manifest.permission.BACKUP)
    public void updateTransportAttributes(
            ComponentName transportComponent,
            String name,
            @NonNull ComponentName transportComponent,
            @NonNull String name,
            @Nullable Intent configurationIntent,
            String currentDestinationString,
            @NonNull String currentDestinationString,
            @Nullable Intent dataManagementIntent,
            @Nullable String dataManagementLabel) {
        updateTransportAttributes(
                transportComponent,
                name,
                configurationIntent,
                currentDestinationString,
                dataManagementIntent,
                (CharSequence) dataManagementLabel);
    }

    /**
     * Update the attributes of the transport identified by {@code transportComponent}. If the
     * specified transport has not been bound at least once (for registration), this call will be
     * ignored. Only the host process of the transport can change its description, otherwise a
     * {@link SecurityException} will be thrown.
     *
     * @param transportComponent The identity of the transport being described.
     * @param name A {@link String} with the new name for the transport. This is NOT for
     *     identification. MUST NOT be {@code null}.
     * @param configurationIntent An {@link Intent} that can be passed to {@link
     *     Context#startActivity} in order to launch the transport's configuration UI. It may be
     *     {@code null} if the transport does not offer any user-facing configuration UI.
     * @param currentDestinationString A {@link String} describing the destination to which the
     *     transport is currently sending data. MUST NOT be {@code null}.
     * @param dataManagementIntent An {@link Intent} that can be passed to {@link
     *     Context#startActivity} in order to launch the transport's data-management UI. It may be
     *     {@code null} if the transport does not offer any user-facing data management UI.
     * @param dataManagementLabel A {@link CharSequence} to be used as the label for the transport's
     *     data management affordance. This MUST be {@code null} when dataManagementIntent is {@code
     *     null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
     * @throws SecurityException If the UID of the calling process differs from the package UID of
     *     {@code transportComponent} or if the caller does NOT have BACKUP permission.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.BACKUP)
    public void updateTransportAttributes(
            @NonNull ComponentName transportComponent,
            @NonNull String name,
            @Nullable Intent configurationIntent,
            @NonNull String currentDestinationString,
            @Nullable Intent dataManagementIntent,
            @Nullable CharSequence dataManagementLabel) {
        checkServiceBinder();
        if (sService != null) {
            try {
@@ -796,7 +841,7 @@ public class BackupManager {
    /**
     * Returns an {@link Intent} for the specified transport's configuration UI.
     * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String,
     * Intent, String)}.
     * Intent, CharSequence)}.
     * @param transportName The name of the registered transport.
     * @hide
     */
@@ -818,7 +863,7 @@ public class BackupManager {
    /**
     * Returns a {@link String} describing where the specified transport is sending data.
     * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String,
     * Intent, String)}.
     * Intent, CharSequence)}.
     * @param transportName The name of the registered transport.
     * @hide
     */
@@ -840,7 +885,7 @@ public class BackupManager {
    /**
     * Returns an {@link Intent} for the specified transport's data management UI.
     * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String,
     * Intent, String)}.
     * Intent, CharSequence)}.
     * @param transportName The name of the registered transport.
     * @hide
     */
@@ -861,23 +906,43 @@ public class BackupManager {

    /**
     * Returns a {@link String} describing what the specified transport's data management intent is
     * used for.
     * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String,
     * Intent, String)}.
     * used for. This value is set by {@link #updateTransportAttributes(ComponentName, String,
     * Intent, String, Intent, CharSequence)}.
     *
     * @param transportName The name of the registered transport.
     * @deprecated Since Android Q, please use the variant {@link
     *     #getDataManagementIntentLabel(String)} instead.
     * @hide
     */
    @Deprecated
    @SystemApi
    @TestApi
    @RequiresPermission(android.Manifest.permission.BACKUP)
    public String getDataManagementLabel(String transportName) {
    @Nullable
    public String getDataManagementLabel(@NonNull String transportName) {
        CharSequence label = getDataManagementIntentLabel(transportName);
        return label == null ? null : label.toString();
    }

    /**
     * Returns a {@link CharSequence} describing what the specified transport's data management
     * intent is used for. This value is set by {@link #updateTransportAttributes(ComponentName,
     * String, Intent, String, Intent, CharSequence)}.
     *
     * @param transportName The name of the registered transport.
     * @hide
     */
    @SystemApi
    @TestApi
    @RequiresPermission(android.Manifest.permission.BACKUP)
    @Nullable
    public CharSequence getDataManagementIntentLabel(@NonNull String transportName) {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.getDataManagementLabelForUser(mContext.getUserId(), transportName);
            } catch (RemoteException e) {
                Log.e(TAG, "getDataManagementLabel() couldn't connect");
                Log.e(TAG, "getDataManagementIntentLabel() couldn't connect");
            }
        }
        return null;
+25 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app.backup;

import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -164,18 +165,35 @@ public class BackupTransport {
    }

    /**
     * On demand, supply a short string that can be shown to the user as the label
     * on an overflow menu item used to invoked the data management UI.
     * On demand, supply a short string that can be shown to the user as the label on an overflow
     * menu item used to invoke the data management UI.
     *
     * @return A string to be used as the label for the transport's data management
     *         affordance.  If the transport supplies a data management intent, this
     *         method must not return {@code null}.
     * @return A string to be used as the label for the transport's data management affordance. If
     *     the transport supplies a data management intent, this method must not return {@code
     *     null}.
     * @deprecated Since Android Q, please use the variant {@link #dataManagementIntentLabel()}
     *     instead.
     */
    @Deprecated
    @Nullable
    public String dataManagementLabel() {
        throw new UnsupportedOperationException(
                "Transport dataManagementLabel() not implemented");
    }

    /**
     * On demand, supply a short CharSequence that can be shown to the user as the label on an
     * overflow menu item used to invoke the data management UI.
     *
     * @return A CharSequence to be used as the label for the transport's data management
     *     affordance. If the transport supplies a data management intent, this method must not
     *     return {@code null}.
     */
    @Nullable
    public CharSequence dataManagementIntentLabel() {
        return dataManagementLabel();
    }

    /**
     * Ask the transport where, on local device storage, to keep backup state blobs.
     * This is per-transport so that mock transports used for testing can coexist with
@@ -651,8 +669,8 @@ public class BackupTransport {
        }

        @Override
        public String dataManagementLabel() {
            return BackupTransport.this.dataManagementLabel();
        public CharSequence dataManagementIntentLabel() {
            return BackupTransport.this.dataManagementIntentLabel();
        }

        @Override
+5 −11
Original line number Diff line number Diff line
@@ -353,16 +353,16 @@ interface IBackupManager {
     *     {@link Context#startActivity} in order to launch the transport's data-management UI. It
     *     may be {@code null} if the transport does not offer any user-facing data
     *     management UI.
     * @param dataManagementLabel A {@link String} to be used as the label for the transport's data
     *     management affordance. This MUST be {@code null} when dataManagementIntent is
     *     {@code null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
     * @param dataManagementLabel A {@link CharSequence} to be used as the label for the transport's
     *     data management affordance. This MUST be {@code null} when dataManagementIntent is {@code
     *     null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
     * @throws SecurityException If the UID of the calling process differs from the package UID of
     *     {@code transportComponent} or if the caller does NOT have BACKUP permission.
     */
    void updateTransportAttributesForUser(int userId, in ComponentName transportComponent,
            in String name,
            in Intent configurationIntent, in String currentDestinationString,
            in Intent dataManagementIntent, in String dataManagementLabel);
            in Intent dataManagementIntent, in CharSequence dataManagementLabel);

    /**
     * Identify the currently selected transport.  Callers must hold the
@@ -525,13 +525,7 @@ interface IBackupManager {
     *
     * @param userId User id for which the manage-data menu label should be reported.
     */
    String getDataManagementLabelForUser(int userId, String transport);

    /**
     * {@link android.app.backup.IBackupManager.getDataManagementLabelForUser} for the calling user
     * id.
     */
    String getDataManagementLabel(String transport);
    CharSequence getDataManagementLabelForUser(int userId, String transport);

    /**
     * Begin a restore session.  Either or both of packageName and transportID
Loading