diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index faeb082d9a805..05bb8fc13fbb4 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -2443,8 +2443,28 @@ public class PackageParser { return null; } + boolean providerExportedDefault = false; + + if (owner.applicationInfo.targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) { + // For compatibility, applications targeting API level 16 or lower + // should have their content providers exported by default, unless they + // specify otherwise. + providerExportedDefault = true; + } + + if (((owner.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) + && (owner.applicationInfo.targetSdkVersion == Build.VERSION_CODES.JELLY_BEAN)) { + // STOPSHIP: REMOVE THIS IF BLOCK + // To expose more bugs, pre-installed system apps targeting API level 16 + // should not have their content providers exported by default. + // This is only a short term check, and should be removed when the + // default SDK version changes to 17. + providerExportedDefault = false; + } + p.info.exported = sa.getBoolean( - com.android.internal.R.styleable.AndroidManifestProvider_exported, true); + com.android.internal.R.styleable.AndroidManifestProvider_exported, + providerExportedDefault); String cpname = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestProvider_authorities, 0); @@ -2516,7 +2536,7 @@ public class PackageParser { } if (cpname == null) { - outError[0] = " does not incude authorities attribute"; + outError[0] = " does not include authorities attribute"; return null; } p.info.authority = cpname.intern(); diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 7cf869ceb6576..dd5d7a6b8e0e8 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -414,6 +414,15 @@ public class Build { /** * Moar jelly beans! + * + *

Applications targeting this or a later release will get these + * new changes in behavior:

+ * */ public static final int JELLY_BEAN_MR1 = 17; } diff --git a/docs/html/guide/topics/manifest/provider-element.jd b/docs/html/guide/topics/manifest/provider-element.jd index 455880035a9ca..7b4ca8fc21c0f 100644 --- a/docs/html/guide/topics/manifest/provider-element.jd +++ b/docs/html/guide/topics/manifest/provider-element.jd @@ -97,7 +97,8 @@ are by default) for the content provider to be enabled. If either is applications — "{@code true}" if it can be, and "{@code false}" if not. If "{@code false}", the provider is available only to components of the same application or applications with the same user ID. The default value -is "{@code true}". +is "{@code true}" for applications which target API level 16 (Jelly Bean) +and below, and "{@code false}" otherwise.

You can export a content provider but still limit access to it with the