fix(android): use domain socket suffix chrome can discover (#26724)

Fixes: https://github.com/microsoft/playwright/issues/26721
This commit is contained in:
Pavel Feldman 2023-08-25 19:30:09 -07:00 коммит произвёл GitHub
Родитель ee86b9bc94
Коммит eb9ef64e7d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -262,13 +262,15 @@ export class AndroidDevice extends SdkObject {
async launchBrowser(pkg: string = 'com.android.chrome', options: channels.AndroidDeviceLaunchBrowserParams): Promise<BrowserContext> {
debug('pw:android')('Force-stopping', pkg);
await this._backend.runCommand(`shell:am force-stop ${pkg}`);
const socketName = isUnderTest() ? 'webview_devtools_remote_playwright_test' : ('playwright-' + createGuid());
const socketName = isUnderTest() ? 'webview_devtools_remote_playwright_test' : ('playwright_' + createGuid() + '_devtools_remote');
const commandLine = this._defaultArgs(options, socketName).join(' ');
debug('pw:android')('Starting', pkg, commandLine);
// encode commandLine to base64 to avoid issues (bash encoding) with special characters
await this._backend.runCommand(`shell:echo "${Buffer.from(commandLine).toString('base64')}" | base64 -d > /data/local/tmp/chrome-command-line`);
await this._backend.runCommand(`shell:am start -a android.intent.action.VIEW -d about:blank ${pkg}`);
return await this._connectToBrowser(socketName, options);
const browserContext = await this._connectToBrowser(socketName, options);
await this._backend.runCommand(`shell:rm /data/local/tmp/chrome-command-line`);
return browserContext;
}
private _defaultArgs(options: channels.AndroidDeviceLaunchBrowserParams, socketName: string): string[] {

Просмотреть файл

@ -11,6 +11,7 @@ fi
bash $PWD/utils/avd_stop.sh
echo "Starting emulator"
# nohup ${ANDROID_HOME}/emulator/emulator -avd android33 -gpu swiftshader &
nohup ${ANDROID_HOME}/emulator/emulator -avd android33 -no-audio -no-window -no-boot-anim -no-snapshot &
${ANDROID_HOME}/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
${ANDROID_HOME}/platform-tools/adb devices