I am trying to connect a zwave device to android tv box.
For that I need to edit handheld_core_hardware.xml file situated in /system/etc/permissions, but I can't do that since it is a read only file.
Can somebody tell me any trick by which I can edit the file?
You cannot access that file without root (superuser) permissions.
Every files located in /data or /system dirs are protected and you can read or write it only with root permissions.
Try something different or your app will run only on rooted devices.
Read more about that :
http://en.wikipedia.org/wiki/Android_rooting
http://www.androidcentral.com/root
Related
I'm using xamarin forms to develop an Android app. I can save a file via
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"appsettiings.txt");
var data = JsonConvert.SerializeObject(this);
File.WriteAllText(fileName, data);
When I debug I can see that the file should be stored at
/data/user/0/<applicationame>/files/.local/share/appsettiings.txt
I like to see if the file is actually saved and what the content is. I opened the Android device monitor but the data folder was 'empty'. From some other SO case I took that I should but myself in root-mode by executing
C:\Program Files (x86)\Android\android-sdk\platform-tools>adb root
Now the data folder contains data and I can drill down up to the files folder, but that one seems to be empty.
When I run the app again and check in code if the file exists, it actually does.
Any further suggestions how to get access to that file from any tooling. I want to delete that file and run the app again.
You can use adb pull to copy the file to local machine and look at it content like this:
adb root
adb pull /data/user/0/<applicationame>/files/.local/share/appsettiings.txt [LOCAL_FOLDER]
then you can use adb shell then rm -f to remove it, like this:
adb shell
su
rm -f /data/user/0/<applicationame>/files/.local/share/appsettiings.txt
Since the file you are requesting is inside /data folder, you need to have the corresponding root priviliege to get it, so you need to do adb root before the adb pull command, and you need to do su before removing the file.
If I am not mistaken, if you save a file with your approach, it should exist, as you already proofed with the .Exists method.
I am not quite sure, are you just trying to read the content out of the file? Or do you want to access it from outside of the application?
If your desire is to just read the content, you could access it with
string content= File.ReadAllText(your file path);
and set a breakpoint (F9) on the next line.
I'm looking at android's source code and i'm trying to add file to the data partition in build time. For that i need to add file to the userdata partition.
Moreover, i need to find where the the permissions for the files in the data directory are determined, in order to give the file the permissions i want.
For that i need to see where in the source code is the userdata partition mounted, because i guess that the permissions are given there as well.
I've looked at init.rc but the only thing i saw is:
mkdir /data 0771 system system
But there doesn't seem to be any mount for user data..
Does someone knows where does this happen?
You can just use PRODUCT_COPY_FILES for example:
PRODUCT_COPY_FILES += device/repo/your_file.so:data/folder/your_file.so
...plenty of examples here, in my device repo... just copy it to data though, instead of system: https://github.com/sudosurootdev/device_lge_g2-common/blob/kk44/g2.mk
More examples: https://github.com/sudosurootdev/vendor_lge/blob/kk44/ls980/ls980-vendor-blobs.mk
NOTE: Just don't add it to an Android.mk file. Use another *.mk file either under an Android.mk which calls all subdir makefiles or call the file specifically from another:
include device/repo/your_file.mk
Now, if it needs it's own directory under data, you will want to add it in the init.rc like you posted.
I'm trying to test the Expansion Pack Files (OBB) In Android following the guide here:
http://developer.android.com/google/play/expansion-files.html
I'm in the step where I need to test my app on my Nexus 4.
I generated my .obb file with jobb and adb-pushed it in the device in this location:
/mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb
When the app run it doesn't find the file.
Method:
Helpers.doesFileExist(context, fileName, xf.mFileSize, false)
return false for my file.
I debugged and found out it is looking for the file in:
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
Specifically this is the path returned by:
Helpers.generateSaveFileName(c, fileName)
The /storage/emulated/0, returned by Environment.getExternalStorageDirectory() doesn't exist browsing the device with adb shell.
But it DOES at runtime, inside the app, I also checked what it contains: it contains almost the same things I found in /mnt/shell/emulated/0, it contains the Android/obb dir, which is empty.
How I found out the path /mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb where I placed my obb file:
$ adb shell
$ ls -ld sdcard
lrwxrwxrwx root root 2013-10-16 17:34 sdcard -> /storage/emulated/legacy
$ ls -ld /storage/emulated/legacy
lrwxrwxrwx root root 2013-10-16 17:34 legacy -> /mnt/shell/emulated/0
And inside that I already found the Android/obb directory, empty.
So the question is: where should I put my obb file for it to be in the right position at runtime?
I did everything said there:
created a draft application in the Market to get the public key
generated a random array of 20 byte (salt)
integrated play_licensing/library and play_apk_expansion/download_library
wrote my Service / Receiver
did the check using the Helpers etc.. exactly like the documentation say.
I suppose everything works but I can't just yet release on Play Store! I need to test locally and I'll have the need to change my obb file pretty often in this initial phase of development.
I can't test on the Emulator because I use 3D and device camera.
Since Android 4.2 multi users support have been added.
To support that Android mount an emulated disk for each users acting as a sandbox layer around the actual filesystem: this let Android handle gracefully either sharing of files between users either personal files.
Long story short:
/storage/emulated
is the emulated filesystem.
if you enter that directory from adb shell you may see a
/storage/emulated/obb
directory. Sometimes it doesn't show up, for some reason (see below for what to do if this happen)
It's not in /Android/obb but that's the right directory where to place your app package / obb file!
If you don't see that directory try looking in:
/mnt/shell/emulated/obb
You should be able to put your file there.
It will be correctly picked up at runtime ending at the
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
path.
I think the Android documentation should explain this.
(I answer my own question because I found out how to solve it while writing it.)
For me the correct location is : mnt/sdcard/Android/obb/nameofyourpackage/
NOT "/mnt/shell"
I am trying to rename the SystemUI.apk in the directory /system/app to something else on my rooted device (Tablet with ICS) just like Root Browser is able to.
It doesn't work the same way as it works in the /sdcard directory. I tried this:
String s = "/system/app";
File from = new File(s, "SystemUI.apk");
File to = new File(s, "_SystemUI.apk");
from.renameTo(to);
(This code works for file in SD-Card)
And I set the permission to write to the external storage:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
However, there is no such permission for the "internal" storage. Do I need to do this via Runtime.getRuntime().exec(some command)?
Thanks for any help.
You need root access, this can not be done with standard java classes.
Run this commands via SU binary
mv /system/app/SystemUI.apk /system/app/_SystemUI.apk
Obviously you can change the cmd as need to do what you need.
Given i have compiled linux exe file in my resources/raw directory.
Can i execute it using Process.execute("./resources/raw/filename") or i have to have special permissions (like ROOT or smth) ?
Firstly, How did you compile the executable? I hope you've used a Cross-Compiler.
And Yes, you can execute applications...No special rights required.
I haven't tried that method, (Process.execute()) But i can Confirm Runtime.getRuntime().exec("/path/a.out"); works.... :)
When you execute it, the application will have the same privilege level as your application (non-root)...unless you rooted the device.