DO NOT MERGE Disable DO single user features when clearDeviceOwner() is called
regardless of the amount of users Bug: 32901196 Bug: 29748723 Change-Id: Ie419b5e496e23656cbe5436942d9aba402bfe68e
This commit is contained in:
@@ -6049,7 +6049,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearDeviceOwnerLocked(ActiveAdmin admin, int userId) {
|
private void clearDeviceOwnerLocked(ActiveAdmin admin, int userId) {
|
||||||
disableDeviceOwnerManagedSingleUserFeaturesIfNeeded();
|
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
admin.disableCamera = false;
|
admin.disableCamera = false;
|
||||||
admin.userRestrictions = null;
|
admin.userRestrictions = null;
|
||||||
@@ -6061,6 +6060,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
mOwners.clearDeviceOwner();
|
mOwners.clearDeviceOwner();
|
||||||
mOwners.writeDeviceOwner();
|
mOwners.writeDeviceOwner();
|
||||||
updateDeviceOwnerLocked();
|
updateDeviceOwnerLocked();
|
||||||
|
disableDeviceOwnerManagedSingleUserFeaturesIfNeeded();
|
||||||
try {
|
try {
|
||||||
if (mInjector.getIBackupManager() != null) {
|
if (mInjector.getIBackupManager() != null) {
|
||||||
// Reactivate backup service.
|
// Reactivate backup service.
|
||||||
@@ -9071,20 +9071,34 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void disableDeviceOwnerManagedSingleUserFeaturesIfNeeded() {
|
private synchronized void disableDeviceOwnerManagedSingleUserFeaturesIfNeeded() {
|
||||||
if (!isDeviceOwnerManagedSingleUserDevice()) {
|
final boolean isSingleUserManagedDevice = isDeviceOwnerManagedSingleUserDevice();
|
||||||
|
|
||||||
|
// disable security logging if needed
|
||||||
|
if (!isSingleUserManagedDevice) {
|
||||||
mInjector.securityLogSetLoggingEnabledProperty(false);
|
mInjector.securityLogSetLoggingEnabledProperty(false);
|
||||||
Slog.w(LOG_TAG, "Security logging turned off as it's no longer a single user device.");
|
Slog.w(LOG_TAG, "Security logging turned off as it's no longer a single user managed"
|
||||||
|
|
||||||
getDeviceOwnerAdminLocked().isNetworkLoggingEnabled = false;
|
|
||||||
saveSettingsLocked(mInjector.userHandleGetCallingUserId());
|
|
||||||
setNetworkLoggingActiveInternal(false);
|
|
||||||
Slog.w(LOG_TAG, "Network logging turned off as it's no longer a single user"
|
|
||||||
+ " device.");
|
+ " device.");
|
||||||
|
}
|
||||||
|
|
||||||
if (mOwners.hasDeviceOwner()) {
|
// disable backup service if needed
|
||||||
|
// note: when clearing DO, the backup service shouldn't be disabled if it was enabled by
|
||||||
|
// the device owner
|
||||||
|
if (mOwners.hasDeviceOwner() && !isSingleUserManagedDevice) {
|
||||||
setBackupServiceEnabledInternal(false);
|
setBackupServiceEnabledInternal(false);
|
||||||
Slog.w(LOG_TAG, "Backup is off as it's a managed device that has more that one user.");
|
Slog.w(LOG_TAG, "Backup is off as it's a managed device that has more that one user.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable network logging if needed
|
||||||
|
if (!isSingleUserManagedDevice) {
|
||||||
|
setNetworkLoggingActiveInternal(false);
|
||||||
|
Slog.w(LOG_TAG, "Network logging turned off as it's no longer a single user managed"
|
||||||
|
+ " device.");
|
||||||
|
// if there still is a device owner, disable logging policy, otherwise the admin
|
||||||
|
// has been nuked
|
||||||
|
if (mOwners.hasDeviceOwner()) {
|
||||||
|
getDeviceOwnerAdminLocked().isNetworkLoggingEnabled = false;
|
||||||
|
saveSettingsLocked(mOwners.getDeviceOwnerUserId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user