932 Commits

Author SHA1 Message Date
phweiss
ebb9fc309d Decrease number of network logging notifications shown
Now, network logging will show one notification when it is enabled
and one after the next reboot.

Bug: 36254499
Test: CTS Verifier > Managed Provisioning > Device Owner Tests
      > Network Logging UI

Change-Id: I60fc64e96ceb0ec0ae7ca832b74ac8b47e581be4
(cherry picked from commit 55dba53ed433d713a075ba0de15504a1ed42852b)
2017-04-18 13:16:54 +00:00
TreeHugger Robot
dcc792a13f Merge "Persistent connection to DO/PO service." into oc-dev 2017-04-03 20:35:18 +00:00
Jeff Sharkey
fe9a53bc45 Consistent dump() permission checking.
This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access.  It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
2017-04-02 22:29:07 -06:00
Makoto Onuki
fc73d799e9 Persistent connection to DO/PO service.
Test: Manual test with customize API tests; CTS coming.
Change-Id: I1d7eaa4b1fdd20726c1832c736d32f934c6a82f9
2017-03-31 14:50:20 -07:00
Chris Wren
282cfefea0 standardize system notification IDs
All the trivial cases, plus some fixes to try to
mitigate collisions with the complex ones.

Complex services to follow in another CL,

Bug: 32584866
Test: make framework services
Change-Id: Ie9663600171d8ede11676e9d66f009dbb06def03
2017-03-31 11:44:05 -04:00
Pavel Grafov
cb3df3bf4a Store up to 5 network log batches if needed.
In the normal mode when the DO fetches the logs ASAP, there will still be
no more than one last full batch in memory at once. If the DO is too slow,
or the broadcast queue is too crowded we will store up to 5 of them,
discarding older ones when there are more than 5.

Also the batch gets discarded 5 minutes after it has been retrieved or
another more recent batch has been retrieved. Previously the last batch
would stay in memory until the next one is ready. But it seems
unreasonable for the DO to rely on it since there are no guarantees.
This would probably even save some memory under normal conditions on
average.

Bug: 35753013
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser
Change-Id: Ib8e91a98103d804375cb0d7423f93175b4b9bcb6
(cherry picked from commit 48733074d7ba80755e40432b7ff02b66e27d3edb)
Merged-in: Ib8e91a98103d804375cb0d7423f93175b4b9bcb6
2017-03-28 16:37:49 +00:00
Bartosz Fabianowski
0ec0000c22 Allow system UID to call isSecurityLoggingEnabled()
This CL allows code running under the system UID to call
isSecurityLoggingEnabled(), so that Settings can find out whether
logging is on or off.

Bug: 36584321
Test: m RunSettingsRoboTests

Change-Id: Icf8b7d6cef0f4e23f57bcf0498ffdcf124d16d38
2017-03-24 15:17:28 +01:00
TreeHugger Robot
74cb00696e Merge "Exfiltrate cert code from DevicePolicyManager" 2017-03-21 17:58:55 +00:00
TreeHugger Robot
71e06d9d29 Merge "Remove leftover DO/PO check in isPackageSuspended" 2017-03-21 17:35:49 +00:00
Pavel Grafov
4ce59d45a7 Request logs from logd with 3s overlap to avoid missing events.
Example: If we got a batch with timestamps [1, 4, 8] and an event
with timestamp 7 was delayed and was added to the buffer later,
if we request the next batch starting from timestamp 8 or 9 that
event will be lost.

The last 3 seconds of events are kept and checked against the next
batch.

Test: afw-test-tradefed-ci run afw-do-security-logging
Change-Id: I55727cfc6143c172edc7dabfd995776f9a0f7eab
Bug: 35373582
Bug: 35026180
Bug: 35648675
2017-03-21 14:52:32 +00:00
Edman Anjos
c8aeef6ae6 Remove leftover DO/PO check in isPackageSuspended
We already check if the caller is a DO, PO, or a delegate in
enforceCanManageScope, the additional call to
getActiveAdminForCallerLocked makes this function inaccessible to
delegate applications and was removed.

Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Change-Id: I5df0f19a017a3b6e130329940c79b12cbb95ec9e
2017-03-21 11:49:11 +01:00
Robin Lee
088d7aa9c1 Exfiltrate cert code from DevicePolicyManager
The intent is for this not to cause any behaviour changes, just to
make it easier to see what is going on with the code.

Permissions are checked in DevicePolicyManagerService. All calls to
CertificateMonitor are privileged.

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: I98224087315a62234732f08b53fe91884be86386
2017-03-17 19:44:53 +00:00
phweiss
e5b9d366c1 Finalize Strings and Icon for Network Logging Notification
Replace network logging icon with generic info icon as the
network logging icon will be deprecated.

Bug: 36254499
Test: CtsVerifier > Managed Provisioning0 > Device Owner Tests
                  > Network Logging UI
Change-Id: I648f160c09761a007948491f5b4ca772beddad70
2017-03-17 18:01:10 +01:00
Chad Brubaker
b64daad733 Explicitly disallow Instant App admins
Instant Apps have no business being device admins, reject any attempt to
install one as an admin.

Bug: 33387067
Test: None currently -- Instant apps already cannot request becoming
device admin.

Change-Id: Ia1daaff659990ff25f16e8cbad240747b67242e2
2017-03-13 15:48:42 -07:00
Pavel Grafov
9cdba2722f Retry SECURITY_LOGS_AVAILABLE if DO doesn't request the logs
Test: manually, with TestDPC.
Bug: 34186771
Change-Id: I99ec406b05f7b072c2c729f6336d1a5cf0f7c3d4
2017-03-07 18:43:36 +00:00
Bartosz Fabianowski
172f7801c7 Rename DPM.isDefaultInputMethodSetByOwner()
Settings.Secure.DEFAULT_INPUT_METHOD is a misnomer. It does not really
record a permanent default of any sort - it just indicates the currently
chosen IME. Thus, isDefaultInputMethodSetByOwner() should more
appropriately be called isCurrentInputMethodSetByOwner().

Furthermore, it turns out that setting a different IME for a user and
the user's work profile is unsupported. Thus, it is sufficient for the
intended use case to just retrieve the calling user's default IME.
There is no need for a |user| parameter.

Bug: 32692748
Test: unit tests (see DevicePolicyManagerTest.java for invocation)
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases

Change-Id: Ia0846d38a1361042429dae7430a8b055575ef2e0
2017-03-06 14:24:12 +01:00
Bartosz Fabianowski
05dc9f764c Add API for checking which CA certs were installed by the DO/PO
With this API, the system can determine whether a CA cert was
installed by the user or the user's DO/PO.

Bug: 32692748
Test: unit tests (see DevicePolicyManagerTest.java for invocation)
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases

Change-Id: I3bcae5ac18ec2b110154184fc515df804fd73da6
2017-03-03 19:42:51 +01:00
Geoffrey Pitsch
af759c52ce Channels for Frameworks notifications
Adapts all notifications used by system services to use channels.
Channels are initialized by SystemServer after the NotificationService
has started.

Test: runtest systemui-notification
Change-Id: I25c45293b786adb57787aeab4c2613c9d7c89dab
2017-03-01 10:17:15 -05:00
TreeHugger Robot
a7aaae881c Merge "Delete ParcelableString, add StringParceledListSlice" 2017-02-28 22:09:06 +00:00
Edman Anjos
3814d5d021 Merge "Fix is installed check condition in DevicePolicyManagerService" 2017-02-28 19:45:28 +00:00
Robin Lee
abaa0695c5 Delete ParcelableString, add StringParceledListSlice
Both inherit from package private BaseParceledListSlice.

This is still bad, but it's not as bad. The existing code that uses
this can just do Foo.bar().getList() now instead of having to marshal
to and from an oddball type at either end as well.

In the longer term ParceledListSlice<> should be eliminated, but it's
not clear how far into the future that is going to happen.

Test: runtest -x services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: runtest -x core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java
Change-Id: Ie69b96b5215d6e04990f6d31345772cdfee21d78
2017-02-28 18:07:08 +00:00
TreeHugger Robot
8732003f69 Merge "Make IKeyChainAliasCallback oneway" 2017-02-27 16:39:56 +00:00
Robin Lee
3e7cf168a5 Make IKeyChainAliasCallback oneway
So it can be sent from devicepolicymanager (system_server) to keychain
(a system_app) without waiting on the response and having to do
everything in a background thread.

Side-effect: the regular keychain => app callback is slightly more
efficient now too. in case anyone particularly needs blazing fast
private key user selections.

Fix: 35675253
Test: cts-tradefed run cts --abi=arm64-v8a --skip-device-info --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement' </dev/null 2>&1
Change-Id: I6e9d96ca3c42e6489d879d8cfb0507eb94838bf1
2017-02-25 01:32:54 +00:00
TreeHugger Robot
ab6798951a Merge "Fix broken RestrictedLockUtils KeyGuard APIs" 2017-02-24 19:29:48 +00:00
Edman Anjos
0423b8f72f Fix is installed check condition in DevicePolicyManagerService
DPMS#setDelegatedScopes generally enforces the delegate is installed in
the device, but this check should be skipped on DELEGATION_CERT_INSTALL
scopes on pre-N. Additionally the check is also skipped when clearing up
delegations on pre-N. The check was extracted to a separate function for
clarity.

Bug: 35234284
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.ProfileOwnerTestApi23#testDelegatedCertInstaller
Change-Id: Ib723b58243f901af907e368017b1ae0bb101360d
2017-02-24 15:53:12 +01:00
Robin Lee
acdeac6809 Fix broken RestrictedLockUtils KeyGuard APIs
They were all broken in that they returned profile admins for parent
queries even when they clearly shouldn't.

Examples:
 - disable unredacted notifications
 - disable fingerprint

This doesn't seem to have been tested beyond the bare basics of one
user with one device admin. Added some reasonable coverage. It could
still do with more.

Test: make RunSettingsLibRoboTests
Bug: 34929375
Change-Id: I1b0e986056ffa62d47091c0010977ac810ebd690
2017-02-22 17:39:34 +00:00
Suprabh Shukla
0b1356ff1f Fix 'Modifying dpm.setSecureSetting call for install_non_market_apps'
The previous change was reverted as it broke work profile provisioning.
Clearing binder calling identity before calling into settings provider
should fix the issue.

Test: runtest managed-provisioning
Test: runtest -x services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: Manually tested that work profile is inflated with expected values
of install_non_market_apps

Bug: 33947615
Bug: 35590590

Change-Id: I3c31a73fef0c25c0e682e18f637272adad39b28d
2017-02-21 18:36:28 -08:00
Victor Chang
5663e05109 Revert "Modifying dpm.setSecureSetting call for install_non_market_apps"
This reverts commit 2e7d6d64b9b16ea27634bc0e8843717a465142b4.

Bug: 35590590
Fix: 35590106
Test: runtest managed-provisioning
Test: manual verified that work profile can be inflated
Change-Id: Ie780b94053e65bca2f96b32055937c0c9e8beae8
2017-02-20 17:00:58 +00:00
TreeHugger Robot
e453d8e762 Merge "Removing unnecessary call to ArraySet#toArray" 2017-02-18 02:48:42 +00:00
Suprabh Shukla
3dea1c7972 Removing unnecessary call to ArraySet#toArray
Iterating over ArraySet using iterators is still more efficient than
first calling ArraySet#toArray and then iterating over the array.

Test: Minor optimization. make and existing tests should suffice.

Change-Id: Ifc282bfca98cf89b047dddddd78a6de020f27381
2017-02-17 16:11:01 -08:00
TreeHugger Robot
dd903d4f0e Merge "Modifying dpm.setSecureSetting call for install_non_market_apps" 2017-02-17 23:05:48 +00:00
Suprabh Shukla
2e7d6d64b9 Modifying dpm.setSecureSetting call for install_non_market_apps
Starting from O, install_non_market_apps is deprecated and will not be
checked by the package installer. Device admin apps should be using the
user restriction instead.
Since on managed profiles, the default value blocked install from
unknown sources, the system will set the user restriction on behalf of
the profile owners (if the profile has one).
For non-managed profiles, the user had access to the settings to change
the value of install_non_market_apps. So going forward, any request to
change it's value by dpm#setSecureSetting in such users is going to be
ignored.

Test: Manually tested that:
1. For a profile with PO, when install_non_market_apps was set to 0,
user restriction is set on upgrade
2. For a profile with PO, when install_non_market_apps was set to 1,
user restriction is not set on upgrade
3. After upgrade, newly created managed profiles with PO have user
restriction set

Bug: 33947615
Change-Id: I063e9ee608b52086ffdf8ed2b24e2928574c58cd
2017-02-17 13:25:14 -08:00
TreeHugger Robot
8c9a6b0089 Merge "Revert "Revert "Per user setting for instant app""" 2017-02-17 20:46:12 +00:00
TreeHugger Robot
a4f3891d28 Merge "Mark clearDeviceOwnerApp/clearProfileOwner as deprecated" 2017-02-17 18:38:36 +00:00
Bartosz Fabianowski
4f7e1fc9af Merge "Add API for checking whether the default IME was set by the DO/PO" 2017-02-17 17:53:02 +00:00
TreeHugger Robot
939ccc3854 Merge "Clear DISALLOW_ADD_USER in clearDeviceOwner for all cases" 2017-02-16 22:08:20 +00:00
Todd Kennedy
be0b8896d1 Revert "Revert "Per user setting for instant app""
This reverts commit be9ffa15af9e1906e9ffb505768328d62d4a3793.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Ib21321cf157a79890de487060a093840f7182047
2017-02-16 12:43:37 -08:00
Victor Chang
348f696d33 Clear DISALLOW_ADD_USER in clearDeviceOwner for all cases
We are not moving the restriction from system to the DO in the end.
clearDeviceOwnerUserRestrictionLocked becomes the permanent solution
for DeviceOwner CTS. Looks like no one setting DISALLOW_ADD_USER
directly in UserManager except DO/PO, and so remove it when DO is
clear

Change-Id: I235bebebd02b5e0d9883eea6dd3a4e49b40fe043
Fix: 33476323
Test: runtest frameworks-services -c com.android.server.devicepolicy.DevicePolicyManagerTest
2017-02-16 20:41:50 +00:00
Esteban Talavera
a5b0963c0c Mark clearDeviceOwnerApp/clearProfileOwner as deprecated
Bug: 33175679
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Change-Id: I05e10638d838ccf8dc67b7a01b3ffeb7cbea8500
2017-02-16 18:47:06 +00:00
Bartosz Fabianowski
aff5e9c21c Add API for checking whether the default IME was set by the DO/PO
With this API, the system can determine whether a user's default
IME was set by the user or the user's DO/PO.

Bug: 32692748
Test: DPMS unit tests and CTS CtsDevicePolicyManagerTestCases

Change-Id: Ibd703ff5c9e4c072599ad8d6023c94a97d728109
2017-02-16 13:07:11 +01:00
Rubin Xu
824b073fbe Merge "Add escrow token API in DevicePolicyManager." 2017-02-16 01:36:46 +00:00
Guang Zhu
626ffb4556 Merge "Revert "Per user setting for instant app"" 2017-02-15 21:47:34 +00:00
Guang Zhu
be9ffa15af Revert "Per user setting for instant app"
Bug: 35390781

This reverts commit 2f5811dcfd840e149851a9333e27ef3cdddf7a46.

Change-Id: Ibb1c8dacbdc6908fc7fa2bc5dca664f2455162bf
2017-02-15 21:43:48 +00:00
Rubin Xu
aab7a4146c 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
2017-02-15 19:54:31 +00:00
Todd Kennedy
bf92b812db Merge "Per user setting for instant app" 2017-02-15 19:19:26 +00:00
Todd Kennedy
2f5811dcfd Per user setting for instant app
The same application can run as either an instant app or an installed
app. Store this setting per-user instead of based upon the install
location.

Bug: 25119046
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Iff565bb1ac10d631499f0bd0f69b401cb073c10e
2017-02-14 13:42:01 -08:00
TreeHugger Robot
f5e107140d Merge "Flush addPersistentPreferredActivity setting in DPMS" 2017-02-14 20:15:34 +00:00
TreeHugger Robot
723eac769e Merge "Use DevicePolicyData#mUserSetupComplete for DPM's isDeviceProvisioned." 2017-02-14 18:47:53 +00:00
Tony Mak
288639860a Flush addPersistentPreferredActivity setting in DPMS
To fix the glitch that "kiosk mode" does not persist if device
is rebooted within 10s after addPersistentPreferredActivity is called.

Test: Manual Test
      1. Using TestDPC to start kisok mode, reboot right away.
      Observed that TestDPC is launched in kiosk mode.
      2. Stop the kiosk mode, reboot without 10s.
         Kisok mode is stopped.

Fix: 28169791

Change-Id: I555fc18efe86380f2e028b698c2bdb01017bf9f5
2017-02-14 18:18:48 +00:00
TreeHugger Robot
a10b057bb8 Merge "MonitoringCertTask no longer relies on software.device_admin" 2017-02-14 15:35:04 +00:00