diff options
author | Roshan Pius <rpius@google.com> | 2019-11-14 07:35:24 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-11-18 11:38:02 -0800 |
commit | 9ddb074cf86618457489e0de156cfb7fd2dcf3b1 (patch) | |
tree | d2c48130e532e1749bf98df67c53034ec01513e8 /tests | |
parent | ce6319e03c423f4dd0e41a40027fe02d76b02599 (diff) |
ScoredNetworkEvaluator: Use new @SystemApi for NetworkScoreManager
Also,
a) retrieve the uid for the scorer app using packageManager instead
of using the @hide getActiveScorer() method.
b) Dump the state of the callback when wifi service dump is triggered.
Bug: 144487252
Test: a) Device boots up and connects to wifi network.
b) Manually verified that network scores are being requested & updated
with the new interface.
Change-Id: Iddf5a640e78553ebef03b9f762904c2dacc57807
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java index bff45c99b..cae97dfd3 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java @@ -24,6 +24,8 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.database.ContentObserver; import android.net.NetworkKey; import android.net.NetworkScoreManager; @@ -72,6 +74,7 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest { @Mock private Clock mClock; @Mock private FrameworkFacade mFrameworkFacade; @Mock private NetworkScoreManager mNetworkScoreManager; + @Mock private PackageManager mPackageManager; @Mock private WifiConfigManager mWifiConfigManager; @Mock private WifiPermissionsUtil mWifiPermissionsUtil; @Mock private OnConnectableListener mOnConnectableListener; @@ -91,13 +94,18 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest { when(mFrameworkFacade.getIntegerSetting(mContext, Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0)) .thenReturn(1); + ApplicationInfo appInfo = new ApplicationInfo(); + appInfo.uid = TEST_UID; + when(mPackageManager.getApplicationInfo(any(), anyInt())) + .thenReturn(appInfo); ArgumentCaptor<ContentObserver> observerCaptor = ArgumentCaptor.forClass(ContentObserver.class); mScoreCache = new WifiNetworkScoreCache(mContext); mScoredNetworkEvaluator = new ScoredNetworkEvaluator(mContext, new Handler(Looper.getMainLooper()), mFrameworkFacade, mNetworkScoreManager, - mWifiConfigManager, new LocalLog(0), mScoreCache, mWifiPermissionsUtil); + mPackageManager, mWifiConfigManager, new LocalLog(0), mScoreCache, + mWifiPermissionsUtil); verify(mFrameworkFacade).registerContentObserver(eq(mContext), any(Uri.class), eq(false), observerCaptor.capture()); mContentObserver = observerCaptor.getValue(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 2f5415ab9..fdabe35f9 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -110,6 +110,7 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.LocalOnlyHotspotCallback; import android.net.wifi.WifiManager.SoftApCallback; +import android.net.wifi.WifiNetworkScoreCache; import android.net.wifi.WifiNetworkSuggestion; import android.net.wifi.WifiSsid; import android.net.wifi.WifiStackClient; @@ -341,6 +342,8 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mClientModeImpl.getWifiScoreReport()).thenReturn(mWifiScoreReport); when(mWifiInjector.getWifiScoreCard()).thenReturn(mWifiScoreCard); when(mWifiInjector.getSarManager()).thenReturn(mSarManager); + when(mWifiInjector.getWifiNetworkScoreCache()) + .thenReturn(mock(WifiNetworkScoreCache.class)); when(mWifiInjector.getWifiThreadRunner()) .thenReturn(new WifiThreadRunner(new Handler(mLooper.getLooper()))); when(mClientModeImpl.syncStartSubscriptionProvisioning(anyInt(), |