NetworkInfo.toString

Please refer to the WifiInfo.toString hook documentation. Changelog (for NetworkInfo.toString): v3 - 2018-10-08 When anonymizing fails, set the returned value to Private. v2 - 2018-10-08 Update doc string. Actually set the fake return value, doh. v1 - 2018-09-05 First public release.

CollectionFif
GroupRead.Network
NameNetworkInfo.toString
AuthorFif_
Version3
Updated (UTC)2018-10-08 22:41:16
Created (UTC)2018-09-05 22:12:03
Downloads1296
Class nameandroid.net.NetworkInfo
Method nametoString
Parameter types
Return typejava.lang.String
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
Settings-
-- NetworkInfo.toString is a Lua hook definition designed to work                     
-- with XPrivacyLua.

-- NetworkInfo.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.

-- NetworkInfo.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(", extra: [(]none[)], [a-zA-Z_]+: ") ~= nil 
       or result:find(", extra: <unknown ssid>, [a-zA-Z_]+: ") ~= nil then
        return false
    end

    local fake, changed, pattern, replacement
    changed = 0
    for pattern, replacement in pairs({[ "(, extra: \").*(\", [a-zA-Z_]+: )"      ] = "%1Private%2",
                                       [ "(, extra: )[^\"][^,]*(, [a-zA-Z_]+: )"  ] = "%1private%2"}) do
        fake, changed = result:gsub(pattern, replacement)
        if changed == 1 then
            break
        end
    end

    if changed == 0 then
        fake = 'Private'
    end

    param:setResult(fake)

    return true, result, fake
end