Merge "Skip battery saver related tests on unsupported devices." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f8eb2722ff
@@ -150,6 +150,11 @@ abstract class AbstractAppIdleTestCase extends AbstractRestrictBackgroundNetwork
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
|
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) return;
|
if (!isSupported()) return;
|
||||||
|
|
||||||
// Check that app is paroled when charging
|
// Check that app is paroled when charging
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.cts.net.hostside;
|
package com.android.cts.net.hostside;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,12 +53,19 @@ abstract class AbstractBatterySaverModeTestCase extends AbstractRestrictBackgrou
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSupported() throws Exception {
|
protected boolean isSupported() throws Exception {
|
||||||
boolean supported = isDozeModeEnabled();
|
String unSupported = "";
|
||||||
if (!supported) {
|
if (!isDozeModeEnabled()) {
|
||||||
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
unSupported += "Doze mode,";
|
||||||
+ "() because device does not support Doze Mode");
|
|
||||||
}
|
}
|
||||||
return supported;
|
if (!isBatterySaverSupported()) {
|
||||||
|
unSupported += "Battery saver mode,";
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(unSupported)) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support " + unSupported);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
@@ -43,12 +44,15 @@ import android.os.BatteryManager;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.compatibility.common.util.BatteryUtils;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -311,6 +315,10 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
|
|||||||
return mSupported;
|
return mSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isBatterySaverSupported() {
|
||||||
|
return BatteryUtils.isBatterySaverSupported();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that an app always have access while on foreground or running a foreground service.
|
* Asserts that an app always have access while on foreground or running a foreground service.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
* Tests all DS ON and BS ON scenarios from network-policy-restrictions.md on metered networks.
|
* Tests all DS ON and BS ON scenarios from network-policy-restrictions.md on metered networks.
|
||||||
*/
|
*/
|
||||||
public void testDataAndBatterySaverModes_meteredNetwork() throws Exception {
|
public void testDataAndBatterySaverModes_meteredNetwork() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) return;
|
if (!isSupported()) return;
|
||||||
|
|
||||||
Log.i(TAG, "testDataAndBatterySaverModes_meteredNetwork() tests");
|
Log.i(TAG, "testDataAndBatterySaverModes_meteredNetwork() tests");
|
||||||
@@ -141,6 +146,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
* networks.
|
* networks.
|
||||||
*/
|
*/
|
||||||
public void testDataAndBatterySaverModes_nonMeteredNetwork() throws Exception {
|
public void testDataAndBatterySaverModes_nonMeteredNetwork() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) return;
|
if (!isSupported()) return;
|
||||||
|
|
||||||
if (!setUnmeteredNetwork()) {
|
if (!setUnmeteredNetwork()) {
|
||||||
@@ -206,6 +216,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
* are enabled.
|
* are enabled.
|
||||||
*/
|
*/
|
||||||
public void testDozeAndBatterySaverMode_powerSaveWhitelists() throws Exception {
|
public void testDozeAndBatterySaverMode_powerSaveWhitelists() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) {
|
if (!isSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -285,6 +300,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAppIdleAndBatterySaver_tempPowerSaveWhitelists() throws Exception {
|
public void testAppIdleAndBatterySaver_tempPowerSaveWhitelists() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) {
|
if (!isSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -361,6 +381,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists() throws Exception {
|
public void testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists() throws Exception {
|
||||||
|
if (!isBatterySaverSupported()) {
|
||||||
|
Log.i(TAG, "Skipping " + getClass() + "." + getName()
|
||||||
|
+ "() because device does not support Battery saver mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSupported()) {
|
if (!isSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user