Merge "Implicitly expose activities"

This commit is contained in:
TreeHugger Robot
2016-12-17 00:19:15 +00:00
committed by Android (Google) Code Review

View File

@@ -3789,6 +3789,8 @@ public class PackageParser {
ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE;
}
final boolean hasVisibleToEphemeral =
sa.hasValue(R.styleable.AndroidManifestActivity_visibleToEphemeral);
final boolean isEphemeral = ((flags & PARSE_IS_EPHEMERAL) != 0);
final boolean visibleToEphemeral = isEphemeral
|| sa.getBoolean(R.styleable.AndroidManifestActivity_visibleToEphemeral, false);
@@ -3827,7 +3829,7 @@ public class PackageParser {
return null;
}
intent.setEphemeral(isEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral || isWebBrowsableIntent(intent));
if (intent.countActions() == 0) {
Slog.w(TAG, "No actions in intent filter at "
+ mArchiveSourcePath + " "
@@ -3835,6 +3837,10 @@ public class PackageParser {
} else {
a.intents.add(intent);
}
// adjust activity flags when we implicitly expose it via a browsable filter
if (!hasVisibleToEphemeral && intent.isVisibleToEphemeral()) {
a.info.flags |= ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL;
}
} else if (!receiver && parser.getName().equals("preferred")) {
ActivityIntentInfo intent = new ActivityIntentInfo(a);
if (!parseIntent(res, parser, false /*allowGlobs*/, false /*allowAutoVerify*/,
@@ -3842,7 +3848,7 @@ public class PackageParser {
return null;
}
intent.setEphemeral(isEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral || isWebBrowsableIntent(intent));
if (intent.countActions() == 0) {
Slog.w(TAG, "No actions in preferred at "
+ mArchiveSourcePath + " "
@@ -3853,6 +3859,10 @@ public class PackageParser {
}
owner.preferredActivityFilters.add(intent);
}
// adjust activity flags when we implicitly expose it via a browsable filter
if (!hasVisibleToEphemeral && intent.isVisibleToEphemeral()) {
a.info.flags |= ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL;
}
} else if (parser.getName().equals("meta-data")) {
if ((a.metaData = parseMetaData(res, parser, a.metaData,
outError)) == null) {
@@ -4093,6 +4103,7 @@ public class PackageParser {
}
}
// TODO add visibleToInstantApp attribute to activity alias
final boolean isEphemeral = ((flags & PARSE_IS_EPHEMERAL) != 0);
final boolean visibleToEphemeral = isEphemeral
|| ((a.info.flags & ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL) != 0);
@@ -4124,9 +4135,14 @@ public class PackageParser {
+ parser.getPositionDescription());
} else {
intent.setEphemeral(isEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral
|| isWebBrowsableIntent(intent));
a.intents.add(intent);
}
// adjust activity flags when we implicitly expose it via a browsable filter
if (intent.isVisibleToEphemeral()) {
a.info.flags |= ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL;
}
} else if (parser.getName().equals("meta-data")) {
if ((a.metaData=parseMetaData(res, parser, a.metaData,
outError)) == null) {
@@ -4262,6 +4278,8 @@ public class PackageParser {
ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE;
}
final boolean hasVisibleToEphemeral =
sa.hasValue(R.styleable.AndroidManifestProvider_visibleToEphemeral);
final boolean isEphemeral = ((flags & PARSE_IS_EPHEMERAL) != 0);
final boolean visibleToEphemeral = isEphemeral
|| sa.getBoolean(R.styleable.AndroidManifestProvider_visibleToEphemeral, false);
@@ -4291,7 +4309,8 @@ public class PackageParser {
}
p.info.authority = cpname.intern();
if (!parseProviderTags(res, parser, isEphemeral, visibleToEphemeral, p, outError)) {
if (!parseProviderTags(
res, parser, isEphemeral, hasVisibleToEphemeral, visibleToEphemeral, p, outError)) {
return null;
}
@@ -4299,8 +4318,9 @@ public class PackageParser {
}
private boolean parseProviderTags(Resources res, XmlResourceParser parser,
boolean isEphemeral, boolean visibleToEphemeral, Provider outInfo, String[] outError)
throws XmlPullParserException, IOException {
boolean isEphemeral, boolean hasVisibleToEphemeral, boolean visibleToEphemeral,
Provider outInfo, String[] outError)
throws XmlPullParserException, IOException {
int outerDepth = parser.getDepth();
int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
@@ -4317,8 +4337,12 @@ public class PackageParser {
return false;
}
intent.setEphemeral(isEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral || isWebBrowsableIntent(intent));
outInfo.intents.add(intent);
// adjust provider flags when we implicitly expose it via a browsable filter
if (!hasVisibleToEphemeral && intent.isVisibleToEphemeral()) {
outInfo.info.flags |= ProviderInfo.FLAG_VISIBLE_TO_EPHEMERAL;
}
} else if (parser.getName().equals("meta-data")) {
if ((outInfo.metaData=parseMetaData(res, parser,
@@ -4565,6 +4589,8 @@ public class PackageParser {
ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE;
}
final boolean hasVisibleToEphemeral =
sa.hasValue(R.styleable.AndroidManifestService_visibleToEphemeral);
final boolean isEphemeral = ((flags & PARSE_IS_EPHEMERAL) != 0);
final boolean visibleToEphemeral = isEphemeral
|| sa.getBoolean(R.styleable.AndroidManifestService_visibleToEphemeral, false);
@@ -4600,8 +4626,11 @@ public class PackageParser {
return null;
}
intent.setEphemeral(isEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral);
intent.setVisibleToEphemeral(visibleToEphemeral || isWebBrowsableIntent(intent));
// adjust activity flags when we implicitly expose it via a browsable filter
if (!hasVisibleToEphemeral && intent.isVisibleToEphemeral()) {
s.info.flags |= ServiceInfo.FLAG_VISIBLE_TO_EPHEMERAL;
}
s.intents.add(intent);
} else if (parser.getName().equals("meta-data")) {
if ((s.metaData=parseMetaData(res, parser, s.metaData,
@@ -4629,6 +4658,12 @@ public class PackageParser {
return s;
}
private boolean isWebBrowsableIntent(IntentInfo intent) {
return intent.hasAction(Intent.ACTION_VIEW)
&& intent.hasCategory(Intent.CATEGORY_BROWSABLE)
&& (intent.hasDataScheme("http") || intent.hasDataScheme("https"));
}
private boolean parseAllMetaData(Resources res, XmlResourceParser parser, String tag,
Component<?> outInfo, String[] outError) throws XmlPullParserException, IOException {
int outerDepth = parser.getDepth();