Snap for 8564071 from ad80b2da67a894127e7ec7c48b54154b238e35cd to mainline-resolv-release

Change-Id: Icd9692d50b87a4a7cd8b022c97336b974d8f4c4c
diff --git a/Android.bp b/Android.bp
index 106ed1e..710f038 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,22 +14,8 @@
 //
 
 package {
-    default_applicable_licenses: [
-        "packages_providers_DownloadProvider_license",
-    ],
-}
-
-// Added automatically by a large-scale-change
-// See: http://go/android-license-faq
-license {
-    name: "packages_providers_DownloadProvider_license",
-    visibility: [":__subpackages__"],
-    license_kinds: [
-        "SPDX-license-identifier-Apache-2.0",
-    ],
-    license_text: [
-        "NOTICE",
-    ],
+    // See: http://go/android-license-faq
+    default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
 android_app {
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/res/values-pa/strings.xml b/res/values-pa/strings.xml
index da877cf..8138364 100644
--- a/res/values-pa/strings.xml
+++ b/res/values-pa/strings.xml
@@ -41,7 +41,7 @@
     <string name="wifi_recommended_body" msgid="8710820743211704403">"ਹੁਣ ਇਸ <xliff:g id="SIZE">%1$s </xliff:g> ਡਾਊਨਲੋਡ ਨੂੰ ਚਾਲੂ ਕਰਨ ਨਾਲ ਤੁਹਾਡੀ ਬੈਟਰੀ ਸਮਰੱਥਾ ਘੱਟ ਸਕਦੀ ਹੈ ਅਤੇ/ਜਾਂ ਇਸਦੇ ਸਿੱਟੇ ਵਜੋਂ ਤੁਹਾਡੇ ਮੋਬਾਈਲ ਡਾਟਾ ਕਨੈਕਸ਼ਨ ਦੀ ਵਾਧੂ ਵਰਤੋਂ ਹੋ ਸਕਦੀ ਹੈ, ਜਿਸ ਨਾਲ ਤੁਹਾਡੇ ਡਾਟਾ ਪਲਾਨ ਦੇ ਆਧਾਰ ਤੇ ਤੁਹਾਡੇ ਮੋਬਾਈਲ ਓਪਰੇਟਰ ਵੱਲੋਂ ਖਰਚੇ ਪਾਏ ਜਾ ਸਕਦੇ ਹਨ।\n\n ਅਗਲੀ ਵਾਰ ਜਦੋਂ ਤੁਸੀਂ ਇੱਕ ਵਾਈ-ਫਾਈ ਨੈੱਟਵਰਕ ਨਾਲ ਕਨੈਕਟ ਕਰੋ ਤਾਂ ਇਸ ਡਾਊਨਲੋਡ ਨੂੰ ਚਾਲੂ ਕਰਨ ਲਈ <xliff:g id="QUEUE_TEXT">%2$s</xliff:g> ਨੂੰ ਸਪੱਰਸ਼ ਕਰੋ।"</string>
     <string name="button_queue_for_wifi" msgid="6650185573566994738">"ਕਤਾਰ"</string>
     <string name="button_cancel_download" msgid="4135046775536601831">"ਰੱਦ ਕਰੋ"</string>
-    <string name="button_start_now" msgid="3817100969365441730">"ਹੁਣ ਚਾਲੂ ਕਰੋ"</string>
+    <string name="button_start_now" msgid="3817100969365441730">"ਹੁਣੇ ਸ਼ੁਰੂ ਕਰੋ"</string>
     <plurals name="notif_summary_active" formatted="false" msgid="8652501374845637331">
       <item quantity="one"><xliff:g id="NUMBER">%d</xliff:g> ਫ਼ਾਈਲਾਂ ਡਾਊਨਲੋਡ ਹੋ ਰਹੀਆਂ ਹਨ</item>
       <item quantity="other"><xliff:g id="NUMBER">%d</xliff:g> ਫ਼ਾਈਲਾਂ ਡਾਊਨਲੋਡ ਹੋ ਰਹੀਆਂ ਹਨ</item>
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/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 00fa30a..c43280d 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -295,7 +295,7 @@
 
             // Network traffic on this thread should be counted against the
             // requesting UID, and is tagged with well-known value.
-            TrafficStats.setThreadStatsTag(TrafficStats.TAG_SYSTEM_DOWNLOAD);
+            TrafficStats.setThreadStatsTagDownload();
             TrafficStats.setThreadStatsUid(mInfo.mUid);
 
             executeDownload();
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);
         }
 
diff --git a/tests/Android.bp b/tests/Android.bp
index d0ba0a5..481e617 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -15,13 +15,7 @@
 
 package {
     // See: http://go/android-license-faq
-    // A large-scale-change added 'default_applicable_licenses' to import
-    // all of the 'license_kinds' from "packages_providers_DownloadProvider_license"
-    // to get the below license kinds:
-    //   SPDX-license-identifier-Apache-2.0
-    default_applicable_licenses: [
-        "packages_providers_DownloadProvider_license",
-    ],
+    default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
 android_test {
diff --git a/tests/permission/Android.bp b/tests/permission/Android.bp
index a96621f..7136f2c 100644
--- a/tests/permission/Android.bp
+++ b/tests/permission/Android.bp
@@ -15,13 +15,7 @@
 
 package {
     // See: http://go/android-license-faq
-    // A large-scale-change added 'default_applicable_licenses' to import
-    // all of the 'license_kinds' from "packages_providers_DownloadProvider_license"
-    // to get the below license kinds:
-    //   SPDX-license-identifier-Apache-2.0
-    default_applicable_licenses: [
-        "packages_providers_DownloadProvider_license",
-    ],
+    default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
 android_test {
diff --git a/tests/public_api_access/Android.bp b/tests/public_api_access/Android.bp
index 3d2cd98..5975ed2 100644
--- a/tests/public_api_access/Android.bp
+++ b/tests/public_api_access/Android.bp
@@ -15,13 +15,7 @@
 
 package {
     // See: http://go/android-license-faq
-    // A large-scale-change added 'default_applicable_licenses' to import
-    // all of the 'license_kinds' from "packages_providers_DownloadProvider_license"
-    // to get the below license kinds:
-    //   SPDX-license-identifier-Apache-2.0
-    default_applicable_licenses: [
-        "packages_providers_DownloadProvider_license",
-    ],
+    default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
 android_test {
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index f45e102..d36635a 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -18,7 +18,6 @@
 
 import static android.app.DownloadManager.STATUS_FAILED;
 import static android.app.DownloadManager.STATUS_PAUSED;
-import static android.net.TrafficStats.GB_IN_BYTES;
 import static android.text.format.DateUtils.SECOND_IN_MILLIS;
 
 import static org.mockito.Matchers.anyInt;
@@ -71,6 +70,7 @@
 public class PublicApiFunctionalTest extends AbstractPublicApiTest {
     private static final String REDIRECTED_PATH = "/other_path";
     private static final String ETAG = "my_etag";
+    private static final long GB_IN_BYTES = 1024 * 1024 * 1024;
 
     protected File mTestDirectory;
     private NotificationManager mNotifManager;
diff --git a/ui/Android.bp b/ui/Android.bp
index 04606c2..b8bea03 100644
--- a/ui/Android.bp
+++ b/ui/Android.bp
@@ -15,13 +15,7 @@
 
 package {
     // See: http://go/android-license-faq
-    // A large-scale-change added 'default_applicable_licenses' to import
-    // all of the 'license_kinds' from "packages_providers_DownloadProvider_license"
-    // to get the below license kinds:
-    //   SPDX-license-identifier-Apache-2.0
-    default_applicable_licenses: [
-        "packages_providers_DownloadProvider_license",
-    ],
+    default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
 android_app {