Loading java/app.go +16 −0 Original line number Diff line number Diff line Loading @@ -926,6 +926,16 @@ func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) { func (a *AndroidAppImport) uncompressEmbeddedJniLibs( ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) { // Test apps don't need their JNI libraries stored uncompressed. As a matter of fact, messing // with them may invalidate pre-existing signature data. if ctx.InstallInTestcases() && Bool(a.properties.Presigned) { ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Output: outputPath, Input: inputPath, }) return } rule := android.NewRuleBuilder() rule.Command(). Textf(`if (zipinfo %s 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath). Loading Loading @@ -1003,6 +1013,8 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext var installDir android.InstallPath if Bool(a.properties.Privileged) { installDir = android.PathForModuleInstall(ctx, "priv-app", a.BaseModuleName()) } else if ctx.InstallInTestcases() { installDir = android.PathForModuleInstall(ctx, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()) } else { installDir = android.PathForModuleInstall(ctx, "app", a.BaseModuleName()) } Loading Loading @@ -1159,6 +1171,10 @@ func (a *AndroidTestImport) GenerateAndroidBuildActions(ctx android.ModuleContex a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data) } func (a *AndroidTestImport) InstallInTestcases() bool { return true } // android_test_import imports a prebuilt test apk with additional processing specified in the // module. DPI or arch variant configurations can be made as with android_app_import. func AndroidTestImportFactory() android.Module { Loading java/app_test.go +34 −0 Original line number Diff line number Diff line Loading @@ -1628,6 +1628,40 @@ func TestAndroidTestImport(t *testing.T) { } } func TestAndroidTestImport_NoJinUncompressForPresigned(t *testing.T) { ctx, _ := testJava(t, ` android_test_import { name: "foo", apk: "prebuilts/apk/app.apk", certificate: "cert/new_cert", data: [ "testdata/data", ], } android_test_import { name: "foo_presigned", apk: "prebuilts/apk/app.apk", presigned: true, data: [ "testdata/data", ], } `) variant := ctx.ModuleForTests("foo", "android_common") jniRule := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command if !strings.HasPrefix(jniRule, "if (zipinfo") { t.Errorf("Unexpected JNI uncompress rule command: " + jniRule) } variant = ctx.ModuleForTests("foo_presigned", "android_common") jniRule = variant.Output("jnis-uncompressed/foo_presigned.apk").BuildParams.Rule.String() if jniRule != android.Cp.String() { t.Errorf("Unexpected JNI uncompress rule: " + jniRule) } } func TestStl(t *testing.T) { ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` cc_library { Loading Loading
java/app.go +16 −0 Original line number Diff line number Diff line Loading @@ -926,6 +926,16 @@ func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) { func (a *AndroidAppImport) uncompressEmbeddedJniLibs( ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) { // Test apps don't need their JNI libraries stored uncompressed. As a matter of fact, messing // with them may invalidate pre-existing signature data. if ctx.InstallInTestcases() && Bool(a.properties.Presigned) { ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Output: outputPath, Input: inputPath, }) return } rule := android.NewRuleBuilder() rule.Command(). Textf(`if (zipinfo %s 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath). Loading Loading @@ -1003,6 +1013,8 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext var installDir android.InstallPath if Bool(a.properties.Privileged) { installDir = android.PathForModuleInstall(ctx, "priv-app", a.BaseModuleName()) } else if ctx.InstallInTestcases() { installDir = android.PathForModuleInstall(ctx, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()) } else { installDir = android.PathForModuleInstall(ctx, "app", a.BaseModuleName()) } Loading Loading @@ -1159,6 +1171,10 @@ func (a *AndroidTestImport) GenerateAndroidBuildActions(ctx android.ModuleContex a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data) } func (a *AndroidTestImport) InstallInTestcases() bool { return true } // android_test_import imports a prebuilt test apk with additional processing specified in the // module. DPI or arch variant configurations can be made as with android_app_import. func AndroidTestImportFactory() android.Module { Loading
java/app_test.go +34 −0 Original line number Diff line number Diff line Loading @@ -1628,6 +1628,40 @@ func TestAndroidTestImport(t *testing.T) { } } func TestAndroidTestImport_NoJinUncompressForPresigned(t *testing.T) { ctx, _ := testJava(t, ` android_test_import { name: "foo", apk: "prebuilts/apk/app.apk", certificate: "cert/new_cert", data: [ "testdata/data", ], } android_test_import { name: "foo_presigned", apk: "prebuilts/apk/app.apk", presigned: true, data: [ "testdata/data", ], } `) variant := ctx.ModuleForTests("foo", "android_common") jniRule := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command if !strings.HasPrefix(jniRule, "if (zipinfo") { t.Errorf("Unexpected JNI uncompress rule command: " + jniRule) } variant = ctx.ModuleForTests("foo_presigned", "android_common") jniRule = variant.Output("jnis-uncompressed/foo_presigned.apk").BuildParams.Rule.String() if jniRule != android.Cp.String() { t.Errorf("Unexpected JNI uncompress rule: " + jniRule) } } func TestStl(t *testing.T) { ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` cc_library { Loading