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

Commit 389cc7ed authored by Raphael Kim's avatar Raphael Kim
Browse files

Refactor CDM transport test API to be more flexible so that either a raw or...

Refactor CDM transport test API to be more flexible so that either a raw or secure transport can be forced.

Bug: 375493007
Test: atest CompanionTests
Flag: TEST_ONLY
Change-Id: Ia14307fbe785a36f43d0bfa32e8f8cf1b63c9023
parent 0bb424e4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -951,7 +951,7 @@ package android.companion {
  }

  public final class CompanionDeviceManager {
    method @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public void enableSecureTransport(boolean);
    method @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public void overrideTransportType(int);
  }

  public abstract class CompanionDeviceService extends android.app.Service {
+0 −2
Original line number Diff line number Diff line
@@ -2027,8 +2027,6 @@ UnflaggedApi: android.companion.AssociationInfo.Builder#setTimeApproved(long):
    New API must be flagged with @FlaggedApi: method android.companion.AssociationInfo.Builder.setTimeApproved(long)
UnflaggedApi: android.companion.CompanionDeviceManager#MESSAGE_REQUEST_PING:
    New API must be flagged with @FlaggedApi: field android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PING
UnflaggedApi: android.companion.CompanionDeviceManager#enableSecureTransport(boolean):
    New API must be flagged with @FlaggedApi: method android.companion.CompanionDeviceManager.enableSecureTransport(boolean)
UnflaggedApi: android.content.AttributionSource#AttributionSource(int, int, String, String, android.os.IBinder, String[], android.content.AttributionSource):
    New API must be flagged with @FlaggedApi: constructor android.content.AttributionSource(int,int,String,String,android.os.IBinder,String[],android.content.AttributionSource)
UnflaggedApi: android.content.AttributionSource#AttributionSource(int, int, String, String, android.os.IBinder, String[], int, android.content.AttributionSource):
+8 −5
Original line number Diff line number Diff line
@@ -1862,22 +1862,25 @@ public final class CompanionDeviceManager {
    }

    /**
     * Enables or disables secure transport for testing. Defaults to being enabled.
     * Should not be used outside of testing.
     * Overrides the type of transport to be assigned.
     * Can be used to force a raw transport or a secure transport.
     * Defaults to letting CDM decide based on device state.
     * DO NOT USE outside of testing.
     *
     * @param enabled true to enable. false to disable.
     * @param override 0 for default, 1 for raw, 2 for secure.
     * @hide
     */
    @TestApi
    @SuppressLint("UnflaggedApi")
    @RequiresPermission(android.Manifest.permission.MANAGE_COMPANION_DEVICES)
    public void enableSecureTransport(boolean enabled) {
    public void overrideTransportType(int typeOverride) {
        if (mService == null) {
            Log.w(TAG, "CompanionDeviceManager service is not available.");
            return;
        }

        try {
            mService.enableSecureTransport(enabled);
            mService.overrideTransportType(typeOverride);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ interface ICompanionDeviceManager {
    PermissionSyncRequest getPermissionSyncRequest(int associationId);

    @EnforcePermission("MANAGE_COMPANION_DEVICES")
    void enableSecureTransport(boolean enabled);
    void overrideTransportType(int typeOverride);

    byte[] getBackupPayload(int userId);

+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class SystemDataTransportTest extends InstrumentationTestCase {
        mContext = getInstrumentation().getTargetContext();
        mCdm = mContext.getSystemService(CompanionDeviceManager.class);
        mAssociationId = createAssociation();
        mCdm.enableSecureTransport(false);
        mCdm.overrideTransportType(1); // Force raw transport
    }

    @Override
@@ -77,7 +77,7 @@ public class SystemDataTransportTest extends InstrumentationTestCase {
        super.tearDown();

        mCdm.disassociate(mAssociationId);
        mCdm.enableSecureTransport(true);
        mCdm.overrideTransportType(0); // Reset transport type
    }

    public void testPingHandRolled() {
Loading