Commit Graph

1604 Commits

Author SHA1 Message Date
Lucas Lin
33f340b54a Merge "Change the parameter type from ContentResolver to Context" am: 0aa487570c am: 825bc7bb90
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1639900

Change-Id: I8553f5723308825239a08127ccd5f1cd6f2432f8
2021-03-17 07:20:45 +00:00
lucaslin
7384af3e6b Change the parameter type from ContentResolver to Context
Context is more useful than ContentResolver, it can provide more
information if we want to change the behavior in the future.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
Merged-In: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
2021-03-16 09:26:57 +00:00
Lucas Lin
3373b94c0d Merge "Have a new API to get private DNS mode" am: 179ecda65f am: 114103eaf2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1620860

Change-Id: I5441212823663f02d20cecfbfdba126c8ed6e0de
2021-03-16 08:46:31 +00:00
lucaslin
c4fa37b00b Have a new API to get private DNS mode
- Expose PRIVATE_DNS_MODE_OFF, PRIVATE_DNS_MODE_OPPORTUNISTIC and
PRIVATE_DNS_MODE_PROVIDER_HOSTNAME for external users.
- Since PRIVATE_DNS_DEFAULT_MODE_FALLBACK might be changed from
release to release, so it cannot be exposed as a system API.
Remove PRIVATE_DNS_DEFAULT_MODE_FALLBACK and have a new API -
getPrivateDnsMode() for users to get the private DNS mode instead.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I02a1e91b4eafb5f5df3eada1c07b99849a050c3c
Merged-In: I02a1e91b4eafb5f5df3eada1c07b99849a050c3c
2021-03-12 17:56:09 +08:00
Treehugger Robot
ccef3d8305 Merge "Keystore 2.0: Remove attestKey from KeyChain." am: eb45aabc03 am: c5792c3904
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559810

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie6a096ec2f220c60b27b1e26f81817b00ae6af35
2021-02-24 22:19:42 +00:00
Treehugger Robot
c5792c3904 Merge "Keystore 2.0: Remove attestKey from KeyChain." am: eb45aabc03
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559810

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1a9df17baef8fa083673a2bb2b117fd112f209a4
2021-02-24 21:42:35 +00:00
Janis Danisevskis
0cdf262ee5 Keystore 2.0: Remove attestKey from KeyChain.
KeyChain supports device id attestation through KeyGenParameterSpec now.
No need to call attest key individually. Also calling attest key
individually is no longer supported by Keystore 2.0 and KeyMint.

Also isBoundKeyAlgorithm returns true.

Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Bug: 171305387
Merged-In: I759fe245b48fe435153fded2c74c9ae99634c146
Change-Id: I759fe245b48fe435153fded2c74c9ae99634c146
2021-02-23 14:41:49 -08:00
Xin Li
be473bf819 Merge ab/7061308 into stage.
Bug: 180401296
Merged-In: I4bf82035631ccff6d5a6144d6d9b1d203b076851
Change-Id: I1b5f3a672a55eaabba0f5389bab110b395553559
2021-02-21 09:39:53 -08:00
Treehugger Robot
767bfd30e8 Merge "Stop using ConnectivityManager for VPNs in DPMS." am: 6ec31401b4 am: d083daabf1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1594172

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I59da3b91cce7c5d21220b13a0924526ec7439dac
2021-02-19 09:17:45 +00:00
Lorenzo Colitti
7a7907a46a Stop using ConnectivityManager for VPNs in DPMS.
These methods have all moved to VpnManager.

Test: m
Bug: 173331190
Change-Id: I46d9a7768546139690154b1ee1e1bf716b3a2c17
Merged-In: I46d9a7768546139690154b1ee1e1bf716b3a2c17
2021-02-18 13:19:17 +00:00
Lorenzo Colitti
b79cddd608 Merge "Rename getVpnLockdownWhitelist to -Allowlist" am: e322ecac2c am: 8cec61d86f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1580383

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2a6a2442a6dffe85c6d9f4783438b4a07865fd05
2021-02-15 12:34:36 +00:00
Lorenzo Colitti
30f4fb0bfe Rename getVpnLockdownWhitelist to -Allowlist
Test: m
Change-Id: Id02a37624655c4ff88744c9c57af9f2a17953667
Merged-In: Id02a37624655c4ff88744c9c57af9f2a17953667
2021-02-15 12:04:13 +00:00
Antoan Angelov
4c308df1b4 [RESTRICT AUTOMERGE] Revert "[RESTRICT AUTOMERGE] Remove DPMS#getProfileOwner in favor of getProfileOwnerAsUser" am: c6bda518da
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13462269

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia1a75f3468b7c316fb75dcfa2e270c73ee7a4553
2021-02-05 21:33:47 +00:00
Antoan Angelov
c6bda518da [RESTRICT AUTOMERGE] Revert "[RESTRICT AUTOMERGE] Remove DPMS#getProfileOwner in favor of getProfileOwnerAsUser"
This reverts commit 10f79644fc.

Reason for revert: Explained in b/153995973#comment40

Bug: 153995973

Change-Id: I437400528cb98e9ce665ebc308bfe05f4f24ca13
2021-02-05 11:59:48 +00:00
arangelov
f5a379201d [RESTRICT AUTOMERGE] Remove DPMS#getProfileOwner in favor of getProfileOwnerAsUser am: 10f79644fc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12977405

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I162d5c8dd07adab106ba7c4201d984d98854e111
2021-01-06 17:31:09 +00:00
Alex Kershaw
fb688b44d8 [RESTRICT AUTOMERGE] Make WPMS look for DOs and POs in the correct calling user am: 72704403aa
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13144052

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia9fa890f6b0582997173c9cef54c397c679db23e
2021-01-06 16:00:40 +00:00
Alex Kershaw
72704403aa [RESTRICT AUTOMERGE] Make WPMS look for DOs and POs in the correct calling user
Currently, it will always look in user 0 since it uses the DPM from
mContext, which will always be from user 0 as WPMS is in the system
server process.

Extend DPMI to provide the necessary external helper API. This is
preferable to just using createContextAsUser before getting the DPM
instance since it avoids a second binding.

Fixes: 144048540
Fixes: 172682826
Bug: 153995973
Bug: 174642338
Test: atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testSetWallpaper_disallowed
Change-Id: I52b71000fac31ff6725ddded58206f69b263ae33
(cherry picked from commit 5b36ee3f1d)
2021-01-06 13:08:42 +00:00
Serik Beketayev
40e7949c5f Merge "[Mainline] Migrate ProxyInfo" am: 3c3711dffd am: 5565118666
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1506616

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ica0e0965296e3bf843fa73fc6d687da6a9ae721d
2020-12-25 09:45:54 +00:00
Serik Beketayev
4abaecefc2 [Mainline] Migrate ProxyInfo
Bug: 173455434
Test: atest FrameworksNetTests
Change-Id: I924aed710b62a0c91b888a9e04ac2c90cdfd88d0
2020-12-23 22:15:51 -08:00
Remi NGUYEN VAN
edc6b0fb67 Merge "Split NetworkUtils and NetworkUtilsInternal" am: 3ed4fd3a89 am: 635d60201d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1513140

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7b2eae7f9988ae8fa8c858709cafc17c1420f4b7
2020-12-23 02:07:05 +00:00
Alex Kershaw
2e6c54c293 DO NOT MERGE Correctly reset cross-profile app-op am: f764d9e98f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13236705

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iea45f7508d51a3a2f2a7be513549b2d8d34e1bb9
2020-12-17 17:22:22 +00:00
Alex Kershaw
f764d9e98f DO NOT MERGE Correctly reset cross-profile app-op
Delegate the resetting of the INTERACT_ACROSS_PROFILES app-op to
DevicePolicyManager, which knows whether it should be pre-granted and
knows to apply it equally across all users in the profile group.

Further unit tests for DevicePolicyManagerInternal will be added in
b/175440570 when we have the better infra for that.

The CrossProfileAppsServiceImpl changes look more complex than they are.
They consist of the following:
- Inclusive language changes to 'allowlist'
- Static imports of permissions to improve readability
- Previously, the setInteractAcrossProfilesAppOp method would set the
app-op for every user within the profile group of the 'calling user'.
However, given that we are now exposing this as a server-side internal
API where we need to pass in a user ID (from AppOpsService), we don't
necessarily have the guarantee that the 'calling user' is in the same
profile group. So we split it up: the client-side API and AIDL API still
set the app-op for the calling profile group, whereas the internal API
sets the app-op for every user within the profile group of the provided
user. The changes simply abstract away references to the 'calling user
ID'.

Fixes: 166561076
Bug: 175440570
Test: atest services/robotests/src/com/android/server/pm/CrossProfileAppsServiceImplRoboTest.java --verbose -c
Test: manual
Change-Id: I2181fe66022aaf6c3e6d784c0569d2f41ab66537
(cherry picked from commit d004f41188)
2020-12-17 13:27:34 +00:00
Tobias Thierer
dabbcf5903 Fix DevicePolicyManager.isBackupServiceEnabled() breakage.
http://ag/12885739 introduced a enforceCallingPermission(BACKUP) check
but callers of this API do not hold that permission. This CL fixes
this by changing the check to enforceCallingOrSelfPermission(BACKUP),
and clearing the binder identity in DevicePolicyManagerService, which
makes the system server process the owner of that call.

Bug: 158482162
Bug: 172466964
Test: atest com.android.cts.devicepolicy.{Device,Profile}OwnerTest#testBackupServiceEnabling
Change-Id: I11d863229c4d62a058aaf37446a694b9c73ae5b8
Merged-In: I11d863229c4d62a058aaf37446a694b9c73ae5b8
(cherry picked from commit 630dec9eb4)
2020-12-11 00:55:44 +00:00
Remi NGUYEN VAN
684a7409e6 Split NetworkUtils and NetworkUtilsInternal
NetworkUtils is planned to move to a dedicated JAR for connectivity
classes, while NetworkUtilsInternal would stay in the
frameworks-minus-apex JAR, in the com.android.internal.net package.

Bug: 171540887
Test: m, boots, wifi working
      atest FrameworksNetTests
Change-Id: I3d38d72ad23a4bf84af823c7baeb6fed25c0665f
2020-12-07 19:41:49 +09:00
arangelov
10f79644fc [RESTRICT AUTOMERGE] Remove DPMS#getProfileOwner in favor of getProfileOwnerAsUser
Test: atest DevicePolicyManagerTest
Test: atest CrossProfileAppsTest
Bug: 153995973
Change-Id: I103c45ea61814e476eea197d357ef0ce75edefdc
(cherry picked from commit 790348fbf1)
2020-12-01 20:27:31 +00:00
Jordan Jozwiak
a26bcb66cf Merge "Do not power off display on lockNow() on automotive builds." into rvc-qpr-dev am: cad8a4f55e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13037790

Change-Id: I2eae34c713b8ebc41e7332eca7a89f594da84c59
2020-11-18 18:11:11 +00:00
Felipe Leme
b7c8877ba1 Do not power off display on lockNow() on automotive builds.
Test: manual verification
Fixes: 171517112

Change-Id: I410e06b911b099c0ed4b7b4e3ac493c9a272fa6b
Merged-In: I410e06b911b099c0ed4b7b4e3ac493c9a272fa6b
(cherry picked from commit fc586009b1)
2020-11-11 22:43:19 +00:00
Eran Messeri
bdd52cb48b DO NOT MERGE: Introduce DPMS shim for active DO/PO check
Introduce a shim into DevicePolicyManagerInternal &
DevicePolicyManagerService so that NetworkStatsAccessTest would not
diverge from internal development branches.

The DevicePolicyManagerService refactoring on the internal branch
removed isActiveAdminWithPolicy in favour of isActiveDeviceOwner and
isActiveProfileOwner.

These methods are being made available in AOSP for
NetworkStatsAccessTest.

Bug: 170459325
Test: atest NetworkStatsAccessTest
Change-Id: Ic7e0898989fb8222aaba2b35436765c04eb3250c
2020-11-04 10:07:06 +00:00
Rubin Xu
d40199b5b2 Fix non-inclusive terms in framework device policy logic
Bug: 170188829
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Merged-In: I8b8ab1442c3f592a4e3ce70852025b1b169d5f18
Change-Id: I8b8ab1442c3f592a4e3ce70852025b1b169d5f18
2020-10-08 14:22:47 +00:00
Alex Johnston
302c1fe947 Change behaviour of screen capture disabled
Background
* Historically, when the screen capture disabled
  policy was set on the personal profile, screen
  capture was disabled for the whole device
  (per-device).
* This should be changed to only be disabled in
  the personal profile (per-profile).

Changes
* Renamed DevicePolicyCache methods to setScreenCaptureAllowed
  and isScreenCaptureAllowed
* Added parameter ownerCanAddInternalSystemWindow to
  isScreenCaptureAllowed

Bug: 148453838
Bug: 157035400
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: If1bd68f0ec3e88497c5d3b4382977b526b2364ba
2020-06-18 22:58:28 +01:00
Pierre Barbier de Reuille
9f52188a62 Send MANAGED_PROFILE_* broadcasts to apps with MODIFY_QUIET_MODE.
Allow apps with MODIFY_QUIET_MODE permission to register
broadcast receivers for MANAGED_PROFILE_* in their manifest.

Fixes: 158870146
Test: atest 'com.android.cts.devicepolicy.QuietModeHostsideTest#testBroadcastManagedProfileAvailable_withCrossProfileAppsOp'
Test: atest 'com.android.cts.devicepolicy.QuietModeHostsideTest#testBroadcastManagedProfileAvailable_withoutCrossProfileAppsOp'
Change-Id: I39746c5b3ff3c49f8a903fc52091fcb8d3607c84
(cherry picked from commit cc8b51873b)
2020-06-12 22:44:26 +00:00
Jordan Jozwiak
7048655cbe Merge "DO NOT MERGE - Allow locking with feature or permission" into rvc-dev 2020-06-12 16:21:05 +00:00
TreeHugger Robot
b14310b5ef Merge "Convert personal app suspension on COMP->COPE migration" into rvc-dev 2020-06-11 00:40:28 +00:00
Pavel Grafov
80b763830e Convert personal app suspension on COMP->COPE migration
* if no apps are suspended by the DO prior to migration, nothing
  changes
* if some apps were suspended by the DO and the DPC targets R+
  via DPM.setPackagesSuspended(), this will result in personal
  apps suspended explicitly by the PO DPC as if it called
  DPM.setPersonalAppsSuspended(). The apps will stay suspended.
* if the DPC target SDK is below R, the apps will be unsuspended
  because the DPC won't have a way to unsuspend them. And the
  user will be stuck with suspended apps.

+ when unsuspending apps, don't collect the list of apps subject
  to suspension, but rather unsuspend all that is suspended. It
  is more robust, e.g. when some app stops meeting the
  conditions, e.g. not SMS app anymore.

Bug: 157270093
Test: com.android.server.devicepolicy.DevicePolicyManagerServiceMigrationTest
Test: Manual, with TestDPC, also patching it to target R

Change-Id: I1eba7216dd557c94bef822b77d25b484dfcd6f63
2020-06-10 23:11:01 +01:00
Rubin Xu
1637f34cd5 Load owner info during DevicePolicyManagerSerivce construction
While most of the admin policy (DevicePolicyData) is loaded lazily
wheneve they are read, the list of Device and Profile owners are
currently loaded during PHASE_LOCK_SETTINGS_READY, which means
policy getters relying on the list of owners, for example
isCommonCriteriaModeEnabled, does not work until this boot phase.
It turns out that some other system services (WifiService) will
attempt to read the policy before this boot phase and hence fails.

Fix this by loading the owner info as part of DevicePolicyManagerSerivce
construction, so the info is always available.

Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Test: Set TestDPC as DO, enable Common Criteria mode, add WiFi,
      Check /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
      for the lack of plaintext WiFi PSK.
Test: atest
com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testSecurityLogging
Bug: 157476512

Change-Id: If403cf98574612cb44f7c8a697095276c65087fe
2020-06-04 20:25:30 +01:00
Jordan Jozwiak
9ead5a3c05 DO NOT MERGE - Allow locking with feature or permission
Instead of requiring the DEVICE_ADMIN feature, we accept either
the feature or the appropriate permission.

Bug: 133240910
Test: Manual testing
Verify that API executes when on a device without DEVICE_ADMIN
when the caller has the LOCK_DEVICE permission.

Change-Id: I30bd0dc81d9d7b7ed5503a926066caffb389b9c0
(cherry picked from commit 3cc489b7f3)
2020-06-04 19:21:31 +00:00
Jeff Sharkey
b9a239bef3 Merge changes from topic "apr12" into rvc-dev
* changes:
  Collect NeededUriGrants without holding locks.
  Initial splitting of calculation and grants.
2020-05-30 00:11:42 +00:00
Jeff Sharkey
938089f376 Initial splitting of calculation and grants.
In upcoming changes, we'll need to shift the calculation of needed
permission grants to occur before we acquire any AM/WM locks; we'll
continue to use that calculated list when actually granting.

This change also reduces the surface area of how callers in the
system server interact with Uri permissions to reduce the risk of
accidental misuse.

This is a no-op refactoring.

Bug: 115619667
Test: atest FrameworksServicesTests:com.android.server.uri
Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.AppSecurityTests#testPermissionDiffCert
Change-Id: Ied529156205903f9b02b4265963fdf59f7dd7f92
2020-05-28 18:29:58 -06:00
Eran Messeri
f7fd4fb116 Only notify when admin enables location for the user
Only notify the user when the admin enables location services on their
device, not on every state change.

Prior to this change the user would be notified when the admin disables
location services, with a misleading notification indicating apps now
have location available.

Tested by installing TestDPC, setting it as device owner, then toggling
location on and off and observing user is notified only on turning
location on.
Test both legacy and new method flows.

Bug: 156602188
Test: Manual using TestDPC (see above)
Change-Id: Ia757802bd7da1afeecfd8071598b692c69860c66
2020-05-27 10:59:13 +01:00
TreeHugger Robot
5d6cf38cd1 Merge "Prevent DPCs from requesting INTERACT_ACROSS_PROFILES" into rvc-dev 2020-05-21 16:25:25 +00:00
Alex Johnston
fa6cf17648 Merge "setAutoTimeRequired disabled on managed profile" into rvc-dev 2020-05-21 10:08:51 +00:00
Alex Johnston
67623cf556 setAutoTimeRequired disabled on managed profile
* A security exception should be thrown when
  setAutoTimeRequired is called on a managed profile
* Update javadoc

Bug: 156620695
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetAutoTimeRequired
      atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testSetAutoTimeRequired
      atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testSetAutoTimeRequired
Change-Id: Ifb53c218947f62aa446aa607d3f4eee354586395
2020-05-20 12:50:04 +01:00
Alex Kershaw
e6a81b38d6 Prevent DPCs from requesting INTERACT_ACROSS_PROFILES
Fixes: 156745686
Test: atest
com.android.cts.devicepolicy.CrossProfileAppsPermissionHostSideTest#testCanRequestInteractAcrossProfiles_profileOwner_returnsFalse
Test: atest services/robotests/src/com/android/server/pm/CrossProfileAppsServiceImplRoboTest.java --verbose

Change-Id: Ia72573991ecccd9a9d01285ba55059e7f9ea14b0
2020-05-19 20:34:17 +01:00
Pavel Grafov
dbae26e47c Merge "Use exact date and time instead of "tomorrow" in notification" into rvc-dev 2020-05-18 11:20:33 +00:00
TreeHugger Robot
dca99f9618 Merge "Set explicit target when constructing PendingIntent" into rvc-dev 2020-05-18 08:57:52 +00:00
Rubin Xu
aacf94557d Set explicit target when constructing PendingIntent
PendingIntent as part of a notification can be intercepted by
a malicious app and re-fired with crafted intent arguments.
System server should set explicit target for these intents
to avoid it being fired to other apps with system privilege.

Bug: 155183624
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Test: Set a DO/PO with TestDPC, turn on location, verify notification
      works
Test: set a DO with TestDPC, request remote bugreport and verify
      notifcation works
Change-Id: Ib7d0039c3d07a9d1ccf57e944303353ec9e9b66d
2020-05-15 20:41:23 +01:00
Pavel Grafov
de75560ab3 Use exact date and time instead of "tomorrow" in notification
This helps avoid confusion if the user only sees the notification the
next day.

Bug: 155740352
Test: manual with TestDPC
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: I6c95a6db2e8967eeffa373f96170cd610f13856a
2020-05-14 17:42:01 +01:00
TreeHugger Robot
55bf41c913 Merge "Don't suspend personal SMS app" into rvc-dev 2020-05-12 16:15:14 +00:00
Pavel Grafov
c8d5a68525 Merge "Make getPersonalAppsSuspensionReasons more robust." into rvc-dev 2020-05-11 18:04:12 +00:00
Pavel Grafov
3b4aa554ac Make getPersonalAppsSuspensionReasons more robust.
* Make sure that if the time is rolled back after the deadline
  has been reached, it is not undone. When the deadline is
  reached it is set to -1 which is far in the past, so timezone
  change won't affect it.
* Return sensible value in case when the deadline has just
  expired and the suspension itself hasn't been enacted.
  Previously the deadline expiration wouldn't be reflected until
  mAppsSuspended gets updated after all apps are suspended.
* Update deadline on time changes. This makes it react to time
  changes via adb.
* Additional debug logging to investigate further if the issue
  persists.

Bug: 155878352
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: I6549f76584121df200ace811285e7a358f262869
2020-05-11 17:09:14 +01:00