Merge "Breaking up hostside network tests module" into main
This commit is contained in:
commit
da77ebefa9
73 changed files with 763 additions and 336 deletions
46
tests/cts/hostside-network-policy/Android.bp
Normal file
46
tests/cts/hostside-network-policy/Android.bp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// 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 {
|
||||
default_team: "trendy_team_framework_backstage_power",
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
java_test_host {
|
||||
name: "CtsHostsideNetworkPolicyTests",
|
||||
defaults: ["cts_defaults"],
|
||||
// Only compile source java files in this apk.
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
":ArgumentConstants",
|
||||
],
|
||||
libs: [
|
||||
"cts-tradefed",
|
||||
"tradefed",
|
||||
],
|
||||
static_libs: [
|
||||
"modules-utils-build-testing",
|
||||
],
|
||||
// Tag this module as a cts test artifact
|
||||
test_suites: [
|
||||
"cts",
|
||||
"general-tests",
|
||||
"sts",
|
||||
],
|
||||
data: [
|
||||
":CtsHostsideNetworkPolicyTestsApp",
|
||||
":CtsHostsideNetworkPolicyTestsApp2",
|
||||
],
|
||||
per_testcase_directory: true,
|
||||
}
|
||||
51
tests/cts/hostside-network-policy/AndroidTest.xml
Normal file
51
tests/cts/hostside-network-policy/AndroidTest.xml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<configuration description="Config for CTS network policy host test cases">
|
||||
<option name="test-suite-tag" value="cts" />
|
||||
<option name="config-descriptor:metadata" key="component" value="networking" />
|
||||
<option name="config-descriptor:metadata" key="token" value="SIM_CARD" />
|
||||
<option name="config-descriptor:metadata" key="parameter" value="instant_app" />
|
||||
<option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
|
||||
<option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
|
||||
|
||||
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.LocationCheck" />
|
||||
<target_preparer class="com.android.cts.netpolicy.NetworkPolicyTestsPreparer" />
|
||||
|
||||
<!-- Enabling change id ALLOW_TEST_API_ACCESS allows that package to access @TestApi methods -->
|
||||
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
|
||||
<option name="run-command" value="am compat enable ALLOW_TEST_API_ACCESS com.android.cts.netpolicy.hostside.app2" />
|
||||
<option name="teardown-command" value="am compat reset ALLOW_TEST_API_ACCESS com.android.cts.netpolicy.hostside.app2" />
|
||||
<option name="teardown-command" value="cmd power set-mode 0" />
|
||||
<option name="teardown-command" value="cmd battery reset" />
|
||||
<option name="teardown-command" value="cmd netpolicy stop-watching" />
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
|
||||
<option name="force-skip-system-props" value="true" />
|
||||
<option name="set-global-setting" key="verifier_verify_adb_installs" value="0" />
|
||||
<option name="set-global-setting" key="low_power_standby_enabled" value="0" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
|
||||
<option name="jar" value="CtsHostsideNetworkPolicyTests.jar" />
|
||||
<option name="runtime-hint" value="3m56s" />
|
||||
</test>
|
||||
|
||||
<metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
|
||||
<option name="directory-keys" value="/sdcard/CtsHostsideNetworkPolicyTests" />
|
||||
<option name="collect-on-run-ended-only" value="true" />
|
||||
</metrics_collector>
|
||||
</configuration>
|
||||
3
tests/cts/hostside-network-policy/OWNERS
Normal file
3
tests/cts/hostside-network-policy/OWNERS
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Bug component: 61373
|
||||
# Inherits parent owners
|
||||
include platform/frameworks/base:/services/core/java/com/android/server/net/OWNERS
|
||||
27
tests/cts/hostside-network-policy/TEST_MAPPING
Normal file
27
tests/cts/hostside-network-policy/TEST_MAPPING
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"presubmit-large": [
|
||||
{
|
||||
"name": "CtsHostsideNetworkPolicyTests",
|
||||
"options": [
|
||||
{
|
||||
"exclude-annotation": "android.platform.test.annotations.FlakyTest"
|
||||
},
|
||||
{
|
||||
"exclude-annotation": "android.platform.test.annotations.RequiresDevice"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"postsubmit": [
|
||||
{
|
||||
// Postsubmit on virtual devices to monitor flakiness of all tests that don't require a
|
||||
// physical device
|
||||
"name": "CtsHostsideNetworkPolicyTests",
|
||||
"options": [
|
||||
{
|
||||
"exclude-annotation": "androidx.test.filters.RequiresDevice"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
26
tests/cts/hostside-network-policy/aidl/Android.bp
Normal file
26
tests/cts/hostside-network-policy/aidl/Android.bp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// 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 {
|
||||
default_team: "trendy_team_framework_backstage_power",
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
java_test_helper_library {
|
||||
name: "CtsHostsideNetworkPolicyTestsAidl",
|
||||
sdk_version: "current",
|
||||
srcs: [
|
||||
"com/android/cts/netpolicy/hostside/*.aidl",
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import android.app.job.JobInfo;
|
||||
|
||||
import com.android.cts.netpolicy.hostside.INetworkCallback;
|
||||
import com.android.cts.netpolicy.hostside.NetworkCheckResult;
|
||||
|
||||
interface IMyService {
|
||||
void registerBroadcastReceiver();
|
||||
int getCounters(String receiverName, String action);
|
||||
NetworkCheckResult checkNetworkStatus(String customUrl);
|
||||
String getRestrictBackgroundStatus();
|
||||
void sendNotification(int notificationId, String notificationType);
|
||||
void registerNetworkCallback(in NetworkRequest request, in INetworkCallback cb);
|
||||
void unregisterNetworkCallback();
|
||||
int scheduleJob(in JobInfo jobInfo);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
|
||||
interface INetworkCallback {
|
||||
void onBlockedStatusChanged(in Network network, boolean blocked);
|
||||
void onAvailable(in Network network);
|
||||
void onLost(in Network network);
|
||||
void onCapabilitiesChanged(in Network network, in NetworkCapabilities cap);
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.android.cts.netpolicy.hostside.NetworkCheckResult;
|
||||
|
||||
interface INetworkStateObserver {
|
||||
void onNetworkStateChecked(int resultCode, in NetworkCheckResult networkCheckResult);
|
||||
|
||||
const int RESULT_SUCCESS_NETWORK_STATE_CHECKED = 0;
|
||||
const int RESULT_ERROR_UNEXPECTED_PROC_STATE = 1;
|
||||
const int RESULT_ERROR_UNEXPECTED_CAPABILITIES = 2;
|
||||
const int RESULT_ERROR_OTHER = 3;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
@JavaDerive(toString=true)
|
||||
parcelable NetworkCheckResult {
|
||||
boolean connected;
|
||||
String details;
|
||||
NetworkInfo networkInfo;
|
||||
}
|
||||
57
tests/cts/hostside-network-policy/app/Android.bp
Normal file
57
tests/cts/hostside-network-policy/app/Android.bp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// 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 {
|
||||
default_team: "trendy_team_framework_backstage_power",
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
java_defaults {
|
||||
name: "CtsHostsideNetworkPolicyTestsAppDefaults",
|
||||
platform_apis: true,
|
||||
static_libs: [
|
||||
"CtsHostsideNetworkPolicyTestsAidl",
|
||||
"androidx.test.ext.junit",
|
||||
"androidx.test.rules",
|
||||
"androidx.test.uiautomator_uiautomator",
|
||||
"compatibility-device-util-axt",
|
||||
"cts-net-utils",
|
||||
"ctstestrunner-axt",
|
||||
"modules-utils-build",
|
||||
],
|
||||
libs: [
|
||||
"android.test.runner",
|
||||
"android.test.base",
|
||||
],
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
":ArgumentConstants",
|
||||
],
|
||||
// Tag this module as a cts test artifact
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"sts",
|
||||
],
|
||||
}
|
||||
|
||||
android_test_helper_app {
|
||||
name: "CtsHostsideNetworkPolicyTestsApp",
|
||||
defaults: [
|
||||
"cts_support_defaults",
|
||||
"framework-connectivity-test-defaults",
|
||||
"CtsHostsideNetworkPolicyTestsAppDefaults",
|
||||
],
|
||||
}
|
||||
50
tests/cts/hostside-network-policy/app/AndroidManifest.xml
Normal file
50
tests/cts/hostside-network-policy/app/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.cts.netpolicy.hostside">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application android:requestLegacyExternalStorage="true">
|
||||
<uses-library android:name="android.test.runner"/>
|
||||
<service android:name=".MyNotificationListenerService"
|
||||
android:label="MyNotificationListenerService"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.notification.NotificationListenerService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.cts.netpolicy.hostside"/>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.APP_STANDBY_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.BATTERY_SAVER_MODE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Base class for metered and non-metered tests on idle apps.
|
||||
*/
|
||||
@RequiredProperties({APP_STANDBY_MODE})
|
||||
abstract class AbstractAppIdleTestCase extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
|
||||
@Before
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Set initial state.
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
setAppIdle(false);
|
||||
turnBatteryOn();
|
||||
|
||||
registerBroadcastReceiver();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
||||
resetBatteryState();
|
||||
setAppIdle(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_enabled() throws Exception {
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure foreground app doesn't lose access upon enabling it.
|
||||
setAppIdle(true);
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_ACTIVTIY);
|
||||
finishActivity();
|
||||
assertAppIdle(false); // verify - not idle anymore, since activity was launched...
|
||||
assertBackgroundNetworkAccess(true);
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Same for foreground service.
|
||||
setAppIdle(true);
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
stopForegroundService();
|
||||
assertAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Set Idle after foreground service start.
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
setAppIdle(true);
|
||||
addPowerSaveModeWhitelist(TEST_PKG);
|
||||
removePowerSaveModeWhitelist(TEST_PKG);
|
||||
assertForegroundServiceNetworkAccess();
|
||||
stopForegroundService();
|
||||
assertAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_whitelisted() throws Exception {
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addPowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertAppIdle(false); // verify - not idle anymore, since whitelisted
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
setAppIdleNoAssert(true);
|
||||
assertAppIdle(false); // app is still whitelisted
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertAppIdle(true); // verify - idle again, once whitelisted was removed
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
setAppIdle(true);
|
||||
addPowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertAppIdle(false); // verify - not idle anymore, since whitelisted
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
setAppIdleNoAssert(true);
|
||||
assertAppIdle(false); // app is still whitelisted
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertAppIdle(true); // verify - idle again, once whitelisted was removed
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
|
||||
// verify - no whitelist, no access!
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_tempWhitelisted() throws Exception {
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addTempPowerSaveModeWhitelist(TEST_APP2_PKG, TEMP_POWERSAVE_WHITELIST_DURATION_MS);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
// Wait until the whitelist duration is expired.
|
||||
SystemClock.sleep(TEMP_POWERSAVE_WHITELIST_DURATION_MS);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_disabled() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
|
||||
@RequiredProperties({BATTERY_SAVER_MODE})
|
||||
@Test
|
||||
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
|
||||
// Check that app is paroled when charging
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnBatteryOff();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
turnBatteryOn();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Check that app is restricted when not idle but power-save is on
|
||||
setAppIdle(false);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
// Use setBatterySaverMode API to leave power-save mode instead of plugging in charger
|
||||
setBatterySaverMode(false);
|
||||
turnBatteryOff();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
// And when no longer charging, it still has network access, since it's not idle
|
||||
turnBatteryOn();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppIdleNetworkAccess_idleWhitelisted() throws Exception {
|
||||
setAppIdle(true);
|
||||
assertAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addAppIdleWhitelist(mUid);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
removeAppIdleWhitelist(mUid);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure whitelisting a random app doesn't affect the tested app.
|
||||
addAppIdleWhitelist(mUid + 1);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
removeAppIdleWhitelist(mUid + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppIdle_toast() throws Exception {
|
||||
setAppIdle(true);
|
||||
assertAppIdle(true);
|
||||
assertEquals("Shown", showToast());
|
||||
assertAppIdle(true);
|
||||
// Wait for a couple of seconds for the toast to actually be shown
|
||||
SystemClock.sleep(2000);
|
||||
assertAppIdle(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.BATTERY_SAVER_MODE;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Base class for metered and non-metered Battery Saver Mode tests.
|
||||
*/
|
||||
@RequiredProperties({BATTERY_SAVER_MODE})
|
||||
abstract class AbstractBatterySaverModeTestCase extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
|
||||
@Before
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Set initial state.
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
setBatterySaverMode(false);
|
||||
|
||||
registerBroadcastReceiver();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
||||
setBatterySaverMode(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_enabled() throws Exception {
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure foreground app doesn't lose access upon Battery Saver.
|
||||
setBatterySaverMode(false);
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_ACTIVTIY);
|
||||
setBatterySaverMode(true);
|
||||
assertTopNetworkAccess(true);
|
||||
|
||||
// Although it should not have access while the screen is off.
|
||||
turnScreenOff();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnScreenOn();
|
||||
assertTopNetworkAccess(true);
|
||||
|
||||
// Goes back to background state.
|
||||
finishActivity();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure foreground service doesn't lose access upon enabling Battery Saver.
|
||||
setBatterySaverMode(false);
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
setBatterySaverMode(true);
|
||||
assertForegroundServiceNetworkAccess();
|
||||
stopForegroundService();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_whitelisted() throws Exception {
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addPowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addPowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_disabled() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static android.app.ActivityManager.PROCESS_STATE_TOP_SLEEPING;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Base class for default, always-on network restrictions.
|
||||
*/
|
||||
abstract class AbstractDefaultRestrictionsTest extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
|
||||
@Before
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
|
||||
registerBroadcastReceiver();
|
||||
assumeTrue("Feature not enabled", isNetworkBlockedForTopSleepingAndAbove());
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFgsNetworkAccess() throws Exception {
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
SystemClock.sleep(PROCESS_STATE_TRANSITION_DELAY_MS);
|
||||
assertNetworkAccess(false, null);
|
||||
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActivityNetworkAccess() throws Exception {
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
SystemClock.sleep(PROCESS_STATE_TRANSITION_DELAY_MS);
|
||||
assertNetworkAccess(false, null);
|
||||
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_ACTIVTIY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_inFullAllowlist() throws Exception {
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
SystemClock.sleep(PROCESS_STATE_TRANSITION_DELAY_MS);
|
||||
assertNetworkAccess(false, null);
|
||||
|
||||
addPowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
assertNetworkAccess(true, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_inExceptIdleAllowlist() throws Exception {
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
SystemClock.sleep(PROCESS_STATE_TRANSITION_DELAY_MS);
|
||||
assertNetworkAccess(false, null);
|
||||
|
||||
addPowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertProcessStateBelow(PROCESS_STATE_TOP_SLEEPING);
|
||||
assertNetworkAccess(true, null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static android.app.ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.DOZE_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.NOT_LOW_RAM_DEVICE;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Base class for metered and non-metered Doze Mode tests.
|
||||
*/
|
||||
@RequiredProperties({DOZE_MODE})
|
||||
abstract class AbstractDozeModeTestCase extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
|
||||
@Before
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Set initial state.
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
setDozeMode(false);
|
||||
|
||||
registerBroadcastReceiver();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
||||
setDozeMode(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_enabled() throws Exception {
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure foreground service doesn't lose network access upon enabling doze.
|
||||
setDozeMode(false);
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
setDozeMode(true);
|
||||
assertForegroundServiceNetworkAccess();
|
||||
stopForegroundService();
|
||||
assertProcessStateBelow(PROCESS_STATE_BOUND_FOREGROUND_SERVICE);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_whitelisted() throws Exception {
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addPowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
removePowerSaveModeWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
addPowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_disabled() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
|
||||
@RequiredProperties({NOT_LOW_RAM_DEVICE})
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_enabledButWhitelistedOnNotificationAction()
|
||||
throws Exception {
|
||||
setPendingIntentAllowlistDuration(NETWORK_TIMEOUT_MS);
|
||||
try {
|
||||
registerNotificationListenerService();
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
testNotification(4, NOTIFICATION_TYPE_CONTENT);
|
||||
testNotification(8, NOTIFICATION_TYPE_DELETE);
|
||||
testNotification(15, NOTIFICATION_TYPE_FULL_SCREEN);
|
||||
testNotification(16, NOTIFICATION_TYPE_BUNDLE);
|
||||
testNotification(23, NOTIFICATION_TYPE_ACTION);
|
||||
testNotification(42, NOTIFICATION_TYPE_ACTION_BUNDLE);
|
||||
testNotification(108, NOTIFICATION_TYPE_ACTION_REMOTE_INPUT);
|
||||
} finally {
|
||||
resetDeviceIdleSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void testNotification(int id, String type) throws Exception {
|
||||
sendNotification(id, type);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
if (type.equals(NOTIFICATION_TYPE_ACTION)) {
|
||||
// Make sure access is disabled after it expires. Since this check considerably slows
|
||||
// downs the CTS tests, do it just once.
|
||||
SystemClock.sleep(NETWORK_TIMEOUT_MS);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Must override so it only tests foreground service - once an app goes to foreground, device
|
||||
// leaves Doze Mode.
|
||||
@Override
|
||||
protected void assertsForegroundAlwaysHasNetworkAccess() throws Exception {
|
||||
launchComponentAndAssertNetworkAccess(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
stopForegroundService();
|
||||
assertProcessStateBelow(PROCESS_STATE_BOUND_FOREGROUND_SERVICE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.NetworkPolicyTestUtils.setRestrictBackground;
|
||||
import static com.android.cts.netpolicy.hostside.Property.APP_STANDBY_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.BATTERY_SAVER_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.DATA_SAVER_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.DOZE_MODE;
|
||||
import static com.android.cts.netpolicy.hostside.Property.METERED_NETWORK;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AbstractExpeditedJobTest extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
@Before
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
resetDeviceState();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
resetDeviceState();
|
||||
}
|
||||
|
||||
private void resetDeviceState() throws Exception {
|
||||
resetBatteryState();
|
||||
setBatterySaverMode(false);
|
||||
setRestrictBackground(false);
|
||||
setAppIdle(false);
|
||||
setDozeMode(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({BATTERY_SAVER_MODE})
|
||||
public void testNetworkAccess_batterySaverMode() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({DATA_SAVER_MODE, METERED_NETWORK})
|
||||
public void testNetworkAccess_dataSaverMode() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setRestrictBackground(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNoNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({APP_STANDBY_MODE})
|
||||
public void testNetworkAccess_appIdleState() throws Exception {
|
||||
turnBatteryOn();
|
||||
setAppIdle(false);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({DOZE_MODE})
|
||||
public void testNetworkAccess_dozeMode() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({DATA_SAVER_MODE, BATTERY_SAVER_MODE, METERED_NETWORK})
|
||||
public void testNetworkAccess_dataAndBatterySaverMode() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setRestrictBackground(true);
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNoNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({DOZE_MODE, DATA_SAVER_MODE, METERED_NETWORK})
|
||||
public void testNetworkAccess_dozeAndDataSaverMode() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setRestrictBackground(true);
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNoNetworkAccess();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiredProperties({DATA_SAVER_MODE, BATTERY_SAVER_MODE, METERED_NETWORK, DOZE_MODE,
|
||||
APP_STANDBY_MODE})
|
||||
public void testNetworkAccess_allRestrictionsEnabled() throws Exception {
|
||||
assertBackgroundNetworkAccess(true);
|
||||
assertExpeditedJobHasNetworkAccess();
|
||||
|
||||
setRestrictBackground(true);
|
||||
setBatterySaverMode(true);
|
||||
setAppIdle(true);
|
||||
setDozeMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
assertExpeditedJobHasNoNetworkAccess();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.METERED_NETWORK;
|
||||
|
||||
@RequiredProperties({METERED_NETWORK})
|
||||
public class AppIdleMeteredTest extends AbstractAppIdleTestCase {
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.NON_METERED_NETWORK;
|
||||
|
||||
@RequiredProperties({NON_METERED_NETWORK})
|
||||
public class AppIdleNonMeteredTest extends AbstractAppIdleTestCase {
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 com.android.cts.netpolicy.hostside;
|
||||
|
||||
import static com.android.cts.netpolicy.hostside.Property.METERED_NETWORK;
|
||||
|
||||
@RequiredProperties({METERED_NETWORK})
|
||||
public class BatterySaverModeMeteredTest extends AbstractBatterySaverModeTestCase {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue