316 Commits

Author SHA1 Message Date
Makoto Onuki
f76b06a6b5 Test more DPM APIs.
Bug 24061108

Change-Id: Ia9da19f62c0f4edf53ca1f4c213f0368ec1983ba
2015-09-23 13:26:31 -07:00
Makoto Onuki
cc4bbeb76a Make DPM/DPMS unit-testable
- Now all services that DPMS uses are injectable.
- Introduce some wrappers to make static methods and final class mockable.
(e.g. for Binder.getCallingUid())

- In unit tests we replace those with Mockito mocks, except we use a partial
mock for PackageManager, because we use way too many methods of this and
most of them are okay to use directly.

- To install a partial mock to PackageManager, I needed to make
ApplicationPackageManager @hide public non-final.

- For a starter, added tests for DPM.setAmin().

Bug 24061108

Change-Id: I2afd51d8bc0038992d5f9be38c686260be775b75
2015-09-22 12:47:44 -07:00
Svetoslav
f3f02ac931 Add get_accounts app op
For each runtime permission we have an app op to toggle the
permission for legacy apps as they cannot handle permission
revocations. We were lacking an app op for get_accounts
which prevented the user from controlling access to accounts
regardelss that they change the state of the permission
toggle in the UI. Even worse the permission UI is written
with the assumption that every runtime permission has an
app op and as a result revoking the contacts group (if the
app requests the get_accounts permission) is reset back to
allowed in the UI.

bug:23854618

Change-Id: I12b83dfd22974d130e5b8e7a195421120813e2db
2015-09-09 07:31:17 -07:00
Lorenzo Colitti
51c61ee23a am fd183706: am 22262f31: am 0bc35668: am 017223ac: Merge changes from topic \'packet-keepalive-fixes\' into mnc-dr-dev
* commit 'fd18370675f8794807747a18276dd7385e25f06e':
  Require the new PACKET_KEEPALIVE_OFFLOAD permission.
  Add an error code for generic hardware error.
  Fix bugs and crashes in PacketKeepalive API.
  Add tests for the PacketKeepalive API.
  Add a PACKET_KEEPALIVE_OFFLOAD permission.
  Use a CountDownLatch instead of sleep() in NetworkFactory tests.
  Get rid of shortSleep() in ConnectivityServiceTest.
  Make ConnectivityServiceTest a bit more readable.
2015-09-09 01:04:38 +00:00
Makoto Onuki
58b684f1cd [split system] Tentatively support running DO on meat user
- setDeviceOwner() now takes a user ID.  (We can infer it from Binder, but
we still need it for the dpm command.)

- Change broadcast target UID for DO to the DO user

- Start the DO user on boot complete.
TODO Investigate whether this is actually the good timing.

TODO Prevent the DO user from being killed

Bug 23827706

Change-Id: I227dbd444f1f4e94d98c317489d151554fe79d91
2015-09-08 11:24:58 -07:00
Lorenzo Colitti
7914ce5dd4 Add tests for the PacketKeepalive API.
This currently fails in many different ways, but it tells us what
to fix.

Bug: 22606153
Bug: 23884210
Change-Id: If2e5ee0a8d7b26cad67d3d566ed5b1383e0db096
2015-09-09 00:16:56 +09:00
Lorenzo Colitti
ffa390b6f3 Use a CountDownLatch instead of sleep() in NetworkFactory tests.
This makes testNetworkFactoryRequests 2-3 times faster.

Bug: 22606153
Change-Id: I9657b6929e77f23ec811d0ab57b2ba974f0b6a69
2015-09-08 16:41:47 +09:00
Lorenzo Colitti
e58961aa5f Get rid of shortSleep() in ConnectivityServiceTest.
Instead, use IdleHandler to wait for things to become idle.

Bug: 22606153
Change-Id: Ic6ab93ad4d336b40962f9be1096629a44b63ee2f
2015-09-08 16:41:47 +09:00
Lorenzo Colitti
83fa2588f6 Make ConnectivityServiceTest a bit more readable.
1. Make TestNetworkCallback a bit smarter and rename it to
   SingleUseNetworkCallback. This allows us to get rid of all the
   calls to TestNetworkCallback#getConditionVariable.
2. Delete the commented out code that used to test a
   ConnectivityService model that has not been used since KK.
3. Remove unused imports, etc.

Bug: 22606153
Change-Id: I81a2d0b970d19e5f4515490d8c2f88d416445fa1
2015-09-07 20:41:51 +09:00
Makoto Onuki
3403b74429 Merge "Replace all occurrences of HashMap/HashSet with ArrayMap/ArraySet." 2015-09-04 17:48:09 +00:00
Ian Pedowitz
988f378587 am 7b0f661d: am 1635e818: am cb92577a: am 7d223aee: am 0a76afb9: Merge "Don\'t crash on (invalid) hardware address lengths > 127." into mnc-dev
* commit '7b0f661d405a1c53067ec104a6c6ddd7abbae1e6':
  Don't crash on (invalid) hardware address lengths > 127.
2015-09-03 18:52:14 +00:00
Ian Pedowitz
7d223aeef8 am 0a76afb9: Merge "Don\'t crash on (invalid) hardware address lengths > 127." into mnc-dev
* commit '0a76afb93e6f303921ab84e2f26747c3ebf19b62':
  Don't crash on (invalid) hardware address lengths > 127.
2015-09-03 17:34:50 +00:00
Xiaohui Chen
e2796c216e Merge "Cleanup USER_OWNER in a11y manager and tests" 2015-09-03 17:24:47 +00:00
Xiaohui Chen
1d52f9f16a Merge "Cleanup USER_OWNER in a11y service and tests" 2015-09-03 17:22:52 +00:00
Lorenzo Colitti
d64144a37c Don't crash on (invalid) hardware address lengths > 127.
These would cause us to crash with a NegativeArraySizeException
when trying to create the clientMac array. Instead, if the length
is > 16 (invalid, because the field is only 16 bytes long), fudge
it to 6 (Ethernet / wifi).  This is a bit less liberal than the
legacy client, which doesn't check the length at all.

Bug: 23725795
Change-Id: I83f47bfc400ffa8ce85dd9d1b8eb96be5afe51a5
2015-09-03 21:28:48 +09:00
Makoto Onuki
2714d448b1 Replace all occurrences of HashMap/HashSet with ArrayMap/ArraySet.
Also fix the command line for OwnersTest in javadoc.

Change-Id: I53c222aa13eee179c5abf7e6ba95c6cbe9a7f47f
2015-09-02 16:57:30 -07:00
Xiaohui Chen
9daa916a4d Cleanup USER_OWNER in a11y manager and tests
Bug: 19913735
Change-Id: Icc2b55e685e7f9c212326bf2317ea9a7afce0359
2015-09-02 13:15:33 -07:00
Xiaohui Chen
a826b8c24c Cleanup USER_OWNER in a11y service and tests
I need to make some changes to get the tests pass.  First a11y service
will now disable when no service is specified, I need to re-enable
a11y after services are enabled.  Second the old event used in tests
seems to be filtered out by the service, I need to pick a new event.
Also the timeout waiting for mock service to start is extended, I hit
the old timeout quite often with N9.

Bug: 19913735
Change-Id: I8fe1b7b5d93b6a52df0a8940a08761ea5fbf5084
2015-09-02 13:15:21 -07:00
Makoto Onuki
c9754cf0df Add unit tests for file persisting in Onwers.
Bug 23432442

Change-Id: If10ed5a46084695b2aca1286713b8baea8c2a418
2015-09-01 09:33:41 -07:00
Makoto Onuki
99aeac27eb Rename DeviceOwner to Owners
Bug 23432442

Change-Id: Ic59c880d45126fbcf50b1bd31e37b2b64e2f3a6d
2015-08-31 11:44:44 -07:00
Makoto Onuki
39e784dd46 Split device owner config files
DPMS.mDeviceOwner is now always non-null, so no null checks are needed.

Bug 22802261
Bug 23432442

Change-Id: Ia8e5f114ecfc0add44b0d1be7d043ef6e37019ef
2015-08-28 12:12:49 -07:00
Xiaohui Chen
72d9c02656 Update UserManagerTest
This makes it work in split system user mode.

Bug: 19913735
Change-Id: Ia1bd7043aba9fb34333e0edcc7375d287570c80a
2015-08-24 16:41:39 +00:00
Xiaohui Chen
f86676ad6d Change framework services tests' runner
Change the test runner to android.support.test.runner.AndroidJUnitRunner
This newer runner support Mockito tests. See b/8138651
This should at least fix RankingHelperTest here.

Change-Id: I68e4f33939478e1ea59a3860d5ded1cd22a47989
2015-08-19 21:32:36 +00:00
Lorenzo Colitti
e0938bed96 am a5bfd73a: am ab5e962e: am d7121f56: am 0257c82f: am 11e84bde: Merge "Don\'t mark NetworkRequests restricted when they don\'t have restricted caps" into mnc-dev
* commit 'a5bfd73ab683d3310ee3ce31d7ad3edb656aa858':
  Don't mark NetworkRequests restricted when they don't have restricted caps
2015-08-19 21:23:03 +00:00
Lorenzo Colitti
0257c82fa1 am 11e84bde: Merge "Don\'t mark NetworkRequests restricted when they don\'t have restricted caps" into mnc-dev
* commit '11e84bde9e98cb4b777a67208989d259883e9375':
  Don't mark NetworkRequests restricted when they don't have restricted caps
2015-08-19 20:54:48 +00:00
Xiaohui Chen
594f208d66 Clean up USER_OWNER reference in pm/Settings
Bug: 19913735
Change-Id: I538ed443b945e9cbb731520450bf5ef39882ae37
2015-08-19 17:34:15 +00:00
Paul Jensen
aae613d961 Don't mark NetworkRequests restricted when they don't have restricted caps
Requests without NET_CAPABILITIES_INTERNET and just the default network
capabilities should not be marked restricted.  Without this fix apps
can hit permissions exceptions if they inadvertently make requests
without NET_CAPABILITIES_INTERNET.

Bug:23164917
Change-Id: I4c7136821315bcb05dfc42ffbc505a5d4f6109e6
2015-08-19 11:08:38 -04:00
Paul Jensen
9180e2ea59 am abd27102: am 41779e46: am 95297732: am 86e7d135: resolved conflicts for merge of dbc4edcc to mnc-dr-dev
* commit 'abd27102f4e232be448bc6012e0bd833637ab3fa':
  Fix NOT_RESTRICTED network capability and enforce it.
2015-08-05 11:44:46 +00:00
Paul Jensen
86e7d135ac resolved conflicts for merge of dbc4edcc to mnc-dr-dev
Change-Id: I3a8624b2b375e0d174983d7690082e0e6932c4de
2015-08-05 07:07:24 -04:00
Paul Jensen
dbc4edccfc Merge "Fix NOT_RESTRICTED network capability and enforce it." into mnc-dev 2015-08-05 10:03:47 +00:00
Paul Jensen
487ffe7d3d Fix NOT_RESTRICTED network capability and enforce it.
With this change:
1. NOT_RESTRICTED should be removed from NetworkRequests that bring up
   special restricted carrier networks (e.g. IMS, FOTA).
2. NetworkRequests without NOT_RESTRICTED require CONNECTIVITY_INTERNAL
   permission to register
3. Binding sockets to networks without NOT_RESTRICTED requires
   CONNECTIVITY_INTERNAL permission

Bug:21637535
Change-Id: I5991d39facaa6b690e969fe15dcbeec52e918321
2015-08-04 07:24:24 -04:00
Lorenzo Colitti
00c8a9d60a am 5bbbf8ed: am 3b03916d: am c7a86e90: am c70348c1: am 496a9d26: Merge "Stop supporting legacy ConnectivityManager routing methods in M." into mnc-dev
* commit '5bbbf8edfd74389f9b38d3497d6d86afb543b8f2':
  Stop supporting legacy ConnectivityManager routing methods in M.
2015-07-31 05:49:08 +00:00
Lorenzo Colitti
c70348c194 am 496a9d26: Merge "Stop supporting legacy ConnectivityManager routing methods in M." into mnc-dev
* commit '496a9d269b0778ffa1965f3b11d768fe70fd7719':
  Stop supporting legacy ConnectivityManager routing methods in M.
2015-07-31 05:24:49 +00:00
Lorenzo Colitti
ffc42b0b7b Stop supporting legacy ConnectivityManager routing methods in M.
The methods startUsingNetworkFeature, stopUsingNetworkFeature and
requestRouteToHost were @removed in all the M preview builds, but
internal and external developers have noted that this imposes
additional burden for applications that need to work across
multiple platform versions because it causes compile-time errors.

We switched from @removed back to @deprecated to avoid these
problems. In order to effectively deprecate these methods, which
are error-prone and insecure, make them throw
UnsupportedOperationException if the app's target SDK is M or
above.

Because there are still one or two places in system code that use
these APIs, exempt Process.SYSTEM_UID and the OMA-DM client from
the check for now.

Bug: 22728205
Change-Id: I790bd32f3aa8067cbb625962a209bb9232f4b58c
2015-07-31 11:08:27 +09:00
Paul Jensen
722113aa5f am 917b275d: am 06287d1c: am 9a2314b0: am 682fd6ae: am a991c66c: Merge "Fix missing onLost NetworkCallbacks when network loses capability" into mnc-dev
* commit '917b275d6b54b08edb6326512d7e48a02163e730':
  Fix missing onLost NetworkCallbacks when network loses capability
2015-07-30 03:12:21 +00:00
Paul Jensen
682fd6aede am a991c66c: Merge "Fix missing onLost NetworkCallbacks when network loses capability" into mnc-dev
* commit 'a991c66c12da30d0240ac6c98736edee93d95977':
  Fix missing onLost NetworkCallbacks when network loses capability
2015-07-30 02:20:49 +00:00
Paul Jensen
a991c66c12 Merge "Fix missing onLost NetworkCallbacks when network loses capability" into mnc-dev 2015-07-30 02:10:50 +00:00
Lorenzo Colitti
98140ecef0 am 2ae3a05b: am b0014e9f: am 08ef66bb: am 62ca62b3: am e288b3af: Merge changes I5c994de5,I6cb0dd84 into mnc-dev
* commit '2ae3a05b424f7ef7c3a28507e2c19fde7f1e5963':
  Add a test for public bugs 2111 and 2136.
  Always check off-link connectivity in NetworkDiagnostics.
2015-07-28 18:48:06 +00:00
Paul Jensen
cf4c2c6372 Fix missing onLost NetworkCallbacks when network loses capability
If a network no longer satisfies a NetworkRequest, send the onLost
NetworkCallback.  If it was a real request (not listen) then update
the NetworkFactories.

To test this change I created a little infrastructure to fake
different Internet connectivity probe results during tests.  This
allowed me to rewrite some of ConnectivityServiceTest's logic for
validating networks.  This brought to light a couple issues that
I had to address to keep tests passing:
1. testUnlingeringDoesNotValidate was relying on a bad side-effect
   of my old method of ConnectivityServiceTest's logic for
   validating networks, so I rewrote the test.
2. ConnectivityService was not sending out NetworkCallbacks for
   WiFi when Cellular was validated.  I'm including a fix for this
   in this CL also.

Bug:22220234
Change-Id: I29314f38189817f8b2561a213c4f9e8522696663
2015-07-28 12:19:32 -04:00
Lorenzo Colitti
62ca62b32a am e288b3af: Merge changes I5c994de5,I6cb0dd84 into mnc-dev
* commit 'e288b3af14421731d8f477b97e8d77588f20498b':
  Add a test for public bugs 2111 and 2136.
  Always check off-link connectivity in NetworkDiagnostics.
2015-07-28 01:20:16 +00:00
Lorenzo Colitti
f28e62bdf6 Add a test for public bugs 2111 and 2136.
Bug: 22602137
Bug: 22104401
Change-Id: I5c994de53b5906416767a8a1abe38fe59afb7cc0
2015-07-27 17:22:21 +09:00
Lorenzo Colitti
cc5b9d6efc am 15cda089: am 6163290e: am e647d93d: am 8bf977d5: ConnectivityManager API for for packet keepalives.
* commit '15cda089b6209ba8d68beea81271b44612bbfb95':
  ConnectivityManager API for for packet keepalives.
2015-07-18 18:05:13 +00:00
Lorenzo Colitti
8bf977d562 ConnectivityManager API for for packet keepalives.
Bug: 21405946
Change-Id: Ie1f8f8bee684fe2bb1092a9f1bc9f5dc29b1defc
2015-07-18 17:00:13 +00:00
Fyodor Kupolov
b5143ecfee am 1fa2a088: am 1281575c: am 41fac5e8: am 189f3136: am 98724126: Merge "Added sendBroadcastMultiplePermissions method" into mnc-dev
* commit '1fa2a0888284ae00c905dce7a3003b995815467a':
  Added sendBroadcastMultiplePermissions method
2015-07-15 01:58:48 +00:00
Fyodor Kupolov
d4fd8c766d Added sendBroadcastMultiplePermissions method
Added Context.sendBroadcastMultiplePermissions(Intent intent, String[]
receiverPermissions) method, which allows an array of required permissions
to be enforced.

Bug: 21852542
Change-Id: I27c9130e8f004b428452501ebc8a36aabde1f343
2015-07-14 17:25:42 -07:00
Fyodor Kupolov
9ac5983c7b am 7aeb1a5c: am cf4617cf: am 1aeceef4: am fc4acfd9: am 4a817924: Merge "Revert "Allow array of required permissions in sendBroadcast"" into mnc-dev
* commit '7aeb1a5c19a1226f2b0ca7b498bdad941d206808':
  Revert "Allow array of required permissions in sendBroadcast"
2015-07-15 00:11:44 +00:00
Fyodor Kupolov
34ff2b04c9 am 64e8aa18: am 7f006b52: am 70174794: am ef77c116: am d69a82c1: Merge "Allow array of required permissions in sendBroadcast" into mnc-dev
* commit '64e8aa18f8c089989113ecd8775d41bffe74b41d':
  Allow array of required permissions in sendBroadcast
2015-07-14 23:10:56 +00:00
Fyodor Kupolov
e37520b49d Revert "Allow array of required permissions in sendBroadcast"
This reverts commit b4e7283c9afd9fb15ebd63f6ce9b75c9c1af658b.

Change-Id: Ie8390964bda5bdfa869cee8f46584043d8e7c664
2015-07-14 22:29:21 +00:00
Fyodor Kupolov
b4e7283c9a Allow array of required permissions in sendBroadcast
Added Context.sendBroadcast(Intent intent, String[] receiverPermissions)
method, which allows an array of required permissions to be enforced.

Bug: 21852542
Change-Id: I3b8ff258fa9f3249c344bb8093b820b24eef00c0
2015-07-14 12:50:22 -07:00
Paul Jensen
365504aca4 am c4417cf9: am f50ac2e7: am cfedbc43: am 7f9e3274: am bbce221e: Merge "Fallback to Cellular if WiFi fails to validate" into mnc-dev
* commit 'c4417cf98a98211072b36cb246d0e30aa650e2f2':
  Fallback to Cellular if WiFi fails to validate
2015-07-10 16:58:13 +00:00