Skip to content

Commit 9d16c21

Browse files
nickkralAndroid (Google) Code Review
authored andcommitted
Merge "Content Providers: change default for android:exported" into jb-mr1-dev
2 parents 5379158 + f097b16 commit 9d16c21

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

core/java/android/content/pm/PackageParser.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,8 +2443,28 @@ private Provider parseProvider(Package owner, Resources res,
24432443
return null;
24442444
}
24452445

2446+
boolean providerExportedDefault = false;
2447+
2448+
if (owner.applicationInfo.targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) {
2449+
// For compatibility, applications targeting API level 16 or lower
2450+
// should have their content providers exported by default, unless they
2451+
// specify otherwise.
2452+
providerExportedDefault = true;
2453+
}
2454+
2455+
if (((owner.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
2456+
&& (owner.applicationInfo.targetSdkVersion == Build.VERSION_CODES.JELLY_BEAN)) {
2457+
// STOPSHIP: REMOVE THIS IF BLOCK
2458+
// To expose more bugs, pre-installed system apps targeting API level 16
2459+
// should not have their content providers exported by default.
2460+
// This is only a short term check, and should be removed when the
2461+
// default SDK version changes to 17.
2462+
providerExportedDefault = false;
2463+
}
2464+
24462465
p.info.exported = sa.getBoolean(
2447-
com.android.internal.R.styleable.AndroidManifestProvider_exported, true);
2466+
com.android.internal.R.styleable.AndroidManifestProvider_exported,
2467+
providerExportedDefault);
24482468

24492469
String cpname = sa.getNonConfigurationString(
24502470
com.android.internal.R.styleable.AndroidManifestProvider_authorities, 0);
@@ -2516,7 +2536,7 @@ private Provider parseProvider(Package owner, Resources res,
25162536
}
25172537

25182538
if (cpname == null) {
2519-
outError[0] = "<provider> does not incude authorities attribute";
2539+
outError[0] = "<provider> does not include authorities attribute";
25202540
return null;
25212541
}
25222542
p.info.authority = cpname.intern();

core/java/android/os/Build.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,15 @@ public static class VERSION_CODES {
414414

415415
/**
416416
* Moar jelly beans!
417+
*
418+
* <p>Applications targeting this or a later release will get these
419+
* new changes in behavior:</p>
420+
* <ul>
421+
* <li>Content Providers: The default value of {@code android:exported} is now
422+
* {@code false}. See
423+
* <a href="{docRoot}guide/topics/manifest/provider-element.html#exported">
424+
* the android:exported section</a> in the provider documentation for more details.</li>
425+
* </ul>
417426
*/
418427
public static final int JELLY_BEAN_MR1 = 17;
419428
}

docs/html/guide/topics/manifest/provider-element.jd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ are by default) for the content provider to be enabled. If either is
9797
applications &mdash; "{@code true}" if it can be, and "{@code false}" if not.
9898
If "{@code false}", the provider is available only to components of the
9999
same application or applications with the same user ID. The default value
100-
is "{@code true}".
100+
is "{@code true}" for applications which target API level 16 (Jelly Bean)
101+
and below, and "{@code false}" otherwise.
101102

102103
<p>
103104
You can export a content provider but still limit access to it with the

0 commit comments

Comments
 (0)