yashsingh1/xdaforums huggingface dataset:
[Zuk Z1 Q&A, Help & Troubleshooting] vagabond:
Make sure you have enabled "allow OEM unlocking" in developer settings. After that go to bootloader and enter the following commands (this will wipe user data)

fastboot oem unlock-go

After entering this command your phone will factory reset.

Now come back to recovery and flash twrp.

fastboot flash recovery twrp.img

fastboot boot twrp.img
[Zuk Z1 Q&A, Help & Troubleshooting] santakittu:
Tried that also, but in the command window after executing the command, it says "waiting for devices" and nothing happens after that. OEM unlocking is already allowed in setting.....I also tried by using toolkit available on internet, but in that, my devices is not detected. Tried Kingo Root, but phone get restart every-time when it goes to 90%.
[Zuk Z1 Q&A, Help & Troubleshooting] mukhiya009:
which os do you have?

---------- Post added at 12:32 PM ---------- Previous post was at 12:31 PM ----------

which rom u have installed?
[Xposed Framework Modules] M66B:
[IMG="XPrivacyLua"]https://lua.xprivacy.eu/ic_launcher.png[/IMG]

XPrivacyLua custom hook definitions

By using XPrivacyLua you can define Xposed hooks and apply them to any app at run time (so, rebooting your device is not necessary). You can write hook code on your device in Lua, which is quite easy to learn.

See the documentation about how to define hooks.

Although XPrivacyLua has 'privacy' in its name, new hooks don't need to be privacy related at all. Disabling the built in privacy related hooks is a matter of selecting another collection of hooks.

This XDA thread is meant to discuss defining hooks, with the restriction that hook definitions must serve a legally allowed purpose. This XDA thread is not meant to make you a developer, so at least some development experience is expected, which means that you'll need to be able to figure out where to hook yourself and that you'll need to be able to write Lua scripts yourself.

XDA:DevDB Information

XPrivacyLua hook definitions, Xposed for all devices (see above for details)

Contributors

M66B

Xposed Package Name:

Version Information

Status: Beta

Created 2018-01-28

Last Updated 2018-04-01
[Xposed Framework Modules] jawz101:
Could there be a generic "always return true" lua script?

And when building a definition, what does it mean to be in a group and collection? Do I just put anything there or do I have to call them something particular?

Well, I'm trying but I'm lost. Just trying to setAnalyticsCollectionEnabled

https://firebase.google.com/support/guides/disable-analytics

public void setAnalyticsCollectionEnabled (boolean enabled) = false

supposedly disables Firebase Analytics (which apparently 67% of the top 200 apps use).

My definition looks like

Collection: privacy

Group: firebase

Name: firebase.analytics

author: whatever

class: com.google.firebase.analytics

method:setAnalyticsCollectionEnabled

parameter type: void

return type: boolean

min/max sdk: 1/999

lua script: @generic_false_value I suppose I can use this?

Even if this looks valid, it feels like maybe this wouldn't fire unless certain other things happen first? Looking at your hooks.json for google analytics it looks like you had to maybe set a chain of events to occur to get to the point of controlling the method you intend to make changes?
[Xposed Framework Modules] M66B:
The built-in scripts are not meant for general use because they might change over time breaking stuff that depends on them. Therefore imported definitions are not linked against the built-in scripts. If needed, you can simply copy and paste the Lua script from another (built in) definition. Copying guarantees your definition will keep working, even when the built-in scripts are changed or even removed.

Calling setAnalyticsCollectionEnabled requires access to an instance of FirebaseAnalytics, which apps needs to get by calling getInstance. So, hook getInstance to call setAnalyticsCollectionEnabled(false) and hook setAnalyticsCollectionEnabled to prevent an app from turning analytics on again.

Restricting Google Analytics (available in the next release of XPrivacyLua) works similar:

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

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

You can also wait until I have added this ... ;)
[Xposed Framework Modules] jawz101:
But firebase isn't necessarily the same thing, right?
[Xposed Framework Modules] M66B:
No, Google Analytics and Firebase Analytics are not the same and need different definitions.
[Xposed Framework Modules] M66B:
Restricting Firebase Analytics works properly with these hook definitions:

https://github.com/M66B/XPrivacyLua/commit/1708fc6e4a15cef85cb973f5c08286d90d3ca806
[Xposed Framework Modules] M66B:
With the latest version of XPrivacyLua / companion app you can change the collection of hooks to use in XPrivacyLua. The default is to use the collection 'Privacy'. You can define your own collection by definition hooks with a new collection name. There can only be one collection active at one time, so if you want to add your own definitions to the built-in privacy collection you'll have to use the collection 'Privacy'. Basically collections exists to allow using XPrivacyLua for things other than privacy.

Groups are listed in the XPrivacyLua app and make it easy to apply a group of hooks to one or more apps. XPrivacyLua cannot and will not handle applying individual hooks to keep things simple, but I might add this to the pro companion app in the near feature. For now you can rename a group of an existing hook definition to be able to apply it separately in XPrivacyLua.

Edit: this has been clarified in the documentation too now: https://github.com/M66B/XPrivacyLua/blob/master/DEFINE.md
[Xposed Framework Modules] mnjm9b:
I still have some questions on when,where,how etc.... but I will wait until I can dedicate more time to playing with this.

I do have a feature request.

could there be a sort of drop down box that queries all valid entries for each item when creating a custom definition.

for example...

when creating a custom definition, when taping on the line for group, you would just type a new group (as it is now) but if there was a drop down arrow at the end of the line that could give a list of currently used groups and then the user could just click the listed group instead of typing and it would auto-fill that field.

maybe even more useful would be for the other items like Name,Class, Method etc...

where it could show possible entries. That would help a lot.
[Xposed Framework Modules] jawz101:
... I turned on notifications for your new Firebase rules. I would think a bunch of apps I have use Firebase Analytics. [MENTION=2799345]M66B[/MENTION] Have you seen any apps trigger it yet?

Even if the app imported Firebase Analytics library and gathers Firebase Analytics but never uses the setAnalyticsCollectionEnabled() method in its own code would it mean this hook will never trigger?

Thanks:highfive:.

This is just a suggestion but if this was my app I would break these 2 elements out to separate screens from the definition builder. You would define collections and groups in a separate spot, and then when building rules the collections and groups would pull in as a selectable dropdown. Avoids typos and helps to explain how there can be only one active collection for XPrivacyLua.
[Xposed Framework Modules] M66B:
I will see what I can do for collection and group, but all the other fields are flexible and depend on the hook.
[Xposed Framework Modules] M66B:
An app will normally not disable/enable analytics given the default is enabled and the user has mostly no choice in this. So see this hook as a safeguard to prevent an app enabling analytics again after we disabled it in another hook ;)
[Xposed Framework Modules] jawz101:
Would there be a way to introduce the app to calling it? Or maybe that's what you're implying. Also, have you noticed that system and google apps seem to gray out the read identifiers permission? Ex: set read identifiers as restricted on Android Webview or Google Photos/Maps/Google TTS. Turns pink Get out of XPrivacyLua and open it again. Read Identifiers is gray. (I'm on LineageOS if that matters)
[Xposed Framework Modules] M66B:
Normally an apps doesn't call the function. Maybe if the user can choose to opt in or opt out, but this is rarely the case.

The other thing should go into the XPrivacyLua XDA thread, but I will look into it anyway.
[Xposed Framework Modules] mnjm9b:
Thanks, That's a good start.

Maybe if the "PRO" app takes off enough for you to bother you could charge extra for the expanded feature of having the drop lists change depending on the choices made?

I did have a moment to look over a definition I was playing with for "TIME"

it serves no real purpose so I gave up early but if I could get a better understanding on why it doesn't work it could help with actual ones.

using the FINGERPRINT example I made several other entries that all worked fine but this one caused issue.

I assumed it was because according to https://developer.android.com/reference/android/os/Build.html the type for TIME wasn't "String" but "Long"

this is the last one I tried...

{
"collection": "Privacy",
"group": "Read.Device",
"name": "Build.TIME",
"author": "M66B",
"className": "android.os.Build",
"methodName": "#TIME",
"parameterTypes": [],
"returnType": "long",
"minSdk": 1,
"maxSdk": 999,
"enabled": true,
"optional": false,
"usage": true,
"notify": false,
"luaScript": "function after(hook, param)\n param:setResult("unknown")\n return true\nend\n"
}

I was also playing with "SUPPORTED_ABIS" which also didn't work and the type was "Sting []" instead of just "String" so I was thinking that was the problem also.

:confused:
[Xposed Framework Modules] Namnodorel:
[MENTION=953466]mnjm9b[/MENTION] You are returning a string (series of characters) as a long (number). Try returning just a number (without the quotes).

String[] is an array (mulitple strings), so you need to return an array as well. But I don't know how to do that in Lua right now
[Xposed Framework Modules] M66B:
You are 100% right.

Returning a string array is not trivial. Look at 'generic_empty_string_array.lua' about how to do this.
[Xposed Framework Modules] mnjm9b:
so in my example the returnType instead of "long" should be a number like 0 without quotes?

I tried that and it still doesn't work.

---------- Post added at 08:55 PM ---------- Previous post was at 08:54 PM ----------

thanks for this, I guess I am in WAY over my head.
[Xposed Framework Modules] Namnodorel:
No. the return type was correct. That specifies what type of object you are expected to return. What you need to change is what you then actually return, which is

param:setResult("unknown")

to

param:setResult(12345678)
[Xposed Framework Modules] Rom:
@M66B

Thank you for your work, if i understand right, you provide us an programmable interface that will execute command lines written in Lua language without having to create a complete module in JAVA for XPosed?

From what i understood in your initial post, you indicate that we must install your module "XPrivacyLua", then that one disposes there after of the possibility to apply for the applications which one wishes, lines of codes written in Lua language and which do not necessarily have to relate to the logic of rights of access concerning privacy?

If yes then we must necessarily install XPrivacyLua even if in view of all your work provided on it the basic functions do not interest me forcibly?

All this seems to be promising however :good:
[Xposed Framework Modules] M66B:
Yes.

Yes.

You'll need XPrivacyLua to install and run defined Xposed hooks written in Lua, but you don't need to use the built in privacy related hooks.

The companion app allows you to switch to another collection of hooks you've written, in effect disabling the built-in privacy related hooks.

Try it and I will help you when needed and in the process I will update the documentation where needed.
[Xposed Framework Modules] hkfires:
They are subset of the getCellLocation hook.

In some apps,they only use getCellLocation to get locations,If getCellLocation returns null to them,They won't work fine.

So i write these to fake a "real" CellLocation to these apps.
[Xposed Framework Modules] Fif_:
Looking at TelephonyManager again, your getCid/getLac hooks:

1. Do not seem to protect against leaking the GsmCellLocation Psc.

2. Won't work with CDMA networks at it's a different CellLocation subclass with entirely different methods.
[Xposed Framework Modules] hkfires:
I try to hook android.telephony.TelephonyManager.getCellLocation,and i write the script below:

But it throw a exception:"org.luaj.vm2.LuaError:script:32 bad argument: userdata expected,got number value=26545"(I input the number 26545 in pro companion app).

It seems like the setLacAndCid method need userdata type arguments but i give it numbers.

I read the introduction about the method with this url:

https://developer.android.com/refer...m/GsmCellLocation.html#setLacAndCid(int, int)

I think the type of the argument i send to the method is right,or did i miss something?

---------- Post added at 12:43 PM ---------- Previous post was at 12:30 PM ----------

Thank you for you replay.I write the hook definitions for personal use,and i'am a newbie to do with it.

I read the TelephonyManager class before,and i don't know how to fake the method of subclass.

So i only hooks getCid and getLac.I'll try to learn and improve it.:)
[Xposed Framework Modules] M66B:
Try fake:setLacAndCid instead of fake.setLacAndCid
[Xposed Framework Modules] hkfires:
It seems to have worked.But i got another exception.

Privacy.TelephonyManager.getCellLocation

Exception:
org.luaj.vm2.LuaError: bad argument: string expected, got userdata value=nil
at org.luaj.vm2.LuaValue.argerror(SourceFile:1058)
at org.luaj.vm2.LuaValue.checkjstring(SourceFile:966)
at org.luaj.vm2.Varargs.checkjstring(SourceFile:336)
at eu.faircode.xlua.XLua$5.execute(SourceFile:501)
at eu.faircode.xlua.XLua$5.afterHookedMethod(SourceFile:457)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:374)
at android.telephony.TelephonyManager.getCellLocation(<Xposed>)
at gyb.k(DeviceInfo.java)
at gya.a(ClientInfo.java)
at gvy.l(BinaryRequest.java)
at gvy.e(BinaryRequest.java)
at gvx.a(BaseNetManager.java)
at gxz.a(AuthConfigManager.java:0)
at gxh.a(AuthUtil.java)
at gwj.b(APS.java)
at gxt.b(APSManager.java)
at gxt.a(APSManager.java:0)
at gxt$a.handleMessage(APSManager.java:0)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.os.HandlerThread.run(HandlerThread.java:61)

Package:
com.alibaba.android.rimet:10116

Method:
after public android.telephony.CellLocation android.telephony.TelephonyManager.getCellLocation()

Arguments:

Return:
GsmCellLocation:[...] (android.telephony.gsm.GsmCellLocation)

Maybe my method is wrong.
[Xposed Framework Modules] M66B:
I am not sure why this happens because the result is checked for null values. This might be a bug in LuaJ.

Try to change to 'return true' only.
[Xposed Framework Modules] M66B:
You can also try:

return true, result:toString(), fake:toString()
[Xposed Framework Modules] hkfires:
It's worked,thank you very much.

But i find a small bug,the setting name in define hook cannot be fully displayed.
[Xposed Framework Modules] M66B:
Great that it works.

I don't think I can fix the display issue. It don't have this problem on my device, so I think this is caused by either a bug in the support library or in your Android version.
[Xposed Framework Modules] Fif_:
How to deal with package-specific hooks?

I wrote a couple of hooks to keep the notifications from a set of apps from being grouped together by Nougat's notification ranker. These hooks are NOT privacy related, but that won't prevent me from publishing them. :)

Now these hooks should only be applied to a single system app, the one that processes notification grouping.

While on my system I can be careful to not apply this hook anywhere but the intended app, I cannot guarantee that other users won't make mistakes. This is particularly problematic with the "Restrict new apps" feature.

My options are:

[1] Make the hooks optional, so that they won't ever break if applied to the wrong app.

Pros: won't break careless users' XPL installations.

Cons: expensive hooking work is done even when unnecessary; methods signature errors are not caught.

[2] Don't make the hook optional, put prominent description warning.

Pros: most efficient

Cons: users never read the documentation.

[3] Maybe we need a pendant to "exclude apps", " only apps" or "exclusive apps" that will make a hook apply only to a subset of apps.

Pros: both [1] and [2] pros are covered, without any of their cons.

Cons: not implemented in XPL [MENTION=2799345]M66B[/MENTION] (and other potential users), what's your preference? I'd rather go with [3], but that puts work on you.
[Xposed Framework Modules] M66B:
Option 4 ;) use the exclude packages option with a negated regex.
[Xposed Framework Modules] Fif_:
Great news. Where is the "exclude packages" feature documented? I couldn't find anything about its format...
[Xposed Framework Modules] M66B:
It is not documented indeed, but there is s field in the pro companion app. It is a regex Android style (Pattern).

https://developer.android.com/reference/java/util/regex/Pattern.html
[Xposed Framework Modules] Fif_:
Great, another regex syntax. It beats the lousy lua patterns, in fact they threw in the kitchen sink when designing java regexes (sorry, patterns). So if I want to exclude everything but say Google Chrome, I could do that with this zero-width negative look-ahead regex:

^(?!com\.android\.chrome).*

Will the backslashes not be parsed/evaluated and will they be passed as-is to the regex engine, or does some additional escaping need to be performed? I'm trying to match a literal "." with "\." And I assume that the regex is not anchored, so the ^ is necessary at the start so that only com.android.chrome is matched and not us.com.android.chrome.
[Xposed Framework Modules] M66B:
I cannot really help you with this because I didn't use the Android Pattern much. In any case XPrivacyLua calls Pattern.matches for excluded packages.
[Xposed Framework Modules] M66B:
[MENTION=5297163]Fif_[/MENTION] you can check if the Pattern is correct in XPrivacyLua because only hooks with a matching Pattern will be shown.
[Xposed Framework Modules] Fif_:
Yes, I got it working with the pattern I posted.

I've uploaded the two hooks to the repo.

The two new hooks are part of a new "Utilities" category and both have a pattern that will only match the intended package.

In XPLP, when looking at the detail view of the package, the new hooks will only show up on the intended package, they won't be shown in any other package. Great so far.

In XPL, when looking at all the restrictions and expanding an app, the "Utilities" category only shows up for the intended package, which is fine.

If in XPL, I select the Utilities category in the header, all packages are displayed, and if I try to toggle it for any package but the intended package, it won't work, which is as planned.

However, there are two buglets in the toggle all feature: if I use the header's "Restrict" button to turn the restriction on for all packages, then:

1. The UI changes all the packages's toggle button to grey. This clears if the list is forcibly refreshed by reentering XPL or refreshing: all the packages have the "Utilities" group disabled while the intended package has it enabled.

2. All packages for which the "Force stop automatically" is active are killed, even the ones that are not affected by the restriction change because they're excluded. While annoying, this is more of a limitation than a bug.
[Xposed Framework Modules] M66B:
This problem will be fixed in the next release:

https://github.com/M66B/XPrivacyLua/commit/33c3b16111923f85fad3e4d4490a1d2293ff36c8
[Xposed Framework Modules] M66B:
You are trying to save a definition without Lua script, which is not allowed.
[Xposed Framework Modules] daniel_m:
Very naive question: Doesn't XPLP generate the Lua script from my hook definition?
[Xposed Framework Modules] M66B:
No, that is not possible because you'll need to tell what the hook does.
[Xposed Framework Modules] daniel_m:
How do I do that? I thought one defines all that in the XPLP hook definition popup?

Yes, I am confused ...
[Xposed Framework Modules] M66B:
You can look at the existing hooks for examples.
[Xposed Framework Modules] daniel_m:
I tried. When I change "Setting names" from an existing hook to something invalid, XPLP does not save the hook.

Now it gets interesting, because I cannot see the text input field of "Setting names" on my Moto Z Plus.

In addition, shouldn't XPLP either save an invalid hook, or display a warning about an invalid input and give me the chance to correct it?
[Xposed Framework Modules] M66B:
There are no invalid settings names. Any name is okay.

I will look into the settings names formatting again later.

Didn't you get an error message that the definition was missing? In any case you cannot save a hook definition with mandatory properties missing.
[Xposed Framework Modules] daniel_m:
No, when I try to save an unfinished hook definition, XPLP just closes the definition dialogue and opens an empty one right away. There is no warning dialogue of any kind.
[Xposed Framework Modules] M66B:
I have just released version 0.58

This version fixes error messages about missing hook definition fields not appearing and clearing the hook definition after such an error. Also, the settings field should be visible now. This seems to be caused by a bug in the Android support library for which there is a workaround now.

[MENTION=4885896]daniel_m[/MENTION]
[Xposed Framework Modules] daniel_m:
It is working now perfectly well now. I see the settings and I get a warning messages with the hook definitions staying in place.

Aaaaaand, I finally understand where the Lua script is supposed to go :) I wasn't aware that the input field is hidden by default and must be opened by touching the down arrow.

Thanks a lot for fixing this so quickly!
[Xposed Framework Modules] hkfires:
Hi,can i set default value for a custom value?

Now,i need to deal with the exception which occurs by the nil value from custom value.
[Xposed Framework Modules] M66B:
You should do that in the hook definition. Check for nil and substitute it with the desired default value.
[Xposed Framework Modules] mhdasif899:
Can anyone confirm that TelephonyManager/getNetworkOperator is working for you because I was checking if the hooks work or not but this app still can access MCC,MNC, com.wilysis..cellinfolite
[Xposed Framework Modules] M66B:
You'll get an error message if something doesn't work.

There are multiple ways to get the MCC and MNC. One of the hooks (Configuration) is disabled. You can try to enable it.
[Xposed Framework Modules] amakuramio:
For me the custom values so far don't seem to work either, all else values work
[Xposed Framework Modules] M66B:
Which hook definition and who is the author?
[Xposed Framework Modules] amakuramio:
Hello! For example to test it out, I did build.model, I did edit, added model in settings name. Then in the custom values I typed in a random stuff and in the device id test app, it still showed unknown.

Same for the other mcc mnc like the person above.

By the way this app is really light, good work. Xprivacy used to cause lag / slight drain :)
[Xposed Framework Modules] M66B:
Can you show me the hook definition?

Are you actually using the setting in the hook Lua script?
[Xposed Framework Modules] amakuramio:
Did I do it right? :)
[Xposed Framework Modules] M66B:
How does the Lua script look? Are you using the defined custom value?
[Xposed Framework Modules] amakuramio:
function after(hook, param)

local result = param:getResult()

if result == nil then

return false

end

local fake = 'unknown'

param:setResult(fake)

return true, result, fake

end

I only did 'edit' then at the end I typed in setting name, then in the custom values ''big boss''!