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

Commit 53e680d2 authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge "Add min_sdk_version to aidlCmd for droidstubs"

parents 262d65d4 757b666c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -304,6 +304,9 @@ func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Op
		flags = append(flags, "-I"+src.String())
	}

	minSdkVersion := j.MinSdkVersion(ctx).ApiLevel.FinalOrFutureInt()
	flags = append(flags, fmt.Sprintf("--min_sdk_version=%v", minSdkVersion))

	return strings.Join(flags, " "), deps
}

+33 −0
Original line number Diff line number Diff line
@@ -1370,6 +1370,39 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
	}
}

func TestAidlFlagsMinSdkVersionDroidstubs(t *testing.T) {
	bpTemplate := `
	droidstubs {
		name: "foo-stubs",
		srcs: ["foo.aidl"],
		%s
		system_modules: "none",
	}
	`
	testCases := []struct {
		desc                  string
		sdkVersionBp          string
		minSdkVersionExpected string
	}{
		{
			desc:                  "sdk_version not set, module compiles against private platform APIs",
			sdkVersionBp:          ``,
			minSdkVersionExpected: "10000",
		},
		{
			desc:                  "sdk_version set to none, module does not build against an SDK",
			sdkVersionBp:          `sdk_version: "none",`,
			minSdkVersionExpected: "10000",
		},
	}
	for _, tc := range testCases {
		ctx := prepareForJavaTest.RunTestWithBp(t, fmt.Sprintf(bpTemplate, tc.sdkVersionBp))
		aidlCmd := ctx.ModuleForTests("foo-stubs", "android_common").Rule("aidl").RuleParams.Command
		expected := "--min_sdk_version=" + tc.minSdkVersionExpected
		android.AssertStringDoesContain(t, "aidl command conatins incorrect min_sdk_version for testCse: "+tc.desc, aidlCmd, expected)
	}
}

func TestAidlEnforcePermissions(t *testing.T) {
	ctx, _ := testJava(t, `
		java_library {