diff options
author | David Su <dysu@google.com> | 2019-12-04 16:27:55 -0800 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-12-09 10:24:58 -0800 |
commit | 158c3f29da578d4a61ee9c04c65b91438f0802f3 (patch) | |
tree | 6b57c201716100cd3bb9940e6da2563764ab7474 | |
parent | a669e034decb682f145e089cec6c204b09e0c07c (diff) |
WifiServiceImpl: Remove sync version of getWifiActivityEnergyInfo
Remove synchronous version of getting the
WifiActivityEnergyInfo since the async version is the
official API.
Bug: 145244073
Test: atest FrameworksWifiTests
Change-Id: Ie3d5612582748369c878ce2f1e0f5b5faeca0597
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 14 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 33 |
2 files changed, 5 insertions, 42 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index dfa09e809..165df13bc 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1742,8 +1742,8 @@ public class WifiServiceImpl extends BaseWifiService { .c(Binder.getCallingUid()) .flush(); } - // reportActivityInfo() performs permission checking - WifiActivityEnergyInfo info = reportActivityInfo(); + // getWifiActivityEnergyInfo() performs permission checking + WifiActivityEnergyInfo info = getWifiActivityEnergyInfo(); try { listener.onWifiActivityEnergyInfo(info); } catch (RemoteException e) { @@ -1751,14 +1751,10 @@ public class WifiServiceImpl extends BaseWifiService { } } - /** - * see {@link android.net.wifi.WifiManager#getControllerActivityEnergyInfo()} - */ - @Override - public WifiActivityEnergyInfo reportActivityInfo() { + private WifiActivityEnergyInfo getWifiActivityEnergyInfo() { enforceAccessPermission(); if (mVerboseLoggingEnabled) { - mLog.info("reportActivityInfo uid=%").c(Binder.getCallingUid()).flush(); + mLog.info("getWifiActivityEnergyInfo uid=%").c(Binder.getCallingUid()).flush(); } if ((getSupportedFeatures() & WifiManager.WIFI_FEATURE_LINK_LAYER_STATS) == 0) { return null; @@ -1787,7 +1783,7 @@ public class WifiServiceImpl extends BaseWifiService { } if (VDBG || rxIdleTimeMillis < 0 || stats.on_time < 0 || stats.tx_time < 0 || stats.rx_time < 0 || stats.on_time_scan < 0) { - Log.d(TAG, " reportActivityInfo: " + Log.d(TAG, " getWifiActivityEnergyInfo: " + " on_time_millis=" + stats.on_time + " tx_time_millis=" + stats.tx_time + " tx_time_per_level_millis=" + Arrays.toString(txTimePerLevelMillis) diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index d45c48e13..e08038d88 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -4688,27 +4688,6 @@ public class WifiServiceImplTest extends WifiBaseTest { mWifiServiceImpl.acquireWifiLock(mAppBinder, wifiLockModeInvalid, "", null); } - /** - * Tests that {@link WifiServiceImpl#reportActivityInfo()} throws {@link SecurityException} if - * the caller doesn't have the necessary permissions. - */ - @Test(expected = SecurityException.class) - public void reportActivityInfoNoPermission() throws Exception { - doThrow(SecurityException.class) - .when(mContext).enforceCallingOrSelfPermission(eq(ACCESS_WIFI_STATE), any()); - mWifiServiceImpl.reportActivityInfo(); - } - - /** - * Tests that {@link WifiServiceImpl#reportActivityInfo()} returns null if link layer stats is - * unsupported. - */ - @Test - public void reportActivityInfoFeatureUnsupported() throws Exception { - when(mClientModeImpl.syncGetSupportedFeatures(any())).thenReturn(0L); - assertNull(mWifiServiceImpl.reportActivityInfo()); - } - private void setupReportActivityInfo() { WifiLinkLayerStats stats = new WifiLinkLayerStats(); stats.on_time = 1000; @@ -4739,18 +4718,6 @@ public class WifiServiceImplTest extends WifiBaseTest { } /** - * Tests that {@link WifiServiceImpl#reportActivityInfo()} returns the expected values on - * success. - */ - @Test - public void reportActivityInfoSuccess() throws Exception { - when(mClientModeImpl.syncGetSupportedFeatures(any())).thenReturn(Long.MAX_VALUE); - setupReportActivityInfo(); - WifiActivityEnergyInfo info = mWifiServiceImpl.reportActivityInfo(); - validateWifiActivityEnergyInfo(info); - } - - /** * Tests that {@link WifiServiceImpl#getWifiActivityEnergyInfoAsync} throws * {@link SecurityException} if the caller doesn't have the necessary permissions. */ |