Skip to content

Commit

Permalink
Use BundleParser to parse and collect the host activities, refer to w…
Browse files Browse the repository at this point in the history
  • Loading branch information
galenlin committed Jun 6, 2017
1 parent bac70fb commit c69f4fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.io.File;
import java.util.HashSet;

/**
Expand Down Expand Up @@ -55,15 +54,10 @@ public void setUp(Context context) {
super.setUp(context);

// Read the registered classes in host's manifest file
PackageInfo pi;
try {
pi = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException ignored) {
// Never reach
return;
}
ActivityInfo[] as = pi.activities;
File sourceFile = new File(context.getApplicationInfo().sourceDir);
BundleParser parser = BundleParser.parsePackage(sourceFile, context.getPackageName());
parser.collectActivities();
ActivityInfo[] as = parser.getPackageInfo().activities;
if (as != null) {
sActivityClasses = new HashSet<String>();
for (ActivityInfo ai : as) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,6 @@ private boolean parsePackage(Resources res, XmlResourceParser parser) {
app.className = null;
}

// Get the label value which used as ABI flags.
// This is depreciated, we read it from the `platformBuildVersionCode` instead.
// TODO: Remove this if the gradle-small 0.9.0 or above being widely used.
if (abiFlags == 0) {
TypedValue label = new TypedValue();
if (sa.getValue(R.styleable.AndroidManifestApplication_label, label)) {
if (label.type == TypedValue.TYPE_STRING) {
abiFlags = Integer.parseInt(label.string.toString());
} else {
abiFlags = label.data;
}
}
if (abiFlags != 0) {
throw new RuntimeException("Please recompile " + mPackageName
+ " use gradle-small 0.9.0 or above");
}
}

app.theme = sa.getResourceId(
R.styleable.AndroidManifestApplication_theme, 0);

Expand Down

0 comments on commit c69f4fb

Please sign in to comment.