Merge "Skip unsupported tests on low ram devices." into stage-aosp-oc-mr1-cts-dev am: e352866bee

am: dfc9fb0901

Change-Id: I81f9100fa7e10c1a18225733a6ce5c3645876a46
This commit is contained in:
Sudheer Shanka
2018-01-03 20:32:37 +00:00
committed by android-build-merger
2 changed files with 8 additions and 1 deletions

View File

@@ -129,7 +129,7 @@ abstract class AbstractDozeModeTestCase extends AbstractRestrictBackgroundNetwor
public void testBackgroundNetworkAccess_enabledButWhitelistedOnNotificationAction() public void testBackgroundNetworkAccess_enabledButWhitelistedOnNotificationAction()
throws Exception { throws Exception {
if (!isSupported()) return; if (!isSupported() || isLowRamDevice()) return;
setPendingIntentWhitelistDuration(NETWORK_TIMEOUT_MS); setPendingIntentWhitelistDuration(NETWORK_TIMEOUT_MS);
try { try {

View File

@@ -26,6 +26,7 @@ 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;
import android.app.ActivityManager;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -476,6 +477,12 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
return errors.toString(); return errors.toString();
} }
protected boolean isLowRamDevice() {
final ActivityManager am = (ActivityManager) mContext.getSystemService(
Context.ACTIVITY_SERVICE);
return am.isLowRamDevice();
}
protected String executeShellCommand(String command) throws Exception { protected String executeShellCommand(String command) throws Exception {
final String result = runShellCommand(mInstrumentation, command).trim(); final String result = runShellCommand(mInstrumentation, command).trim();
if (DEBUG) Log.d(TAG, "Command '" + command + "' returned '" + result + "'"); if (DEBUG) Log.d(TAG, "Command '" + command + "' returned '" + result + "'");