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

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

Merge "Add getCurrentTransportComponent() API"

parents e39d3a8c 98b17a61
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ package android.app.backup {
    method public long getAvailableRestoreToken(java.lang.String);
    method public android.content.Intent getConfigurationIntent(java.lang.String);
    method public java.lang.String getCurrentTransport();
    method public android.content.ComponentName getCurrentTransportComponent();
    method public android.content.Intent getDataManagementIntent(java.lang.String);
    method public java.lang.String getDataManagementLabel(java.lang.String);
    method public java.lang.String getDestinationString(java.lang.String);
+21 −0
Original line number Diff line number Diff line
@@ -442,6 +442,27 @@ public class BackupManager {
        return null;
    }

    /**
     * Returns the {@link ComponentName} of the host service of the selected transport or {@code
     * null} if no transport selected or if the transport selected is not registered.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.BACKUP)
    @Nullable
    public ComponentName getCurrentTransportComponent() {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.getCurrentTransportComponent();
            } catch (RemoteException e) {
                Log.e(TAG, "getCurrentTransportComponent() couldn't connect");
            }
        }
        return null;
    }

    /**
     * Request a list of all available backup transports' names.
     *
+7 −5
Original line number Diff line number Diff line
@@ -244,8 +244,6 @@ interface IBackupManager {
     *     {@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
     */
    void updateTransportAttributes(in ComponentName transportComponent, in String name,
            in Intent configurationIntent, in String currentDestinationString,
@@ -257,6 +255,13 @@ interface IBackupManager {
     */
    String getCurrentTransport();

     /**
      * Returns the {@link ComponentName} of the host service of the selected transport or {@code
      * null} if no transport selected or if the transport selected is not registered.  Callers must
      * hold the android.permission.BACKUP permission to use this method.
      */
    ComponentName getCurrentTransportComponent();

    /**
     * Request a list of all available backup transports' names.  Callers must
     * hold the android.permission.BACKUP permission to use this method.
@@ -296,8 +301,6 @@ interface IBackupManager {
     *                  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}.
     *
     * @hide
     */
    void selectBackupTransportAsync(in ComponentName transport, ISelectBackupTransportCallback listener);

@@ -364,7 +367,6 @@ interface IBackupManager {
     * @param result In the case of a full backup measure operation, the estimated
     *        total file size that would result from the operation. Unused in all other
     *        cases.
     * {@hide}
     */
    void opComplete(int token, long result);

+19 −0
Original line number Diff line number Diff line
@@ -2901,6 +2901,25 @@ public class BackupManagerService implements BackupManagerServiceInterface {
        return currentTransport;
    }

    /**
     * Returns the {@link ComponentName} of the host service of the selected transport or {@code
     * null} if no transport selected or if the transport selected is not registered.
     */
    @Override
    @Nullable
    public ComponentName getCurrentTransportComponent() {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.BACKUP, "getCurrentTransportComponent");
        long oldId = Binder.clearCallingIdentity();
        try {
            return mTransportManager.getCurrentTransportComponent();
        } catch (TransportNotRegisteredException e) {
            return null;
        } finally {
            Binder.restoreCallingIdentity(oldId);
        }
    }

    // Report all known, available backup transports
    @Override
    public String[] listAllTransports() {
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.backup;

import android.annotation.Nullable;
import android.app.IBackupAgent;
import android.app.backup.IBackupManager;
import android.app.backup.IBackupManagerMonitor;
@@ -132,6 +133,10 @@ public interface BackupManagerServiceInterface {
  // Report the name of the currently active transport
  String getCurrentTransport();

  // Report the component name of the host service of the currently active transport
  @Nullable
  ComponentName getCurrentTransportComponent();

  // Report all known, available backup transports
  String[] listAllTransports();

Loading