class BackupManagerService implements BackupManagerServiceInterface {

    @Override
    public void selectBackupTransportAsync(
            ComponentName transportComponent, @Nullable 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();
            Slog.v(TAG, "selectBackupTransportAsync(transport = " + transportString + ")");
            mBackupHandler.post(
                    () -> {
                        String transportName = null;
                        int result =
                                mTransportManager.registerAndSelectTransport(transportComponent);
                        if (result == BackupManager.SUCCESS) {
                            try {
                                transportName =
                                        mTransportManager.getTransportName(transportComponent);
                                updateStateForTransport(transportName);
                            } catch (TransportNotRegisteredException e) {
                                Slog.e(TAG, "Transport got unregistered");
                                result = BackupManager.ERROR_TRANSPORT_UNAVAILABLE;
                            }
                        }

                        try {
                            if (listener != null) {
                                if (transportName != null) {
                                    listener.onSuccess(transportName);
                                } else {
                                    listener.onFailure(result);
                                }
                            }
                        } catch (RemoteException e) {
                            Slog.e(TAG, "ISelectBackupTransportCallback listener not available");
                        }
                    });
        } finally {
            Binder.restoreCallingIdentity(oldId);
        }
    }

    @VisibleForTesting  BackupManagerService(
            Context context,
            Trampoline parent,
            HandlerThread backupThread,
            File baseStateDir,
            File dataDir,
            TransportManager transportManager);

}