const PRODUCT_NAME_KEY = 'ro.product.name' ; const PRODUCT_MODEL_KEY = 'ro.product.model' ; const PRODUCT_DEVICE_KEY = 'ro.product.device' ; const FEATURES_KEY = 'features' ; const DEFAULT_PRODUCT_VALUE = '<unkwnown>' ; export class AdbConnectionInformation { constructor ( readonly productName , readonly productDevice , readonly productModel , readonly features ) { } static fromDataView ( input ) { const textDecoder = new TextDecoder ( ) ; const decodedInput = textDecoder . decode ( input ) ; return AdbConnectionInformation . fromString ( decodedInput ) ; } param input static fromString ( input ) { const start = input . indexOf ( '::' ) ; const properties = input . substring ( start + 2 ) . split ( ';' ) ; let productName = DEFAULT_PRODUCT_VALUE ; let productDevice = DEFAULT_PRODUCT_VALUE ; let productModel = DEFAULT_PRODUCT_VALUE ; let features = [ ] ; for ( const property of properties ) { if ( property . startsWith ( PRODUCT_NAME_KEY ) ) { productName = property . substring ( PRODUCT_NAME_KEY . length + 1 ) ; continue ; } if ( property . startsWith ( PRODUCT_MODEL_KEY ) ) { productModel = property . substring ( PRODUCT_MODEL_KEY . length + 1 ) ; continue ; } if ( property . startsWith ( PRODUCT_DEVICE_KEY ) ) { productDevice = property . substring ( PRODUCT_DEVICE_KEY . length + 1 ) ; continue ; } if ( property . startsWith ( FEATURES_KEY ) ) { features = property . substring ( FEATURES_KEY . length + 1 ) . split ( ',' ) ; } } return new AdbConnectionInformation ( productName , productDevice , productModel , features ) ; } }