Skip to content

Commit

Permalink
Related to #32: Wait for devices to boot (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
zner0L authored Mar 29, 2023
1 parent 3a48fe9 commit 97e9f9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ An ID of a known permission on Android.

#### Defined in

[android.ts:714](https://github.com/tweaselORG/platform-apis/blob/main/src/android.ts#L714)
[android.ts:730](https://github.com/tweaselORG/platform-apis/blob/main/src/android.ts#L730)

___

Expand Down Expand Up @@ -274,7 +274,7 @@ The IDs of known permissions on Android.

#### Defined in

[android.ts:583](https://github.com/tweaselORG/platform-apis/blob/main/src/android.ts#L583)
[android.ts:599](https://github.com/tweaselORG/platform-apis/blob/main/src/android.ts#L599)

___

Expand Down
24 changes: 20 additions & 4 deletions src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,26 @@ export const androidApi = <RunTarget extends SupportedRunTarget<'android'>>(
objectionProcesses: [],

awaitAdb: async () => {
const adbIsStarted = await retryCondition(
async () => (await execa('adb', ['get-state'], { reject: false })).exitCode === 0,
100
);
const adbIsStarted = await retryCondition(async () => {
const { stdout: devBootcomplete } = await execa(
'adb',
['wait-for-device', 'shell', 'getprop', 'dev.bootcomplete'],
{ reject: false }
);
const { stdout: sysBootCompleted } = await execa(
'adb',
['wait-for-device', 'shell', 'getprop', 'sys.boot_completed'],
{ reject: false }
);
const { stdout: bootanim } = await execa(
'adb',
['wait-for-device', 'shell', 'getprop', 'init.svc.bootanim'],
{
reject: false,
}
);
return devBootcomplete.includes('1') && sysBootCompleted.includes('1') && bootanim.includes('stopped');
}, 100);
if (!adbIsStarted) throw new Error('Failed to connect via adb.');
},
async ensureFrida() {
Expand Down

0 comments on commit 97e9f9f

Please sign in to comment.