Don't create adb client during module import

Summary:
Creation of the adb client requires the logger to already be initialized, so this should never be called at the global scope in a module, or you'll get weird import-order related bugs.

I noticed this while debugging, I don't think it's impacting anything right now, but have made it lazy just to avoid confusion in future.

Reviewed By: passy

Differential Revision: D16162266

fbshipit-source-id: 5363292d5cfcf2867a2654777cd8f4baed01d2c0
This commit is contained in:
John Knox
2019-07-09 07:59:52 -07:00
committed by Facebook Github Bot
parent c588b650ae
commit 385d9ded57

View File

@@ -19,8 +19,6 @@ const appNotDebuggableRegex = /debuggable/;
const operationNotPermittedRegex = /not permitted/;
const logTag = 'androidContainerUtility';
const adb = getAdbClient();
export opaque type AppName = string;
export opaque type Command = string;
export opaque type FilePath = string;
@@ -77,7 +75,7 @@ function executeCommandAsApp(
app: string,
command: string,
): Promise<string> {
return adb
return getAdbClient()
.then(client =>
client.shell(deviceId, `echo '${command}' | run-as '${app}'`),
)