Update behavior of some DownloadManager APIs.

-- Update behavior of DownloadManager.setDestinationUri(),
   DownloadManager.setDestinationInExternalPublicDir() and
   DownloadManager.addCompletedDownload() based on the latest
   storage re-design. Essentially, going forward these APIs
   will only allow downloading files into package owned dirs
   or the top-level Download dir.
-- Allow some system components to specify
   MediaColumns.OWNER_PACKAGE_NAME when inserting items into
   MediaProvider.
-- Don't copy DownloadManager.COLUMN_TITLE to MediaProvider.
   DownloadProvider and MediaProvider have different constraints
   around "title" and there isn't really a need to keep these
   in sync.
-- Sanity check file download paths hinted by apps.
-- Remove sandbox related logic in DownloadProvider.

Bug: 120879208
Bug: 128630262
Bug: 130797842

Test: manual
Test: atest DownloadProviderTests
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java
Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*

Change-Id: If48bc9ecf9ed94412c6c62ce4e5e6a55fff9b789
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index dde1e6a..c32c264 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -54,7 +54,6 @@
 
     /** {@hide} */
     public static final String DIR_ANDROID = "Android";
-    private static final String DIR_SANDBOX = "sandbox";
     private static final String DIR_DATA = "data";
     private static final String DIR_MEDIA = "media";
     private static final String DIR_OBB = "obb";
@@ -128,10 +127,6 @@
             return buildPaths(getExternalDirs(), type);
         }
 
-        public File[] buildExternalStorageAndroidSandboxDirs() {
-            return buildPaths(getExternalDirs(), DIR_ANDROID, DIR_SANDBOX);
-        }
-
         public File[] buildExternalStorageAndroidDataDirs() {
             return buildPaths(getExternalDirs(), DIR_ANDROID, DIR_DATA);
         }
@@ -842,15 +837,6 @@
      * Returns the path for android-specific data on the SD card.
      * @hide
      */
-    public static File[] buildExternalStorageAndroidSandboxDirs() {
-        throwIfUserRequired();
-        return sCurrentUser.buildExternalStorageAndroidSandboxDirs();
-    }
-
-    /**
-     * Returns the path for android-specific data on the SD card.
-     * @hide
-     */
     @UnsupportedAppUsage
     public static File[] buildExternalStorageAndroidDataDirs() {
         throwIfUserRequired();
@@ -907,6 +893,12 @@
         return sCurrentUser.buildExternalStorageAppCacheDirs(packageName);
     }
 
+    /** @hide */
+    public static File[] buildExternalStoragePublicDirs(@NonNull String dirType) {
+        throwIfUserRequired();
+        return sCurrentUser.buildExternalStoragePublicDirs(dirType);
+    }
+
     /**
      * Return the download/cache content directory.
      */