diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index ac8c89644f951..2ab091444ed8a 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4460,4 +4460,6 @@
Productivity
+
+ Device storage
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 643dd02b54863..15011c856e3c3 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1880,6 +1880,7 @@
+
diff --git a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
index a3837b28b168b..afdec9ffddc32 100644
--- a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
+++ b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
@@ -16,6 +16,7 @@
package com.android.server.storage;
+import android.app.NotificationChannel;
import com.android.server.EventLogTags;
import com.android.server.SystemService;
import com.android.server.pm.InstructionSets;
@@ -140,6 +141,8 @@ public class DeviceStorageMonitorService extends SystemService {
*/
static final String SERVICE = "devicestoragemonitor";
+ private static final String NOTIFICATION_CHANNEL_ID = SERVICE;
+
/**
* Handler that checks the amount of disk space on the device and sends a
* notification if the device runs low on disk space
@@ -365,7 +368,8 @@ public class DeviceStorageMonitorService extends SystemService {
@Override
public void onStart() {
// cache storage thresholds
- final StorageManager sm = StorageManager.from(getContext());
+ Context context = getContext();
+ final StorageManager sm = StorageManager.from(context);
mMemLowThreshold = sm.getStorageLowBytes(DATA_PATH);
mMemFullThreshold = sm.getStorageFullBytes(DATA_PATH);
@@ -378,6 +382,21 @@ public class DeviceStorageMonitorService extends SystemService {
mCacheFileDeletedObserver = new CacheFileDeletedObserver();
mCacheFileDeletedObserver.startWatching();
+ // Ensure that the notification channel is set up
+ NotificationManager notificationMgr =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ PackageManager packageManager = context.getPackageManager();
+ boolean isTv = packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
+
+ int importance = isTv
+ ? NotificationManager.IMPORTANCE_HIGH // Do not change: this is TV-specific
+ : NotificationManager.IMPORTANCE_LOW;
+ notificationMgr.createNotificationChannel(
+ new NotificationChannel(NOTIFICATION_CHANNEL_ID,
+ context.getString(
+ com.android.internal.R.string.device_storage_monitor_notification_channel),
+ importance));
+
publishBinderService(SERVICE, mRemoteService);
publishLocalService(DeviceStorageMonitorInternal.class, mLocalService);
}
@@ -466,7 +485,7 @@ public class DeviceStorageMonitorService extends SystemService {
Intent lowMemIntent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
lowMemIntent.putExtra("memory", mFreeMem);
lowMemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- NotificationManager mNotificationMgr =
+ NotificationManager notificationMgr =
(NotificationManager)context.getSystemService(
Context.NOTIFICATION_SERVICE);
CharSequence title = context.getText(
@@ -488,9 +507,11 @@ public class DeviceStorageMonitorService extends SystemService {
.bigText(details))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setCategory(Notification.CATEGORY_SYSTEM)
+ .setChannel(NOTIFICATION_CHANNEL_ID)
+ .extend(new Notification.TvExtender())
.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
- mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
+ notificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
UserHandle.ALL);
context.sendStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
}