Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPermissions API for Android #477

Open
raphkr opened this issue Dec 28, 2017 · 6 comments
Open

setPermissions API for Android #477

raphkr opened this issue Dec 28, 2017 · 6 comments

Comments

@raphkr
Copy link

raphkr commented Dec 28, 2017

With the device object how do I set the overlay permissions to true for android.

@Crash--
Copy link
Contributor

Crash-- commented Jan 2, 2018

You just have to install it since install use -g option ( https://github.com/wix/detox/blob/419d356506f0c1751072b8c44bfc663bece4a856/detox/src/devices/android/ADB.js#L51)

from adb

 install [-lrtsdg] PACKAGE
 install-multiple [-lrtsdpg] PACKAGE...
     push package(s) to the device and install them
     -l: forward lock application
     -r: replace existing application
     -t: allow test packages
     -s: install application on sdcard
     -d: allow version code downgrade (debuggable packages only)
     -p: partial application install (install-multiple only)
     -g: grant all runtime permissions

@LeoNatan
Copy link
Contributor

I do see a use case where a setPermissions API would be beneficial for testing, just like iOS, where you may want to test your UI behaves correctly if permission has been granted or denied.

@LeoNatan LeoNatan changed the title Granting overlay permissions on Android setPermissions API for Android Jan 10, 2018
@simonracz
Copy link
Contributor

@raphkr Maybe you ran into this too?
A fix will be in the next release for emulators running on API lvl 23 or lower. (API lvl 24 and above worked well before.)

@yogeshthanvi
Copy link

Hi I have noticed in detox by default all permissions are set to be true in android. Is this the true behaviour of detox

@Himani33
Copy link

Himani33 commented Mar 9, 2022

Is any update on this issue? How can we setPermission to NO in Android device for example in launch() API we want to set {Camera: No}

@SarjuHansaliya
Copy link

For anyone looking for a workaround, currently I am using adb command to grant/revoke camera and other permissions.

Here is code I am using

export const grantAndroidCameraPermission = async (
  bundleIdentifier: string
) => {
  execSync(`adb shell pm grant ${bundleIdentifier} android.permission.CAMERA`);
};

And I run this as soon as launch the app

beforeEach(async () => {
  await launchApp();
  await grantAndroidCameraPermission("com.xyz.abc");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants