WebUSB transferIn not a function

Currently I am trying to receive data using the transferIn for webusb api. However this function does not appear to work. Also noticed that my transferOut commands do not execute on my devices. Some info, I am trying to make my flutter web app run ADB commands using the WebUSB api for chromium browsers.

This is my sendADBCommand function:

async function sendADBCommand(command) {
    const device = window.adbDevice;
    const outEndpoint = window.adbOutEndpoint;
    const inEndpoint = window.adbInEndpoint;

    if (!device) {
        console.error('ADB device is not available.');
        return;
    }

    const encoder = new TextEncoder();
    const data = encoder.encode(command + 'n');

    try {
        const sentResult = await device.transferOut(outEndpoint, data);
        console.log('Sent command:', command, 'Result:', sentResult);

        try {
            const response = await device.transferIn(inEndpoint, 1024);
            const decoder = new TextDecoder();
            const responseData = decoder.decode(response.data);
            console.log(`Respone: `, responseData);
        } catch (error) {
            console.warn(`No response received: `, error);
        }

        return sentResult;
    } catch (error) {
        console.error('Error sending command:', error);
        console.error('Error name:', error.name);
        console.error('Error message:', error.message);
        console.error('Stack trace:', error.stack);
    }
}

This is my function to send a install/replace of an APK on the device:

async function updateApk(){
    const apkPath = "/var/www/portal/web/apk/app.apk";
    for (let device of connectedDevices) {
        console.log(`Attempting to update App on device: ${device.serialNumber}`);
        try {
            const result = await sendADBCommand(`adb -s ${device.serialNumber} install -r ${apkPath}`);
            if(result){
                console.log(`Successfully updated App on device: ${device.serialNumber}: ${result}`);
            } else {
                console.error(`Failed to send install command to device: ${device.serialNumber}`);
            }
        } catch (error) {
            console.error(`Error updating App on device ${device.serialNumber}:`, error);
        }
    }
}

And then my function to connect a device:

let connectedDevices = [];

async function requestADBDevice(filters = []) {
    let device;
    try {
        device = await navigator.usb.requestDevice({ filters });
        await device.open();

        if (device.configuration === null) {
            await device.selectConfiguration(1);
        }
        await device.claimInterface(0);

        const productName = device.productName || 'Unknown product';
        const vendorId = device.vendorId.toString(16).padStart(4, '0');
        const productId = device.productId.toString(16).padStart(4, '0');
        const interfaceNumber = device.configuration.interfaces[0]?.interfaceNumber || 'Unknown interface';

        const endpoints = device.configuration.interfaces[0].alternates[0].endpoints;
        let inEndpoint = null;
        let outEndpoint = null;

        for (const endpoint of endpoints){
            if(endpoint.direction === 'in'){
                inEndpoint = endpoint.endpointNumber;
            } else if (endpoint.direction === 'out'){
                outEndpoint = endpoint.endpointNumber;
            }
        }

        if(inEndpoint === null || outEndpoint === null){
            throw new Error('Could not find appriopriate IN and OUT endpoints');
        }

        device.inEndpoint = inEndpoint;
        device.outEndpoint = outEndpoint;

        window.adbDevice = device;
        window.adbInEndpoint = inEndpoint;
        window.adbOutEndpoint = outEndpoint;

        console.log(`Device connected: ${productName}`);
        console.log(`Vendor ID: 0x${vendorId}, Product ID: 0x${productId}`);
        console.log(`Interface number: ${interfaceNumber}`);
        console.log(`IN Endpoint: ${inEndpoint}, OUT Endpoint: ${outEndpoint}`);

        connectedDevices.push(device);

        return device;
    } catch (error) {
        if (device) {
            try {
                if (device.opened) {
                    await device.close();
                }
            } catch (closeError) {
                console.error('Error closing device after failure:', closeError);
            }
        }
        console.error('Error requesting ADB device:', error);
    }
}

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật