From d8ff97bf8d33d71a098733b0e241290c2fbe53eb Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Mon, 18 Apr 2022 17:50:35 +0000 Subject: [PATCH] Remove NOT_RESTRICTED from basic network requests. JobScheduler only ever tells a job to run on the default network. If the connectivity stack says an app's default network is a restricted network, then the app has permission to use that restricted network. However, default NetworkRequests exclude restricted networks by default. Removing this exclusion for basic job NetworkRequests so that a job can run on a restricted network if the app is allowed to do so. Bug: 219788183 Test: atest CtsJobSchedulerTestCases:JobInfoTest Change-Id: I3c2b9f725c7e1254c7708f5b8df7bdf18163608e --- apex/jobscheduler/framework/java/android/app/job/JobInfo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java index b9673f25d680f..18665e7f4d22c 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java @@ -18,6 +18,7 @@ package android.app.job; import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED; +import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN; import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED; @@ -1332,6 +1333,7 @@ public class JobInfo implements Parcelable { builder.addCapability(NET_CAPABILITY_INTERNET); builder.addCapability(NET_CAPABILITY_VALIDATED); builder.removeCapability(NET_CAPABILITY_NOT_VPN); + builder.removeCapability(NET_CAPABILITY_NOT_RESTRICTED); if (networkType == NETWORK_TYPE_ANY) { // No other capabilities