Loading wifi/java/android/net/wifi/WifiManager.java +14 −7 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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; } /** Loading wifi/tests/src/android/net/wifi/WifiManagerTest.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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()); } /** Loading Loading
wifi/java/android/net/wifi/WifiManager.java +14 −7 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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; } /** Loading
wifi/tests/src/android/net/wifi/WifiManagerTest.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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()); } /** Loading