From 38338a951d4faf82371fcdd2249fc41f5759385e Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Sun, 15 Dec 2019 22:05:02 -0700 Subject: [PATCH] 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: I6d6da165848b934f4ca7ecfca7b97de6f97897e3 --- android/neverallow.go | 9 +++++++++ android/neverallow_test.go | 13 +++++++++++++ java/config/config.go | 1 + 3 files changed, 23 insertions(+) diff --git a/android/neverallow.go b/android/neverallow.go index 48efb4f9a..4f721611e 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -52,6 +52,7 @@ func init() { AddNeverAllowRules(createTrebleRules()...) AddNeverAllowRules(createLibcoreRules()...) AddNeverAllowRules(createMediaRules()...) + AddNeverAllowRules(createMediaProviderRules()...) AddNeverAllowRules(createJavaDeviceForHostRules()...) } @@ -160,6 +161,14 @@ func createMediaRules() []Rule { } } +func createMediaProviderRules() []Rule { + return []Rule{ + NeverAllow(). + With("libs", "framework-mediaprovider"). + Because("framework-mediaprovider includes private APIs. Use framework_mediaprovider_stubs instead."), + } +} + func createJavaDeviceForHostRules() []Rule { javaDeviceForHostProjectsWhitelist := []string{ "external/guava", diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 6f07a4a73..b57bb3fd6 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -202,6 +202,19 @@ var neverallowTests = []struct { "updatable-media includes private APIs. Use updatable_media_stubs instead.", }, }, + { + name: "dependency on framework-mediaprovider", + fs: map[string][]byte{ + "Android.bp": []byte(` + java_library { + name: "needs_framework_mediaprovider", + libs: ["framework-mediaprovider"], + }`), + }, + expectedErrors: []string{ + "framework-mediaprovider includes private APIs. Use framework_mediaprovider_stubs instead.", + }, + }, { name: "java_device_for_host", fs: map[string][]byte{ diff --git a/java/config/config.go b/java/config/config.go index 8443693a5..88d94113f 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -47,6 +47,7 @@ var ( "core-oj", "core-libart", "updatable-media", + "framework-mediaprovider", "ike", } )