summaryrefslogtreecommitdiff
path: root/mime/Android.bp
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2019-08-18 15:19:45 +0100
committerTobias Thierer <tobiast@google.com>2019-09-27 16:53:15 +0100
commit878c77b70478463757b59e7c2719cc62f6604177 (patch)
tree77fff3dde2dc8d0d7b4d854c5630586e9473bd4e /mime/Android.bp
parent52efd46075d7f64da9d46de121a0cf6f93e4a7a1 (diff)
Move default MimeMap implementation to frameworks.
This is the second attempt to submit this CL. The first attempt regressed on app startup because RuntimeInit installed the custom MimeMap from commonInit() which runs post-fork of the zygote, but that was fixed by installing it pre-fork. This CL topic moves the default MimeMap implementation to frameworks. Libcore starts with a minimal implementation sufficient to pass CtsLibcoreTestCases, but frameworks can inject the real implementation. Before this CL topic, the data files and logic (MimeMapImpl) were part of core-*.jar on device; after this CL, they instead live in framework.jar. Tests from MimeMapTest that check behavior of that default implementation also move to a non-libcore CTS test. Planned work for follow-up CL: 1. Make CTS more opinionated, with a plan to assert that all of the default mappings are present. How exactly the expectated mapping will be bundled in CTS is still TBD. 2. Add a vendor.mime.types file (defaults to empty) where vendors can add additional mappings; I plan to make it such that mappings in that file are parsed last but never override any earlier mappings, as if each mime type / file extension was prefixed with '?'. 3. Perhaps enforce that public APIs android.webkit.MimeTypeMap and java.net.URLConnection.getFileNameMap() behave consistently with MimeMap.getDefault(). Test: atest CtsLibcoreTestCases Test: atest CtsMimeMapTestCases Test: Checked that CtsLibcoreTestCases still passes on a build that is missing the MimeMap.setDefault() call from RuntimeInit.java. Test: Checked that app startup time does not regress as part of this CL topic - see http://b/136256059#comment17 Bug: 136256059 Change-Id: I716914bf1a7e6205e539f0551f010615dacb17a8
Diffstat (limited to 'mime/Android.bp')
-rw-r--r--mime/Android.bp43
1 files changed, 43 insertions, 0 deletions
diff --git a/mime/Android.bp b/mime/Android.bp
new file mode 100644
index 000000000000..9303755ba73d
--- /dev/null
+++ b/mime/Android.bp
@@ -0,0 +1,43 @@
+// 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.
+
+java_library {
+ name: "mimemap",
+ visibility: [
+ "//cts/tests/tests/mimemap:__subpackages__",
+ "//frameworks/base:__subpackages__",
+ ],
+
+ srcs: [
+ "java/android/content/type/MimeMapImpl.java",
+ ],
+
+ java_resources: [
+ ":debian.mime.types",
+ ":android.mime.types",
+ ],
+
+ sdk_version: "core_platform",
+}
+
+filegroup {
+ name: "android.mime.types",
+ visibility: [
+ "//visibility:private",
+ ],
+ path: "java-res/",
+ srcs: [
+ "java-res/android.mime.types",
+ ],
+}