1- import { exec } from 'teen_process' ;
2- import { log } from '../logger.js' ;
3- import { fs , zip , tempDir , util } from '@appium/support' ;
41import path from 'node:path' ;
2+
3+ import { fs , zip , tempDir , util } from '@appium/support' ;
4+ import { exec } from 'teen_process' ;
5+
56import type { ADB } from '../adb.js' ;
6- import type { APKInfo , PlatformInfo , StringRecord } from './types .js' ;
7+ import { log } from '../logger .js' ;
78import { APKS_EXTENSION , readPackageManifest , unzipFile } from '../utils/index.js' ;
9+ import type { APKInfo , PlatformInfo , StringRecord } from './types.js' ;
810
911/**
1012 * Extract package and main activity name from application manifest.
@@ -14,10 +16,7 @@ import {APKS_EXTENSION, readPackageManifest, unzipFile} from '../utils/index.js'
1416 * @throws {error } If there was an error while getting the data from the given
1517 * application package.
1618 */
17- export async function packageAndLaunchActivityFromManifest (
18- this : ADB ,
19- appPath : string ,
20- ) : Promise < APKInfo > {
19+ export async function packageAndLaunchActivityFromManifest ( this : ADB , appPath : string ) : Promise < APKInfo > {
2120 if ( appPath . endsWith ( APKS_EXTENSION ) ) {
2221 appPath = await this . extractBaseApk ( appPath ) ;
2322 }
@@ -48,10 +47,7 @@ export async function targetSdkVersionFromManifest(this: ADB, appPath: string):
4847
4948 const { targetSdkVersion} = await readPackageManifest . bind ( this ) ( appPath ) ;
5049 if ( ! targetSdkVersion ) {
51- throw new Error (
52- `Cannot extract targetSdkVersion of '${ originalAppPath } '. Does ` +
53- `the package manifest define it?` ,
54- ) ;
50+ throw new Error ( `Cannot extract targetSdkVersion of '${ originalAppPath } '. Does the package manifest define it?` ) ;
5551 }
5652 return targetSdkVersion ;
5753}
@@ -71,9 +67,7 @@ export async function targetSdkVersionUsingPKG(
7167) : Promise < number > {
7268 const stdout = cmdOutput || ( await this . shell ( [ 'dumpsys' , 'package' , pkg ] ) ) ;
7369 const targetSdkVersionMatch = new RegExp ( / t a r g e t S d k = ( [ ^ \s \s ] + ) / g) . exec ( stdout ) ;
74- return targetSdkVersionMatch && targetSdkVersionMatch . length >= 2
75- ? parseInt ( targetSdkVersionMatch [ 1 ] , 10 )
76- : 0 ;
70+ return targetSdkVersionMatch && targetSdkVersionMatch . length >= 2 ? parseInt ( targetSdkVersionMatch [ 1 ] , 10 ) : 0 ;
7771}
7872
7973/**
@@ -93,9 +87,7 @@ export async function compileManifest(
9387) : Promise < void > {
9488 const { platform, platformPath} = await getAndroidPlatformAndPath ( this . sdkRoot as string ) ;
9589 if ( ! platform || ! platformPath ) {
96- throw new Error (
97- 'Cannot compile the manifest. The required platform does not exist (API level >= 17)' ,
98- ) ;
90+ throw new Error ( 'Cannot compile the manifest. The required platform does not exist (API level >= 17)' ) ;
9991 }
10092 const resultPath = `${ manifest } .apk` ;
10193 const androidJarPath = path . resolve ( platformPath , 'android.jar' ) ;
@@ -169,12 +161,7 @@ export async function compileManifest(
169161 * @param dstApk - Full path to the resulting package.
170162 * The file will be overridden if it already exists.
171163 */
172- export async function insertManifest (
173- this : ADB ,
174- manifest : string ,
175- srcApk : string ,
176- dstApk : string ,
177- ) : Promise < void > {
164+ export async function insertManifest ( this : ADB , manifest : string , srcApk : string , dstApk : string ) : Promise < void > {
178165 log . debug ( `Inserting manifest '${ manifest } ', src: '${ srcApk } ', dst: '${ dstApk } '` ) ;
179166 await zip . assertValidZip ( srcApk ) ;
180167 await unzipFile ( `${ manifest } .apk` ) ;
@@ -221,10 +208,7 @@ export async function insertManifest(
221208 * @param appPath - The full path to .apk(s) package.
222209 * @return True if the manifest requires Internet access permission.
223210 */
224- export async function hasInternetPermissionFromManifest (
225- this : ADB ,
226- appPath : string ,
227- ) : Promise < boolean > {
211+ export async function hasInternetPermissionFromManifest ( this : ADB , appPath : string ) : Promise < boolean > {
228212 log . debug ( `Checking if '${ appPath } ' requires internet access permission in the manifest` ) ;
229213 if ( appPath . endsWith ( APKS_EXTENSION ) ) {
230214 appPath = await this . extractBaseApk ( appPath ) ;
0 commit comments