Change system settings with android root app - android

What is the best (most safe) way to change protected system settings like brightness, gps, data, ... within a root app?
I read about 2 ways to do so:
1) copy settings.db to your app folder manipulate it with sql api and then copy it back -
seems more than just a bit risky to me.
See here
2) use root to copy your app to the system folder and hold WIRTE_SECURE_SETTINGS permission - seems doable, but does that break the market link, so the users won't receive updates anymore? See here
Or is there a different way?
Thx for your help!

Instead of moving your app to /system/app, you can execute your "modification" commands as root using su
An explanation of how to do this using Runtime.exec() (and also one implementation) can be found here.

Related

how to hide files in android (new proposed method)

is it possible to hide files in android by transfering/moving them to a location or sector (like in root folders or something) of which other apps don't have access to (via adb or termux or something)?.
I have mentioned adb and termux because i've seen performing actions like uninstalling system apps from device. and if possible, i don't want to root my device.
One humble request: i don't know the ABC's of app building/compiling, maximum i can do is execute commands in adb/termux. so if you paste any code, please also mention what to do with it.
i have tried:
putting dot at starting of the name of the files is too older method and everyone knows about it. encryption and decryption is too much time consuming process. And i don't have that much important data, i just want to hide it from direct access so that most of the people can't find it by normal methods.
Thank you very much

android ext4 file deletion / recovery without utilities

i´m trying to find a way how to delete and restore files in android - not using android file explorer tools or external tools for forensic analysis.
So far i understand that most devices has ext4 file system and that erased data still exist, only metadata are deleted.
I´ve read few articles about forensic analysis but they all use tools.
I guess i have to use Adb shell and find a header of the file and alter it, but haven´t found any explanation how.
Am i heading right direction or wrong ? Any help appreciated.
(I have one rooted and not rooted device, both higher than 5.0 Android)
I'm afraid you will need to use tools. Consider the question, "I want to hammer a nail into mahogany without using tools?" How would you answer that question? A hammer is the natural instrument one would us to accomplish the task. But it's a tool. I suppose you could use a rock, but technically speakinng, that's also why a tool. It's why we talk about prehistoric humans as being tool users, even if they are using tools made out of an axe.
In this particular case, you'll want to take a full image backup of the disk partition which will require root, and then use a program like photorec to recover the deleted files.

Kivy on Android : keep local storage files after app updates

I've got an Android app written in Kivy (Python), which stores local files that should survive an app update (adb install -r).
If the files are stored in a subdirectory of the current directory ("data/data/app_name/files"), I see that they are deleted after update.
However after some experiments I could "solve" this by storing the files in the "data/data/app_name/shared_prefs" directory, which seems to be persistent after updates. By the way, I didn't check but maybe the "data/data/app_name/databases" also is.
Is there a cleaner way of doing things ?
I need to test if I can create a new folder not called shared_prefs nor databases under "data/data/app_name", and if it is persistent.
(this seems kind of a hack because those directories have another dedicated purpose, even though my app is not using them for this dedicated purpose right now)
(NB: I don't want to keep the files outside the app private directory)
There is not a simple way (as in a build hook or similar) right now, but it's something we've specifically discussed in the last few days as the current situation has become a direct problem. I'm not sure what the resolution was, but there will probably be a change in python-for-android to fix it fairly soon.
If you want to keep up to date with this, ask on the kivy mailing list or irc. In particular, knapper_tech was making these changes.

Android userspace filesystem driver on non-rooted device?

Can I write a custom userspace file system that can be run on non-rooted factory devices through the standard available utilities?
I am aware of the existence of fuse-android, however as far as I have understood, it requires a rooted device. If that is not the case, please do correct me.
The goal I am trying to achieve is create a 'fake' FS that actually is mounted to a file.
I had the same need some time ago and came to the point where I had to admit that's not possible at all (mostly). It shouldn't be a problem to build libfuse for android, also the Java wrapper is no problem.
The real problem is that most of the systems I have seen aren't build with fuse support buildin nor do they provide modules which may be loaded (which would require root, but anyway).
You can easily find out if fuse is enabled by reading /proc/filesystems. It should list fuse, otherwise you will need root. But it's very likely that most android devices are build without fuse support.
My other ideas were to use another filesystem to "fake" something like fuse. This may be possible with nfs or some other network filesystem where you can implement the server by yourself. This whould enable you to write a fake fuse but I don't think it's worth it.
Edit:
And even if many devices would have fuse support buildin chances are high they wouldn't let you mount it as a user, you would need root access as your app wouldn't have the privileges to mount fuse filesystems.
Luminger almost has the right idea. Here's what I found on my Galaxy S3 (on Verizon):
The appropriate fuse stuff does exist in /proc/filesystems. So something must be using it, quite possibly system. However, when I attempt to execute 'fusermount', I get "Cannot execute -- Permission denied."
So it looks like all the FUSE stuff is there, but I've got no idea whether I could actually use it directly (dropbox? sshfs?) without rooting the device.
It depends on your implementation. What it sounds like to me is you want to have a physical file(s) that represent a full user space file system. Perhaps similar to a mounted .iso. If this is the case, I cannot think of any reason for needing root: You simply create/install the file somewhere such as /sdcard/ and "mount" your file system on top of it.
That said, if you want said file system to be accessible from other applications that you do not control, you'll need root as your application will be running in a Android sandbox otherwise.

What is an appropriate directory in which to install Android SDK?

I don't use java much so what are the common (best practice) locations to install components like this. I want to put them in a system directory so multiple users have access.
Common locations are /opt, /srv, and /usr/local. I tend to lean toward /usr/local.
Note that the Android SDK doesn't really require you to install much, it's mostly self-contained. All you need to do is tell Eclipse where it is. You may also want to add the tools and/or platform-tools directories to the system-wide PATH so that your users can use adb and other tools.
See http://developer.android.com/sdk/installing.html.
On Linux, I typically use /usr/local/android-sdk, but anywhere that makes sense and that won't get clobbered by your system works. Just be aware that it may actually make sense to put the SDK in a per-user location, since it requires write access to create a VM image and to download SDK updates.
To be more concise and allow user writing for things like sdk installations and etc, you could put it somewhere inside the ~/.local directory as per the XDG file system hierarchy like ~/.local/lib/arch-id/android-sdk
Also remember to set the ANDROID_SDK_ROOT env variable to that directory as the ANDROID_HOME variable was deprecated.
It doesnt matter where you put the sdk. Just put it in any folder where all user's can access it...

Categories

Resources