diff options
| author | 2022-11-14 21:11:33 +0000 | |
|---|---|---|
| committer | 2022-11-14 21:11:33 +0000 | |
| commit | 82c27e6ac080342d1d04efc5fcb4d19e1822f04d (patch) | |
| tree | 55207a57bc6e2d52610eda0e68e7058e389d43cc | |
| parent | 80c690554a9dc6aa01245d4c769785c2518324e8 (diff) | |
| parent | 7ed0d6ad8b002f2bdf9537365005b3f7091ccc34 (diff) | |
Merge "Move receiver registration to background thread" into tm-qpr-dev am: e75afe61a2 am: 7ed0d6ad8b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20442059
Change-Id: Ib2669da3495041c3600cb6cca6ca7ae65c90433e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java | 11 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java | 39 |
2 files changed, 37 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java index 25418c3f2105..0664e9f6ac39 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java @@ -17,6 +17,7 @@ package com.android.systemui.dagger; import android.annotation.Nullable; +import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.app.AlarmManager; @@ -69,6 +70,7 @@ import android.os.PowerManager; import android.os.ServiceManager; import android.os.UserManager; import android.os.Vibrator; +import android.os.storage.StorageManager; import android.permission.PermissionManager; import android.safetycenter.SafetyCenterManager; import android.service.dreams.DreamService; @@ -110,6 +112,7 @@ import dagger.Provides; /** * Provides Non-SystemUI, Framework-Owned instances to the dependency graph. */ +@SuppressLint("NonInjectedService") @Module public class FrameworkServicesModule { @Provides @@ -469,7 +472,13 @@ public class FrameworkServicesModule { @Provides @Singleton - static SubscriptionManager provideSubcriptionManager(Context context) { + static StorageManager provideStorageManager(Context context) { + return context.getSystemService(StorageManager.class); + } + + @Provides + @Singleton + static SubscriptionManager provideSubscriptionManager(Context context) { return context.getSystemService(SubscriptionManager.class); } diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java index 3507cb7c40a4..095718bddf97 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java @@ -46,6 +46,7 @@ import com.android.internal.R; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.systemui.CoreStartable; import com.android.systemui.SystemUIApplication; +import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.util.NotificationChannels; @@ -61,15 +62,24 @@ public class StorageNotification implements CoreStartable { private static final String ACTION_SNOOZE_VOLUME = "com.android.systemui.action.SNOOZE_VOLUME"; private static final String ACTION_FINISH_WIZARD = "com.android.systemui.action.FINISH_WIZARD"; private final Context mContext; + private final BroadcastDispatcher mBroadcastDispatcher; // TODO: delay some notifications to avoid bumpy fast operations - private NotificationManager mNotificationManager; - private StorageManager mStorageManager; + private final NotificationManager mNotificationManager; + private final StorageManager mStorageManager; @Inject - public StorageNotification(Context context) { + public StorageNotification( + Context context, + BroadcastDispatcher broadcastDispatcher, + NotificationManager notificationManager, + StorageManager storageManager + ) { mContext = context; + mBroadcastDispatcher = broadcastDispatcher; + mNotificationManager = notificationManager; + mStorageManager = storageManager; } private static class MoveInfo { @@ -168,17 +178,22 @@ public class StorageNotification implements CoreStartable { @Override public void start() { - mNotificationManager = mContext.getSystemService(NotificationManager.class); - - mStorageManager = mContext.getSystemService(StorageManager.class); mStorageManager.registerListener(mListener); - mContext.registerReceiver(mSnoozeReceiver, new IntentFilter(ACTION_SNOOZE_VOLUME), - android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null, - Context.RECEIVER_EXPORTED_UNAUDITED); - mContext.registerReceiver(mFinishReceiver, new IntentFilter(ACTION_FINISH_WIZARD), - android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null, - Context.RECEIVER_EXPORTED_UNAUDITED); + mBroadcastDispatcher.registerReceiver( + mSnoozeReceiver, + new IntentFilter(ACTION_SNOOZE_VOLUME), + null, + null, + Context.RECEIVER_EXPORTED_UNAUDITED, + android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS); + mBroadcastDispatcher.registerReceiver( + mFinishReceiver, + new IntentFilter(ACTION_FINISH_WIZARD), + null, + null, + Context.RECEIVER_EXPORTED_UNAUDITED, + android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS); // Kick current state into place final List<DiskInfo> disks = mStorageManager.getDisks(); |