1/* 2 * Copyright (C) 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import {Component, EventEmitter, Input, Output} from '@angular/core'; 18import {proxySetupStyles} from 'app/styles/proxy_setup.styles'; 19import {ConnectionState} from 'trace_collection/connection_state'; 20 21@Component({ 22 selector: 'wdp-setup', 23 template: ` 24 <ng-container [ngSwitch]="state"> 25 <ng-container *ngSwitchCase="${ConnectionState.CONNECTING}"> 26 <p class="connecting-message mat-body-1"> 27 Connecting... 28 </p> 29 </ng-container> 30 <ng-container *ngSwitchCase="${ConnectionState.NOT_FOUND}"> 31 <div class="further-adb-info-text"> 32 <p class="mat-body-1"> 33 Failed to connect. Web Device Proxy doesn't seem to be running. 34 </p> 35 <p class="mat-body-1"> 36 Please check you have Web Device Proxy installed. 37 </p> 38 </div> 39 <div class="further-adb-info-actions"> 40 <button 41 color="primary" 42 mat-stroked-button 43 class="install" 44 (click)="onInstallButtonClick()">Install Web Device Proxy</button> 45 <button 46 color="primary" 47 mat-stroked-button 48 class="retry" 49 (click)="onRetryButtonClick()">Retry</button> 50 </div> 51 </ng-container> 52 53 <ng-container *ngSwitchCase="${ConnectionState.UNAUTH}"> 54 <div class="further-adb-info-text"> 55 <p class="icon-information mat-body-1"> 56 <mat-icon class="adb-icon">lock</mat-icon> 57 <span class="adb-info">Web Device Proxy not yet authorized. Enable popups and try again.</span> 58 </p> 59 </div> 60 61 <div class="further-adb-info-actions"> 62 <button 63 color="primary" 64 mat-stroked-button 65 class="retry" 66 (click)="onRetryButtonClick()">Retry</button> 67 </div> 68 </ng-container> 69 70 <ng-container *ngSwitchDefault></ng-container> 71 </ng-container> 72 `, 73 styles: [proxySetupStyles], 74}) 75export class WdpSetupComponent { 76 @Input() state: ConnectionState | undefined; 77 @Output() readonly retryConnection = new EventEmitter(); 78 79 onInstallButtonClick() { 80 window.open( 81 'https://tools.google.com/dlpage/android_web_device_proxy', 82 '_blank', 83 ); 84 } 85 86 onRetryButtonClick() { 87 this.retryConnection.emit(); 88 } 89} 90