From bf91ebda60d64c1d709431fdf4a6ca5d6fc697d4 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Wed, 14 Jul 2021 15:16:16 +0100 Subject: [PATCH] (Take two) Do not hold lock when calling into NotificationManager setNetworkLoggingActiveInternal() is being called at a few places where lock has already been acquired, so it's not sufficient to just move around NotificationManager calls within setNetworkLoggingActiveInternal. Post those calls to a handler thread as a quick fix for now. Bug: 192435507 Test: atest DeviceOwnerTest#testAdminActionBookkeeping Test: atest DeviceOwnerTest#testNetworkLoggingWithSingleUser Test: atest DeviceOwnerTest#testNetworkLogging_multipleBatches Test: atest DeviceOwnerTest#testNetworkLoggingWithTwoUsers Test: atest DeviceOwnerTest#testNetworkLogging_rebootResetsId Test: atest OrgOwnedProfileOwnerTest#testNetworkLoggingLogged Test: atest OrgOwnedProfileOwnerTest#testNetworkLoggingDelegate Test: atest OrgOwnedProfileOwnerTest#testNetworkLogging Test: atest DeviceOwnerPlusProfileOwnerTest#testNetworkAndSecurityLoggingAvailableIfAffiliated Test: atest MixedDeviceOwnerTest#testDelegation Test: CTSVerifier: Device Owner Tests -> Network Logging U Change-Id: I34d90c933525a9bf31a1ab9a40866006790796ad --- .../server/devicepolicy/DevicePolicyManagerService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index e9babceb87c6d..193d92a3b2ff9 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -15019,10 +15019,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } if (active) { if (shouldSendNotification) { - sendNetworkLoggingNotification(); + mHandler.post(() -> sendNetworkLoggingNotification()); } } else { - mInjector.getNotificationManager().cancel(SystemMessage.NOTE_NETWORK_LOGGING); + mHandler.post(() -> mInjector.getNotificationManager().cancel( + SystemMessage.NOTE_NETWORK_LOGGING)); } }); }