summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author lijilou <lijilou@xiaomi.corp-partner.google.com> 2025-01-24 14:23:41 +0800
committer Jilou li <lijilou@xiaomi.corp-partner.google.com> 2025-02-06 04:33:47 -0800
commitf211b805df218353286799020d1acc3323fec937 (patch)
treeeacb6ea3fd073bb226b57f531d04ea187849086f
parent69c28d692497cb810491b3b0dd373b112e517d74 (diff)
Do not post notification when system boot is not ready.
When the system boot is not ready,receive update port add message from the AIDL/HIDL, but the system_server boot is not ready, so the notification service may not publish. Test: monkey test Flag: EXEMPT bugfix Bug: 391982620 Change-Id: I22f96286f5440b07dbf5470643bd69b6fe878a4f
-rw-r--r--services/usb/java/com/android/server/usb/UsbPortManager.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbPortManager.java b/services/usb/java/com/android/server/usb/UsbPortManager.java
index 55a89239b864..86468b0cf821 100644
--- a/services/usb/java/com/android/server/usb/UsbPortManager.java
+++ b/services/usb/java/com/android/server/usb/UsbPortManager.java
@@ -200,7 +200,11 @@ public class UsbPortManager implements IBinder.DeathRecipient {
mHandler.sendEmptyMessage(MSG_SYSTEM_READY);
}
- private void updateContaminantNotification() {
+ private void updateContaminantNotificationLocked() {
+ if (mNotificationManager == null) {
+ return;
+ }
+
PortInfo currentPortInfo = null;
Resources r = mContext.getResources();
int contaminantStatus = UsbPortStatus.CONTAMINANT_DETECTION_NOT_DETECTED;
@@ -1171,7 +1175,7 @@ public class UsbPortManager implements IBinder.DeathRecipient {
private void handlePortLocked(PortInfo portInfo, IndentingPrintWriter pw) {
sendPortChangedBroadcastLocked(portInfo);
logToStatsd(portInfo, pw);
- updateContaminantNotification();
+ updateContaminantNotificationLocked();
}
private void handlePortAddedLocked(PortInfo portInfo, IndentingPrintWriter pw) {
@@ -1433,6 +1437,9 @@ public class UsbPortManager implements IBinder.DeathRecipient {
case MSG_SYSTEM_READY: {
mNotificationManager = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ synchronized (mLock) {
+ updateContaminantNotificationLocked();
+ }
break;
}
}