Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6efa3fc authored by David Su's avatar David Su
Browse files

framework-wifi: Stop using @hide isLowRamDeviceStatic

Migrate isLowRamDeviceStatic() to isLowRamDevice()

Bug: 145409537
Test: atest FrameworksWifiApiTests
Change-Id: I4346e5b5b470f0e5ab8c8c2e89f0f8a575aa2b3e
parent b26b3c9c
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+11 −2
Original line number Diff line number Diff line
@@ -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;
@@ -1395,8 +1397,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());
    }

    /**