Loading Android Kernel modules - android

After weeks of mucking around i have (i think) successfully compiled g_hid.ko (USB Gadget HID module) for my Samsung Galaxy S3 but have been unable to test it. If i try and use insmod from the directory it is stored in i get insmod: can't insert 'g_hid.ko': No such device I'm new to this but i think this means that i should have loaded something else that g_hid is dependent on first. Any one know what this would be or how i can find out?
Also when trying to use rmmod i receive the following error rmmod: chdir(/system/lib/modules): No such file or directory which is true, that directory doesnt exist, as far as i can tell, my modules are stored in /lib/modules but this is a read only file system so i cant add my modle there. I also get the same error if i try and use modprobe. Any help you can offer would be greatly appreiated.
Thanks
Adrian

I eventually got this to work. The continual discussion on the topic is at Is it possible to program Android to act as physical USB keyboard? and http://forum.xda-developers.com/showthread.php?t=1871281 When i have some free time in a few weeks (after uni) i intend to write up how i did every thing as there appears to be a lot of interest.

Regarding the inability to place the module into system/lib/modules... You must first connect to the device and issue the commands:
adb root
adb remount
After issuing these commands you can place your .ko into the correct directory and the "read only file system" problem will go away.

Related

Can't access local files in data/data of some phones

I'm having three not rooted phones here. Two of them have Android 10 and one has Android 8.0. On one with Android 10 I just cant access the app files in /data/data directory with the Device File Explorer in Android Studio.
The error I get is:
`run-as: /data has wrong owner: 0/1000, not 1000ยด
I'm just not finding anything useful to fix this.
Since I had to dive into the comments of the original question to solve it for myself, I'll repeat the answer that helped me.
I uninstalled the app, restarted my phone, installed it again with android studio and it worked like a charm after that.
In case you're still looking for an answer.
This most likely happens when your database is created in the past (probably from some code that was a bit off). I advise you to delete the existing database from the device file explorer, make sure your code is right, and re-run the app.
This should create a new database and work.

Device is not showing in Android Device Monitor?

Files under the device are not visible please tell me something about it
I also uploaded the screen shot of it.
You can pull files from android device using adb command line tool. I don't know which file you exacly want. In case of sqlite database, it is stored in //data/data/<your app>/databases/<databaseName.db>. Probably you will need to be root to do that. Many files are hidden and inaccessible when you don't have root privileges.

Android root access

I have a Google Nexus 7, and I've been developing on it. Only recently, however, have I become unable to access the /data/ directory using the file browser in eclipse. The device was never rooted, but now since I upgraded it, I believe that I have lost access to this. Is there any way to get eclipse to use the "run-as" command to access my app's data directory? How come I have suddenly lost access to this?
Is the only option left to root the device?
Thanks
Is there any way to get eclipse to use the "run-as" command to access my app's data directory?
There is nothing for you to run "as" that would help here, AFAIK.
How come I have suddenly lost access to this?
You should not have had access to it in the first place. If you did, that was a security flaw in the device, perhaps fixed by a firmware upgrade.
Is the only option left to root the device?
You could not browse the /data/ directory on production hardware. For example, you can browse /data/ on the emulator.
I am able to given root permission by installing apk.
http://gadgets.ndtv.com/mobiles/features/how-to-root-nokia-x-and-get-access-to-google-play-store-and-google-now-508391

Android SD card writing fails, but not consistently

I've got a pretty thorny problem with Android 2.3: I have an app that gathers various logs for debugging and support purposes (my company does Linux for rugged hardware), and has stopped working lately, because it's failing to write to the SD card. Here are the symptoms I've seen and the investigations I've carried out:
Happens across multiple devices of multiple types with different SD cards, all of which have been checked for filesystem corruption (no issues found).
All devices report: Environment.getExternalStorageState() equals Environment.MEDIA_MOUNTED.
All devices also report that Environment.getExternalStorageDirectory().getAbsolutePath().canWrite() is false.
Via PackageManager.checkPermission(), my app reports that it has the WRITE_EXTERNAL_STORAGE permission.
OI File Manager is able to create directories and move files on the SD card; my app can do neither.
This code is sufficient to cause a failure:
String sdcardDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
File directory = new File(sdcardDirectory + "/logger");
if(!directory.mkdirs()){
//fails here.
Log.w("Logger", "Could not create logger directory.");
}
Since I have access to the keys for this device, I even went so far as to sign the app with the platform key and run it as android.uid.system, with no luck. Anyone have any ideas?
It turns out this is a case partly of bad diagnosis on my part, and partly an apparent change in 2.1 to 2.3.
The bad diagnosis was that the directory above was indeed being created. The apparent change between 2.1 and 2.3 may be Android internally, or it may be the way we're setting up paths, PATH, and symbolic links in our own builds. Further down from the code in the original post, there are a few calls to exec() to get e.g. output from logcat and copies of various bits of useful information in /proc; using absolute paths to the commands fixed the problem.
Thanks for the help in ruling things out.

"No media found". How to insert image in android

I am new to android programming so I will be really grateful if someone helps me.
I am trying to implement steganography in android but my problem is I don't know how to insert images in android. Because of which I am getting "No media found". Please help me with this.
I tried
c:> adb push c:\image1.png /sdcard/image1.png
But I get this in the Command Prompt.
failed to copy 'c:\image1.png' to 'sdcard/image1.png' : Read-only file system
I had the same problem, so in case anyone lands on this page here is how I solved it
When creating the emulator device (I use IntelliJ IDEA) - do not forget to move the radio button on SDCard option to the Size option, and specify the needed size, this way a new SDCard will be created and mounted to the emulator. In eclipse there are some command line parameters you can pass (or something else, I am not sure, since I read it only on the stackoverflow).
After that I stopped receiving the "Read-only file system" error, but I tried and tried and tried copying the files to the sdcard using:
adb push image.jpg /sdcard/image.jpg
or
adb push image.jpg /mnt/sdcard/image.jpg
but was receiving "No media found" error in my app or when I went to the gallery.
So I went to Dev Tools on the emulator applications, then to the Media Scanner. It quickly scanned the sdcard, and boom - I finally got to see my images.
Hope this helps :)
The correct directory for my emulator is mnt/sdcard. This works for me:
adb push README mnt/sdcard
Also note that you can explore directories using adb shell ls <path>, which might have tipped you off to the right path.
Edit - apparently sdcard is a symlink to mnt/sdcard and works for me as well. Using a file named image1.png is also working. Maybe there is a problematic file already located at that location for you?
Edit 2 - I think you also need to have the USB mounting option turned off when you use adb to push files. It sounds like you have this on given your comment about the gallery not finding your media.

Categories

Resources