Skip to content
Commit 30f6fd38 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

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
parent 751e3419
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment