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

Commit 1b9877ab authored by Annie Meng's avatar Annie Meng
Browse files

Move transport constant to BackupTransport API

Previously, the transport registration extra was a private
constant. Since GMSCore depends on this value being passed, moving
it to a public API prevents having to define it twice in
framework and GMSCore, and ensures compatibility between the two.

TODO: Update GMSCore with this constant once this drops
into GMSCore.

Bug: 72730566
Test: 1) m -j ROBOTEST_FILTER=TransportManagerTest RunFrameworksServicesRoboTests
2) m -j ROBOTEST_FILTER=TransportClientManagerTest RunFrameworksServicesRoboTests

Change-Id: I8f7a2ca0275047a5d3cc1a530cd86499d0170f2f
parent 6611f83f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -617,6 +617,7 @@ package android.app.backup {
    method public java.lang.String transportDirName();
    field public static final int AGENT_ERROR = -1003; // 0xfffffc15
    field public static final int AGENT_UNKNOWN = -1004; // 0xfffffc14
    field public static final java.lang.String EXTRA_TRANSPORT_REGISTRATION = "android.app.backup.extra.TRANSPORT_REGISTRATION";
    field public static final int FLAG_INCREMENTAL = 2; // 0x2
    field public static final int FLAG_NON_INCREMENTAL = 4; // 0x4
    field public static final int FLAG_USER_INITIATED = 1; // 0x1
+7 −0
Original line number Diff line number Diff line
@@ -83,6 +83,13 @@ public class BackupTransport {
     */
    public static final int FLAG_NON_INCREMENTAL = 1 << 2;

    /**
     * Used as a boolean extra in the binding intent of transports. We pass {@code true} to
     * notify transports that the current connection is used for registering the transport.
     */
    public static final String EXTRA_TRANSPORT_REGISTRATION =
            "android.app.backup.extra.TRANSPORT_REGISTRATION";

    IBackupTransport mBinderImpl = new TransportImpl();

    public IBinder getBinder() {
+2 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.backup;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
import android.app.backup.BackupManager;
import android.app.backup.BackupTransport;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -58,8 +59,6 @@ public class TransportManager {
    @VisibleForTesting
    public static final String SERVICE_ACTION_TRANSPORT_HOST = "android.backup.TRANSPORT_HOST";

    private static final String EXTRA_TRANSPORT_REGISTRATION = "transport_registration";

    private final Intent mTransportServiceIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST);
    private final Context mContext;
    private final PackageManager mPackageManager;
@@ -587,7 +586,7 @@ public class TransportManager {
        String callerLogString = "TransportManager.registerTransport()";

        Bundle extras = new Bundle();
        extras.putBoolean(EXTRA_TRANSPORT_REGISTRATION, true);
        extras.putBoolean(BackupTransport.EXTRA_TRANSPORT_REGISTRATION, true);

        TransportClient transportClient = mTransportClientManager.getTransportClient(
            transportComponent, extras, callerLogString);
+3 −7
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import static java.util.stream.Stream.concat;

import android.annotation.Nullable;
import android.app.backup.BackupManager;
import android.app.backup.BackupTransport;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -86,12 +87,6 @@ public class TransportManagerTest {
    private static final String PACKAGE_A = "some.package.a";
    private static final String PACKAGE_B = "some.package.b";

    /**
     * GMSCore depends on this constant so we define it here on top of the definition in {@link
     * TransportManager} to verify this extra is passed
     */
    private static final String EXTRA_TRANSPORT_REGISTRATION = "transport_registration";

    @Mock private OnTransportRegisteredListener mListener;
    @Mock private TransportClientManager mTransportClientManager;
    private TransportData mTransportA1;
@@ -210,7 +205,8 @@ public class TransportManagerTest {
        verify(mTransportClientManager)
                .getTransportClient(
                        eq(mTransportA1.getTransportComponent()),
                        argThat(bundle -> bundle.getBoolean(EXTRA_TRANSPORT_REGISTRATION)),
                        argThat(bundle ->
                                bundle.getBoolean(BackupTransport.EXTRA_TRANSPORT_REGISTRATION)),
                        anyString());
    }