import { DeviceDriver } from '../../drivers/types'; import { sleep, waitForSource } from './element.helper'; import { scrollToAndTap } from './device-settings.helper'; export async function navigateToFirmwarePage(driver: DeviceDriver): Promise { const tapped = await scrollToAndTap(driver, 'Firmware Update'); if (tapped) return true; return await scrollToAndTap(driver, 'Firmware & Battery'); } export async function checkFirmwareVersion(driver: DeviceDriver): Promise { const source = await driver.getSource(); if (driver.platform === 'android') { const versionMatch = source.match(/text="(V[\d.]+)"/); return versionMatch ? versionMatch[1] : 'unknown'; } const versionMatch = source.match(/name="(V[\d.]+)"/); return versionMatch ? versionMatch[1] : 'unknown'; } export async function isFirmwareUpToDate(driver: DeviceDriver): Promise { const source = await driver.getSource(); return source.includes('Up to date') || source.includes('Latest') || !source.includes('Update'); }