Skip to content

Commit

Permalink
Merge android10-release
Browse files Browse the repository at this point in the history
Change-Id: Ic3495f737d5449fce7d7f1ff5451f0af408b2480
  • Loading branch information
earseneau committed Nov 19, 2019
2 parents 672fe2a + 37a24f5 commit 1a06b5a
Show file tree
Hide file tree
Showing 18 changed files with 1,005 additions and 145 deletions.
42 changes: 22 additions & 20 deletions core/java/android/app/DownloadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public class DownloadManager {
*/
public final static String COLUMN_STATUS = Downloads.Impl.COLUMN_STATUS;

/** {@hide} */
public static final String COLUMN_FILE_NAME_HINT = Downloads.Impl.COLUMN_FILE_NAME_HINT;

/**
* Provides more detail on the status of the download. Its meaning depends on the value of
* {@link #COLUMN_STATUS}.
Expand Down Expand Up @@ -173,6 +176,9 @@ public class DownloadManager {
@TestApi
public static final String COLUMN_MEDIASTORE_URI = Downloads.Impl.COLUMN_MEDIASTORE_URI;

/** {@hide} */
public static final String COLUMN_DESTINATION = Downloads.Impl.COLUMN_DESTINATION;

/**
* @hide
*/
Expand Down Expand Up @@ -340,26 +346,22 @@ public class DownloadManager {
*/
@UnsupportedAppUsage
public static final String[] UNDERLYING_COLUMNS = new String[] {
Downloads.Impl._ID,
Downloads.Impl._DATA + " AS " + COLUMN_LOCAL_FILENAME,
Downloads.Impl.COLUMN_MEDIAPROVIDER_URI,
Downloads.Impl.COLUMN_DESTINATION,
Downloads.Impl.COLUMN_TITLE,
Downloads.Impl.COLUMN_DESCRIPTION,
Downloads.Impl.COLUMN_URI,
Downloads.Impl.COLUMN_STATUS,
Downloads.Impl.COLUMN_FILE_NAME_HINT,
Downloads.Impl.COLUMN_MIME_TYPE + " AS " + COLUMN_MEDIA_TYPE,
Downloads.Impl.COLUMN_TOTAL_BYTES + " AS " + COLUMN_TOTAL_SIZE_BYTES,
Downloads.Impl.COLUMN_LAST_MODIFICATION + " AS " + COLUMN_LAST_MODIFIED_TIMESTAMP,
Downloads.Impl.COLUMN_CURRENT_BYTES + " AS " + COLUMN_BYTES_DOWNLOADED_SO_FAR,
Downloads.Impl.COLUMN_ALLOW_WRITE,
/* add the following 'computed' columns to the cursor.
* they are not 'returned' by the database, but their inclusion
* eliminates need to have lot of methods in CursorTranslator
*/
"'placeholder' AS " + COLUMN_LOCAL_URI,
"'placeholder' AS " + COLUMN_REASON
DownloadManager.COLUMN_ID,
DownloadManager.COLUMN_LOCAL_FILENAME,
DownloadManager.COLUMN_MEDIAPROVIDER_URI,
DownloadManager.COLUMN_DESTINATION,
DownloadManager.COLUMN_TITLE,
DownloadManager.COLUMN_DESCRIPTION,
DownloadManager.COLUMN_URI,
DownloadManager.COLUMN_STATUS,
DownloadManager.COLUMN_FILE_NAME_HINT,
DownloadManager.COLUMN_MEDIA_TYPE,
DownloadManager.COLUMN_TOTAL_SIZE_BYTES,
DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP,
DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR,
DownloadManager.COLUMN_ALLOW_WRITE,
DownloadManager.COLUMN_LOCAL_URI,
DownloadManager.COLUMN_REASON
};

/**
Expand Down
20 changes: 14 additions & 6 deletions core/java/android/app/slice/SliceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ public final String getType(Uri uri) {
@Override
public Bundle call(String method, String arg, Bundle extras) {
if (method.equals(METHOD_SLICE)) {
Uri uri = getUriWithoutUserId(extras.getParcelable(EXTRA_BIND_URI));
Uri uri = getUriWithoutUserId(validateIncomingUriOrNull(
extras.getParcelable(EXTRA_BIND_URI)));
List<SliceSpec> supportedSpecs = extras.getParcelableArrayList(EXTRA_SUPPORTED_SPECS);

String callingPackage = getCallingPackage();
Expand All @@ -369,7 +370,7 @@ public Bundle call(String method, String arg, Bundle extras) {
} else if (method.equals(METHOD_MAP_INTENT)) {
Intent intent = extras.getParcelable(EXTRA_INTENT);
if (intent == null) return null;
Uri uri = onMapIntentToUri(intent);
Uri uri = validateIncomingUriOrNull(onMapIntentToUri(intent));
List<SliceSpec> supportedSpecs = extras.getParcelableArrayList(EXTRA_SUPPORTED_SPECS);
Bundle b = new Bundle();
if (uri != null) {
Expand All @@ -383,24 +384,27 @@ public Bundle call(String method, String arg, Bundle extras) {
} else if (method.equals(METHOD_MAP_ONLY_INTENT)) {
Intent intent = extras.getParcelable(EXTRA_INTENT);
if (intent == null) return null;
Uri uri = onMapIntentToUri(intent);
Uri uri = validateIncomingUriOrNull(onMapIntentToUri(intent));
Bundle b = new Bundle();
b.putParcelable(EXTRA_SLICE, uri);
return b;
} else if (method.equals(METHOD_PIN)) {
Uri uri = getUriWithoutUserId(extras.getParcelable(EXTRA_BIND_URI));
Uri uri = getUriWithoutUserId(validateIncomingUriOrNull(
extras.getParcelable(EXTRA_BIND_URI)));
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
throw new SecurityException("Only the system can pin/unpin slices");
}
handlePinSlice(uri);
} else if (method.equals(METHOD_UNPIN)) {
Uri uri = getUriWithoutUserId(extras.getParcelable(EXTRA_BIND_URI));
Uri uri = getUriWithoutUserId(validateIncomingUriOrNull(
extras.getParcelable(EXTRA_BIND_URI)));
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
throw new SecurityException("Only the system can pin/unpin slices");
}
handleUnpinSlice(uri);
} else if (method.equals(METHOD_GET_DESCENDANTS)) {
Uri uri = getUriWithoutUserId(extras.getParcelable(EXTRA_BIND_URI));
Uri uri = getUriWithoutUserId(
validateIncomingUriOrNull(extras.getParcelable(EXTRA_BIND_URI)));
Bundle b = new Bundle();
b.putParcelableArrayList(EXTRA_SLICE_DESCENDANTS,
new ArrayList<>(handleGetDescendants(uri)));
Expand All @@ -416,6 +420,10 @@ public Bundle call(String method, String arg, Bundle extras) {
return super.call(method, arg, extras);
}

private Uri validateIncomingUriOrNull(Uri uri) {
return uri == null ? null : validateIncomingUri(uri);
}

private Collection<Uri> handleGetDescendants(Uri uri) {
mCallback = "onGetSliceDescendants";
return onGetSliceDescendants(uri);
Expand Down
Loading

0 comments on commit 1a06b5a

Please sign in to comment.