testSetAirplaneMode: use runAsShell to adopt shell permissions.
This is more correct for three reasons: 1. adoptShellPermission / dropShellPermission calls cannot be nested, because the first drop call drops all permissions, not just the most-recently adopted set. 2. adoptShellPermissionIdentity calls that do not specify any permissions are discouraged because they have the side effect of changing the UID and removing any permissions that the calling UID had. This can cause privileged tests to fail. 3. The comments in the test say that the permission being tested is NETWORK_AIRPLANE_MODE, but the shell doesn't even have NETWORK_AIRPLANE_MODE; the test currently passes only because it adopts all shell permissions, including NETWORK_SETTINGS. A treehugger run suggests this is the only test that has problem (1) above. Once this test is fixed, we can make runAsShell throw an exception when nested, making it easier to avoid this problem. Test: test-only change Change-Id: I0ce4514f01280148f7af859b6163ebdc7baa26d2
Loading
Please register or sign in to comment