Merge "framework-wifi: Stop using @hide isLowRamDeviceStatic"

This commit is contained in:
David Su
2019-12-03 20:12:23 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 9 deletions

View File

@@ -146,12 +146,11 @@ public class WifiManager {
@Deprecated
public static final int ERROR_AUTH_FAILURE_EAP_FAILURE = 3;
/**
* Maximum number of active network suggestions allowed per app.
* @hide
*/
public static final int NETWORK_SUGGESTIONS_MAX_PER_APP =
ActivityManager.isLowRamDeviceStatic() ? 256 : 1024;
/** @hide */
public static final int NETWORK_SUGGESTIONS_MAX_PER_APP_LOW_RAM = 256;
/** @hide */
public static final int NETWORK_SUGGESTIONS_MAX_PER_APP_HIGH_RAM = 1024;
/**
* Reason code if all of the network suggestions were successfully added or removed.
@@ -1830,7 +1829,15 @@ public class WifiManager {
* @see #removeNetworkSuggestions(List)
*/
public int getMaxNumberOfNetworkSuggestionsPerApp() {
return NETWORK_SUGGESTIONS_MAX_PER_APP;
return getMaxNumberOfNetworkSuggestionsPerApp(
mContext.getSystemService(ActivityManager.class).isLowRamDevice());
}
/** @hide */
public static int getMaxNumberOfNetworkSuggestionsPerApp(boolean isLowRamDevice) {
return isLowRamDevice
? NETWORK_SUGGESTIONS_MAX_PER_APP_LOW_RAM
: NETWORK_SUGGESTIONS_MAX_PER_APP_HIGH_RAM;
}
/**

View File

@@ -50,6 +50,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.net.DhcpInfo;
@@ -116,6 +117,7 @@ public class WifiManagerTest {
@Mock Runnable mRunnable;
@Mock Executor mExecutor;
@Mock Executor mAnotherExecutor;
@Mock ActivityManager mActivityManager;
private Handler mHandler;
private TestLooper mLooper;
@@ -1459,8 +1461,15 @@ public class WifiManagerTest {
*/
@Test
public void getMaxNumberOfNetworkSuggestionsPerApp() {
assertEquals(WifiManager.NETWORK_SUGGESTIONS_MAX_PER_APP,
mWifiManager.getMaxNumberOfNetworkSuggestionsPerApp());
when(mContext.getSystemServiceName(ActivityManager.class))
.thenReturn(Context.ACTIVITY_SERVICE);
when(mContext.getSystemService(Context.ACTIVITY_SERVICE))
.thenReturn(mActivityManager);
when(mActivityManager.isLowRamDevice()).thenReturn(true);
assertEquals(256, mWifiManager.getMaxNumberOfNetworkSuggestionsPerApp());
when(mActivityManager.isLowRamDevice()).thenReturn(false);
assertEquals(1024, mWifiManager.getMaxNumberOfNetworkSuggestionsPerApp());
}
/**