diff --git a/desktop/flipper-server-core/src/devices/android/androidContainerUtility.tsx b/desktop/flipper-server-core/src/devices/android/androidContainerUtility.tsx index de658d0c5..8b2f3cc71 100644 --- a/desktop/flipper-server-core/src/devices/android/androidContainerUtility.tsx +++ b/desktop/flipper-server-core/src/devices/android/androidContainerUtility.tsx @@ -14,6 +14,7 @@ const allowedAppNameRegex = /^[\w.-]+$/; const appNotApplicationRegex = /not an application/; const appNotDebuggableRegex = /debuggable/; const operationNotPermittedRegex = /not permitted/; +const permissionDeniedRegex = /permission denied/; const logTag = 'androidContainerUtility'; export type AppName = string; @@ -66,6 +67,7 @@ function validateFileContent(content: string): void { enum RunAsErrorCode { NotAnApp = 1, NotDebuggable = 2, + PermissionDenied = 3, } class RunAsError extends Error { @@ -177,6 +179,12 @@ function _executeCommandWithRunner( `Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`, ); } + if (output.toLowerCase().match(permissionDeniedRegex)) { + throw new RunAsError( + RunAsErrorCode.PermissionDenied, + `No permission to run-as application. To use it with Flipper, either run adb as root or allow running as app`, + ); + } return output; }); }