Skip unsupported tests on low ram devices.

Notification listeners are not allowed on low ram devices.
Skip testDozeModeMetered_enabledButWhitelistedOnNotificationAction
and testDozeModeNonMetered_enabledButWhitelistedOnNotificationAction
on low ram devices since these tests depend on being able to
register notification listeners.

Bug: 70242457
Bug: 70545780
Test: testDozeModeMetered_enabledButWhitelistedOnNotificationAction
and testDozeModeNonMetered_enabledButWhitelistedOnNotificationAction
Change-Id: I8ce6f330760042ca790cd6fb10e62ebe86498a06
This commit is contained in:
Sudheer Shanka
2017-12-16 20:18:18 -08:00
parent cd4ab882f0
commit b7a503b578
2 changed files with 8 additions and 1 deletions

View File

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

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
@@ -476,6 +477,12 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
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 {
final String result = runShellCommand(mInstrumentation, command).trim();
if (DEBUG) Log.d(TAG, "Command '" + command + "' returned '" + result + "'");