DO NOT MERGE - Merge Android 13

Bug: 242648940
Merged-In: I367da9ed23c6de012e6b48d6159b68358cdbc908
Change-Id: I3bfbc45209e3d27c5fc2fcb2fc2aca8ea994fb6f
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 43cf258..336b250 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -61,6 +61,7 @@
     <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
     <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS"/>
+    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
 
     <application android:process="android.process.media"
                  android:label="@string/app_label"
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index 224aee4..3377432 100644
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -287,7 +287,8 @@
             }
 
             // Calculate and show progress
-            String remainingText = null;
+            String remainingLongText = null;
+            String remainingShortText = null;
             String percentText = null;
             if (type == TYPE_ACTIVE) {
                 long current = 0;
@@ -315,8 +316,10 @@
 
                     if (speed > 0) {
                         final long remainingMillis = ((total - current) * 1000) / speed;
-                        remainingText = res.getString(R.string.download_remaining,
-                                DateUtils.formatDuration(remainingMillis));
+                        remainingLongText = getRemainingText(res, remainingMillis,
+                            DateUtils.LENGTH_LONG);
+                        remainingShortText = getRemainingText(res, remainingMillis,
+                            DateUtils.LENGTH_SHORTEST);
                     }
 
                     final int percent = (int) ((current * 100) / total);
@@ -337,7 +340,7 @@
                     if (!TextUtils.isEmpty(description)) {
                         builder.setContentText(description);
                     } else {
-                        builder.setContentText(remainingText);
+                        builder.setContentText(remainingLongText);
                     }
                     builder.setContentInfo(percentText);
 
@@ -368,9 +371,9 @@
                 if (type == TYPE_ACTIVE) {
                     builder.setContentTitle(res.getQuantityString(
                             R.plurals.notif_summary_active, cluster.size(), cluster.size()));
-                    builder.setContentText(remainingText);
+                    builder.setContentText(remainingLongText);
                     builder.setContentInfo(percentText);
-                    inboxStyle.setSummaryText(remainingText);
+                    inboxStyle.setSummaryText(remainingShortText);
 
                 } else if (type == TYPE_WAITING) {
                     builder.setContentTitle(res.getQuantityString(
@@ -399,6 +402,11 @@
         }
     }
 
+    private String getRemainingText(Resources res, long remainingMillis, int abbrev) {
+        return res.getString(R.string.download_remaining,
+            DateUtils.formatDuration(remainingMillis, abbrev));
+    }
+
     private static CharSequence getDownloadTitle(Resources res, Cursor cursor) {
         final String title = cursor.getString(UpdateQuery.TITLE);
         if (!TextUtils.isEmpty(title)) {
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index 574b222..32e4dcc 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -171,9 +171,9 @@
                 new ComponentName(context, DownloadJobService.class));
 
         // When this download will show a notification, run with a higher
-        // priority, since it's effectively a foreground service
+        // bias, since it's effectively a foreground service
         if (info.isVisible()) {
-            builder.setPriority(JobInfo.PRIORITY_FOREGROUND_SERVICE);
+            builder.setBias(JobInfo.BIAS_FOREGROUND_SERVICE);
             builder.setFlags(JobInfo.FLAG_WILL_BE_FOREGROUND);
         }