how to modify android.os.Build's static field? - Xposed General

Hi, I'm just use Xposed to dev a simple project.
I'm trying to modify device info by using Xposed. When I hook TelephonyManager.getDeviceId, return the value that just what I set.
But I can't find out how to modify the fields in andoid.os.Build. They are FINAL fields and Xposed can just hook on methods but not fields.
I get a way to set the fields using XposedHelpers.setStaticObjectField. It can ONLY modify ONCE when the target apk has not started. When the target apk( such as device info viewer ) started, I have to reboot or force close the apk because of the handleLoadPackage method can not reinvoke.
Waiting online for any solution. Thanks very much.

joetony said:
Hi, I'm just use Xposed to dev a simple project.
I'm trying to modify device info by using Xposed. When I hook TelephonyManager.getDeviceId, return the value that just what I set.
But I can't find out how to modify the fields in andoid.os.Build. They are FINAL fields and Xposed can just hook on methods but not fields.
I get a way to set the fields using XposedHelpers.setStaticObjectField. It can ONLY modify ONCE when the target apk has not started. When the target apk( such as device info viewer ) started, I have to reboot or force close the apk because of the handleLoadPackage method can not reinvoke.
Waiting online for any solution. Thanks very much.
Click to expand...
Click to collapse
I don't know which final field you are trying to change, but most of them get their values from getString(), getStringList() or getLong() methods.
You need to hook in these methods, read their "property" parameter ( param.args[0] ) to see if it is the one you want to change, and finally change the method result ( param.setResult() ).

Hello. Is there a solution to change the fields like Build.MODEL on the fly? Any examples not worked. Thanks.

Some fields can't be replaced, am I right?

Code is poetry:
https://github.com/M66B/XPrivacy/blob/master/src/biz/bokhorst/xprivacy/XPrivacy.java#L159

Your code is amazing

M66B said:
Code is poetry:
https://github.com/M66B/XPrivacy/blob/master/src/biz/bokhorst/xprivacy/XPrivacy.java#L159
Click to expand...
Click to collapse
It's worked only in own application with this code. In other apps it's not worked. I need to make changes to apply to all applications.
PS: Sorry for my bad English.

ifynk said:
It's worked only in own application with this code. In other apps it's not worked. I need to make changes to apply to all applications.
PS: Sorry for my bad English.
Click to expand...
Click to collapse
You can do this only when the Java VM is being initialized in handle load package.

M66B said:
You can do this only when the Java VM is being initialized in handle load package.
Click to expand...
Click to collapse
Thanks. How i can restart package for new init for handle load?

ifynk said:
Thanks. How i can restart package for new init for handle load?
Click to expand...
Click to collapse
There is no need for restarts, just set a new value in the Xposed handleLoadPackage callback for the applications you want to modify values.
Note that changing Build properties for Android might result in a bootloop.
Edit: if you don't known about handleLoadPackage , you need to do some studying ...

This all can be simplified by XposedHelpers.setStaticObjectField(clazz, name, value)

M66B said:
Edit: if you don't known about handleLoadPackage , you need to do some studying ...
Click to expand...
Click to collapse
Were i can read about handleLoadPackage? Thanks.

Related

How do I change the package name in a template?

Hi All,
I'm a super noob in app development and am not a programmer. I want to make my own soundboard and share it on the market so my friends with android phones can dl it. I'm using the steps in http://www.myandroidsoundboard.com/
and everything works great and I have been able to make my own fully working .apk's (woohoo) but when I upload it to the market, it gives me this error:
The package name of your apk (com.soundboard) is the same as the package name of another developer's application. Choose a new package name.
so how do i change the package name? I searched and most results come up for people starting from scratch but not for people using templates already written.
any help would be greatly appreciated.
thanks
1) find the package "com.soundboard" in the 'package explorer' pane.
2) right click on the package name, choose refactor->rename
3) type in a new package name, ex: com.agentkalaw, make sure the checkbox 'update references' is checked.
4) press ok, let eclipse make the change for you.
If there are any references to the old package name in \AndroidManifest.xml you will have to change those manually.
wow! thanks a lot britoso.
any tips on how i can change references in \androidmanifest.xml ?
i only get one error now (so close!) but i can't figure it out. I get
"class com.soundboard.soundboard does not exist" this is in the android:label="@string/app_name">
thanks again!
agentkalaw said:
wow! thanks a lot britoso.
any tips on how i can change references in \androidmanifest.xml ?
i only get one error now (so close!) but i can't figure it out. I get
"class com.soundboard.soundboard does not exist" this is in the android:label="@string/app_name">
thanks again!
Click to expand...
Click to collapse
THe xml will have to be edited manually, simply replace com.soundboard by com.agentkalaw

[Emulator][Unnoficial] Leapcast the Chromecast Emulator All-In-One File

After several hours of tinkering and editing, I think I've finally managed to make an easy way to emulate a Chromecast on your PC. Iv'e only worked on x64 based systems so far, but I'll do x32 if anyone needs it. All you have to do is download the file, place it on your desktop (or it won't work), extract the .tar (don't make a new folder) and follow the directions in INSTALL.txt. It shouldn't require any extra files except Google Chrome, but if it does or you have any other errors or advice, feedback is very appreciated.​
I take no responsibility for any damages done by this. USE AT YOUR OWN RISK. Leapcast is the property of dz0ny at GitHub, not me. All I did was make an all-in-one install script.​
I already have Python installed....Can I just run the Bat file?
Error running LeapCast.bat
I completed the installation but when I run LeapCast.bat got this error (see the image)
Edit: I found the problem, I need to Edit "PATH" environment variable to include this "C:\Python27" and this "C:\Python27\Scripts".
Good job!!!!
Only youtube detected the leapcast, I check Plex, Avia, Crackle and Allcast and they don't.
lordkain2 said:
I completed the installation but when I run LeapCast.bat got this error (see the image)
Edit: I found the problem, I need to Edit "PATH" environment variable to include this "C:\Python27" and this "C:\Python27\Scripts".
Good job!!!!
Only youtube detected the leapcast, I check Plex, Avia, Crackle and Allcast and they don't.
Click to expand...
Click to collapse
It's probably an error in my install script. It should have edited your PATH automatically, so I'll look into it. The compatibility problem is probably just an issue with the emulator itself. I'll keep an eye on the github page and update this as soon as its available. Thanks for the feedback!
Did you use the Chromecast app on your phone/tablet to detect it before you tried the other apps?
Asphyx said:
I already have Python installed....Can I just run the Bat file?
Click to expand...
Click to collapse
That's part of what the script does. If you want, you can ignore the basic Python install if you specifically have Python 2.7.5 installed, but you definitely need to let setuptools and pip install. Won't work without them I'm afraid. Thanks for the feedback!
thatscottguy93 said:
That's part of what the script does. If you want, you can ignore the basic Python install if you specifically have Python 2.7.5 installed, but you definitely need to let setuptools and pip install. Won't work without them I'm afraid. Thanks for the feedback!
Click to expand...
Click to collapse
Thanks Kind of what I expected....Will try this later tonite
Thanks for the effort!
Unfortunately, this doesn't seem to work. The .bat file it leaves on the desktop has a strange trailing ascii-character, but it still doesn't run correctly even after you remove it. I don't know why you would run it from desktop anyway rather than c:\python27\scripts anyway... It should run from anywhere if the PATH is set correctly, but this script didn't seem to do that. Finally, it would be smarter to use the .vbs provided by the leapcast dev instead of your errant .bat on the desktop. Again though, thanks for the attempt.
It would be great if someone could put together a full install using install-shield and all, or at least a working batch script that has been tested on a fresh install of WinXP/Win7/Win8.1 Maybe I will try to.
NOTE: If this works for others, please let us know, but I am fairly certain it has at least a few minor errors preventing it from working by following the instructions alone.
thatscottguy93 said:
It's probably an error in my install script. It should have edited your PATH automatically, so I'll look into it. The compatibility problem is probably just an issue with the emulator itself. I'll keep an eye on the github page and update this as soon as its available. Thanks for the feedback!
Did you use the Chromecast app on your phone/tablet to detect it before you tried the other apps?
Click to expand...
Click to collapse
i have tried editing my system variables, but after running Leapcast.bat it say:
'leapcast' is not recognized as an internal or external command,operable program or batch file.
Please guide me through. AND github is down in my country right now
---------- Post added at 01:17 PM ---------- Previous post was at 12:49 PM ----------
Okay I got this post on google+
https://plus.google.com/+NicandrosNicolaou/posts/8RjWfMXxje8
it help me do a complete install of LEAPCAST...
-------------------------------------------------------------------
I just wanted to ask if there will be any update for V2 chromecast ? @thatscottguy93
link is not working
can you post a mirror link please?
thatscottguy93 said:
After several hours of tinkering and editing, I think I've finally managed to make an easy way to emulate a Chromecast on your PC. Iv'e only worked on x64 based systems so far, but I'll do x32 if anyone needs it. All you have to do is download the file, place it on your desktop (or it won't work), extract the .tar (don't make a new folder) and follow the directions in INSTALL.txt. It shouldn't require any extra files except Google Chrome, but if it does or you have any other errors or advice, feedback is very appreciated.​
I take no responsibility for any damages done by this. USE AT YOUR OWN RISK. Leapcast is the property of dz0ny at GitHub, not me. All I did was make an all-in-one install script.​
Click to expand...
Click to collapse
punkmexic said:
can you post a mirror link please?
Click to expand...
Click to collapse
Just tried, and works for me....
punkmexic said:
can you post a mirror link please?
Click to expand...
Click to collapse
Its attached to the first post... no need for a mirror...
Installation files for 32 bit system
can you make a setup for 32 bit computer?
Can i run xbmc/kodi on my windows pc and use leapcast to send the video feed to my android phone - this way I can use the laptop as a remote and the phone as existing hardware - lowering my android tv experience to a cost of zero - or should I stick with remote desktop... lag could be an issue as leapcast is light weight via python - minus the $5 mhl
Nope
mikeymackinon said:
Can i run xbmc/kodi on my windows pc and use leapcast to send the video feed to my android phone - this way I can use the laptop as a remote and the phone as existing hardware - lowering my android tv experience to a cost of zero - or should I stick with remote desktop... lag could be an issue as leapcast is light weight via python - minus the $5 mhl
Click to expand...
Click to collapse
Leapcast does not work that way, its mainly for youtube etc... web based viewings. Why not run the laptop/ desktop to the TV set and remote in from the Android phone/ tablet via a remote control app or team view etc... You would defiantly have lagging issues if reversed. Plus you do not have the buy the micro usb to hdmi adapter? Kewl story bro!
Seriously smart, as you will not have to get up to change from one episode to the next and at no cost.
thatscottguy93 said:
After several hours of tinkering and editing, I think I've finally managed to make an easy way to emulate a Chromecast on your PC. Iv'e only worked on x64 based systems so far, but I'll do x32 if anyone needs it. All you have to do is download the file, place it on your desktop (or it won't work), extract the .tar (don't make a new folder) and follow the directions in INSTALL.txt. It shouldn't require any extra files except Google Chrome, but if it does or you have any other errors or advice, feedback is very appreciated.​
I take no responsibility for any damages done by this. USE AT YOUR OWN RISK. Leapcast is the property of dz0ny at GitHub, not me. All I did was make an all-in-one install script.​
Click to expand...
Click to collapse
Thank you very much!!! Nice Work! I love you <3 #nohomo
Hi,
i wanted to try this but iam stucking at this error
C:\Users\Administrator\Desktop\LeapcastForWindows\leapcast>leapcast --name Leapcast --chrome "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --fullscreen
Traceback (most recent call last):
File "C:\Python27\scripts\leapcast-script.py", line 9, in <module>
load_entry_point('Leapcast==0.1.3', 'console_scripts', 'leapcast')()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2431, in load_entry_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2147, in load
['__name__'])
ImportError: No module named leapcast.__main__
Anyone know how to fix this?
Managed to got it almost working IT's an old thread but I will give it a go.
Had to update Python to 2.7.9 for the SSL thing.
This is my issue :
Code:
C:\Users\d3x\Desktop\LeapcastForWindows\leapcast>leapcast --name Leapcast --chrome "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --fullscreen
INFO:root:Starting SSDP server
INFO:root:Starting LEAP server
INFO:root:Loading Config-JSON from Google-Server
Traceback (most recent call last):
File "C:\Python27\Scripts\leapcast-script.py", line 9, in <module>
load_entry_point('Leapcast==0.1.3', 'console_scripts', 'leapcast')()
File "c:\leapcast\leapcast\__main__.py", line 38, in main
leap_server.start()
File "c:\leapcast\leapcast\services\leap.py", line 35, in start
resp = requests.get(url=app_dict_url)
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='clients3.google.com', port=443): Max retries exceeded with url: /cast/chromecast/device/config (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))
Would that mean that google changed something and this no longer works?
-chrizz- said:
Hi,
i wanted to try this but iam stucking at this error
C:\Users\Administrator\Desktop\LeapcastForWindows\leapcast>leapcast --name Leapcast --chrome "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --fullscreen
Traceback (most recent call last):
File "C:\Python27\scripts\leapcast-script.py", line 9, in <module>
load_entry_point('Leapcast==0.1.3', 'console_scripts', 'leapcast')()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2431, in load_entry_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2147, in load
['__name__'])
ImportError: No module named leapcast.__main__
Anyone know how to fix this?
Click to expand...
Click to collapse
Did u solved this?? same problem here.. let me know if u solved this
Don't know about your specific error, but Google definitely changed something. Leapcast doesn't work anymore. According to dz0ny on github:
This project no longer works because Google locked down entire API. There are alternatives like cloning device, casting apk from nexus player etc. Thanks for all contibutors and I hope we all learned something from this project. Meanwhile I'am keeping https://github.com/dz0ny/leapcast/issues/130 open if anyone wants to discuss something related to lepacast or 2nd screen paradigm.
I would love to re-implement this as an open source alternative to chromecast someday, but I won't make any promises.
Does anyone know a proper way to uninstall this?

Starting a service with same permissions as hooked package

Simple question. I want to start my own service from my package with the same permissions as the package i am hooking. Does anybody know how i could do this? I know if i use android:sharedUserId="android.uid.systemui" in the manifest, but it prevents it based off of signature mismatch. Could i use xposed to grant my app the sharedUserId?
Simple question. I want to start my own service from my package with the same permissions as the package i am hooking.
Click to expand...
Click to collapse
I don't think that is possible. I haven't worked with services yet, but as far as I understood, you have to declare them in your manifest (in contrast to BroadcastReceivers, which can also be registered at runtime). Theoretically again, you could try to modify the manifest parsing and try to inject additional entries there.
elesbb said:
Could i use xposed to grant my app the sharedUserId?
Click to expand...
Click to collapse
Theoretically, I think yes, you could hook the package manager to ignore the signature mismatch etc. But I think it will be quite fragile.
What do you want to achieve with this?
rovo89 said:
I don't think that is possible. I haven't worked with services yet, but as far as I understood, you have to declare them in your manifest (in contrast to BroadcastReceivers, which can also be registered at runtime). Theoretically again, you could try to modify the manifest parsing and try to inject additional entries there.
Theoretically, I think yes, you could hook the package manager to ignore the signature mismatch etc. But I think it will be quite fragile.
What do you want to achieve with this?
Click to expand...
Click to collapse
I hate how Samsung removed widgets from the lockscreen. So i figured i'll create my own lockscreen and have it loaded by the system. I might just skip the whole service thing (which would make my lockscreen easier to write by having classes that extend things like FrameLayout as the stock lockscreen does) but i found where the lockscreen is actually shown. i may just inflate my own xml of the lockscreen using xposed resources and then adding it with windowmanager. Then the inflated view will follow the same permissions as the stock lockscreen and allow me to handle key presses and still preserve the security behind it.
Thanks rovo for the reply!
@rovo89
If i am inflating my own view inside a hooked method, how can i get the ids of my layout? I tried XModuleResources myRes; myRes.getIdentifier() but it returned null.
Be careful, Resources.getIdentifier() expects the arguments in a different order than Xposed, like getIdentifier("mystring", "string", "my.package.name").
Apart from that, simply use R.layout.my_layout.

Give system service permission to external storage

Hi,
I'm studying how PackageManagerService works, and i noticed that if an application was downloaded to /data/app i can access the file and open inputstream .
but if APK was downloaded to SD card, i can't access the file from PackageManagerService.
is there something i can do?
I want to be able to read the APK before it get installed...
Thanks,
pi.publicSourceDir = apk file path
pyler said:
pi.publicSourceDir = apk file path
Click to expand...
Click to collapse
not sure i follow you.
I'm in the packageManagerService context, i don't have PackageInfo (the application is still not installed)
You could hook PermissionGranter and give the process extra permissions, or see where the system is actually parsing the APK's manifest before installing it.
GermainZ said:
You could hook PermissionGranter and give the process extra permissions, or see where the system is actually parsing the APK's manifest before installing it.
Click to expand...
Click to collapse
Thanks, what I don't understand is, if i give my xposed module permissions to read external storage, why does it still can't read it?
shnapsi said:
Thanks, what I don't understand is, if i give my xposed module permissions to read external storage, why does it still can't read it?
Click to expand...
Click to collapse
They're different processes.
http://forum.xda-developers.com/showpost.php?p=55332926&postcount=9
http://forum.xda-developers.com/showpost.php?p=55186575&postcount=2
GermainZ said:
They're different processes.
http://forum.xda-developers.com/showpost.php?p=55332926&postcount=9
http://forum.xda-developers.com/showpost.php?p=55186575&postcount=2
Click to expand...
Click to collapse
So just to make sure I understand, I can create a service and run it from the hooked method and it should work?
if so, i have another question
How can i stop the original method from running until a point i allow it to continue?
Thanks GermainZ !
shnapsi said:
So just to make sure I understand, I can create a service and run it from the hooked method and it should work?
Click to expand...
Click to collapse
I don't understand how you read that from my reply, to be honest. Here's what I meant:
Hooked code *is not* run as your app. The hooked code is run as the hooked app.
If the hooked app can't do X, then the hooked code can't do X either.
Your app's permissions do not affect the hooked code in any way, only normal (not hooked) code.
shnapsi said:
How can i stop the original method from running until a point i allow it to continue?
Click to expand...
Click to collapse
Using the normal ways you'd normally use if it weren't an Xposed module, in the beforeHookedMethod hook. I'm not familiar with the exact methods, you can look that up. Just be aware that blocking it for too long will cause an ANR.

Lollipop: initZygote() has no access to /data/data/<module package> files

In the initZygote() of a module, it is not possible anymore to access files under /data/data/<module package>.
For example, my module needs to load a native library in /data/data/<module package>/lib, with System.loadLibrary().
It fails with an error, as no file is visible under /data/data/<module package>.
Is there any workaround ? Is it possible to restore the pre-Lollipop behavior in Xposed ?
The comment for
Code:
SELinuxHelper.getAppDataFileService()
tells
Retrieve the service to be used when accessing files in /data/data/*
Click to expand...
Click to collapse
dont know how it works
defim said:
The comment for
Code:
SELinuxHelper.getAppDataFileService()
tells
dont know how it works
Click to expand...
Click to collapse
Thanks for the pointer.
I could fix my problem trivially by moving some code from initZygote() to handleLoadPackage() which has permissions to access its own data directory.

Categories

Resources