TelephonyManager.getCellLocation

Replace the built-in hook to fake cid and lac with getCellLocation method,for gsm users only.Don't use with my previous getCID and getLAC hooks simultaneously.Setting must match exactly like "LAC,CID",for example,"26550,187363073".If you want to get a fake location by Celluar,you should also download and enable my modified getNetworkOperator hook definition.

CollectionPrivacy
GroupRead.Network
NameTelephonyManager.getCellLocation
AuthorM66B,hKFirEs
Version4
Updated (UTC)2018-03-14 10:56:05
Created (UTC)2018-03-14 10:56:05
Downloads1466
Class nameandroid.telephony.TelephonyManager
Method namegetCellLocation
Parameter types
Return typeandroid.telephony.CellLocation
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
SettingsLAC,CID

-- This file is part of XPrivacyLua.

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

-- XPrivacyLua 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/>.

-- Copyright 2017-2018 Marcel Bokhorst (M66B)

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

    local null

    local setting = param:getSetting("LAC,CID")
    if setting == nil then
    	param:setResult(null)
    	return true, result:toString(), null
    end

    local index = string.find(setting,",",1,true)
    if index == nil then
    	param:setResult(null)
    	return true, result:toString(), null
    end

    local fakelac = tonumber(string.sub(setting,1,index-1))
    local fakecid = tonumber(string.sub(setting,index+1,-1))

    if fakecid == nil or fakelac == nil then
        param:setResult(null)
        return true, result:toString(), null
    end
	
    local fake = luajava.newInstance('android.telephony.gsm.GsmCellLocation')
    fake:setLacAndCid(fakelac, fakecid)
    param:setResult(fake)
    return true, result:toString(), fake:toString()
end