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

Commit fd05a74e authored by Dario Freni's avatar Dario Freni
Browse files

Add support for /product-services partition

This is an adaptation of Icc4f8c16bc389fe20db680849f311d02df1299c3, to
support modules that are installed on the /product-services partition.

Bug: 80741439
Test: m -j both with and without enabling the new partition
Change-Id: I72b335ad38baff5848cd3da7489343f8cf98ff16
parent 23be3838
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -242,6 +242,9 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
		if Bool(amod.commonProperties.Product_specific) {
			fmt.Fprintln(&data.preamble, "LOCAL_PRODUCT_MODULE := true")
		}
		if Bool(amod.commonProperties.ProductServices_specific) {
			fmt.Fprintln(&data.preamble, "LOCAL_PRODUCT_SERVICES_MODULE := true")
		}
		if amod.commonProperties.Owner != nil {
			fmt.Fprintln(&data.preamble, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
		}
+7 −0
Original line number Diff line number Diff line
@@ -763,6 +763,13 @@ func (c *deviceConfig) ProductPath() string {
	return "product"
}

func (c *deviceConfig) ProductServicesPath() string {
	if c.config.productVariables.ProductServicesPath != nil {
		return *c.config.productVariables.ProductServicesPath
	}
	return "product-services"
}

func (c *deviceConfig) BtConfigIncludeDir() string {
	return String(c.config.productVariables.BtConfigIncludeDir)
}
+50 −11
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ type androidBaseContext interface {
	DeviceSpecific() bool
	SocSpecific() bool
	ProductSpecific() bool
	ProductServicesSpecific() bool
	AConfig() Config
	DeviceConfig() DeviceConfig
}
@@ -241,6 +242,11 @@ type commonProperties struct {
	// /system/product if product partition does not exist).
	Product_specific *bool

	// whether this module provides services owned by the OS provider to the core platform. When set
	// to true, it is installed into  /product-services (or /system/product-services if
	// product-services partition does not exist).
	ProductServices_specific *bool

	// Whether this module is installed to recovery partition
	Recovery *bool

@@ -303,6 +309,7 @@ const (
	deviceSpecificModule
	socSpecificModule
	productSpecificModule
	productServicesSpecificModule
)

func (k moduleKind) String() string {
@@ -315,6 +322,8 @@ func (k moduleKind) String() string {
		return "soc-specific"
	case productSpecificModule:
		return "product-specific"
	case productServicesSpecificModule:
		return "productservices-specific"
	default:
		panic(fmt.Errorf("unknown module kind %d", k))
	}
@@ -507,7 +516,7 @@ func (a *ModuleBase) DeviceSupported() bool {
}

func (a *ModuleBase) Platform() bool {
	return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific()
	return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific() && !a.ProductServicesSpecific()
}

func (a *ModuleBase) DeviceSpecific() bool {
@@ -522,6 +531,10 @@ func (a *ModuleBase) ProductSpecific() bool {
	return Bool(a.commonProperties.Product_specific)
}

func (a *ModuleBase) ProductServicesSpecific() bool {
	return Bool(a.commonProperties.ProductServices_specific)
}

func (a *ModuleBase) Enabled() bool {
	if a.commonProperties.Enabled == nil {
		return !a.Os().DefaultDisabled
@@ -632,17 +645,36 @@ func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
	var socSpecific = Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
	var deviceSpecific = Bool(a.commonProperties.Device_specific)
	var productSpecific = Bool(a.commonProperties.Product_specific)
	var productServicesSpecific = Bool(a.commonProperties.ProductServices_specific)

	if ((socSpecific || deviceSpecific) && productSpecific) || (socSpecific && deviceSpecific) {
	msg := "conflicting value set here"
	if socSpecific && deviceSpecific {
		ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
		if Bool(a.commonProperties.Vendor) {
			ctx.PropertyErrorf("vendor", msg)
		}
		if Bool(a.commonProperties.Proprietary) {
			ctx.PropertyErrorf("proprietary", msg)
		}
		if Bool(a.commonProperties.Soc_specific) {
			ctx.PropertyErrorf("soc_specific", msg)
		}
	}

	if productSpecific && productServicesSpecific {
		ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and product_services at the same time.")
		ctx.PropertyErrorf("product_services_specific", msg)
	}

	if (socSpecific || deviceSpecific) && (productSpecific || productServicesSpecific) {
		if productSpecific {
			ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
		} else {
			ctx.PropertyErrorf("product_services_specific", "a module cannot be specific to SoC or device and product_services at the same time.")
		}
		if deviceSpecific {
			ctx.PropertyErrorf("device_specific", msg)
			}
		} else {
			ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
		}
			if Bool(a.commonProperties.Vendor) {
				ctx.PropertyErrorf("vendor", msg)
			}
@@ -653,9 +685,12 @@ func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
				ctx.PropertyErrorf("soc_specific", msg)
			}
		}
	}

	if productSpecific {
		return productSpecificModule
	} else if productServicesSpecific {
		return productServicesSpecificModule
	} else if deviceSpecific {
		return deviceSpecificModule
	} else if socSpecific {
@@ -1012,6 +1047,10 @@ func (a *androidBaseContextImpl) ProductSpecific() bool {
	return a.kind == productSpecificModule
}

func (a *androidBaseContextImpl) ProductServicesSpecific() bool {
	return a.kind == productServicesSpecificModule
}

func (a *androidModuleContext) InstallInData() bool {
	return a.module.InstallInData()
}
+2 −0
Original line number Diff line number Diff line
@@ -961,6 +961,8 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
			partition = ctx.DeviceConfig().OdmPath()
		} else if ctx.ProductSpecific() {
			partition = ctx.DeviceConfig().ProductPath()
		} else if ctx.ProductServicesSpecific() {
			partition = ctx.DeviceConfig().ProductServicesPath()
		} else {
			partition = "system"
		}
+50 −0
Original line number Diff line number Diff line
@@ -292,6 +292,17 @@ func TestPathForModuleInstall(t *testing.T) {
			in:  []string{"bin", "my_test"},
			out: "target/product/test_device/product/bin/my_test",
		},
		{
			name: "product-services binary",
			ctx: &moduleInstallPathContextImpl{
				androidBaseContextImpl: androidBaseContextImpl{
					target: deviceTarget,
					kind:   productServicesSpecificModule,
				},
			},
			in:  []string{"bin", "my_test"},
			out: "target/product/test_device/product-services/bin/my_test",
		},

		{
			name: "system native test binary",
@@ -341,6 +352,19 @@ func TestPathForModuleInstall(t *testing.T) {
			out: "target/product/test_device/data/nativetest/my_test",
		},

		{
			name: "product-services native test binary",
			ctx: &moduleInstallPathContextImpl{
				androidBaseContextImpl: androidBaseContextImpl{
					target: deviceTarget,
					kind:   productServicesSpecificModule,
				},
				inData: true,
			},
			in:  []string{"nativetest", "my_test"},
			out: "target/product/test_device/data/nativetest/my_test",
		},

		{
			name: "sanitized system binary",
			ctx: &moduleInstallPathContextImpl{
@@ -389,6 +413,19 @@ func TestPathForModuleInstall(t *testing.T) {
			out: "target/product/test_device/data/asan/product/bin/my_test",
		},

		{
			name: "sanitized product-services binary",
			ctx: &moduleInstallPathContextImpl{
				androidBaseContextImpl: androidBaseContextImpl{
					target: deviceTarget,
					kind:   productServicesSpecificModule,
				},
				inSanitizerDir: true,
			},
			in:  []string{"bin", "my_test"},
			out: "target/product/test_device/data/asan/product-services/bin/my_test",
		},

		{
			name: "sanitized system native test binary",
			ctx: &moduleInstallPathContextImpl{
@@ -440,6 +477,19 @@ func TestPathForModuleInstall(t *testing.T) {
			in:  []string{"nativetest", "my_test"},
			out: "target/product/test_device/data/asan/data/nativetest/my_test",
		},
		{
			name: "sanitized product-services native test binary",
			ctx: &moduleInstallPathContextImpl{
				androidBaseContextImpl: androidBaseContextImpl{
					target: deviceTarget,
					kind:   productServicesSpecificModule,
				},
				inData:         true,
				inSanitizerDir: true,
			},
			in:  []string{"nativetest", "my_test"},
			out: "target/product/test_device/data/asan/data/nativetest/my_test",
		},
	}

	for _, tc := range testCases {
Loading