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

Commit c0643da0 authored by Rebecca Silberstein's avatar Rebecca Silberstein Committed by Android (Google) Code Review
Browse files

Merge "WifiManager: setWifiApEnabled always returns false" into oc-dev

parents 0b45799a 8cc4eb79
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -1802,25 +1802,25 @@ public class WifiManager {
    }

    /**
     * Start AccessPoint mode with the specified
     * configuration. If the radio is already running in
     * AP mode, update the new configuration
     * Note that starting in access point mode disables station
     * mode operation
     * This call will be deprecated and removed in an upcoming release.  It is no longer used to
     * start WiFi Tethering.  Please use {@link ConnectivityManager#startTethering(int, boolean,
     * ConnectivityManager#OnStartTetheringCallback)} if
     * the caller has proper permissions.  Callers can also use the LocalOnlyHotspot feature for a
     * hotspot capable of communicating with co-located devices {@link
     * WifiManager#startLocalOnlyHotspot(LocalOnlyHotspotCallback)}.
     *
     * @param wifiConfig SSID, security and channel details as
     *        part of WifiConfiguration
     * @return {@code true} if the operation succeeds, {@code false} otherwise
     * @return {@code false}
     *
     * @hide
     */
    @SystemApi
    public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
        try {
            mService.setWifiApEnabled(wifiConfig, enabled);
            return true;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        String packageName = mContext.getOpPackageName();

        Log.w(TAG, packageName + " attempted call to setWifiApEnabled: enabled = " + enabled);
        return false;
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -778,4 +778,13 @@ public class WifiManagerTest {
        verify(mWifiService).stopWatchLocalOnlyHotspot();
    }

    /**
     * Verify that calls to setWifiApEnabled return false.
     */
    @Test
    public void testSetWifiApEnabledReturnsFalse() throws Exception {
        assertFalse(mWifiManager.setWifiApEnabled(null, true));
        assertFalse(mWifiManager.setWifiApEnabled(null, false));
        verify(mWifiService, never()).setWifiApEnabled(any(), anyBoolean());
    }
}