History log of /frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d2010e1bbe598d72920a1367cebab6332103cf42 03-Jul-2017 Tony Mak <tonymak@google.com> Mocked system properties should return default value by default

Change-Id: I328531abc6620c141f2625aaf05caa2ef6ba8b16

Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java

Fix: 63253153
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
75c0a891ae2f1170d64b06baeca49908b6183b70 18-May-2017 Pavel Grafov <pgrafov@google.com> Cleanup some more DPM tests to use runAsCaller.

Factored MockSystemServices out of DpmMockContext. It contains all system
mocks that should be shared by all contexts. So now we can have several
contexts in the test without having to adjust mocks behavior for each of
them separately.

+ minor cleanup: imports, lambdas, redundant generic arguments,
unnecessary try-finally

Bug: 38445735
Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Change-Id: Id18b574b021c16f86fda8ae31291dd5defec0004
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
2c68dadb200a4a7113b2d5162fc9137eed944ddf 17-Mar-2017 Robin Lee <rgl@google.com> Better call emulation for DevicePolicyManagerTest

Let's have several separate contexts instead of doing strange things
with package names in one monolithic context representing every single
user on the device at once, sometimes multiple times in the same call.

Syntax looks like:

runAsCaller(callerContext, dpms, (dpm) -> {
assertSomething(dpm.doSomething(caller, param));
});

When a caller calls into DevicePolicyManager here's what happens:

PRE

- a new DevicePolicyManager is created with the caller context
- service context callingIdentity is saved
- the callingUid, callingPid, and callingPermissions are added to the service context

TEST

- client-side test code interacts with DevicePolicyManager using the caller context
- server-side coder under test runs as DevicePolicyManagerService using the service context

POST

- service context callingIdentity is restored to what it was before the test.

This should be easier to reason about.

Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases
Change-Id: I148e3f298b0a958639ce261e9cf91f6eb49fae4d
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
aab7a4146ccd14f94ac87f4c52895f1bb5d37645 30-Dec-2016 Rubin Xu <rubinxu@google.com> Add escrow token API in DevicePolicyManager.

Take advantage of the new authentication flow in LockSettingsService
and allow PO or DO to provision escrow tokens on the device. The
escrow token grants them the ability to change device lockscreen
(if used by DO) or work profile challenge (if used by PO). The
new password reset mechanism is even usable before user unlocks,
and it preserves authentication-bound keys in keystore.

Test: runtest frameworks-services -c com.android.server.SyntheticPasswordTests
Test: runtest frameworks-services -c com.android.server.devicepolicy.DevicePolicyManagerTest
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testResetPasswordWithToken
Bug: 33126620
Change-Id: Iaa684c51946f726cbd909e9ac70ad3e9ca3de1ac
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
45d29078635372e6c6b230d3de4e9d94c0d324b1 18-Jan-2017 Nicolas Prevot <nprevot@google.com> Update DPM unit tests checking isProvisioningAllowed for comp.

Two of the tests were actually checking the same thing. Removed one.
Refactore another test to make it easier to read.

Test: adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest
-w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
BUG:32629873

Change-Id: Id4ca9bd8c113a858b016fb02d04bf4c76bbcb027
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
01576869a3f46923d1d893866677e3bf9a00fc2b 15-Dec-2016 Esteban Talavera <etalavera@google.com> Enforce DISALLOW_ADD_MANAGED_PROFILE

Only the device owner should be able to create a managed
profile if that restriction is set

Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Bug: 31952368

Change-Id: Ia5170e54594ccba1e5bcedffaec98c2af42264c0
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
2f26b79eea905f88c872804be01431020e4efb2e 28-Nov-2016 Tony Mak <tonymak@google.com> Unit test for getBindDeviceAdminTargetUsers

Was meant to write test for bindDeviceAdminServiceAsUser, but
it can't be done without having tests for
getBindDeviceAdminTargetUsers first as bindDeviceAdminService depends
on getBindDeviceAdminTargetUsers.

A bit shocked by we didn't have any managed profile tests in
DevicePolicyManagerTest. Added managed profile support in the CL.

Bug: 32764274

Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java

Change-Id: If412e4f44c3ae998f69e17411f2503a97f80149f
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
6ad5f92512462f774a2ff7e59abdf5edbfd215b3 19-Sep-2016 Makoto Onuki <omakoto@google.com> Fix DPM unit tests, also fix a log message.

Bug 31446501

Change-Id: I37debbe2f4e983fb8bad026f8dd9bd91b7448dce
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
889c0880661bda16e3759995e03766ddf0350732 17-Feb-2016 Makoto Onuki <omakoto@google.com> Support safe mode properly.

In safe mode, IPM.queryXxx() doesn't work. Use IPM.getReceiverInfo()
directly instead.

Bug 27108276

Change-Id: Ice8f882559b8f0596a19ddb3a16395a4dc538a25
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
184db600df42c2b27a2d34deecab57d591434b22 18-Feb-2016 Makoto Onuki <omakoto@google.com> Ensure DO/PO are also DA.

Bug 24503508

Change-Id: Ib957b84d5bee185501636c406d9aaf4985a79d8d
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
8375fcec625d482af894cfed7b608f10cacb0f5d 04-Feb-2016 Esteban Talavera <etalavera@google.com> Fix unit tests

http://ag/858485 added a new flag and the mockito didn't match
the call any more

Change-Id: I8f99b1b6063488aeced08513b11c79bf0162006e
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
4c052f237a108457fca3d3864c5654ebd4505111 25-Jan-2016 Bartosz Fabianowski <bartfab@google.com> Implement user affiliation

A user/profile is considered affiliated if it is managed by the same
entity as the device. This is determined by having the device owner and
profile owners specify a set of opaque affiliation ids each. If the sets
intersect, they must have come from the same source, which means that the
device owner and profile owner are controlled by the same entity.

BUG=25599229

Change-Id: I393fe0de70272307ed3c811aaba4b48a5109c562
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
e06b4d1d9f718b9fe02980fea794a36831a16db2 06-Jan-2016 Jeff Sharkey <jsharkey@android.com> Consistent naming for PackageManager methods.

When hidden PackageManager methods take a userId argument, they
should be named explicitly with the "AsUser" suffix. This fixes
several lagging examples so that we can pave the way to safely
start passing flags to new methods without scary overloading.

Also fix spacing issues in various logging statements.

Change-Id: I1e42f7f66427410275df713bea04f6e0445fba28
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
3ab6f2e219c167fd35f16b6cf233ae6a39d9de02 05-Nov-2015 Makoto Onuki <omakoto@google.com> DA receiver should be protected with BIND_DEVICE_ADMIN.

- DPM.setActiveAdmin() will not accept DAs without BIND_DEVICE_ADMIN
when it's targeting NYC or above.

- DAs without BIND_DEVICE_ADMIN targeting MNC or below will still be
accepted. (with a logcat warning)

- DAs that are already set on a device without BIND_DEVICE_ADMIN
will still be accepted regardless of the target API level, even when
it's upgraded to a version targeting NYC.

Bug 24168653

Change-Id: I1914c2ec99135d9dd8cbac3f6914f9e43bafacc8
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
068c54a5be697c3df4657dcda33cd17c4b547710 13-Oct-2015 Makoto Onuki <omakoto@google.com> Layer user restrictions

- Now DPMS remembers user restrictions set by DO / PO in their ActiveAdmin.

- User restrictions set by DO/PO will no longer be saved by UserManger. Instead,
when needed, UMS will consult DPMS to build "effective" user restrictions.

- UM.getUserRestrictions() will now always return "effective" user restrictions.

- DPMS migrates existing user restrictions per the eng spec.

- Also now UM.setUserRestrictions() will crash. UMS.setUserRestrictions() has
been removed.
This was needed because UM.setUserRestrctions(UM.getUserRestrictions()) will no
longer be a valid use like it used to be.

- Also introduced a fined-grained lock for user restrictions in UM to avoid
deadlock between DPMS and also for better performance.

Bug 23902097

Change-Id: If0e1e49344e2f3e9226532d00777976d1eaa7df3
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
d932f7689d799b07a6776bc7c59749f672528239 30-Sep-2015 Makoto Onuki <omakoto@google.com> Refactor DPMS tests to be able to test more different cases.

- DpmMockContext.addUser() allows to create more users. This will set up
UserManager properly and create a data directory.

- Updated DevicePolicyManagerTest so it can now easily emulate calls from
different secondary users.

Change-Id: Ic9d3e8d0d1e7f41e184c82e6dc323c244535b8d8
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
b643fb0e67460344ade2e3db92738999f8168496 23-Sep-2015 Makoto Onuki <omakoto@google.com> Use a factory class for dependency injection, add more tests.

- Extracting into a factory allows us to use mocks in other classes.
(Such as Owners.)

- Also removed broken test ApplicationRestrictionsTest. Instead added a new
simplified test to DevicePolicyManagerTest.

- Also stop caching rarely used instances in DPMS.

Bug 24061108
Bug 24275172

Change-Id: Ice9e57204b18e7b5f6b115126dab2209041439c2
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
cc4bbeb76af92a8484fe05f37c4ff412b4c47ccc 17-Sep-2015 Makoto Onuki <omakoto@google.com> 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
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java
c9754cf0dfa66d39ce9ea0d2eeab5f7c442a9686 31-Aug-2015 Makoto Onuki <omakoto@google.com> Add unit tests for file persisting in Onwers.

Bug 23432442

Change-Id: If10ed5a46084695b2aca1286713b8baea8c2a418
/frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DpmTestBase.java