/* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import {Component, EventEmitter, Input, Output} from '@angular/core'; import {proxySetupStyles} from 'app/styles/proxy_setup.styles'; import {Download} from 'common/download'; import {getRootUrl} from 'common/url_utils'; import {ConnectionState} from 'trace_collection/connection_state'; import {VERSION} from 'trace_collection/winscope_proxy/utils'; @Component({ selector: 'winscope-proxy-setup', template: `

Connecting...

Launch the Winscope ADB Connect proxy to capture traces directly from your browser.

Python 3.10+ and ADB are required. Run this command:

Or download below.

update Your local proxy version is incompatible with Winscope.

Please update the proxy to version {{ proxyVersion }}. Run this command:

Or download below.

lock Proxy authorization required.

Enter Winscope proxy token:

The proxy token is printed to console on proxy launch, copy and paste it above.

`, styles: [ ` /* TODO(b/300063426): remove after migration to angular 15, replace with subscriptSizing */ ::ng-deep .proxy-command-form .mat-form-field-wrapper { padding: 0; } .proxy-command-text { user-select: all; overflow: auto; } `, proxySetupStyles, ], }) export class WinscopeProxySetupComponent { @Input() state: ConnectionState | undefined; @Output() readonly retryConnection = new EventEmitter(); readonly downloadProxyUrl: string = getRootUrl() + 'winscope_proxy.py'; readonly proxyCommand: string = 'python3 $ANDROID_BUILD_TOP/development/tools/winscope/src/adb/winscope_proxy.py'; readonly proxyVersion = VERSION; proxyToken = ''; onRetryButtonClick() { if (this.state !== ConnectionState.UNAUTH || this.proxyToken.length > 0) { this.retryConnection.emit(this.proxyToken); } } onKeydownEnterProxyTokenInput(event: MouseEvent) { (event.target as HTMLInputElement).blur(); this.onRetryButtonClick(); } onDownloadProxyClick() { Download.fromUrl(this.downloadProxyUrl, 'winscope_proxy.py'); } }