Commit Graph

1307 Commits

Author SHA1 Message Date
Pavel Grafov
b9c4862b86 Re-activate backup service after cleaning a profile owner
Currently backup service is re-activated unconditionally when clearing
a device owner but not profile owner. With this CL it should be
re-activate in both cases.

NB: there are two bits of state related to backup service:
1. activated or deactivated: This is out of user control, but can be
   changed by the admin via DPM.setBackupServiceEnabled (this name is
   a bit misleading here).
2. enabled or disabled: this is controlled by the user via Settings
   and only available when backup service is activated (see 1.)

Bug: 143274029
Bug: 147997438
Test: atest CtsAdminTestCases && adb shell bmgr enabled
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Merged-In: I6f11642abe544c7df265ed7e2ad466d47796e7f9
Change-Id: I6f11642abe544c7df265ed7e2ad466d47796e7f9
(cherry picked from commit 775b26d884)
2020-02-04 10:54:27 +00:00
Svet Ganov
7fe065eb66 Update PermissionChecker usages to avoid unnecessary attribution.
We had accidental usages of the PermissionChecker for cases where no
private data was provided to the app but the checkPermission API on
the latter also did blame data access on the app. The PermissionChecker
was designed to handle IPC calls and not for generic API checks.

To avoid future accidental incorrect PermissionChecker usages this
change renames the existing APIs of the latter to clearly indicate
that they should be used for data delivery and also adds sibling
methods for doing the same permission checks for preflight purposes.
Also the documentation is improved to furhter assist developers.

In addition, this change fixes accidental permission checker usages
that blame when they should not by using the new preflight flavor
of the permission check APIs.

Test:
    atest com.android.settingslib.location.RecentLocationAppsTest
    atest CtsPermissionTestCases
    added: LocationAccessCheckTest#notificationOnlyForAccessesSinceFeatureWasEnabled
    added: LocationAccessCheckTest#noNotificationIfFeatureDisabled
    added: LocationAccessCheckTest#noNotificationIfBlamerNotSystemOrLocationProvider
    added: LocationAccessCheckTest#testOpeningLocationSettingsDoesNotTriggerAccess

bug:141028068
Merged-In: I65c71569d0dd8a40bc6fecabb22c5373dd6e806e
Change-Id: I65c71569d0dd8a40bc6fecabb22c5373dd6e806e
2019-10-03 21:58:13 +00:00
Ivan Podogov
680e357976 Don't dismiss keyguard when enabling it
Introduced in ag/2664156, dismissing a keyguard when it's being disabled has
also caused it to be shown whenever it's being enabled (or re-enabled, or
calling DPM.setKeyguardDisabled when keyguard is enabled).

This change should stop keyguard randomly popping up.

Bug: 133730775
Test: manual
Change-Id: I49f28714b2d149f13168e7564947aaf09c593117
2019-06-20 14:15:32 +01:00
Pavel Grafov
e13f1b5a5f Log correct number of whitelisted packages.
Bug: 135525766
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn
Change-Id: Ia66978d60bcfb30d3182e7d30f3594f59d5f8ad7
2019-06-18 16:55:42 +01:00
jovanak
718c91cc78 Removing requirement for FEATURE_DEVICE_ADMIN in DPMS.setActivePasswordState().
Bug:133782444
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.PasswordComplexityTest#testGetPasswordComplexity (on a device without the feature)
Change-Id: I5f55a867a1a5a86387f9ad9877e593adac6f6f90
2019-05-30 16:58:02 -07:00
Rubin Xu
6cf5ea63eb Merge "Fix deadlock in KeyguardDisableHandler" into qt-dev 2019-05-27 19:50:06 +00:00
Alex Kershaw
494f8de3df Add a mapping for kDownloadMetadataSignatureMismatch.
Add a mapping for kDownloadMetadataSignatureMismatch (26) from
error_code.h. This involves creating a new system API constant, but it's
just a simple definition so we don't have to hard-code '26'. These
constants are already set in error_code.h. A TODO has been added to
create this constant in the next release.

Test: manual
Bug: 132827080
Bug: 133396459
Change-Id: I4d59702879f2ed654dd467a1ae2dc8e400a0938d
2019-05-23 10:50:40 +00:00
Rubin Xu
13531ccab8 Fix deadlock in KeyguardDisableHandler
At the moment KeyguardDisableHandler calls into DevicePolicyManager
to retrive the aggregated password quality for the current user
while holding the WindowManager lock. This is a lock inversion
and causes deadlock. To fix this, introduce a per-user password quality
cache in DevicePolicyCache and switch KeyguardDisableHandler
to use that instead.

Test: manual
Fix: 129087668
Change-Id: I8c02ca442dde76ed350f22ac04a52adc82d21d00
2019-05-23 11:27:11 +01:00
Jonathan Scott
367ebf4819 Whitelist background activity starts from device admin in #sendAdminCommandLocked.
Test: cts-verifier > Device Owner Tests > Managed User Test
Fixes: 131815491
Change-Id: I818348159a0b501638ecf06e0621923ebc03d1fa
2019-05-20 14:40:49 +01:00
Philip P. Moltmann
4f09b09f62 Merge "Whitelist all perms on installExistingPackage" into qt-dev 2019-05-17 19:56:19 +00:00
Philip P. Moltmann
a4bd150588 Whitelist all perms on installExistingPackage
The code allows to also whitelist only a select set of permissions, but
this is not yet exposed in the API.

Also: Fix up shell commands for restricted permissions

Fixes: 132368462
Test: - Enabled app via device admin in secondary profile
        -> verified that permissions were whitelisted
      - Installed existing and new app using --restrictpermissions and
        not
	-> verified that permissions were whitelisted or not
      atest AppRestrictionsHelperTest
            RestrictedPermissionsTest
Change-Id: I9cd76c555b40663f2e25ad86e8a54991baae346c
Merged-In: I9787e63d8beb8f6b1ba2d15532d4c0f69dbdf863
2019-05-15 11:09:45 -07:00
Rubin Xu
17d08f474c Do not compare ID when deduplicating SecurityEvent
Two SecurityEvents should be considered identical as long as
their event content equals, disregarding the id field.

Test: manual
Change-Id: I811f9a104ed3a0d9e02991aeb9e3653c5c02efc3
Fix: 132367517
2019-05-15 17:39:46 +01:00
Rubin Xu
897750a79b Bump several device admin notifications to high priority
The following device admin related events now generate interruptive notifications:
1. Admin-triggered remote bug report collections (requires user action)
2. Remote work profile wipe - post wipe notification
3. The enabling of Network logging
4. Admin remotely installs/removes an APK
5. Work profile needs unlocking after boot

Test: manual
Change-Id: If5a51123c05b15e544a31ac7ec6b42ec831a1ccc
Fix: 130623009
Fix: 120770584
Fix: 118810015
2019-05-09 16:35:16 +01:00
Michael Wachenschwanz
3e1e24afde Add a resource config to define a default supervision component.
Bug: 124066840
Test: manual (overlay resource with component name and confirm only that
component can be set as profile owner after setup is complete)

Change-Id: If67ca69f03fda35ee8a2d5a43e96a9f1e64d8886
2019-05-01 20:46:44 -07:00
Alex Kershaw
07806b3d78 Merge "Don't ignore updated policies on PO/DO." into qt-dev 2019-04-25 18:40:11 +00:00
Makoto Onuki
a883567c16 Always enable DPMS lock check
It has good enough performance for dogfooders, so let's just keep it.

Change-Id: Iea4a82e66f83f5199107fc95f4ef67390590590b
Fix: 74553426
Test: build / boot
2019-04-24 14:39:31 -07:00
Alex Kershaw
e4d398c917 Don't ignore updated policies on PO/DO.
For DA, it is important that apps can't update their policies from what
the user agreed to. This doesn't apply to DO and PO.

Fixes: 123415062
Test: Manually tested with custom TestDPC build.
Change-Id: I6d4dd98bdc6bee8fee03451530d98d67ce005b30
2019-04-24 17:49:52 +00:00
Alex Kershaw
76f824b18c Catch exceptions thrown from UpdateEngine#applyPayload.
Note: we can't add a CTS test for this behaviour since the UpdateEngine
is an implementation detail.

Fixes: 124106342
Test: Manually tested
Change-Id: Ib8e6895211b5d39a4d037d383c115011084ea257
2019-04-12 17:19:34 +00:00
TreeHugger Robot
ab48af4b76 Merge "Check device owner by callingUid in ActivityStarter" into qt-dev 2019-04-11 17:23:56 +00:00
Ricky Wai
96f5c350f0 Check device owner by callingUid in ActivityStarter
Bug: 129565838
Test: atest ActivityStarterTests
Change-Id: Ic75a3198f7de34078ba3b9c794db893779e7bb77
2019-04-11 16:03:19 +01:00
Pavel Grafov
7b68bad0fe Limit IsSeparateProfileChallengeAllowed to system callers am: 1b6301cf24
am: 406229f0c8

Change-Id: Ibcdd009840f36c0ac566a2211a50ac75f6db5c28
2019-04-10 12:20:17 -07:00
Pavel Grafov
406229f0c8 Limit IsSeparateProfileChallengeAllowed to system callers
am: 1b6301cf24

Change-Id: I1145186590622d415c6c10c4750cf9429806bdbe
2019-04-10 11:47:42 -07:00
Pavel Grafov
1b6301cf24 Limit IsSeparateProfileChallengeAllowed to system callers
Fixes: 128599668
Test: build, set up separate challenge
Change-Id: I2fef9ab13614627c0f1bcca04759d0974fc6181a
2019-04-10 13:39:05 +01:00
Rubin Xu
edeb2ffab3 Remove DELEGATION_PACKAGE_INSTALLATION
Bug: 112982695
Test: atest MixedDeviceOwnerTest.testDelegation
Change-Id: I729f27e132e608e81d4971966743b3988e612ab5
2019-04-04 15:39:09 +01:00
TreeHugger Robot
b00f655fc2 Merge "Ensure that we always log updating from file." 2019-04-03 18:33:29 +00:00
Alex Kershaw
ca4a85818a Ensure that we always log updating from file.
If an exception was thrown by one of the methods, we were not logging
the event, which caused the CTS test to fail.

In particular, this happened on non-AB devices, such as the emulator.

Bug: 127268862
Change-Id: I8f853d5e0a8e810a570562071fb73266fee3b696
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.DeviceOwnerTest#testInstallUpdateLogged
2019-04-03 17:04:44 +00:00
Lenka Trochtova
e9715fd3bc BaseIDevicePolicyManager Q cleanup.
Bug: 126706812
Test: make && atest DevicePolicyManagerTest

Change-Id: Ie9a62b76b0cc47a50bf4b0d26fe60cc541bcb18d
2019-04-02 17:20:08 +02:00
Michael Groover
d18900b937 Merge "Remove unused code and cleanup parameters for DPM dev ID access" 2019-04-01 19:27:42 +00:00
Michael Groover
9fd02c5027 Remove unused code and cleanup parameters for DPM dev ID access
Fixes: 123684619
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.DeviceOwnerTest#testDeviceOwnerCanGetDeviceIdentifiers
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.ManagedProfileTest#testProfileOwnerCanGetDeviceIdentifiers
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.ManagedProfileTest#testProfileOwnerCannotGetDeviceIdentifiersWithoutPermission
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.DeviceOwnerTest#testDeviceOwnerCannotGetDeviceIdentifiersWithoutPermission

Change-Id: Ibc647847a47911c0c32cf5cf33bd3187dc3aebd2
2019-03-29 11:31:44 -07:00
TreeHugger Robot
5659644ebf Merge "Show correct restriction enforcement info for unknown apps installs." 2019-03-29 15:22:18 +00:00
TreeHugger Robot
b5e820c778 Merge "Fix SecurityException when calling DevicePolicyManager.setMaximumTimeToLock" 2019-03-22 19:18:45 +00:00
Irina Dumitrescu
edc3e6a7e5 Show correct restriction enforcement info for unknown apps installs.
Obtain the correct admin and dialog information when a restriction prevents the
user from installing apps from unknown sources.

Bug: 118881180
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: I8112aaca64f85d421ee1029edc5c47909e31f12f
2019-03-22 17:22:57 +00:00
Rubin Xu
0c696c943c Fix SecurityException when calling DevicePolicyManager.setMaximumTimeToLock
Test: atest com.android.cts.devicepolicy.DeviceOwnerTest#testSecurityLoggingWithSingleUser (only on cuttlefish)
Change-Id: Icd8a24481c281842e9690c6e16c9c31d2d613a2c
Fix: 127264133
2019-03-22 16:36:39 +00:00
Irina Dumitrescu
c90674dcc2 Change existing LockPatternUtil APIs to fail untrusted password updates.
Add alternative APIs to allow untrusted password changes explicitly, so the caller
can choose to use them if needed.

Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/
Bug: 120039091
Change-Id: I4ca03c9185081d300d7e325965b1e20515e33d51
2019-03-22 16:07:03 +00:00
Pavel Grafov
19a4fb3fe0 Make LSS report honest password quality to DPMS
Previously password quality would be promoted to whatever admin
has requested or depending on whether it was PIN or password.

Bug: 120536847
Test: manual, steps from b/123924734
Test: atest DeviceAdminHostSideTestApi24#testRunDeviceOwnerPasswordTest
Test: atest MixedManagedProfileOwnerTest#testResetPasswordWithToken
Test: atest com.android.cts.devicepolicy.PasswordComplexityTest
Test: atest PasswordMetricsTest
Change-Id: I51ca2d327f4c6db8f74c0b0ec35e4a3a346a9b5c
2019-03-20 15:53:02 +00:00
Rich Cannings
820b2504f3 DO NOT MERGE Refactor passwords/pins/patterns to byte[]
Relating to frameworks/base

Bug: 120484642
Test: manual - test setting and unlocking passwords/pins/patterns.
      automated - atest services/tests/servicestests/src/com/android/server/locksettings/

Change-Id: I57aa530ca2db1a026c56b66f5b4c91172f2667f6
(cherry picked from commit f64ec63a02)
2019-03-19 11:13:18 -07:00
Rubin Xu
8b17ad02b7 Add metric logging for new delegated APIs
Add metric logging to:
 * Delegated cert selection
 * Delegated network logging access
 * Delegated silent package installation and removal

Bug: 122639711
Test: manual
Change-Id: I0655b742937b6413bc5c10474e4fd4559a8eaf92
2019-03-14 22:12:23 +00:00
Eran Messeri
c7f498fe0b Merge "Private DNS API: Follow-up on review" 2019-03-12 16:37:15 +00:00
TreeHugger Robot
794d22d0a7 Merge "Update screen lock complexity permission to password complexity" 2019-03-12 16:22:11 +00:00
Eran Messeri
ff9c10593e Private DNS API: Follow-up on review
To follow up on the previous review, rename the success constant from
"success" to "no error" since the enum it's associated with now refers
to error codes.

Bug: 124301971
Test: atest com.android.cts.devicepolicy.DeviceOwnerTest#testPrivateDnsPolicy
Change-Id: I6b82dd44cbf2c18fb8c1673a272f22f0e8b39dbb
2019-03-12 13:40:14 +00:00
bernardchau
7ac9a71880 Update screen lock complexity permission to password complexity
This is to match the method name "getPasswordComplexity" as requested by API review feedback

Bug: 128030136
Test: N/A
Change-Id: I999657f88ed425333adbe97b9ecc33da3769ba90
2019-03-11 16:37:44 +00:00
Ram Periathiruvadi
32d5355b4d Notify the TrustAgent when the token is activated.
Previously, the agent will have to query the TrustManager to see if a
recently added escrow token has been activated.  If the agent asked too
soon about the token state, then the result could be inactive.  That
will be hard to distinguish from when the token is actually inactive
because activation failed.

This change pipes the call from LockSettings to the TrustAgentService
through the TrustManager when the token is activated.  So, the trust
agent doesn't have to query, it just gets notified.

Bug: 124312230
Test: Observe the onTokenStateReceived() callback received on the trust
agent.

Change-Id: I0ac674219fd7925ba36f50bb695c9998c18226f7
2019-03-08 13:21:02 -08:00
Lenka Trochtova
cef704e172 Improve documentation of secure lock screen feature.
Add more a specific description of what methods do when the
secure lock screen feature is not supported by the device.

Bug: 123270501
Test: make

Change-Id: Ib6c16f421cf3dc60b0f0cb0c6335c6dc35ac7ece
2019-02-28 12:00:05 +01:00
Rich Cannings
383223ab18 Merge "Refactor passwords/pins/patterns to byte[]" 2019-02-27 03:21:57 +00:00
Philip P. Moltmann
933c8e06e8 Merge changes from topics "policy_fixed_set_via_perm_controller", "protect-policy-flags"
* changes:
  Ask Perm Controller to set policy-fixed perms
  Guard changing policy_fixed flag behind permission
2019-02-22 04:39:31 +00:00
Philip P. Moltmann
41df9f94ae Ask Perm Controller to set policy-fixed perms
This is much slower than the old way as we need to call into a different
process. On the other hand this handles the following cases correctly:
- foreground / background permissions
- pre-M apps
- split permissions

Test: CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionGrant,testPermissionPolicy,testPermissionMixedPolicies,testPermissionAppUpdate,testPermissionGrantPreMApp
Change-Id: I5cd139ad29e5b77b77b02e12c75eb774984a7759
Bug: 124128308
2019-02-21 16:56:25 -08:00
Rich Cannings
f64ec63a02 Refactor passwords/pins/patterns to byte[]
Relating to frameworks/base

Bug: 120484642
Test: manual - test setting and unlocking passwords/pins/patterns.
      automated - about 20 failing due to an issue in the test code.

Change-Id: I57aa530ca2db1a026c56b66f5b4c91172f2667f6
2019-02-21 14:39:05 -08:00
TreeHugger Robot
5bf79b4a3f Merge "Fix logging string" 2019-02-20 04:29:01 +00:00
Pavel Grafov
047bf28243 Merge "Dummy change to test postsubmit invocation" 2019-02-19 15:24:07 +00:00
Eran Messeri
7418ef9c6b Fix logging string
Remove spurious 'if' in the device ID access log message.

Bug: 124732723
Test: That it builds
Change-Id: I4cee42942e3d1f4d37794ad9d722cf77c54814eb
2019-02-19 12:31:02 +00:00