• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2022 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import {assertExists} from '../../../base/logging';
16import {AdbConnectionOverWebusb} from '../adb_connection_over_webusb';
17import {AdbKeyManager} from '../auth/adb_key_manager';
18import {
19  OnTargetChangeCallback,
20  TargetInfo,
21} from '../recording_interfaces_v2';
22import {AndroidTarget} from './android_target';
23
24export class AndroidWebusbTarget extends AndroidTarget {
25  constructor(
26      private device: USBDevice, keyManager: AdbKeyManager,
27      onTargetChange: OnTargetChangeCallback) {
28    super(new AdbConnectionOverWebusb(device, keyManager), onTargetChange);
29  }
30
31  getInfo(): TargetInfo {
32    const name = assertExists(this.device.productName) + ' ' +
33        assertExists(this.device.serialNumber) + ' WebUsb';
34    return {
35      targetType: 'ANDROID',
36      // 'androidApiLevel' will be populated after ADB authorization.
37      androidApiLevel: this.androidApiLevel,
38      dataSources: this.dataSources || [],
39      name,
40    };
41  }
42}
43