yashsingh1/xdaforums huggingface dataset:
[Xposed Framework Modules] M66B:
You'll need to make it work yourself, see also the opening post.

However, I will try to help you with suggestions:

Did you got any error notifications / messages?

Did you check the logcat for errors?

How do you know it doesn't work?

Are you aware that an app might simply ignore this and connect to the internet anyway?
[Xposed Framework Modules] inguna:
I did not get any errors.

I use Xprivacy on a different device. I restricted "isConnected" to an app with Xprivacy and it thinks that I am not connected to the internet, the app throws an error when trying to go online. However on a phone with Xprivacylua using this hook the same app can connect to the internet.

I will check logcat now.

Thanks
[Xposed Framework Modules] M66B:
Never overlook the obvious, so

Did you enabled the collection 'Test' ?

Did you enabled the restriction group 'Trick into offline' for the app?
[Xposed Framework Modules] inguna:
Yes, I did that.

I even get a notification saying " Restricted 'Test.NetworkInfo.isConnected' "

Can't find any errors in logcat relating to this.
[Xposed Framework Modules] M66B:
Then the hook definition is correct and is being executed.

The hook should show up in the log of the pro companion app too.
[Xposed Framework Modules] inguna:
Yes, it is there but unfortunately it doesn't work.

I applied this hook to some more apps (apps without native libs) and they all can connect to internet.

But at the same time your "Internet.Offline" works.

I got used to restricting "isConneted" in Xprivacy this is why I wanted to create this hook.

Thank you for your time
[Xposed Framework Modules] Fif_:
Your problem is likely caused by maxApk set to zero. It should be INT_MAX (2147483647), which is the default.
[Xposed Framework Modules] inguna:
Tried your suggestion, still wouldn't work.

Can you confirm it works on your device please.

This is how it works in Xprivacy

https://github.com/M66B/XPrivacy/blob/master/src/biz/bokhorst/xprivacy/XNetworkInfo.java

Thank you
[Xposed Framework Modules] Fif_:
My testing indicates that hooking NetworkInfo.isConnected or NetworkInfo.isConnectedOrConnecting is unnecessary, at least on Nougat: using the repo's existing NetworkInfo.createFromParcel hook is enough to mask the online state.

You can use the attached hooks to prove it to yourself: the hooks will run and log what the original (unhooked) function returns, and it always says "result = false" (when NetworkInfo.createFromParcel is active of course).

Run the hooks and check the logcat for "Fif.NetworkInfo.isConnected".

Note: I'm not planning to upload these two attached hooks to the repo as they are unnecessary.
[Xposed Framework Modules] inguna:
I will try them ASAP. I am on Oreo 8.0.

Thank you for your time and work, I really appreciate it :good:
[Xposed Framework Modules] Fif_:
Please let us know if these two hooks make any difference for you, I might then upload them to the repo (and remove the debug logging).
[Xposed Framework Modules] inguna:
It doesn't work on my phone, probably because I am on EMUI8. Never mind. Thank you again.

I started using X Firewall module.
[Xposed Framework Modules] Fif_:
I'd recommend using AFWall instead. AFWall will also prevent native code from accessing the network while X Firewall, being Xposed-based, won't.

Note that AFWall won't prevent apps from seeing the network state (connected or not), it will only prevent apps from establishing outbound connections. I'm not sure what X Firewall does with regards to network state.

You may also want to consider Netguard, which is a filtering VPN proxy which can block apps altogether or select domains, amongst other great things.
[Xposed Framework Modules] PeyCapri:
I wanna to fake "CarrierName, CountryIso, MCC, MNC, NetworkCountryIso, NetworkOperator NetworkOperatorName, SimCountryIso, SimOperator & SimOperatorName" on my nexus 6p to unlock google map timeline service in China. However, the log on the xprivacylua pro app shows that the faking operation does not work properly on some google apps such as google play service, google service framework, google play store.

I got the information "SimCountryIso, SimOperator & SimOperatorName" from the log page in xprivacylua pro app after i insert my AT&T sim card.

Here are my google play service app's faking configuration:

CarrierName, AT&T

CountryIso, 61

MCC, 505

MNC, 88

NetworkCountryIso, us

NetworkOperator, 310410

NetworkOperatorName, AT&T

SimCountryIso, us

SimOperator, 310410

SimOperatorName, AT&T​

Replace the AT&T sim card with China's sim card.

Then the log page update automatically, but the faking operation failed. Google play service did not get the fake value set before.

Log page:

google play service:

Privacy.TelephonyManager/getSimOperator

46001

00101

Privacy.TelephonyManager/getNetworkOperarotName

CHN-UNICOM

unkown

Privacy.TelephonyManager/getSimOperarotName

(blank)

unkonwn

Privacy.TelephonyManager/getSimCountryIso

cn

xx

Privacy.TelephonyManager/getNetworkCountryIso

cn

xx​

Now i'm so confused what i did wrong. Could anybody help me?
[Xposed Framework Modules] M66B:
Looking at the end result: this is how it supposed to be.

The pro features and some custom hook definitions allow you to override some of the default fake values.

My question: how/where did you set the fake values?

Note that XPrivacyLua is to protect your privacy. Letting apps do what they normally don't, is not supported, see also the opening post.
[Xposed Framework Modules] mikbeHD:
Firewall hooks

@M66B

thanks for new lua version. However, I was missing some functions from the old version like

Name="internet" Method="InetAddress.getAllByName"

Name="internet" Method="InetAddress.getByName"

Name="internet" Method="connect"

Type="Command" Name="/system/bin/ping -c 1 8.8.8.8" Value="false" />

Name="view" Method="loadUrl"

I found the first two in the internet.firewall group from @Fif_ (could they be added by default?)

But still apps can bypass this by native code, command, and loadurl.

In previous version this could be blocked:

<Restriction Id="10431" Name="view" Method="loadUrl" Restricted="false" Asked="true" />

Type="Url" Name="https://tags.tiqcdn.com/..." Value="false" />

Type="Url" Name="https://goo...core-v40.html" Value="false" />

Type="Command" Name="/system/bin/ping -c 1 8.8.8.8" Value="false" />

Is there a module for xprivacylua to hook the url and command call? It's WebView.loadUrl right if I create an own hook?

What class is behind xprivacy's Name="internet" Method="connect", is it still needed?
[Xposed Framework Modules] M66B:
Please see this FAQ:

https://github.com/M66B/XPrivacyLua/blob/master/FAQ.md#user-content-faq4

This is the XPrivacy internet/connect implementation:

https://github.com/M66B/XPrivacy/blob/master/src/biz/bokhorst/xprivacy/XIoBridge.java#L70

XPrivacyLua is extensible, that is what this XDA thread is about, so could try to add this yourself.
[Xposed Framework Modules] mikbeHD:
thanks, I didn't find XIoBridge.java right away!
[Xposed Framework Modules] Ashish Gupta1999:
how to view and restrict sub categories in xprivacy Lua , like we do in xprivacy ?
[Xposed Framework Modules] M66B:
You can do that with the pro companion app.

This forum is for custom hook definition development, so can you next time please use this forum?
[Xposed Framework Modules] sdz2:
What is the Lua script syntax to get the value of a System Setting, such as ACCESSIBILITY_DISPLAY_INVERSION_ENABLED?

https://developer.android.com/refer....html#ACCESSIBILITY_DISPLAY_INVERSION_ENABLED
[Xposed Framework Modules] M66B:
This hook is an example of how to hook into system settings:

https://github.com/M66B/XPrivacyLua/blob/master/app/src/main/assets/hooks.json#L993
[Xposed Framework Modules] sdz2:
I don't want to hook into a system setting. I want to get the current value of a system setting in another hook. More specifically, I want to allow clipboard access only if inversion is enabled.

I used the luaScript below, which is your ClipData.CreateFromParcel with my modifications within the comment lines.

function after(hook, param)
local result = param:getResult()
if result == null or result:getItemCount() == 0 then
return false
end
--
local context = param:getApplicationContext()
local clsSettings = luajava.bindClass('android.provider.Settings$Secure')
local isColorInverted = clsSettings:getInt(context, clsSettings:ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,0)
if isColorInverted == 1 then
return true
end
--
local fake = result:newPlainText('XPrivacyLua', 'Private')
param:setResult(fake)
return true
end

It returns the error:

[string "script"]:10: function arguments expected

Line 10 is the getInt call.

I pulled this together from similar examples. I have minimal experience coding in java and lua. I suspect this is a simple syntax issue.

What am I doing wrong?
[Xposed Framework Modules] M66B:
Try replacing clsSettings:ACCESSIBILITY... by clsSettings.ACCESSIBILITY...

If that doesn't work, try using the setting name directly.
[Xposed Framework Modules] sdz2:
No luck.

clsSetting:ACCESSIBILITY... function arguments expected

clsSetting.ACCESSIBILITY... no coercible public method

ACCESSIBILITY... no coercible public method

My goal is a toggle for the "Read clipboard" restriction without requiring an app restart. The solution preferably would have a visual indicator (inversion, notification icon, etc)

My approach:

Create a flow in Automate to toggle display inversion -- WORKS

Add shortcut to Quick Launch via GravityBox -- WORKS

Create alternate XPrivacyLua ClipData.CreateFromParcel hook -- ERRORS

Would you recommend a different approach for a runtime "Read clipboard" restriction toggle?
[Xposed Framework Modules] M66B:
Did you already try to use the plain settings name without referencing the constant?
[Xposed Framework Modules] sdz2:
I just tried:

local isColorInverted = clsSettings:getInt(context, 'accessibility_display_inversion_enabled')

It also returns: no coercible public method

Got it!!

It was the first parameter that was wrong. It takes a ContentResolver. I was passing an ApplicationContext.

Below is the working code.

function after(hook, param)
local result = param:getResult()
if result == null or result:getItemCount() == 0 then
return false
end
--
local context = param:getApplicationContext()
local cr = context:getContentResolver()
local clsSettings = luajava.bindClass('android.provider.Settings$Secure')
local isColorInverted = clsSettings:getInt(cr, 'accessibility_display_inversion_enabled')
if isColorInverted == 1 then
return true
end
--
local fake = result:newPlainText('XPrivacyLua', 'Private')
param:setResult(fake)
return true
end
[Xposed Framework Modules] M66B:
The problem is something else: getInt is a static method with two parameters, so you need to call:

cls:getInt(name, default)
[Xposed Framework Modules] glops:
Hello Fif_

if possible to adapt your hook to add the randomization as proposed by M66B

thanks in advance
[Xposed Framework Modules] Fif_:
I'm not sure if it's even going to be possible to do randomization for my hooks the same way that XPL Pro does randomization (at boot).

Which hooks would you think require randomization?
[Xposed Framework Modules] arianat01:
Hi

Is there any simple way to add all hosts/domains to blacklist by your hook?
[Xposed Framework Modules] Fif_:
It uses suffix search, so "just" add all the top-level domains:

com net org arpa ar az ...

Unfortunately, there's now 1500 of them: https://en.m.wikipedia.org/wiki/List_of_Internet_top-level_domains

Why don't you use AfWall or Netguard instead?

You could also flip the logic in the hook and use a whitelist.
[Xposed Framework Modules] arianat01:
apps like netgaurd can't be used with vpn together. AFWall is good.

How can I flip the logic in the hook and use a whitelist. Need I edit hook and just change all blacklist words to whitelist? Sorry I'm noob

Thank you
[Xposed Framework Modules] Fif_:
No, it's not like that ;)

11 lines from the end of the lua script, you'll fine a line that says:

if pass then

Change it to:

if not pass then

And you should be good to go.

Disclaimer: I haven't tested this, but it should work™.

If there's interest (other users than [MENTION=6424213]arianat01[/MENTION]), I could upload a version with a white / blacklist toggle.
[Xposed Framework Modules] arianat01:
It's work in many apps I tested. But didn't work in browsers like chrome and Firefox and Puffin.

works great in other apps. That's important for me. So I don't need to use any firewall any more.

Thank you.
[Xposed Framework Modules] Fif_:
The XPL "firewall" doesn't work in the browsers because they likely are using native code and hence are out of reach of Xposed.

Glad to hear the hacked hooks fit your purpose.
[Xposed Framework Modules] M66B:
You are getting this error because Lua cannot find the class member. The Lua name/member resolver is rather limited and in fact I have already modified it at several places for this reason. It isn't going to be much better without a big structural change, so unfortunately this is not easy to solve :(

A possible alternative might be to intercept the call to enable activity recognition.
[Xposed Framework Modules] Fif_:
Ugh, that's disappointing for luaj.

Intercepting the API call to enable activity recognition is likely more disruptive to the app as it will change the system behavior: the regular intent callbacks won't be fired for one.

On another subject, I ran into the TaiChi framework . Yet another Xposed replacement. I haven't tried it.
[Xposed Framework Modules] Namnodorel:
Tai-Chi works by patching APKs in a way that enables Xposed modules to get control of their process. For obvious reasons, this doesn't work on the system, and afaik, it is closed source :/
[Xposed Framework Modules] Fif_:
They have a Magisk module that supposedly allows hooking the system too.

But the mechanics (patching apks) looks brittle.
[Xposed Framework Modules] ViRb3:
Hey, sorry for posting in the wrong thread earlier. I am looking for a way to fake the MAC address returned from getHardwareAddress (a byte array), as your hook simply returns 'nothing', which crashes apps. How could I do this? Thanks.
[Xposed Framework Modules] M66B:
First of all the app should not crash because returning nothing is a valid return.

The simplest is to overwrite the existing addresses byte by byte. Alternatively, you can create a new array (using Lua's newInstance), but this is more complicated.
[Xposed Framework Modules] ViRb3:
For the sake of learning something today I decided to take the latter approach. Here's what I have so far:

local byteClass = luajava.bindClass('java.lang.Byte')
local arrayClass = luajava.bindClass('java.lang.reflect.Array')
local fake = arrayClass:newInstance(byteClass, 6)
fake[0]=1
fake[1]=2
param:setResult(fake)
return true

However, the hook does not activate, even though it is enabled. Is the script incorrect?

Thanks!
[Xposed Framework Modules] M66B:
I don't know if the hook is active because I don't know how you defined it and if you enabled it.

In any case, if there is an error in the script, you'll get a status bar notification with an error message when the hook is executed.

The definition looks okay, but details do matter.
[Xposed Framework Modules] ViRb3:
Indeed, there seems to be an error in the status bar. Here's the beginning:

Exception: org.luaj.vm2.LuaError: script:27 index expected, got userdata value = nil at org.luaj.vm2.LuaVal ue.typeerror(SourceFile: 1073) ...

I discovered that lua arrays start from index 1, but even when changing that the error remains. The error line:

fake[1]=1

Thanks.
[Xposed Framework Modules] M66B:
I don't know what is on line 27.
[Xposed Framework Modules] ViRb3:
It's that line I quoted:

fake[1]=1
[Xposed Framework Modules] M66B:
Then 'fake' is null. Try a dot instead of a semicolon before newInstance.
[Xposed Framework Modules] ViRb3:
New error:

org.luaj.vm2.LuaError: script:26 no coercible public method at ...

( this is the line where I changed : to . )

Could the binding be failing? Are my class definitions proper? Thanks.
[Xposed Framework Modules] M66B:
LuaJ bindings are simple and therefore at times problematic. I guess the previous line was better, but I am not sure why no new instance is being made.
[Xposed Framework Modules] ViRb3:
I fixed it by using the primitive "byte" instead of the boxed "java.lang.Byte" :)

Could I suggest making this a built-in hook instead of optional? The method reliably leaks the MAC address of all Android versions up to 9 and it's a huge privacy issue IMO. I will gladly send a PR that makes it return "02:00:00:00:00:00" instead of empty byte array for stability purposes.
[Xposed Framework Modules] M66B:
The MAC address isn't exposed on recent Android versions anymore, which is why this hook definition isn't a part of the core restrictions.
[Xposed Framework Modules] ViRb3:
I am running stock Android 9 and this method certainly reveals my (correct) MAC. The only protected method in Android 6+ is

WifiInfo.getMacAddress()

More info: https://stackoverflow.com/questions/33103798/how-to-get-wi-fi-mac-address-in-android-marshmallow
[Xposed Framework Modules] M66B:
You'll have to 'thank' the manufacturer of your device for changing Android in this way because this should not be the case, see here:

https://developer.android.com/train...tml#version_specific_details_identifiers_in_m

Related FAQ:

https://github.com/M66B/XPrivacyLua/blob/master/FAQ.md#user-content-faq4
[Xposed Framework Modules] ViRb3:
I am running stock AOSP, no modifications. The policy change you linked me affects

WifiInfo.getMacAddress()

, but not

NetworkInterface.getHardwareAddress()

. As I said, the latter reliably leaks the MAC on all Android versions.
[Xposed Framework Modules] M66B:
There is already a hook definition for this in the repository.

Note that adding new hook definitions to existing restriction categories can and will lead to trouble for existing users, so I am hesitant in doing this.
[Xposed Framework Modules] ViRb3:
I understand. It would be a good idea to at least update the FAQ, though. I can submit a PR later tonight if you do not have the time.
[Xposed Framework Modules] M66B:
Since there is already information about this in the FAQ: what would you like to add?
[Xposed Framework Modules] ViRb3:
I submitted a PR here:

https://github.com/M66B/XPrivacyLua/pull/7
[Xposed Framework Modules] fpoke:
Hi all,

Getting started on editing some scripts to define my own hooks for the Build.FINGERPRINT value.

How would I go about creating an array of strings and have the returned value choose a string from the array randomly?

Currently, I go to Manage Hook Definitions>Build.FINGERPRINT>Edit>Lua Script. I understand that the default fake value is set to 'unknown' and I can edit that string in the script.

In this case, I'm planning to create an array with possible values and have the "local fake = 'unknown' " line read a random value from the array instead of 'unknown'. I would also like to change the value every time that the app is opened. Is this possible?
[Xposed Framework Modules] M66B:
I guess this will be a good start:

https://stackoverflow.com/questions/2988246/choose-a-random-item-from-a-table
[Xposed Framework Modules] fpoke:
Wow, thanks! That was super useful!!

One more thing I'd like to try is getting a variable from another script. For example, setting a variable in the Settings.Secure.getString/android_id hook and reading it in the Build.Fingerprint.

I tried using the _G. prefix on a variable to define a global variable, but that didn't work. I also tried removing the 'local' definition of a variable, but that didn't work either.

Online I also read that I could try the require('Settings.Secure.getString/android_id') to load the first script, but that didn't work either.

Would you have any guidance on how to create a global variable? Or even to read a variable from one script in another?
[Xposed Framework Modules] Fif_:
You can't create global variables but you can store and retrieve key value pairs in thread-local storage with param:setValue () and param:getValue().

See the InetAddress.getAllByName hook in the repo for a complex example.
[Xposed Framework Modules] M66B:
Using global variables is also explained here:

https://github.com/M66B/XPrivacyLua/blob/master/DEFINE.md
[Xposed Framework Modules] Fif_:
Well that's odd.

Because while the error occurs during the hook lua code execution, it's throwing an exception trying to access the NotificationChannel class, which is not used by the hook.

So I'm stumped.

A few questions for you:

Does the error go away when you disable the hook?

Does the error still occur if you disable all hooks except BlockGuardOS.open?

Does the error still occur if you disable all Xposed modules but XPL?

Which device, ROM and Android version is this happening on?

Which exact version of Magisk, Xposed, XPL and the hook are you using?

Are you doing anything "odd" or non-standard? (Restricting system, running MicroG, multi-ROM, or anything else out of the ordinary).

Can you provide a logcat starting before you start the app? (Force stop the app, run logcat, start the app, wait for the crash, PM me the logcat).

I've tried installing com.streema.simpleradio from play store, but it didn't crash here (I've just launched the app with all restrictions on, but didn't do anything with it).
[Xposed Framework Modules] J4jks:
Which device, ROM and Android version is this happening on?

Moto G2 , AOKP N with magisk canary 19.2+ systemless xposed 89.3

With fake gapps,minminguard,Rootcloak and XPl

Does the error go away when you disable the hook?

Yes, returns after enabling it.

Does the error still occur if you disable all hooks except BlockGuardOS.open?

Yes , it is happening with only this hook enabled.

Are you doing anything "odd" or non-standard? (Restricting system, running MicroG, multi-ROM, or anything else out of the ordinary).

I have microG running with most of the provided hooks applied to it, except Get. applications, firewall Offline and public storage.

And I have Bromite system webview v.68 is installed.

Enabled multi process webview( Run webview renderers separately) in developers settings
[Xposed Framework Modules] Fif_:
Thanks.

Unfortunately, the logcats you sent are incomplete or partial, so I cannot help you.

I need the full logcat from before the app start until the crash. I understand this may contain sensitive information, which is why I suggested a PM.

Edit: it's probably Bromite that's causing issues since there are already special whitelist entries for WebView and Chrome running as System WebView. But I can't tell without a logcat.
[Xposed Framework Modules] J4jks:
There is no crash

The app is running just fine with this error.

I shared this error thinking you may find something to fix this

Thanks
[Xposed Framework Modules] Fif_:
Maybe I would, with a full logcat. ;)
[Xposed Framework Modules] iu1nguoi:
Hi. I have an error with BlockguardOs due to Bromite webview. When I disable the BlockguardOs, the error disappears. Can you update the hook to whitelist Bromite webview? Thank you. I send you the crash log.
[Xposed Framework Modules] Fif_:
Yes, there are special rules for WebView and Chrome as WebView, it would make sense that bromite WebView would require special rules as well.

I'll need the logcat though. Please send it by PM. Edit: I have the logcat, thanks.
[Xposed Framework Modules] Fif_:
I've published version 9 of the Fif.BlockGuardOS.open hook which addresses this problem.
[Xposed Framework Modules] dorkserv81:
Hello,

Can someone help and explain me how can i replace an empty result with a fake value? for example in NetworkInfo.getExtraInfo hook how can i get a fake result instead of an empty value?
[Xposed Framework Modules] M66B:
You can check here how the built-in hook definitions handle this:

https://github.com/M66B/XPrivacyLua/tree/master/app/src/main/assets
[Xposed Framework Modules] M66B:
Check for example here how a location is being returned:

https://github.com/M66B/XPrivacyLua/blob/master/app/src/main/assets/bundle_get_location.lua