Commit Graph

1435 Commits

Author SHA1 Message Date
Alex Johnston
feff951d37 Add metrics logging for setTime and setTimeZone
Bug: 148841428
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetTime
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetTimeZone

Change-Id: I9588d1259026f7a4c655a10407fbc90dbef309ca
2020-02-06 13:39:06 +00:00
Jonathan Scott
38f9ab54ca Add vendor_cross_profile_apps.xml and hidden API to read them.
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest;
Change-Id: Ie84e7d28ddc9c1f46d33cb4a543b04615b3b26e7
2020-02-03 10:51:33 +00:00
Alex Johnston
05956bd77e Modify setDefaultSmsApplication API
* Introduced new logic that allows the profile owner of an
  organization-owned device (COPE PO) to set the default
  SMS application in the personal profile.
* Modified the API to be callable on the parent profile
  instance if called by the COPE PO.
* When called by the COPE PO, the package provided
  must be a system package, otherwise an IllegalArgument
  Exception is thrown.

Bug: 148060194
Test: atest android.admin.cts.DevicePolicyManagerTest#testSetDefaultSmsApplication_failIfNotDeviceOwner
Change-Id: I5b86b10a13064f4ec852631e19f89a80a104dc2b
2020-01-30 15:51:08 +00:00
Soonil Nagarkar
614210991b Merge "Add DPM API to request location provider enable" 2020-01-24 21:27:31 +00:00
Pavel Grafov
1559c076a3 Merge "Add API to limit maximum time the profile can be turned off." 2020-01-24 13:42:58 +00:00
Pavel Grafov
746e1341c3 Add API to limit maximum time the profile can be turned off.
If this policy is set:
* Whenever work profile gets turned off or system boots, timer is
  started, so theat unless the profile is unlocked in time, apps
  will be suspended.
* when the user is unlocked, alarm is discharged.

Currently there is no upfront warning notification, will be addressed
in a follow-up.

Bug: 143517719
Test: manual, using TestDPC
Change-Id: Ib0f936b6d1414f65ae8c86367b7059c14862827d
2020-01-24 11:50:42 +00:00
Soonil Nagarkar
980ce6a741 Add DPM API to request location provider enable
DPM can currently control the master location toggle, but cannot
influence the behavior of individual providers. This adds an API for
DPM (or other privileged entities) to request a provider to turn itself
on.

Practically, this is necessary to allow DPM to control network location,
which may be gated by additional consents. This change also renames some
internal location code to make clearer the distinction between provider
enabled and provider allowed: enabled = location on && allowed

Bug: 136219903
Test: CTS tests to be added
Change-Id: I05f03c976428f0f5a8a2cf627a84dc9e2baf3e67
2020-01-23 18:06:31 -08:00
TreeHugger Robot
296afcc029 Merge "Expose system update related API to corp-owned managed profile" 2020-01-23 21:41:39 +00:00
Alex Johnston
371edb56f3 Merge "Modify setApplicationHidden and isApplicationHidden APIs" 2020-01-23 18:42:54 +00:00
Rubin Xu
ca00dd4900 Expose system update related API to corp-owned managed profile
Allows profile owner of corporate-owned managed profile to call
the following APIs:
* setSystemUpdatePolicy
* installSystemUpdate

The following APIs can already be called by regular profile owners
so no changes are needed:
* getSystemUpdatePolicy
* getPendingSystemUpdate

Test: atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testSystemUpdatePolicy
Test: atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testInstallUpdate
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSystemUpdatePolicy
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testInstallUpdate
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testInstallUpdateLogged
Bug: 147414327
Change-Id: I7224eb208f665ca7cb301daa7d17cce5126f7858
2020-01-23 17:35:41 +00:00
Alex Johnston
a552dd65fa Modify setApplicationHidden and isApplicationHidden APIs
* Introduced new logic that allows the profile owner of an
  organization-owned device (COPE PO) to hide/unhide system
  apps in the personal profile.
* Modified both APIs to be callable on the parent profile
  instance if called by the COPE PO.
* When called by the COPE PO, the package provided
  must be a system package, otherwise an IllegalArgument
  Exception is thrown.

Bug: 147413198
Test: manual testing
      atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testApplicationHidden
      atest com.android.cts.devicepolicy.ManagedProfileTest#testParentProfileApiDisabled

Change-Id: I4fae8acee9f00e3b9c805f29cf826f917cda6abd
2020-01-23 17:05:58 +00:00
Pavel Grafov
31c7fe0459 Merge "Add DPM methods to allow org owned PO to suspend personal apps" 2020-01-23 15:22:45 +00:00
Eran Messeri
d474dcd54f Merge "Prevent auto-granting of location permission via DPM" 2020-01-23 14:38:56 +00:00
Pavel Grafov
499f005e3d Add DPM methods to allow org owned PO to suspend personal apps
* When personal apps are suspended, only dialer, IMEs, a11y, launcher
  are some other critical apps are exempted.
* User is presented with notification, clicking on which invokes an
  activity in the DPC.

Bug: 147414651
Test: manual via TestDPC
Change-Id: I09f8dad08e54b0ce8201cd5c76b3f34342e0da8f
2020-01-23 13:33:39 +00:00
Mathew Inwood
996edee3eb Merge "Fix some @link tags in @ChangeId docs." 2020-01-22 15:36:00 +00:00
Alex Kershaw
4b0197d8ba Reset unset app-ops when the admin sets cross-profile packages.
When the admin unsets cross-profile packages, reset the
INTERACT_ACROSS_PROFILES app-op back to the default if it is no longer
configurable by the user.

Other minor changes:
- Remove the explicit app-op permission check from
setInteractAcrossProfilesAppOp, since AppOpManager performs that check
when required.
- Fix the broadcasting logic in CrossProfileAppsServiceImpl to correctly
set the component and flags.

Bug: 136249261
Bug: 148010178
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.ManagedProfileCrossProfileTest
Change-Id: Ib8b5f331fb92fc475bc95ad039adf93fac04da37
2020-01-22 13:20:24 +00:00
Yvonne Jiang
b7024a251c Adding API for displaying a DO/PO controlled secondary lock screen post initial system lock screen.
The new DPM API allows DP/POs to set whether the keyguard needs to show a secondary lockscreen after the primary locking mechanism is dismissed. If enabled, the keyguard will check for a service handling ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE and request the secondary lockscreen content from it.

Bug: 136085151
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Test: atest KeyguardUpdateMonitorTest
Test: atest AdminSecondaryLockScreenControllerTest
Change-Id: If82921b4fc2d78c0522a20ef91b48f9a93dd8b61
2020-01-21 15:52:57 -08:00
Alex Kershaw
4c6d714539 Merge "Add a checks for _ACROSS_PROFILES apppop or permission." 2020-01-21 22:06:36 +00:00
Alex Johnston
35a650b9fd Merge "Add new APIs to control modification of admin configured networks" 2020-01-21 18:33:02 +00:00
Alex Johnston
f13a6fb624 Add new APIs to control modification of admin configured networks
* Historically, only the device owner could prevent the user from modifying
  networks that have been configured by the device owner.
* In New COPE mode, the COPE profile owner should now be able to prevent the
  user from modifying networks as well as the device owner.
* This CL adds new APIs which are callable by the device owner or profile
  owner of an organization-owned managed profile. These new API can be used
  to toggle the global setting WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, instead of
  setting the global setting directly.
* This CL only affects networks configured by the admin, is does not prevent
  the user from creating more network configurations.

Bug: 147476790
Test: manual testing with TestDPC
      atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAdminConfiguredNetworks
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testAdminConfiguredNetworks

Change-Id: Ia16e639922bb08cdacd9a3766d978ac150b693c5
2020-01-21 15:51:47 +00:00
kholoud mohamed
79a89f022d Add a checks for _ACROSS_PROFILES apppop or permission.
Use hasPermissionOrAppOpForPreflight to check for
INTERACT_ACROSS_PROFILES permission or appop rather than only
checking for the permission.

BUG: 140728653
BUG: 136249261
Test: atest CrossProfileAppsPermissionHostSideTest
Test: atest CrossProfileAppsHostSideTest
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Test: atest ContextCrossProfileHostTest
Change-Id: I81d428d47afd54f294ef9bb44133004762840d09
2020-01-21 14:28:46 +00:00
Eran Messeri
cc5d11e8bb Prevent auto-granting of location permission via DPM
Prevent the device policy client from granting the location permission
via explicit grant (setPermissionGrantState).

Unless on a managed, unattended kiosk device, the user has to explicitly
grant location-related permissions.

Location-related permissions can still be denied automatically.

Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testLocationPermissions
Bug: 147650798
Change-Id: I5a1099a15b94a287414e42e174735dc87f930c6f
2020-01-21 13:58:50 +00:00
Valentin Iftime
89df4c8d17 Change some UserManager APIs to @SystemApi
Added @SystemApi to all APIs currently used by TvProfileService that were @hide only.

Bug: 139914710
Test: Apps built with stable_system or experimental_system can use the APIs
Change-Id: I3499244b4d545a7a9401c7941663045bcd89c6fe
2020-01-20 09:39:40 +01:00
Pavel Grafov
522853818d Fix NPE during migration.
User restrictions are null for PO parent admin, so we need to ensure
they are initialized before adding.

Bug: 147884539
Test: atest com.android.server.devicepolicy.DevicePolicyManagerServiceMigrationTest#testCompMigrationAffiliated
Change-Id: I5024ac585e30081f944717cfe8d4b920b644213e
2020-01-17 18:28:59 +00:00
TreeHugger Robot
4b08336289 Merge "Put getActiveAdminForCallerLocked call into synchronized block." 2020-01-17 13:32:43 +00:00
Mathew Inwood
12be21dc21 Fix some @link tags in @ChangeId docs.
We now have javadoc based docs generated from these comments now. Ensure
the links can be resolved.

Bug: 144927670
Test: Test: m -j offline-sdk-docs
Change-Id: Ie9827ad02ad91ab7f01226a3a741c94fa46de730
2020-01-17 11:29:23 +00:00
Rubin Xu
41bdd9713d Add device policy API to toggle Common Criteria mode
Common Criteria mode puts device into a state where certain
funtionalities are tuned or turned on to meet the higher security
requirement from Common Criteria certification. Device Owner
can use the new device policy API to toggle Common Criteria mode.

Bug: 137937540
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Test: atest SettingsProviderTest
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testCommonCriteriaMode
Test: atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testCommonCriteriaMode
Change-Id: If07c053437e980ed3317d3838cc74e5bfd44efce
2020-01-17 10:20:21 +00:00
Pavel Grafov
c770487161 Put getActiveAdminForCallerLocked call into synchronized block.
Test: compiles
Bug: 147811995
Change-Id: I2e714dd685ad22b512ec127608c693d9ac95d3e6
2020-01-16 18:17:52 +00:00
Pavel Grafov
864d7e5675 Merge "Migrate COMP to PO on corp owned device on boot." 2020-01-16 17:09:10 +00:00
Alex Johnston
01cfbacc93 Merge "Refactor DPMS security check" 2020-01-16 09:46:22 +00:00
TreeHugger Robot
a98a0c6f46 Merge "Make the method for finding out if a device is org-owned public." 2020-01-16 01:58:08 +00:00
Pavel Grafov
72451325a2 Migrate COMP to PO on corp owned device on boot.
When the syste boots, check if the device is in COMP mode and if it is:
  * Mark PO as PO on corp owned device.
  * Migrate policies from from DO admin to PO parent instance:
    * password, timeout, keyguard related policies
    * camera, screenshot
    * accounts types with management disabled
    * support messages
    * applicable user restrictions
  * Clears DO and disables it as device admin.

Two new unit tests verify that the decision whether to migrate or not is made
correctly and that after the migrateion DO ceases to be device admin.

Test: atest com.android.server.devicepolicy.DevicePolicyManagerServiceMigrationTest
Bug: 143516163
Change-Id: I9131fb35da0f78066a662eed9c00207a5a923352
2020-01-15 18:06:00 +00:00
Alex Johnston
988f28b668 Refactor DPMS security check
Refactored enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned in DPMS

Bug: 145286957
Test: Manual testing
      atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetAutoTimeZone
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetAutoTime
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testSetTime
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testSetTimeZone

Change-Id: Id75b60bec3ed5aedc2ccd1dcf39142cb5d8ff2e9
2020-01-15 14:39:26 +00:00
Eran Messeri
41c2aed9c1 Make the method for finding out if a device is org-owned public.
Make isOrganizationOwnedDeviceWithManagedProfile a public method, as
there is no reason to keep this information hidden from apps.

Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedDeviceOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
Bug: 143518237
Bug: 144978467
Bug: 147340575
Bug: 146123237
Change-Id: Iab45f20c9150a6b8bd48eea610484f36f199d3d7
2020-01-15 14:26:48 +00:00
Pavel Grafov
2f44f8fe3c Clear calling identity before calling into UserManager
Currently "adb shell dpm set-profile-owner" fails because shell
lacks MANAGE_USERS.

Bug: 147655081
Test: atest ManagedProfileTest
Change-Id: I2d09d6bd9f95b63cc4d124363aaabff7d5f63c64
2020-01-14 12:56:10 +00:00
Eran Messeri
3662019068 Merge "Disable provisioning in COMP mode" 2020-01-14 07:22:57 +00:00
TreeHugger Robot
83a1f6a98c Merge "Add new Factory reset protection policy APIs" 2020-01-13 19:21:11 +00:00
Eran Messeri
6ad0e194d7 Disable provisioning in COMP mode
Restrict adding a managed profile when the device has a device owner.

This mode is no longer supported, in favour of Corporate Owned,
Personally Enabled mode (Organization-Owned device with Managed Profile).

The restriction on adding managed profiles is now added by default when
a device owner is set, and is removed when the device owner is removed,
to avoid other system copoments from creating a managed profile when
there's a device owner.

Additionally, the method for checking whether pre-provisioning
conditions are met has been modified to return an error if the
restriction is set.

Bug: 145271440
Test: atest FrameworksServicesTests:DevicePolicyManagerTest

Change-Id: Ife25f4e2faffe84d85ab7786407c14997b4cf069
2020-01-13 14:56:33 +00:00
Alex Johnston
011f5c6ea5 Add new Factory reset protection policy APIs
Historically, FRP behaviour was built on top of the application restrictions
infrastructure. This CL introduces new behaviour, as the profile owner of an
organization-owned device needs to be able to control FRP behaviour and
cannot set application restrictions on user 0.

- Introduced a new FactoryResetProtectionPolicy object
  - Added it as a field to ActiveAdmin
  - Created a default value
- Added setFactoryResetProtectionPolicy to DPM which is used to set a
  factory reset protection policy. If the policy is null, the current
  policy is cleared and set back to the default value.
- Added getFactoryResetProtectionPolicy to DPM to retrieve the current
  factory reset protection policy. If this is the default value, then
  no policy is set.
- Both these APIs are callable by the device owner or profile owner of
  an organization-owned device.

Bug: 143517230
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.server.devicepolicy.FactoryResetProtectionPolicyTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testFactoryResetProtectionPolicy
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testFactoryResetProtectionPolicy

Change-Id: I72c4d06ec8a27741a1956d082969573077937726
2020-01-13 10:55:28 +00:00
Yanli Wan
0c581ec46d Merge "Add support to start financed device provisioning" 2020-01-11 05:24:17 +00:00
Yanli Wan
01c9255ec4 Add support to start financed device provisioning
* Add intent action used to trigger financed device provisioning
* Add financed device provisioning precondition check

Bug: 135486391
Test: atest DevicePolicyManagerTest
Change-Id: Id0f65816026cd195481022b6b75c3232996ec6e7
2020-01-10 16:14:57 -08:00
kholoud mohamed
946df39c29 Add can interact/request to interact across profiles APIs
Add CrossProfileApps#canRequestInteractAcrossProfiles,
and CrossProfileApps#canInteractAcrossProfiles public APIs.
This provides apps the ability to check if they can interact across profiles,
or can they request that from the user if not.

BUG: 136249261
Test: in progress

Change-Id: Ifd561d5d5efcd167e24a5f05c22496d1fe9c81fc
2020-01-09 16:01:45 +00:00
Eran Messeri
76a011ba2a Merge "DPM: Add method for Organization-owned device detection" 2020-01-08 19:35:46 +00:00
TreeHugger Robot
e13ef94a6a Merge "Fix bug in getProfileOwnerAdminsForCurrentProfileGroup" 2020-01-08 16:43:14 +00:00
Eran Messeri
a1015c8c95 DPM: Add method for Organization-owned device detection
Add a method to the DevicePolicyManager for finding out if the device is
an organization-owned device with a work profile (i.e. it has a work
profile but the work profile was created during the provisioning flow).

This method is currently available for privileged callers (system API),
since other methods (e.g. isDeviceManaged) are also restricted.

NOTE: Addition of GTS tests is pending final decision on whether this
will be public API or not.

Bug: 143518237
Bug: 144978467
Bug: 147340575
Test: atest FrameworksServicesTests:DevicePolicyManagerTest#testIsOrganizationOwnedDevice
Test: CTS tests that are on hold for now.

Change-Id: I26ce1de10844dc297924427a6d46df9208931ab0
2020-01-08 16:02:44 +00:00
kholoud mohamed
d59513f9ec Fix bug in getProfileOwnerAdminsForCurrentProfileGroup
Fixing a bug in ag/9885696.
Changed to get the active admin for the current user rather
than the calling user.

BUG: 136249261
Test: atest CrossProfileAppsPermissionHostSideTest
Change-Id: I847056b4dbca215438a9856c456d6042ea4fa891
2020-01-08 12:10:01 +00:00
Srinivas Paladugu
edfdd4153a Merge "Add new dpm api to disable user control over apps" 2020-01-08 01:32:55 +00:00
TreeHugger Robot
e131981931 Merge "Log to SecurityLog if camera is disabled by admin" 2020-01-07 14:00:28 +00:00
Eran Messeri
f3825c3b5d Merge "Rename canProfileOwnerAccessDeviceIds" 2020-01-07 13:15:48 +00:00
Kholoud Mohamed
b848a1017c Merge "Add default cross-profile package APIs" 2020-01-07 11:29:09 +00:00