summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2019-04-29 12:14:57 +0100
committerTobias Thierer <tobiast@google.com>2019-05-11 00:37:35 +0100
commit01ee319530fdf6e2f7c74826bd16f9830f4fff79 (patch)
tree4371bf665700e70553efcb614d0af76ebf3b9561
parent14ee0b7d5c6b51d119d2e80074610dbd0247167c (diff)
Customizable MIME type <-> file extension mapping, step 3 (attempt #2).
This is attempt #2 to submit this CL. The first attempt failed because some usages of MimeUtils had remained in the downstream -plus-aosp branch. These are now cleaned up by cherry-picking the corresponding internal master changes to that branch. Delete unused class MimeUtils. Some MimeUtils calls used to be on the graylist and used by some apps through reflection; such apps can instead use this public API, for now: android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(String) android.webkit.MimeTypeMap.getSingleton().getExtensionFromMimeType(String) Test: Treehugger Change-Id: I8bec5aebbbcf0a0a4a8e5dc317d188830f219a1e
-rw-r--r--luni/src/main/java/libcore/net/MimeUtils.java74
-rw-r--r--mmodules/core_platform_api/api/platform/current-api.txt7
-rw-r--r--non_openjdk_java_files.bp1
3 files changed, 0 insertions, 82 deletions
diff --git a/luni/src/main/java/libcore/net/MimeUtils.java b/luni/src/main/java/libcore/net/MimeUtils.java
deleted file mode 100644
index a9dd00a237..0000000000
--- a/luni/src/main/java/libcore/net/MimeUtils.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2010 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 libcore.net;
-
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * Utilities for dealing with MIME types.
- * Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
- * @hide
- */
-@libcore.api.CorePlatformApi
-public final class MimeUtils {
-
- private MimeUtils() {
- }
-
- @libcore.api.CorePlatformApi
- public static boolean hasMimeType(String mimeType) {
- return MimeMap.getDefault().hasMimeType(mimeType);
- }
-
- /**
- * Returns the MIME type for the given case insensitive file extension.
- * @param extension A file extension without the leading '.'
- * @return The MIME type has been registered for
- * the given case insensitive file extension or null if there is none.
- */
- @UnsupportedAppUsage
- @libcore.api.CorePlatformApi
- public static String guessMimeTypeFromExtension(String extension) {
- return MimeMap.getDefault().guessMimeTypeFromExtension(extension);
- }
-
- /**
- * Returns true if the given case insensitive extension has a registered MIME type.
- * @param extension A file extension without the leading '.'
- * @return True if a MIME type has been registered for
- * the given case insensitive file extension.
- */
- @libcore.api.CorePlatformApi
- public static boolean hasExtension(String extension) {
- return MimeMap.getDefault().hasExtension(extension);
- }
-
- /**
- * Returns the registered extension for the given case insensitive MIME type. Note that some
- * MIME types map to multiple extensions. This call will return the most
- * common extension for the given MIME type.
- * @param mimeType A MIME type (i.e. text/plain)
- * @return The extension has been registered for
- * the given case insensitive MIME type or null if there is none.
- */
- @UnsupportedAppUsage
- @libcore.api.CorePlatformApi
- public static String guessExtensionFromMimeType(String mimeType) {
- return MimeMap.getDefault().guessExtensionFromMimeType(mimeType);
- }
-}
diff --git a/mmodules/core_platform_api/api/platform/current-api.txt b/mmodules/core_platform_api/api/platform/current-api.txt
index d78b1d2642..39432eb72b 100644
--- a/mmodules/core_platform_api/api/platform/current-api.txt
+++ b/mmodules/core_platform_api/api/platform/current-api.txt
@@ -1166,13 +1166,6 @@ package libcore.net {
method public final boolean hasMimeType(@Nullable String);
}
- public final class MimeUtils {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String guessExtensionFromMimeType(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String guessMimeTypeFromExtension(String);
- method public static boolean hasExtension(String);
- method public static boolean hasMimeType(String);
- }
-
public abstract class NetworkSecurityPolicy {
ctor public NetworkSecurityPolicy();
method public static libcore.net.NetworkSecurityPolicy getInstance();
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index f2b564a1bd..1952687571 100644
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -178,7 +178,6 @@ filegroup {
"luni/src/main/java/libcore/net/InetAddressUtils.java",
"luni/src/main/java/libcore/net/MimeMap.java",
"luni/src/main/java/libcore/net/MimeMapImpl.java",
- "luni/src/main/java/libcore/net/MimeUtils.java",
"luni/src/main/java/libcore/net/NetworkSecurityPolicy.java",
"luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java",
"luni/src/main/java/libcore/timezone/CountryTimeZones.java",