Restricting background apps from running jobs
Introducing a new app op which controls whether apps are allowed to run
jobs in the background. When the app op mode is set to ignored, jobs
will be delayed until the app is in the foreground. The same semantics
as background check for O apps will apply, which means power whitelisted
apps can still run jobs freely and apps will have some settle time after
going to background after which their jobs will be stopped.
Test:
Added AppOpsUpgradeTest for upgrading appops to inherit existing value of
OP_RUN_ANY_IN_BACKGROUND from OP_RUN_IN_BACKGROUND
Added backgroundRestrictionsTest for background jobs. To run the test:
mmm -j32 services/tests/servicestests/
adb install -r \
out/target/product/marlin/data/app/JobTestApp/JobTestApp.apk
adb install -r \
out/target/product/marlin/data/app/FrameworksServicesTests/FrameworksServicesTests.apk
adb shell am instrument -e class
'com.android.server.job.BackgroundRestrictionsTest' -w
'com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner'
Bug: 63001625
Change-Id: I6eb01adb6cd2c1d0e7be4f7eca960f57ad9581bf
diff --git a/services/tests/servicestests/Android.mk b/services/tests/servicestests/Android.mk
index 507b483..baec956 100644
--- a/services/tests/servicestests/Android.mk
+++ b/services/tests/servicestests/Android.mk
@@ -30,6 +30,7 @@
LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl
LOCAL_SRC_FILES += aidl/com/android/servicestests/aidl/INetworkStateObserver.aidl
+LOCAL_SRC_FILES += $(call all-java-files-under, test-apps/JobTestApp/src)
LOCAL_JAVA_LIBRARIES := android.test.mock legacy-android-test
@@ -61,3 +62,5 @@
LOCAL_STATIC_JAVA_LIBRARIES += ub-uiautomator
include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under, $(LOCAL_PATH))