Move MediaStore.java inside APEX boundary.

Recent work has paved the way to get MediaStore.java building against
"core_platform", and this change is actually shifting MediaStore.java
inside the MediaProvider APEX boundary.

This involves defining a new "updatable-mediaprovider" library JAR
and ensuring that it's spliced into classpaths where needed to keep
everything building and working.

Note that the MediaProvider APK itself is still bundled, so we're
manually including the MediaStore.java when building that APK so that
we can continue referencing @hide symbols, but there's a STOPSHIP
comment to remove that once we get the APK building against
"system_current".

Bug: 144247087
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I27ed3fde40751d9ac136a31710c62004b1b8962f
This commit is contained in:
Jeff Sharkey
2019-12-18 14:06:48 -07:00
committed by Jeff Sharkey
parent 8cb0e1cfb7
commit 40182833f7
7 changed files with 32 additions and 3895 deletions

View File

@@ -265,6 +265,7 @@ filegroup {
":framework-sdkext-sources",
":framework-statsd-sources",
":updatable-media-srcs",
":framework-mediaprovider-sources",
":framework-wifi-updatable-sources",
]
}
@@ -380,6 +381,7 @@ java_defaults {
"ext",
"unsupportedappusage",
"updatable_media_stubs",
"framework_mediaprovider_stubs",
],
jarjar_rules: ":framework-jarjar-rules",
@@ -468,6 +470,7 @@ java_library {
static_libs: [
"framework-minus-apex",
"updatable_media_stubs",
"framework_mediaprovider_stubs",
"framework-appsearch", // TODO(b/146218515): should be framework-appsearch-stubs
"framework-sdkext-stubs-systemapi",
// TODO(b/146167933): Use framework-statsd-stubs instead.
@@ -583,11 +586,14 @@ gensrcs {
filegroup {
name: "framework-annotations",
srcs: [
"core/java/android/annotation/NonNull.java",
"core/java/android/annotation/Nullable.java",
"core/java/android/annotation/IntDef.java",
"core/java/android/annotation/IntRange.java",
"core/java/android/annotation/NonNull.java",
"core/java/android/annotation/Nullable.java",
"core/java/android/annotation/RequiresPermission.java",
"core/java/android/annotation/SdkConstant.java",
"core/java/android/annotation/SystemApi.java",
"core/java/android/annotation/TestApi.java",
"core/java/android/annotation/UnsupportedAppUsage.java",
"core/java/com/android/internal/annotations/GuardedBy.java",
"core/java/com/android/internal/annotations/VisibleForTesting.java",
@@ -1648,20 +1654,23 @@ filegroup {
filegroup {
name: "framework-media-annotation-srcs",
srcs: [
":framework-annotations",
"core/java/android/annotation/CallbackExecutor.java",
"core/java/android/annotation/CallSuper.java",
"core/java/android/annotation/DrawableRes.java",
"core/java/android/annotation/IntDef.java",
"core/java/android/annotation/LongDef.java",
"core/java/android/annotation/NonNull.java",
"core/java/android/annotation/Nullable.java",
"core/java/android/annotation/RequiresPermission.java",
"core/java/android/annotation/SdkConstant.java",
"core/java/android/annotation/StringDef.java",
"core/java/android/annotation/SystemApi.java",
"core/java/android/annotation/TestApi.java",
"core/java/android/annotation/UnsupportedAppUsage.java",
"core/java/com/android/internal/annotations/GuardedBy.java",
],
}
filegroup {
name: "framework-mediaprovider-annotation-sources",
srcs: [
":framework-annotations",
"core/java/android/annotation/BytesLong.java",
"core/java/android/annotation/CurrentTimeMillisLong.java",
"core/java/android/annotation/CurrentTimeSecondsLong.java",
"core/java/android/annotation/DurationMillisLong.java",
],
}

View File

@@ -39060,6 +39060,8 @@ package android.provider {
field public static final String GENRE = "genre";
field public static final String HEIGHT = "height";
field public static final String INSTANCE_ID = "instance_id";
field public static final String IS_DOWNLOAD = "is_download";
field public static final String IS_DRM = "is_drm";
field public static final String IS_FAVORITE = "is_favorite";
field public static final String IS_PENDING = "is_pending";
field public static final String IS_TRASHED = "is_trashed";

View File

@@ -7277,8 +7277,12 @@ package android.provider {
}
public final class MediaStore {
method @NonNull public static android.net.Uri rewriteToLegacy(@NonNull android.net.Uri);
method @NonNull public static android.net.Uri scanFile(@NonNull android.content.ContentResolver, @NonNull java.io.File);
method public static void scanVolume(@NonNull android.content.ContentResolver, @NonNull String);
method public static void waitForIdle(@NonNull android.content.ContentResolver);
field public static final String AUTHORITY_LEGACY = "media_legacy";
field @NonNull public static final android.net.Uri AUTHORITY_LEGACY_URI;
}
public abstract class SearchIndexableData {

View File

@@ -1,50 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.provider;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Denotes that a field is a {@link ContentProvider} column. It can be used as a
* key for {@link ContentValues} when inserting or updating data, or as a
* projection when querying.
*
* @hide
*/
@Documented
@Retention(RUNTIME)
@Target({FIELD})
public @interface Column {
/**
* The {@link Cursor#getType(int)} of the data stored in this column.
*/
int value();
/**
* This column is read-only and cannot be defined during insert or updates.
*/
boolean readOnly() default false;
}

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,7 @@ static const char* kPathWhitelist[] = {
"/apex/com.android.conscrypt/javalib/conscrypt.jar",
"/apex/com.android.ipsec/javalib/ike.jar",
"/apex/com.android.media/javalib/updatable-media.jar",
"/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar",
"/apex/com.android.os.statsd/javalib/framework-statsd.jar",
"/apex/com.android.sdkext/javalib/framework-sdkext.jar",
"/apex/com.android.telephony/javalib/telephony-common.jar",

View File

@@ -102,6 +102,9 @@ public class ExternalStorageProvider extends FileSystemProvider {
DocumentsContract.EXTERNAL_STORAGE_PRIMARY_EMULATED_ROOT_ID;
private static final String ROOT_ID_HOME = "home";
private static final String GET_DOCUMENT_URI_CALL = "get_document_uri";
private static final String GET_MEDIA_URI_CALL = "get_media_uri";
private StorageManager mStorageManager;
private UserManager mUserManager;
@@ -665,7 +668,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
}
break;
}
case MediaStore.GET_DOCUMENT_URI_CALL: {
case GET_DOCUMENT_URI_CALL: {
// All callers must go through MediaProvider
getContext().enforceCallingPermission(
android.Manifest.permission.WRITE_MEDIA_STORAGE, TAG);
@@ -684,7 +687,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
throw new IllegalStateException("File in " + path + " is not found.", e);
}
}
case MediaStore.GET_MEDIA_URI_CALL: {
case GET_MEDIA_URI_CALL: {
// All callers must go through MediaProvider
getContext().enforceCallingPermission(
android.Manifest.permission.WRITE_MEDIA_STORAGE, TAG);