Loading apex/jobscheduler/service/java/com/android/server/alarm/UserWakeupStore.java +8 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package com.android.server.alarm; import android.annotation.Nullable; import android.os.Environment; import android.os.SystemClock; import android.os.UserHandle; import android.util.AtomicFile; import android.util.IndentingPrintWriter; import android.util.Pair; Loading Loading @@ -113,16 +114,19 @@ public class UserWakeupStore { } /** * Add user wakeup for the alarm. * Add user wakeup for the alarm if needed. * @param userId Id of the user that scheduled alarm. * @param alarmTime time when alarm is expected to trigger. */ public void addUserWakeup(int userId, long alarmTime) { // SYSTEM user is always running, so no need to schedule wakeup for it. if (userId != UserHandle.USER_SYSTEM) { synchronized (mUserWakeupLock) { mUserStarts.put(userId, alarmTime - BUFFER_TIME_MS + getUserWakeupOffset()); } updateUserListFile(); } } /** * Remove wakeup scheduled for the user with given userId if present. Loading api/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -29,12 +29,14 @@ bootstrap_go_package { pkgPath: "android/soong/api", deps: [ "blueprint", "blueprint-proptools", "soong", "soong-android", "soong-genrule", "soong-java", ], srcs: ["api.go"], testSrcs: ["api_test.go"], pluginFor: ["soong_build"], } Loading api/api.go +18 −10 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ var non_updatable_modules = []string{virtualization, location} // The properties of the combined_apis module type. type CombinedApisProperties struct { // Module libraries in the bootclasspath Bootclasspath []string Bootclasspath proptools.Configurable[[]string] // Module libraries on the bootclasspath if include_nonpublic_framework_api is true. Conditional_bootclasspath []string // Module libraries in system server System_server_classpath []string System_server_classpath proptools.Configurable[[]string] } type CombinedApis struct { Loading @@ -79,29 +79,37 @@ func registerBuildComponents(ctx android.RegistrationContext) { var PrepareForCombinedApisTest = android.FixtureRegisterWithContext(registerBuildComponents) func (a *CombinedApis) apiFingerprintStubDeps() []string { func (a *CombinedApis) bootclasspath(ctx android.ConfigAndErrorContext) []string { return a.properties.Bootclasspath.GetOrDefault(a.ConfigurableEvaluator(ctx), nil) } func (a *CombinedApis) systemServerClasspath(ctx android.ConfigAndErrorContext) []string { return a.properties.System_server_classpath.GetOrDefault(a.ConfigurableEvaluator(ctx), nil) } func (a *CombinedApis) apiFingerprintStubDeps(ctx android.BottomUpMutatorContext) []string { ret := []string{} ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs")..., transformArray(a.bootclasspath(ctx), "", ".stubs")..., ) ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs.system")..., transformArray(a.bootclasspath(ctx), "", ".stubs.system")..., ) ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs.module_lib")..., transformArray(a.bootclasspath(ctx), "", ".stubs.module_lib")..., ) ret = append( ret, transformArray(a.properties.System_server_classpath, "", ".stubs.system_server")..., transformArray(a.systemServerClasspath(ctx), "", ".stubs.system_server")..., ) return ret } func (a *CombinedApis) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.AddDependency(ctx.Module(), nil, a.apiFingerprintStubDeps()...) ctx.AddDependency(ctx.Module(), nil, a.apiFingerprintStubDeps(ctx)...) } func (a *CombinedApis) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading Loading @@ -532,8 +540,8 @@ func createFullExportableApiLibraries(ctx android.LoadHookContext) { } func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { bootclasspath := a.properties.Bootclasspath system_server_classpath := a.properties.System_server_classpath bootclasspath := a.bootclasspath(ctx) system_server_classpath := a.systemServerClasspath(ctx) if ctx.Config().VendorConfig("ANDROID").Bool("include_nonpublic_framework_api") { bootclasspath = append(bootclasspath, a.properties.Conditional_bootclasspath...) sort.Strings(bootclasspath) Loading api/api_test.go 0 → 100644 +254 −0 Original line number Diff line number Diff line // Copyright (C) 2024 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package api import ( "android/soong/android" "android/soong/java" "fmt" "testing" "github.com/google/blueprint/proptools" ) var prepareForTestWithCombinedApis = android.GroupFixturePreparers( android.FixtureRegisterWithContext(registerBuildComponents), java.PrepareForTestWithJavaBuildComponents, android.FixtureAddTextFile("a/Android.bp", gatherRequiredDepsForTest()), java.PrepareForTestWithJavaSdkLibraryFiles, android.FixtureMergeMockFs(android.MockFS{ "a/api/current.txt": nil, "a/api/removed.txt": nil, "a/api/system-current.txt": nil, "a/api/system-removed.txt": nil, "a/api/test-current.txt": nil, "a/api/test-removed.txt": nil, "a/api/module-lib-current.txt": nil, "a/api/module-lib-removed.txt": nil, }), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Allow_missing_dependencies = proptools.BoolPtr(true) }), ) func gatherRequiredDepsForTest() string { var bp string extraLibraryModules := []string{ "stable.core.platform.api.stubs", "core-lambda-stubs", "core.current.stubs", "ext", "framework", "android_stubs_current.from-text", "android_system_stubs_current.from-text", "android_test_stubs_current.from-text", "android_test_frameworks_core_stubs_current.from-text", "android_module_lib_stubs_current.from-text", "android_system_server_stubs_current.from-text", "android_stubs_current.from-source", "android_system_stubs_current.from-source", "android_test_stubs_current.from-source", "android_test_frameworks_core_stubs_current.from-source", "android_module_lib_stubs_current.from-source", "android_system_server_stubs_current.from-source", "android_stubs_current_exportable.from-source", "android_system_stubs_current_exportable.from-source", "android_test_stubs_current_exportable.from-source", "android_module_lib_stubs_current_exportable.from-source", "android_system_server_stubs_current_exportable.from-source", "stub-annotations", } extraSdkLibraryModules := []string{ "framework-virtualization", "framework-location", } extraSystemModules := []string{ "core-public-stubs-system-modules", "core-module-lib-stubs-system-modules", "stable-core-platform-api-stubs-system-modules", } extraFilegroupModules := []string{ "non-updatable-current.txt", "non-updatable-removed.txt", "non-updatable-system-current.txt", "non-updatable-system-removed.txt", "non-updatable-test-current.txt", "non-updatable-test-removed.txt", "non-updatable-module-lib-current.txt", "non-updatable-module-lib-removed.txt", "non-updatable-system-server-current.txt", "non-updatable-system-server-removed.txt", "non-updatable-exportable-current.txt", "non-updatable-exportable-removed.txt", "non-updatable-exportable-system-current.txt", "non-updatable-exportable-system-removed.txt", "non-updatable-exportable-test-current.txt", "non-updatable-exportable-test-removed.txt", "non-updatable-exportable-module-lib-current.txt", "non-updatable-exportable-module-lib-removed.txt", "non-updatable-exportable-system-server-current.txt", "non-updatable-exportable-system-server-removed.txt", } for _, extra := range extraLibraryModules { bp += fmt.Sprintf(` java_library { name: "%s", srcs: ["a.java"], sdk_version: "none", system_modules: "stable-core-platform-api-stubs-system-modules", compile_dex: true, } `, extra) } for _, extra := range extraSdkLibraryModules { bp += fmt.Sprintf(` java_sdk_library { name: "%s", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", compile_dex: true, annotations_enabled: true, } `, extra) } for _, extra := range extraFilegroupModules { bp += fmt.Sprintf(` filegroup { name: "%[1]s", } `, extra) } for _, extra := range extraSystemModules { bp += fmt.Sprintf(` java_system_modules { name: "%[1]s", libs: ["%[1]s-lib"], } java_library { name: "%[1]s-lib", sdk_version: "none", system_modules: "none", } `, extra) } bp += fmt.Sprintf(` java_defaults { name: "android.jar_defaults", } `) return bp } func TestCombinedApisDefaults(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithCombinedApis, java.FixtureWithLastReleaseApis( "framework-location", "framework-virtualization", "framework-foo", "framework-bar"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.VendorVars = map[string]map[string]string{ "boolean_var": { "for_testing": "true", }, } }), ).RunTestWithBp(t, ` java_sdk_library { name: "framework-foo", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", annotations_enabled: true, } java_sdk_library { name: "framework-bar", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", annotations_enabled: true, } combined_apis { name: "foo", bootclasspath: [ "framework-bar", ] + select(boolean_var_for_testing(), { true: [ "framework-foo", ], default: [], }), } `) subModuleDependsOnSelectAppendedModule := java.CheckModuleHasDependency(t, result.TestContext, "foo-current.txt", "", "framework-foo") android.AssertBoolEquals(t, "Submodule expected to depend on the select-appended module", true, subModuleDependsOnSelectAppendedModule) } api/go.work +3 −3 Original line number Diff line number Diff line go 1.18 go 1.22 use ( . ../../../build/soong ../../../build/blueprint ../../../build/soong ../../../external/go-cmp ../../../external/golang-protobuf ) replace ( android/soong v0.0.0 => ../../../build/soong google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf github.com/google/blueprint v0.0.0 => ../../../build/blueprint github.com/google/go-cmp v0.0.0 => ../../../external/go-cmp go.starlark.net v0.0.0 => ../../../external/starlark-go google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf ) Loading
apex/jobscheduler/service/java/com/android/server/alarm/UserWakeupStore.java +8 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package com.android.server.alarm; import android.annotation.Nullable; import android.os.Environment; import android.os.SystemClock; import android.os.UserHandle; import android.util.AtomicFile; import android.util.IndentingPrintWriter; import android.util.Pair; Loading Loading @@ -113,16 +114,19 @@ public class UserWakeupStore { } /** * Add user wakeup for the alarm. * Add user wakeup for the alarm if needed. * @param userId Id of the user that scheduled alarm. * @param alarmTime time when alarm is expected to trigger. */ public void addUserWakeup(int userId, long alarmTime) { // SYSTEM user is always running, so no need to schedule wakeup for it. if (userId != UserHandle.USER_SYSTEM) { synchronized (mUserWakeupLock) { mUserStarts.put(userId, alarmTime - BUFFER_TIME_MS + getUserWakeupOffset()); } updateUserListFile(); } } /** * Remove wakeup scheduled for the user with given userId if present. Loading
api/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -29,12 +29,14 @@ bootstrap_go_package { pkgPath: "android/soong/api", deps: [ "blueprint", "blueprint-proptools", "soong", "soong-android", "soong-genrule", "soong-java", ], srcs: ["api.go"], testSrcs: ["api_test.go"], pluginFor: ["soong_build"], } Loading
api/api.go +18 −10 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ var non_updatable_modules = []string{virtualization, location} // The properties of the combined_apis module type. type CombinedApisProperties struct { // Module libraries in the bootclasspath Bootclasspath []string Bootclasspath proptools.Configurable[[]string] // Module libraries on the bootclasspath if include_nonpublic_framework_api is true. Conditional_bootclasspath []string // Module libraries in system server System_server_classpath []string System_server_classpath proptools.Configurable[[]string] } type CombinedApis struct { Loading @@ -79,29 +79,37 @@ func registerBuildComponents(ctx android.RegistrationContext) { var PrepareForCombinedApisTest = android.FixtureRegisterWithContext(registerBuildComponents) func (a *CombinedApis) apiFingerprintStubDeps() []string { func (a *CombinedApis) bootclasspath(ctx android.ConfigAndErrorContext) []string { return a.properties.Bootclasspath.GetOrDefault(a.ConfigurableEvaluator(ctx), nil) } func (a *CombinedApis) systemServerClasspath(ctx android.ConfigAndErrorContext) []string { return a.properties.System_server_classpath.GetOrDefault(a.ConfigurableEvaluator(ctx), nil) } func (a *CombinedApis) apiFingerprintStubDeps(ctx android.BottomUpMutatorContext) []string { ret := []string{} ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs")..., transformArray(a.bootclasspath(ctx), "", ".stubs")..., ) ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs.system")..., transformArray(a.bootclasspath(ctx), "", ".stubs.system")..., ) ret = append( ret, transformArray(a.properties.Bootclasspath, "", ".stubs.module_lib")..., transformArray(a.bootclasspath(ctx), "", ".stubs.module_lib")..., ) ret = append( ret, transformArray(a.properties.System_server_classpath, "", ".stubs.system_server")..., transformArray(a.systemServerClasspath(ctx), "", ".stubs.system_server")..., ) return ret } func (a *CombinedApis) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.AddDependency(ctx.Module(), nil, a.apiFingerprintStubDeps()...) ctx.AddDependency(ctx.Module(), nil, a.apiFingerprintStubDeps(ctx)...) } func (a *CombinedApis) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading Loading @@ -532,8 +540,8 @@ func createFullExportableApiLibraries(ctx android.LoadHookContext) { } func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { bootclasspath := a.properties.Bootclasspath system_server_classpath := a.properties.System_server_classpath bootclasspath := a.bootclasspath(ctx) system_server_classpath := a.systemServerClasspath(ctx) if ctx.Config().VendorConfig("ANDROID").Bool("include_nonpublic_framework_api") { bootclasspath = append(bootclasspath, a.properties.Conditional_bootclasspath...) sort.Strings(bootclasspath) Loading
api/api_test.go 0 → 100644 +254 −0 Original line number Diff line number Diff line // Copyright (C) 2024 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package api import ( "android/soong/android" "android/soong/java" "fmt" "testing" "github.com/google/blueprint/proptools" ) var prepareForTestWithCombinedApis = android.GroupFixturePreparers( android.FixtureRegisterWithContext(registerBuildComponents), java.PrepareForTestWithJavaBuildComponents, android.FixtureAddTextFile("a/Android.bp", gatherRequiredDepsForTest()), java.PrepareForTestWithJavaSdkLibraryFiles, android.FixtureMergeMockFs(android.MockFS{ "a/api/current.txt": nil, "a/api/removed.txt": nil, "a/api/system-current.txt": nil, "a/api/system-removed.txt": nil, "a/api/test-current.txt": nil, "a/api/test-removed.txt": nil, "a/api/module-lib-current.txt": nil, "a/api/module-lib-removed.txt": nil, }), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Allow_missing_dependencies = proptools.BoolPtr(true) }), ) func gatherRequiredDepsForTest() string { var bp string extraLibraryModules := []string{ "stable.core.platform.api.stubs", "core-lambda-stubs", "core.current.stubs", "ext", "framework", "android_stubs_current.from-text", "android_system_stubs_current.from-text", "android_test_stubs_current.from-text", "android_test_frameworks_core_stubs_current.from-text", "android_module_lib_stubs_current.from-text", "android_system_server_stubs_current.from-text", "android_stubs_current.from-source", "android_system_stubs_current.from-source", "android_test_stubs_current.from-source", "android_test_frameworks_core_stubs_current.from-source", "android_module_lib_stubs_current.from-source", "android_system_server_stubs_current.from-source", "android_stubs_current_exportable.from-source", "android_system_stubs_current_exportable.from-source", "android_test_stubs_current_exportable.from-source", "android_module_lib_stubs_current_exportable.from-source", "android_system_server_stubs_current_exportable.from-source", "stub-annotations", } extraSdkLibraryModules := []string{ "framework-virtualization", "framework-location", } extraSystemModules := []string{ "core-public-stubs-system-modules", "core-module-lib-stubs-system-modules", "stable-core-platform-api-stubs-system-modules", } extraFilegroupModules := []string{ "non-updatable-current.txt", "non-updatable-removed.txt", "non-updatable-system-current.txt", "non-updatable-system-removed.txt", "non-updatable-test-current.txt", "non-updatable-test-removed.txt", "non-updatable-module-lib-current.txt", "non-updatable-module-lib-removed.txt", "non-updatable-system-server-current.txt", "non-updatable-system-server-removed.txt", "non-updatable-exportable-current.txt", "non-updatable-exportable-removed.txt", "non-updatable-exportable-system-current.txt", "non-updatable-exportable-system-removed.txt", "non-updatable-exportable-test-current.txt", "non-updatable-exportable-test-removed.txt", "non-updatable-exportable-module-lib-current.txt", "non-updatable-exportable-module-lib-removed.txt", "non-updatable-exportable-system-server-current.txt", "non-updatable-exportable-system-server-removed.txt", } for _, extra := range extraLibraryModules { bp += fmt.Sprintf(` java_library { name: "%s", srcs: ["a.java"], sdk_version: "none", system_modules: "stable-core-platform-api-stubs-system-modules", compile_dex: true, } `, extra) } for _, extra := range extraSdkLibraryModules { bp += fmt.Sprintf(` java_sdk_library { name: "%s", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", compile_dex: true, annotations_enabled: true, } `, extra) } for _, extra := range extraFilegroupModules { bp += fmt.Sprintf(` filegroup { name: "%[1]s", } `, extra) } for _, extra := range extraSystemModules { bp += fmt.Sprintf(` java_system_modules { name: "%[1]s", libs: ["%[1]s-lib"], } java_library { name: "%[1]s-lib", sdk_version: "none", system_modules: "none", } `, extra) } bp += fmt.Sprintf(` java_defaults { name: "android.jar_defaults", } `) return bp } func TestCombinedApisDefaults(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithCombinedApis, java.FixtureWithLastReleaseApis( "framework-location", "framework-virtualization", "framework-foo", "framework-bar"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.VendorVars = map[string]map[string]string{ "boolean_var": { "for_testing": "true", }, } }), ).RunTestWithBp(t, ` java_sdk_library { name: "framework-foo", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", annotations_enabled: true, } java_sdk_library { name: "framework-bar", srcs: ["a.java"], public: { enabled: true, }, system: { enabled: true, }, test: { enabled: true, }, module_lib: { enabled: true, }, api_packages: [ "foo", ], sdk_version: "core_current", annotations_enabled: true, } combined_apis { name: "foo", bootclasspath: [ "framework-bar", ] + select(boolean_var_for_testing(), { true: [ "framework-foo", ], default: [], }), } `) subModuleDependsOnSelectAppendedModule := java.CheckModuleHasDependency(t, result.TestContext, "foo-current.txt", "", "framework-foo") android.AssertBoolEquals(t, "Submodule expected to depend on the select-appended module", true, subModuleDependsOnSelectAppendedModule) }
api/go.work +3 −3 Original line number Diff line number Diff line go 1.18 go 1.22 use ( . ../../../build/soong ../../../build/blueprint ../../../build/soong ../../../external/go-cmp ../../../external/golang-protobuf ) replace ( android/soong v0.0.0 => ../../../build/soong google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf github.com/google/blueprint v0.0.0 => ../../../build/blueprint github.com/google/go-cmp v0.0.0 => ../../../external/go-cmp go.starlark.net v0.0.0 => ../../../external/starlark-go google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf )