Commit Graph

1153 Commits

Author SHA1 Message Date
TreeHugger Robot
aeeb3f5eda Merge "BaseIDevicePolicyManager cleanup." 2018-10-04 14:35:40 +00:00
Makoto Onuki
8c7c5cc91e Persistent connection to SMS app 2/2 (main)
Bug: 109809543
Test: atest CtsAppBindingHostTestCases
Test: atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/am/PersistentConnectionTest.java
Change-Id: If927050fba5edea63137e10af5570c3450165237
2018-10-02 14:19:53 -07:00
Makoto Onuki
23961c8a80 Merge "Allow default SMS app to be always running" 2018-10-02 15:32:50 +00:00
TreeHugger Robot
e1251df8eb Merge "Device-wide unknown sources block option for DPC." 2018-10-02 13:07:25 +00:00
Lenka Trochtova
9ecde320ad BaseIDevicePolicyManager cleanup.
Move P APIs out of BaseIDevicePolicyManager.

Bug: 73469681
Test: make -j64 checkbuild
Test: make RunFrameworksServicesRoboTests

Change-Id: Ieffafb5c331b0befed5356f8d45e9ac6e0d81bee
2018-10-02 11:13:58 +02:00
Irina Dumitrescu
4638edd79f Device-wide unknown sources block option for DPC.
This adds a new framework user restriction that can be used by the DPC
to block installs from unknown sources on all profiles of a device.

Test: Manual test, disallowing installs in TestDPC disables installing
unknown sources apps.
Bug: 111335021
Change-Id: Ib9fb672c5e5dea2ac63bf8cbd1b04484b12b4056
2018-10-01 21:45:00 +01:00
Makoto Onuki
87d260a3a3 Allow default SMS app to be always running
Bug: 109809543
Test: atest CtsAppBindingHostTestCases
Test: atest services/tests/servicestests/src/com/android/server/am/PersistentConnectionTest.java
Change-Id: Ic016f2c073d178db4aa36268628ebf3880acb3c3
2018-09-28 14:48:53 -07:00
TreeHugger Robot
d2b1a57093 Merge "Suppress suppressing work profile removed notification if reason is null" 2018-09-20 18:06:28 +00:00
Zimuzo Ezeozue
3bf9f76b88 Merge "Add privileged APIs to lock device and reset device password" 2018-09-17 19:27:18 +00:00
Alex Chau
16d9490245 Suppress suppressing work profile removed notification if reason is null
Bug: 114711242
Test: cts-tradefed run singleCommand cts -m CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.ManagedProfileTest#testWipeDataWithoutReason
Change-Id: Icea2c95272f3d3d693c3289a5c4a55761026a8f9
2018-09-17 19:33:28 +01:00
Zimuzo
9f62a26385 Add privileged APIs to lock device and reset device password
In 534d732e9f274ad3f3e0637b9da963f889309afb, we are restricting privileged apps from silently becoming
Device Admins. Privileged apps can now call the following existing Device Admin APIs provided they have the correct permissions:
1. DevicePolicyManager#resetPassword -> Guarded by android.permission.RESET_PASSWORD
2. DevicePolicyManager#lockNow -> Guarded by android.permission.LOCK_DEVICE

The following existing Device Admin APIs already have alternatives hence no change required:
3. DevicePolicyManager#wipeData -> Send ACTION_FACTORY_RESET broadcast.
Guarded by android.permission.MASTER_CLEAR
4. DevicePolicyManager#setKeyguardDisabledFeatures -> Write '0' to LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS setting
Guarded by WRITE_SECURE_SETTINGS

Bug: 111153365
Bug: 112601004
Test: Manually tested with dev privileged app
Change-Id: Ia4e1ce9b81756e7f84ed0aa22d97e0b968cd8d89
2018-09-12 13:28:24 +01:00
Lenka Trochtova
3b6e08772e Revert the mandatory backups feature.
Bug: 79736299
Test: make RunFrameworksServicesRoboTests
Test: cts-tradefed run cts -m CtsBackupHostTestCase

Change-Id: I1209174c9f6aa794c7ca67f4a8737c0589d5fd69
2018-09-12 13:39:05 +02:00
TreeHugger Robot
6c1c842dc7 Merge "Frameworks: Annotate trivial @GuardedBy in services" 2018-09-10 22:18:40 +00:00
Eric Sandness
a521deb920 Merge "Block Policies From Device Admin Targetting Q" 2018-09-07 09:07:21 +00:00
Andreas Gampe
8ce7ed95a0 Frameworks: Annotate trivial @GuardedBy in services
Add @GuardedBy for simple functions that require locks and have a name in
one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$").

Derived by errorprone.

Bug: 73000847
Test: m
Change-Id: If70bb03313388af34d547efca20fb5115de95bf1
2018-09-05 17:02:08 -07:00
Eric Sandness
ca5969d6e0 Block Policies From Device Admin Targetting Q
If a device admin app targets Android Q or above, and it is not a device
owner or profile owner, throw a SecurityException if it attempts to
control the following policies:
  - DeviceAdminInfo.USES_POLICY_DISABLE_CAMERA
  - DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES
  - DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD
  - DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD

The set of policies available to a device admin targetting Android P or below is unchanged.

Bug: 111546201
Test: com.android.server.devicepolicy.DevicePolicyManagerTest
Test: com.android.cts.devicepolicy.DeviceAdminHostSideTestApi24
Test: com.android.cts.devicepolicy.DeviceAdminHostSideTestApi29
Test: com.android.cts.devicepolicy.ManagedProfileTest
Change-Id: Idcd0b4b91ad2fa363535c718928d382c7da054d4
2018-09-05 18:47:42 +01:00
Philip P. Moltmann
4e615e6986 Factor some RestrictedLockUtils out of SettingLib
Also make the new lib only use system-apis.

This allows mainline module to use the new
RestrictedLockUtilsSettingLib.

Unfortunately the whole RestrictedLockUtils would have caused to much
new system-api. Hence it was split into RestrictedLockUtils and
RestrictedLockUtilsInternal. This caused a lot of trivial code changes.

Bug: 110953302
Test: Built
Change-Id: I693b3bf56f3be71f0790776e3aad5694717786ef
2018-08-30 11:59:29 -07:00
Pavel Grafov
b90dc43e15 Use DPM's counter for invalid password attempts
Currently Keyguard uses separate counter for invalid password attempts
that is not persisted and is always initialized to zero after boot,
so if the user made several attempts and rebooted the device, the
device will show more allowed attempts before wipe than actually
available. The counter is also incorrectly reset to zero when
fingerprint is used successfully.

With this CL the same counter is used for that message and for actual
wipe triggering, it is persisted and is not reset upon reboot or
fingerprint authehtication.

Counting failed password attempts should be available in DevicePolicyManager
even without PackageManager.FEATURE_DEVICE_ADMIN.

Test: manual, tried using fingerprint and rebooting.
Bug: 112588257
Change-Id: I1f4012a95c6f6758885206f69e7ebe2c3704a567
2018-08-16 14:31:08 +01:00
Wale Ogunwale
6d50dcc8af Moved URI grants code out of ActivityManagerService to its own service (13/n)
Allows for other services like window manager to call uri grants without
holding AM service lock.

Bug: 80414790
Test: Existing tests pass.
Change-Id: Ie5b4ddb19a2cedff09332dbeb56bcd9292fd18ac
2018-07-23 16:37:46 -07:00
Eran Messeri
607a995691 DPM: Propagate StrongBox-related exception
When the caller attempts to generate a key via DevicePolicyManager
(using DevicePolicyManager.generateKeyPair), and specifies that
StrongBox should be used, throw the right exception indicating
StrongBox unavailability - the same one that is thrown if the same
parameters were passed to the KeyStore's key generation method.

This is achieved by catching the StrongBoxUnavailableException in
KeyChain, returning an error code indicating this particular failure
to the DevicePolicyManagerService, which then propagates it by
throwing a service-specific exception with a value indicating
StrongBox unavailability.
The DevicePolicyManager then raises StrongBoxUnavailableException.

Prior to this change the exception propagated from KeyChain would be
a generic failure so the caller would simply get a null result.

Bug: 110882855
Bug: 111183576
Bug: 111322478
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: I9abe3f449b48eb5a960fafbc15c59b9b4ce7a966
2018-07-17 12:58:13 +01:00
TreeHugger Robot
abe78cd313 Merge changes from topic "biometrics-face"
* changes:
  5/n: Move FaceService to biometrics directory
  4/n: Add face authentication framework
2018-06-22 18:44:27 +00:00
Gilad Bretter
cb51b8b847 4/n: Add face authentication framework
This change is cherry-picked and rebased from AOSP
https://android-review.googlesource.com/c/platform/frameworks/base/+/660242

Add face recognition as an identification method, following fingerprint
design. Unlike fingerprint, only one face template can be enrolled per
user, and a vendor message is passed from the HAL all the way to the
client callback to allow GUI indication about the enrolled face
templates.

Add FaceAuthenticationManager and FaceService.
Add face authentication capability to TrustManager and Keyguard.
Modify TrustManager and KeyguardUpdateMonitorCallback fingerprint code
to support generic biometric method to eliminate duplications.
Add BiometricSourceType enum to keep track of the specific biometric
method.

Test: biometric authentication still works on the device

Fixes: 110385761

Change-Id: I5d04fe69a112c13d3ef7330b9c08c146e36c5335
Signed-off-by: Gilad Bretter <gilad.bretter@intel.com>
2018-06-21 17:00:07 -07:00
Irina Dumitrescu
24ed35cd83 Add dpm force-network-logs command to force network logs retrieval.
This is useful because logs are batched every 1.5-2hrs if there are
not enough logs to fill up a batch. The command is throttled at
10 seconds as a spam prevention measure.

Bug: 62251154
Test: in adb shell run dpm force-network-logs. Observe a new batch
being created in the phone directory
/storage/emulated/0/Android/data/com.afwsamples.testdpc/files/. Also
observe a fresh batch is being displayed on the phone in the TestDPC
app, under "Retrieve network logs".
Change-Id: I5ff9d5c78497ea81533b5248816b4d6e160d338f
2018-06-20 16:23:58 +01:00
Wale Ogunwale
04d9cb5f40 Moved some activities implementation to ActivityTaskManagerService (2/n)
Second step in unifying the window hierarchy that is currently split
within AM and WM packages. We move some of the API implementation for
activities from ActivityManagerService.java to
ActivityTaskManagerService.java.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790

Change-Id: I23dcd924493d8ad1e0b6e3a55386fd72b0146605
2018-06-12 13:38:39 -07:00
Pavel Grafov
2560f6f872 Only call getActiveAdminForCallerLocked when holding a lock
+ factored out all device-owner checking calls
+ some profile owner checks

Fixes: 110040849
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.DeviceOwnerTest#testSetTime
Test: create a profile with TestDPS, it sets profile name.
Change-Id: I5fec70505d089bd7dcea80eae3df9c0f2b7094dd
2018-06-12 15:57:34 +01:00
Pavel Grafov
acafeeb7de Merge "Start SecurityLogMonitor after broadcasts are allowed." into pi-dev am: 8e0ad6534d
am: eec59f4851

Change-Id: Ia4338c836ac7ca16548c82ffcd5c4d68ef43ab09
2018-06-07 10:53:03 -07:00
Pavel Grafov
3bca09f308 Start SecurityLogMonitor after broadcasts are allowed.
Otherwise if boot takes long enough, DO broadcast will be sent while
ActivityManagerSerivce is not ready, causing IllegalStateException.

Change-Id: I6b55ed45ed7b1f3ed9ad6ec20695907b4fa6f3b1
Fixes: 109746888
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.DeviceOwnerTest#testSecurityLoggingWithSingleUser
Test: provisioned TestDPC as DO in SuW, enabled logging.
2018-06-07 11:16:46 +01:00
Dianne Hackborn
2b8336f241 Merge "Allow device/profile owners to change app ops modes." into pi-dev am: adaca2146d
am: 82a87674ce

Change-Id: Id4a52aaca3d94075ff179141e96fba5c7326d4ee
2018-05-14 14:32:23 -07:00
Dianne Hackborn
d52544183e Allow device/profile owners to change app ops modes.
This allows them to continue to have this capability the
same as before we locked down access to it.

Bug: 78480444
Test: manual
Change-Id: If2b0722945235eb67676ace3f54efaa71a64bcde
2018-05-14 11:29:43 -07:00
Pavel Grafov
10e6d7083e Merge "Log wipe failure" into pi-dev am: 9cf46fd625
am: 69e93ee993

Change-Id: I09dfe69ecde525bd7dd6f060903ba36c58faad6e
2018-05-09 13:29:35 -07:00
Pavel Grafov
3060967af8 Merge "Acquire lock before calling getDeviceOwnerAdminLocked" into pi-dev am: b9ab72bf96
am: fc9dd7c67b

Change-Id: I08f626298bd0d58cfa55b3e731e08eb22242e181
2018-05-09 13:24:11 -07:00
Pavel Grafov
9cf46fd625 Merge "Log wipe failure" into pi-dev 2018-05-09 19:46:05 +00:00
Pavel Grafov
a0d201b548 Log wipe failure
Test: injected an error into RecoverySystem.rebootWipeUserData
Fixes: 79417596
Change-Id: I3fef4bdd2f6357b08be4976c35c651908e9b3599
2018-05-09 18:27:45 +01:00
Pavel Grafov
517260ecef Acquire lock before calling getDeviceOwnerAdminLocked
Change-Id: I318c7cea8e9b7de2dc9fa05f786524848c9c76dd
Fixes: 79418618
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement
2018-05-09 17:42:06 +01:00
Eran Messeri
c12e69a357 Merge "Save password requirements on the right user" into pi-dev am: f0db8fe188
am: 7c10001d6c

Change-Id: I517d4fca46080bea0ad083a54a6076cf893e0f1b
2018-05-02 05:54:36 -07:00
Eran Messeri
9ecde42164 Save password requirements on the right user
When changing the password requirements, two changes have to be saved:
(1) Whether the current password complies with the new password
requirements.
(2) The new password requirements themselves.

(1) is stored on the credential owner of the user, (2) is stored on the
user itself.

In ag/3729963 (Change-ID: Ide5b2e53cf100b087822844ca51b3bc69e7ddf82),
we've switched from saving the password sufficiency flag (1) in the
user to the credential owner.
A side effect was that the password requirements themselves, (2), which
were changed on the original user the call related to, were not saved.

This fixes the bug introduced in the aforementioned CL.

Bug: 78499736
Test: Manual with TestDPC.
Change-Id: I11faef37fa6f0e8e8e558069e77021c48ee36cd4
2018-05-01 14:12:23 +01:00
Eran Messeri
1fd8278382 Merge "Remove unnecessary WTFs from password state check" into pi-dev am: 24ba8398fe
am: 4ac95fbe91

Change-Id: I232671cc125875cdbe47067d2d2022966718d180
2018-04-25 02:50:16 -07:00
Eran Messeri
24ba8398fe Merge "Remove unnecessary WTFs from password state check" into pi-dev 2018-04-25 09:28:15 +00:00
Eran Messeri
3c26b8f92e Remove unnecessary WTFs from password state check
It is possible to have null PasswordMetrics object for a given user -
if, for example, the user never had a password set.

Do not WTF in that case.

Bug: 78191197
Test: That it compiles.
Change-Id: I807c2755890b0772e295b4cb0095cac1bf2d0aef
2018-04-24 19:28:57 +01:00
Suprabh Shukla
c6638510d2 Merge "Merge "Failing setPackagesSuspended if user has a DO / PO" into pi-dev am: 694f60005e" into pi-dev-plus-aosp
am: fecb262029

Change-Id: I58139151f963f6a45493615d07e9b7e4a5417456
2018-04-23 18:05:45 -07:00
Suprabh Shukla
7ea5378f89 Failing setPackagesSuspended if user has a DO / PO
Device or profile owners should be suspending packages via
DevicePolicyManager. If an app with SUSPEND_APPS tries use the
PackageManager api on a user with a DO or a PO, the call should fail

Test: gts-tradefed run gts-dev -m SuspendApps

Bug: 78132137
Change-Id: If478db0726073c2e59dba3a7049cc16c56d9f3d5
2018-04-19 21:31:10 -07:00
Makoto Onuki
a31a1c67f4 Merge "Add stats logging to ServiceManager and NPMS" into pi-dev am: a26e755900
am: fa3a2acfbc

Change-Id: I30bea4b59318ac1871293739c6c5f2d9b7551fb1
2018-04-11 19:01:30 -07:00
Makoto Onuki
49392d335a Add stats logging to ServiceManager and NPMS
ServiceManager:
- Do an event log every N getService() calls with total time spent
in getService().
where N = 100 for core UIDs and 200 for other apps.

- Do an event log if getService() takes longer than N ms.
where N = 10 for core UIDs and 50 for other apps.

... with some extra throttling.

NPMS:
- Do the basic "stats logger" log for updateNetworkEnabledNL() and
isUidNetworkingBlocked()

This CL also enhances StatsLogegr so it now can show the slowest call
and the max # of calls per-second.

Bug: 77853238
Test: Manual test:
- Insert a SIM card
- Set data limit
- toggle airplane mode
- toggle wifi
- toggle mobile data

Then
- "dumpsys netpolicy" and "dumpsys activity processes" and check the stats
- also check "adb logcat -b all | grep ' service_manager'"

Change-Id: I5789541063f95d0eac501189816c8604a4571ba0
2018-04-11 16:37:57 -07:00
Eric Sandness
cea884244e Merge "Permission Check For DPM.getPermittedAccessibilityServices" into pi-dev am: 0997a32523
am: bdfd63688c

Change-Id: I493a042d5d8c8e174597553c265fe7570ba07315
2018-04-09 06:37:01 -07:00
Eric Sandness
5ab98de315 Permission Check For DPM.getPermittedAccessibilityServices
Require the callers of DPM.getPermittedAccessibilityServices(userId) to
hold the MANAGE_USERS permission.  The only known callers of this API
are settings apps that already hold this permission.

Bug: 62343414
Test: com.android.server.devicepolicy.DevicePolicyManagerTest
Test: com.google.android.gts.devicepolicy.DeviceOwnerTest
Test: Manually checked accessibility settings in DO and PO modes
Change-Id: I8ee3f876fcaffa63636645f0f59709cd147254ef
2018-04-09 07:47:13 +00:00
Suprabh Shukla
acdfc1df62 Merge "Activity interceptor dialog for suspended apps" into pi-dev am: 822ce4f3aa
am: fce7bf015e

Change-Id: I20ef2001636ee1a75bcf5d9d7b097848bb15c710
2018-04-05 14:41:00 -07:00
Makoto Onuki
929b42e747 Always enable inversion lock check in DPMS
Bug: 74553426
Test: boot
Change-Id: I4e970b37bc4c1c0939c3075d213d7e6834f8b05b
2018-04-05 10:11:35 -07:00
Suprabh Shukla
3c3af1406e Activity interceptor dialog for suspended apps
Added an AlertActivity to intercept the start for an activity belonging
to a suspended app. More details will be shown if the suspending app
also defines an activity to handle the API action
SHOW_SUSPENDED_APP_DETAILS.

Test: Added tests to existing classes. Can be run via:
atest com.android.server.pm.SuspendPackagesTest
atest com.android.server.pm.PackageManagerSettingsTests
atest com.android.server.pm.PackageUserStateTest

Bug: 75332201
Change-Id: I85dc4e9efd15eedba306ed5b856f651e3abd3e99
2018-04-04 18:40:19 -07:00
Makoto Onuki
eed5b5a31c Add basic inversion lock detection to DPMS.
For now enable it on ENG builds only.
(I'll change the condition in master so I'll get WTFs from qt-release devices
too.)

This will detect calling into DPMS with the following locks held:

APP_OPS
POWER
USER
PACKAGES
STORAGE
WINDOW
ACTIVITY
DPMS

On marlin-eng pi-dev, each guard() takes ~25us.
    LockGuard.guard(): count=7246, total=175.1ms, avg=0.024ms

Used the following command to ensure all locks are replaced.
$ grep synchronized /android/pi-dev/frameworks/base/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | sed -e 's/  *//' | uniq

Bug: 74553426
Test: Manual test with an intentional lock inversion.
Change-Id: Id59d562d7c275b6ea127a211284496f5d64f9f93
2018-04-04 12:18:54 -07:00
Rubin Xu
69196f6fad Merge "Remove password blacklist API" into pi-dev 2018-03-30 13:38:31 +00:00