-
Notifications
You must be signed in to change notification settings - Fork 76
/
wireless-connection.component.ts
51 lines (45 loc) · 1.84 KB
/
wireless-connection.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Component, OnInit } from '@angular/core';
import { AdbClientService, ConnectionStatus } from '../adb-client.service';
import { AppService } from '../app.service';
import { StatusBarService } from '../status-bar.service';
@Component({
selector: 'app-wireless-connection',
templateUrl: './wireless-connection.component.html',
styleUrls: ['./wireless-connection.component.scss'],
})
export class WirelessConnectionComponent implements OnInit {
connectWifiIp: string;
constructor(public adbService: AdbClientService, appService: AppService, private statusService: StatusBarService) {
appService.webService.isWebviewOpen = false;
appService.resetTop();
if (adbService.deviceIp) {
this.connectWifiIp = adbService.deviceIp;
}
}
ngOnInit() {}
connectWifi() {
let status = 'Attempting wifi connection...';
this.statusService.showStatus(status, false, true);
this.adbService.deviceStatusMessage = status;
((this.adbService.isReady ? this.adbService.runAdbCommand('adb tcpip 5555', true) : Promise.resolve()) as any).then(() => {
setTimeout(() => {
this.adbService.runAdbCommand('adb connect ' + this.adbService.deviceIp + ':5555', true);
}, 3000);
});
}
reset() {
this.adbService.runAdbCommand('adb disconnect', true);
this.statusService.showStatus('Resetting ADB connection...', false, true);
}
isConnected() {
const isConnected = this.adbService.deviceStatus === ConnectionStatus.CONNECTED;
// if (isConnected && !this.isOpen) {
// this.isOpen = true;
// this.open('/sdcard/');
// }
return isConnected;
}
connectManualWifi() {
this.adbService.runAdbCommand('adb connect ' + this.connectWifiIp + ':5555', true);
}
}