diff options
| author | 2021-03-15 14:16:01 +0000 | |
|---|---|---|
| committer | 2021-03-15 14:16:01 +0000 | |
| commit | 10f5e2997a0b14a16081717d99f43253a28b9932 (patch) | |
| tree | 019d130f255c17a35eaf3eea4603c4fd2ac8be85 | |
| parent | e52905994631f3911efb1be42bf4726070ddcb1a (diff) | |
Remove profile owner network logging notification
Notification should only be shown if the
device owner enables network logging, not
the profile owner.
Bug: 181218676
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testNetworkLogging
com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithTwoUsers
atest com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser
Change-Id: Ic088bd9ca9b216aa567bdf8258cb72a913b2a6ed
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index a3dadd835202..6323fd0bc483 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -14668,24 +14668,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { private void sendNetworkLoggingNotificationLocked() { ensureLocked(); - final ActiveAdmin activeAdmin = getNetworkLoggingControllingAdminLocked(); - if (activeAdmin == null || !activeAdmin.isNetworkLoggingEnabled) { + // Send a network logging notification if the admin is a device owner, not profile owner. + final ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked(); + if (deviceOwner == null || !deviceOwner.isNetworkLoggingEnabled) { return; } - if (activeAdmin.numNetworkLoggingNotifications + if (deviceOwner.numNetworkLoggingNotifications >= ActiveAdmin.DEF_MAXIMUM_NETWORK_LOGGING_NOTIFICATIONS_SHOWN) { return; } final long now = System.currentTimeMillis(); - if (now - activeAdmin.lastNetworkLoggingNotificationTimeMs < MS_PER_DAY) { + if (now - deviceOwner.lastNetworkLoggingNotificationTimeMs < MS_PER_DAY) { return; } - activeAdmin.numNetworkLoggingNotifications++; - if (activeAdmin.numNetworkLoggingNotifications + deviceOwner.numNetworkLoggingNotifications++; + if (deviceOwner.numNetworkLoggingNotifications >= ActiveAdmin.DEF_MAXIMUM_NETWORK_LOGGING_NOTIFICATIONS_SHOWN) { - activeAdmin.lastNetworkLoggingNotificationTimeMs = 0; + deviceOwner.lastNetworkLoggingNotificationTimeMs = 0; } else { - activeAdmin.lastNetworkLoggingNotificationTimeMs = now; + deviceOwner.lastNetworkLoggingNotificationTimeMs = now; } final PackageManagerInternal pm = mInjector.getPackageManagerInternal(); final Intent intent = new Intent(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG); @@ -14705,7 +14706,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { .bigText(mContext.getString(R.string.network_logging_notification_text))) .build(); mInjector.getNotificationManager().notify(SystemMessage.NOTE_NETWORK_LOGGING, notification); - saveSettingsLocked(activeAdmin.getUserHandle().getIdentifier()); + saveSettingsLocked(deviceOwner.getUserHandle().getIdentifier()); } /** |