bug:3341145 if ignore_size_limits flag set, validate caller's perms
Vasu Nori [Wed, 2 Feb 2011 23:01:41 +0000 (15:01 -0800)]
and then of course ignore the mobile network size limits

Change-Id: I6765be9255187f93bd51acecc19a15db4f324204

src/com/android/providers/downloads/Constants.java
src/com/android/providers/downloads/DownloadInfo.java
src/com/android/providers/downloads/DownloadProvider.java

index ef0c6db..4b95e76 100644 (file)
@@ -31,9 +31,6 @@ public class Constants {
     /** The column that used to be used for the HTTP method of the request */
     public static final String RETRY_AFTER_X_REDIRECT_COUNT = "method";
 
-    /** The column that used to be used for the magic OTA update filename */
-    public static final String OTA_UPDATE = "otaupdate";
-
     /** The column that used to be used to reject system filetypes */
     public static final String NO_SYSTEM_FILES = "no_system";
 
index f375b3f..4647999 100644 (file)
@@ -90,7 +90,7 @@ public class DownloadInfo {
             info.mDescription = getString(Downloads.Impl.COLUMN_DESCRIPTION);
             info.mBypassRecommendedSizeLimit =
                     getInt(Downloads.Impl.COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT);
-            info.mOtaUpdate = getInt(Constants.OTA_UPDATE) == 1;
+            info.mOtaUpdate = getInt(Downloads.Impl.COLUMN_IGNORE_SIZE_LIMITS) == 1;
 
             synchronized (this) {
                 info.mControl = getInt(Downloads.Impl.COLUMN_CONTROL);
index 94b10d5..26b43cd 100644 (file)
@@ -359,7 +359,7 @@ public final class DownloadProvider extends ContentProvider {
                         Downloads.Impl.COLUMN_APP_DATA + " TEXT, " +
                         Downloads.Impl.COLUMN_NO_INTEGRITY + " BOOLEAN, " +
                         Downloads.Impl.COLUMN_FILE_NAME_HINT + " TEXT, " +
-                        Constants.OTA_UPDATE + " BOOLEAN, " +
+                        Downloads.Impl.COLUMN_IGNORE_SIZE_LIMITS + " BOOLEAN, " +
                         Downloads.Impl._DATA + " TEXT, " +
                         Downloads.Impl.COLUMN_MIME_TYPE + " TEXT, " +
                         Downloads.Impl.COLUMN_DESTINATION + " INTEGER, " +
@@ -588,11 +588,15 @@ public final class DownloadProvider extends ContentProvider {
             copyBoolean(Downloads.Impl.COLUMN_ALLOW_ROAMING, values, filteredValues);
         }
 
-        // TODO: replace this hack with something cleaner
-        if (pckg.equals(GSF_PACKAGE_NAME) &&
+        if (values.containsKey(Downloads.Impl.COLUMN_IGNORE_SIZE_LIMITS)) {
+            boolean ignoreLimits = values.getAsBoolean(Downloads.Impl.COLUMN_IGNORE_SIZE_LIMITS);
+            if (ignoreLimits &&
                 (getContext().checkCallingPermission(Downloads.Impl.PERMISSION_ACCESS_ADVANCED)
-                        == PackageManager.PERMISSION_GRANTED)) {
-            filteredValues.put(Constants.OTA_UPDATE, Boolean.TRUE);
+                        != PackageManager.PERMISSION_GRANTED)) {
+                throw new SecurityException("seting ignore_size_limits flag to true NOT allowed, " +
+                        "unless android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED is granted");
+            }
+            filteredValues.put(Downloads.Impl.COLUMN_IGNORE_SIZE_LIMITS, ignoreLimits);
         }
 
         if (Constants.LOGVV) {