Skip to content

Commit 7caa577

Browse files
committed
chore(platform-android): add debug logs for permission grants
1 parent 8380f1d commit 7caa577

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

  • packages/platform-android/src

packages/platform-android/src/adb.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type AndroidAppLaunchOptions } from '@react-native-harness/platforms';
2-
import { spawn, SubprocessError } from '@react-native-harness/tools';
2+
import { logger, spawn, SubprocessError } from '@react-native-harness/tools';
33
import { spawn as nodeSpawn } from 'node:child_process';
44
import type { ChildProcessByStdio } from 'node:child_process';
55
import { access, rm } from 'node:fs/promises';
@@ -63,6 +63,7 @@ const waitWithSignal = async (
6363

6464
const EMULATOR_STARTUP_OBSERVATION_TIMEOUT_MS = 5000;
6565
const EMULATOR_OUTPUT_BUFFER_LIMIT = 16 * 1024;
66+
const androidAdbLogger = logger.child('android-adb');
6667

6768
export const emulatorProcess = {
6869
startDetachedProcess: (
@@ -812,6 +813,11 @@ export const grantPermissions = async (
812813
adbId: string,
813814
bundleId: string,
814815
): Promise<void> => {
816+
androidAdbLogger.debug('grantPermissions:start %o', {
817+
adbId,
818+
bundleId,
819+
});
820+
815821
const isInstalled = await isAppInstalled(adbId, bundleId);
816822
if (!isInstalled) {
817823
throw new AdbAppNotInstalledError(bundleId, adbId);
@@ -825,7 +831,18 @@ export const grantPermissions = async (
825831
dangerousPermissions.has(permission),
826832
);
827833

834+
androidAdbLogger.debug('grantPermissions:resolved %o', {
835+
adbId,
836+
bundleId,
837+
requestedPermissions,
838+
permissions,
839+
});
840+
828841
if (permissions.length === 0) {
842+
androidAdbLogger.debug('grantPermissions:skip %o', {
843+
adbId,
844+
bundleId,
845+
});
829846
return;
830847
}
831848

@@ -840,10 +857,28 @@ export const grantPermissions = async (
840857
]);
841858

842859
try {
860+
androidAdbLogger.debug('grantPermissions:commands %o', {
861+
adbId,
862+
bundleId,
863+
grantCommands,
864+
});
865+
843866
await Promise.all(
844867
grantCommands.map((args) => spawn(getAdbBinaryPath(), args as string[])),
845868
);
869+
870+
androidAdbLogger.debug('grantPermissions:success %o', {
871+
adbId,
872+
bundleId,
873+
permissions,
874+
});
846875
} catch (error) {
876+
androidAdbLogger.debug('grantPermissions:error %o', {
877+
adbId,
878+
bundleId,
879+
permissions,
880+
error,
881+
});
847882
throw new AdbPermissionGrantError(bundleId, permissions, adbId);
848883
}
849884
};

0 commit comments

Comments
 (0)