Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2aa190b authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes I046d75db,Ie13817dc

* changes:
  Don't panic if no certificates found
  Move proguard test files to java package
parents 8c81305c 412436f7
Loading
Loading
Loading
Loading
+36 −38
Original line number Diff line number Diff line
@@ -202,8 +202,6 @@ var prepareForApexTest = android.GroupFixturePreparers(
		"myapex.apks":                          nil,
		"frameworks/base/api/current.txt":      nil,
		"framework/aidl/a.aidl":                nil,
		"build/make/core/proguard.flags":             nil,
		"build/make/core/proguard_basic_keeps.flags": nil,
		"dummy.txt":                            nil,
		"baz":                                  nil,
		"bar/baz":                              nil,
+15 −1
Original line number Diff line number Diff line
@@ -638,7 +638,21 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
	}

	certificates := processMainCert(a.ModuleBase, a.getCertString(ctx), certificateDeps, ctx)

	// This can be reached with an empty certificate list if AllowMissingDependencies is set
	// and the certificate property for this module is a module reference to a missing module.
	if len(certificates) > 0 {
		a.certificate = certificates[0]
	} else {
		if !ctx.Config().AllowMissingDependencies() && len(ctx.GetMissingDependencies()) > 0 {
			panic("Should only get here if AllowMissingDependencies set and there are missing dependencies")
		}
		// Set a certificate to avoid panics later when accessing it.
		a.certificate = Certificate{
			Key: android.PathForModuleOut(ctx, "missing.pk8"),
			Pem: android.PathForModuleOut(ctx, "missing.pem"),
		}
	}

	// Build a final signed app package.
	packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
+21 −0
Original line number Diff line number Diff line
@@ -2948,3 +2948,24 @@ func TestTargetSdkVersionManifestFixer(t *testing.T) {
		android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion  "+testCase.targetSdkVersionExpected)
	}
}

func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) {
	result := android.GroupFixturePreparers(
		PrepareForTestWithJavaDefaultModules,
		android.PrepareForTestWithAllowMissingDependencies,
		android.PrepareForTestWithAndroidMk,
	).RunTestWithBp(t, `
		android_app {
			name: "foo",
			srcs: ["a.java"],
			certificate: ":missing_certificate",
			sdk_version: "current",
		}`)

	foo := result.ModuleForTests("foo", "android_common")
	fooApk := foo.Output("foo.apk")
	if fooApk.Rule != android.ErrorRule {
		t.Fatalf("expected ErrorRule for foo.apk, got %s", fooApk.Rule.String())
	}
	android.AssertStringDoesContain(t, "expected error rule message", fooApk.Args["error"], "missing dependencies: missing_certificate\n")
}
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixtu
		defaultJavaDir + "/framework/aidl": nil,
		// Needed for various deps defined in GatherRequiredDepsForTest()
		defaultJavaDir + "/a.java": nil,

		// Needed for R8 rules on apps
		"build/make/core/proguard.flags":             nil,
		"build/make/core/proguard_basic_keeps.flags": nil,
	}.AddToFixture(),
	// The java default module definitions.
	android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
+0 −3
Original line number Diff line number Diff line
@@ -98,9 +98,6 @@ func test(t *testing.T, bp string) *android.TestResult {

		"build/soong/scripts/jar-wrapper.sh": nil,

		"build/make/core/proguard.flags":             nil,
		"build/make/core/proguard_basic_keeps.flags": nil,

		"jdk8/jre/lib/jce.jar": nil,
		"jdk8/jre/lib/rt.jar":  nil,
		"jdk8/lib/tools.jar":   nil,