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

Commit eff8f5c1 authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiServiceImpl: Pass in package name for all toggle API's

Needed for iface concurrency priority decisions in HalDeviceManager.

Bug: 162344695
Test: atest android.net.wifi
Change-Id: Ic368665a41b118bb7553d704d1e3a7debe189e16
parent 81c782dd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ interface IWifiManager

    DhcpInfo getDhcpInfo();

    void setScanAlwaysAvailable(boolean isAvailable);
    void setScanAlwaysAvailable(boolean isAvailable, String packageName);

    boolean isScanAlwaysAvailable();

@@ -142,9 +142,9 @@ interface IWifiManager

    void updateInterfaceIpState(String ifaceName, int mode);

    boolean startSoftAp(in WifiConfiguration wifiConfig);
    boolean startSoftAp(in WifiConfiguration wifiConfig, String packageName);

    boolean startTetheredHotspot(in SoftApConfiguration softApConfig);
    boolean startTetheredHotspot(in SoftApConfiguration softApConfig, String packageName);

    boolean stopSoftAp();

+3 −3
Original line number Diff line number Diff line
@@ -2802,7 +2802,7 @@ public class WifiManager {
    @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
    public void setScanAlwaysAvailable(boolean isAvailable) {
        try {
            mService.setScanAlwaysAvailable(isAvailable);
            mService.setScanAlwaysAvailable(isAvailable, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3035,7 +3035,7 @@ public class WifiManager {
    })
    public boolean startSoftAp(@Nullable WifiConfiguration wifiConfig) {
        try {
            return mService.startSoftAp(wifiConfig);
            return mService.startSoftAp(wifiConfig, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3059,7 +3059,7 @@ public class WifiManager {
    })
    public boolean startTetheredHotspot(@Nullable SoftApConfiguration softApConfig) {
        try {
            return mService.startTetheredHotspot(softApConfig);
            return mService.startTetheredHotspot(softApConfig, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+11 −9
Original line number Diff line number Diff line
@@ -218,10 +218,10 @@ public class WifiManagerTest {
     */
    @Test
    public void testStartSoftApCallsServiceWithWifiConfig() throws Exception {
        when(mWifiService.startSoftAp(eq(mApConfig))).thenReturn(true);
        when(mWifiService.startSoftAp(mApConfig, TEST_PACKAGE_NAME)).thenReturn(true);
        assertTrue(mWifiManager.startSoftAp(mApConfig));

        when(mWifiService.startSoftAp(eq(mApConfig))).thenReturn(false);
        when(mWifiService.startSoftAp(mApConfig, TEST_PACKAGE_NAME)).thenReturn(false);
        assertFalse(mWifiManager.startSoftAp(mApConfig));
    }

@@ -231,10 +231,10 @@ public class WifiManagerTest {
     */
    @Test
    public void testStartSoftApCallsServiceWithNullConfig() throws Exception {
        when(mWifiService.startSoftAp(eq(null))).thenReturn(true);
        when(mWifiService.startSoftAp(null, TEST_PACKAGE_NAME)).thenReturn(true);
        assertTrue(mWifiManager.startSoftAp(null));

        when(mWifiService.startSoftAp(eq(null))).thenReturn(false);
        when(mWifiService.startSoftAp(null, TEST_PACKAGE_NAME)).thenReturn(false);
        assertFalse(mWifiManager.startSoftAp(null));
    }

@@ -257,10 +257,12 @@ public class WifiManagerTest {
    @Test
    public void testStartTetheredHotspotCallsServiceWithSoftApConfig() throws Exception {
        SoftApConfiguration softApConfig = generatorTestSoftApConfig();
        when(mWifiService.startTetheredHotspot(eq(softApConfig))).thenReturn(true);
        when(mWifiService.startTetheredHotspot(softApConfig, TEST_PACKAGE_NAME))
                .thenReturn(true);
        assertTrue(mWifiManager.startTetheredHotspot(softApConfig));

        when(mWifiService.startTetheredHotspot(eq(softApConfig))).thenReturn(false);
        when(mWifiService.startTetheredHotspot(softApConfig, TEST_PACKAGE_NAME))
                .thenReturn(false);
        assertFalse(mWifiManager.startTetheredHotspot(softApConfig));
    }

@@ -270,10 +272,10 @@ public class WifiManagerTest {
     */
    @Test
    public void testStartTetheredHotspotCallsServiceWithNullConfig() throws Exception {
        when(mWifiService.startTetheredHotspot(eq(null))).thenReturn(true);
        when(mWifiService.startTetheredHotspot(null, TEST_PACKAGE_NAME)).thenReturn(true);
        assertTrue(mWifiManager.startTetheredHotspot(null));

        when(mWifiService.startTetheredHotspot(eq(null))).thenReturn(false);
        when(mWifiService.startTetheredHotspot(null, TEST_PACKAGE_NAME)).thenReturn(false);
        assertFalse(mWifiManager.startTetheredHotspot(null));
    }

@@ -2375,7 +2377,7 @@ public class WifiManagerTest {
    @Test
    public void testScanAvailable() throws Exception {
        mWifiManager.setScanAlwaysAvailable(true);
        verify(mWifiService).setScanAlwaysAvailable(true);
        verify(mWifiService).setScanAlwaysAvailable(true, TEST_PACKAGE_NAME);

        when(mWifiService.isScanAlwaysAvailable()).thenReturn(false);
        assertFalse(mWifiManager.isScanAlwaysAvailable());