WifiInfo.toString

NetworkInfo.toString and WifiInfo.toString block other ways an app can get your SSID (Wi-Fi Network Name) and other private network parameters. The NetworkInfo.toString hook also blocks the APN leaking when connected via a cellular network. The hooks will attempt to edit SSID, BSSID, APN and MAC address in the semi-formatted data returned by the toString methods, but will fall back to just overwriting everything if that fails. For complete coverage, you may also want to enable the following hooks: - NetworkInfo.toString (repo) - NetworkInfo.getExtraInfo (stock) - WifiInfo.getIpAddress (repo) - WifiInfo.getBSSID (stock or repo version) - WifiInfo.getMacAddress (repo, may not be necessary in Android 6 Marshmallow or later) - WifiInfo.getSSID (stock) You may also want NetworkInfo.createFromParcel (in the repo), but that's for hiding online state, and has a separate category ("Internet offline") Instructions: 1. Download either or both NetworkInfo.toString and WifiInfo.toString hooks. 2. Make sure that the Fif collection is enabled in XPL Pro. 3. For any app for which you want the hook to apply: 3.a. Toggle the "Read Network" category until it's fully enabled (red) in XPL. 3.b. Or, alternately, enable either or both NetworkInfo.toString and WifiInfo.toString hook in XPL Pro. Changelog (for WifiInfo.toString): v1 - 2018-10-08 First public release.

CollectionFif
GroupRead.Network
NameWifiInfo.toString
AuthorFif_
Version1
Updated (UTC)2018-10-08 22:41:23
Created (UTC)2018-10-08 22:00:28
Downloads1167
Class nameandroid.net.wifi.WifiInfo
Method nametoString
Parameter types
Return typejava.lang.String
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
Settings-
-- WifiInfo.toString is a Lua hook definition designed to work                     
-- with XPrivacyLua.

-- WifiInfo.toString is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.

-- WifiInfo.toString is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.

function after(hook, param)
    local result = param:getResult()
    if result == nil then
        return false
    end

    if result:find("SSID: ") == nil then
        return false
    end

    local fake = result
    local changed, pattern, replacement
    local changes = 0
    for pattern, replacement in pairs({[ "^(SSID: ).*(, BSSID: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x, MAC:)"  ] = "%1Private%2",
                                       [ "(, SSID: ).*(, BSSID: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x, MAC:)" ] = "%1Private%2",
                                       [ "(, BSSID: )%x%x:%x%x:%x%x:%x%x:%x%x:%x%x(, )"               ] = "%102:00:00:00:00:00%2",
                                       [ "(, MAC: )%x%x:%x%x:%x%x:%x%x:%x%x:%x%x(, )"                 ] = "%102:00:00:00:00:00%2"}) do
        fake, changed = fake:gsub(pattern, replacement)
        if changed == 1 then
            changes = changes + 1
        end
    end

    if changes == 0 then
        fake = "Private"
    end

    param:setResult(fake)

    return true, result, fake
end