SystemProperties.get.default/custom

Please refer to the SystemProperties.get/custom hook documentation.

CollectionFif
GroupUse.Tracking
NameSystemProperties.get.default/custom
AuthorFif_
Version5
Updated (UTC)2018-10-01 05:47:20
Created (UTC)2018-02-23 01:27:26
Downloads1579
Class nameandroid.os.SystemProperties
Method nameget
Parameter typesjava.lang.String, java.lang.String
Return typejava.lang.String
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
SettingsProperty blacklist (prefixes)
-- Fif.SystemProperties.get_custom is a Lua hook designed to work with XPrivacyLua.
-- Copyright (C) 2018 Philippe Troin (Fif_ on XDA)

-- Fif.SystemProperties.get_custom 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.

-- Fif.SystemProperties.get_custom 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.

-- You should have received a copy of the GNU General Public License
-- along with XPrivacyLua.  If not, see <http://www.gnu.org/licenses/>.

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

    local context = param:getApplicationContext()
    local BlacklistPropertyPrefixes = param:getValue('Fif.SystemProperties.get_custom.BlacklistPropertyPrefixes', context)

    if BlacklistPropertyPrefixes == nil then
        local blacklist = param:getSetting("Property blacklist (prefixes)")
        BlacklistPropertyPrefixes = {}
        if blacklist ~= nil then
            blacklist:gsub('[%S]+', function(x) table.insert(BlacklistPropertyPrefixes, x) end)
        end
        param:putValue('Fif.SystemProperties.get_custom.BlacklistPropertyPrefixes', BlacklistPropertyPrefixes, context)
        log('Property prefix blacklist: ' .. table.concat(BlacklistPropertyPrefixes, ', '))
    end

    local key = param:getArgument(0)
    local found = false
    local i, prefix
    for i, prefix in pairs(BlacklistPropertyPrefixes) do
        if string.sub(key, 1, string.len(prefix)) == prefix then
            found = true
            break
        end
    end

    if found then
        local fake
        if result:match('^[0-9a-fA-F]+$') then
            fake = string.rep('0', result:len())
        else
            fake = 'Private'
        end
        log('Deny ' .. key .. '=' .. result .. ' → ' .. fake)
        param:setResult(fake)
        return true, key .. '=' .. result, key .. '=' .. fake
    else
        log('Allow ' .. key .. '=' .. result)
        return false
    end
end