Change timestamp with touch in Android - android

I'm trying to change the timestamp of the pictures I copied to my new phone from my old one. I'm using busybox's touch command through adb shell. The files names are like: IMG_20131203_223152.jpg so:
# for i in `ls IMG_*` ;
do
d=`echo $i|cut -d"_" -f2` ;
t=`echo $i|cut -d"_" -f3|cut -d"." -f1` ;
touch -t $d.$t $i ;
done
It requieres to be root in order to change the timestamp but it works, as I can see with and "ls -l". The problem is that if I go to Pictures on the phone and see the Details still show the timestamp of the moment I copied the pictures from the computer. It`s like the changes are not persisted. Ejecting and unpluging the phone from the computer doesn't work either. And I forgeting something? Thanks in advance.
EDIT: My phone hasn't external sdcard so I think is emulated using FUSE.

I found the solution. It was pretty stupid, I just have to reboot the phone.

Related

How to change vendor.img contents with android emulator?

So, I have a custom AOSP image that I'm building, and it allows me to provide my own kernel and debugging features that I want (this is just for the record, because you can't do some things that are needed with a regular AVD). I need to change the contents of /vendor, and I thought that I could do this by providing my .img file to the emulator with:
emulator -vendor /path/to/my/vendor.img
But, as I checked, the md5sum does not match for some files between my vendor.img and in the /vendor/path/to/file when I run the emulator and connect with adb shell. This is perplexing to me, because when I run with -verbose, I can see the arguments given to qemu for the drive and I expect that img to be mounted under /vendor. Looking at the original vendor-qemu.img with 7z, I can check the md5sum of ome files and see that despite the -vendor argument, the sums did not change to the values in my img, but match the old intead. I even went to the length of renaming the original vendor-qemu.img and putting my img in it's place with the name vendor-qemu.img. Same result with the md5sums though.
Perhaps I could be wrong, and the -vendor emulator argument shouldn't change the contents of /vendor in the running emulator instance. What do I do to get the /vendor directory contents of a running emulator instance to match with the vendor.img?
The way I found to do it was to go to:
out/target/product/<lunch tgt>/vendor/
And just put the vendor contents the way you wish them to be. When finished do:
make vendorimage && make systemimage

Pasting text on new Android emulator

I am using the emulator that comes with Android Studio and need to past text between my OSX Yosemite machine and an app in the emulator.
I started my emulator with emulator -avd Nexus_6_API_23
I tried long click Command-V it does not paste
I see How can I copy/pate multibyte characters on Android Emulator? and a few others like Paste text on Android Emulator but they seem related to adb and not the new emulator.
Any ideas pls?
Follow these steps for write copied text:
Open Terminal
Write command: adb devices (it will list the device currently connected)
Select Textbox where you want to write text
Write command: adb shell input text 'Yourtext' (make sure only one device is connected to run this command and that you can also use Single Quotes)
Done!
In a terminal, type
adb shell input text 'my string here.'
This work only you have one emulator or one device connected your PC.
I had the same problem - need to copy text from macOS to a Android Virtual Device (AVD) in Android Studio. I tried the sms or telnet solutions, they worked but not really well for a large sum of text (e.g. a whole page of text with spaces, line feeds and all kinds of special characters).
Thanks to someone who created an Apple script to force input password into the password field when opening an encrypted volume. That amazing script also solved this problem! And its more straight forward in utilizing this script to copy and paste from Mac to an AVD.
I have the Apple script icon always stay on top of the screen (the status bar) so whenever I need to copy and paste, it is just one click away.
Here is a copy of the script (whoever created this, thank you again!)
——————
set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92}
set input to do shell script "pbpaste"
if (input is not missing value) then
tell application "System Events"
repeat with char in the characters of input
try
key code numbers_key_codes's item (char + 1)
on error
keystroke char
end try
end repeat
end tell
end if
——————
Just copy the source text, click on the target location in the AVD, and then activate the script by clicking on the script icon, voilà, everything will be pasted like typing automatically!
Be warned that if there’s a huge sum of characters you are copying and pasting, it may take a few seconds for the script to complete the ‘typing’.
There is a tool to execute a command in the adb console to paste when ctrl + v is tapped. Try it out :)
https://github.com/HknCore/AndroidPaster/releases/tag/1.0.0
This feature is just not implemented. You can create a feature request from the emulator's help page

Changing screen resolution on android devices without re booting

I tried changing the screen resolution in build.prop file in system, but it requires re booting.
I need a solution for changing screen resolution on android devices without re booting.
Thanks,
Krishna
Unfortunately that is not possible. Everytime when Android boots, it will read the build.prop file and set parameters pointed by it accordingly. After it has booted, it will not access that file dynamically to change parameters. So for any change to take effect, a reboot is compulsary, you cannot escape it.
Set resolution (e.g. 1024x768):
$ am display-size 1024x768
Reset:
$ am display-size reset
Doesn't require a reboot. This works with Android 4.2. Solution for 4.3 is mentioned by LiTTle
There is also an App for that called NOMone Resolution Changer.
Android can change the screen resolution.
I think that you need Android 4.0 and above version.
Only things you need is terminal emulator and root access.
Reproduce the following steps:
1. Open the terminal emulator app.
2. Type su.
3. Type wm.
Read the help message appeared and you will understand...
In case you want an App take a look at this on Play Store or the source from Github.

Image in Widget not appearing on device but working fine on Emulator. How to fix?

I made a widget which reads an image from internal storage and displays it in an ImageView. It is working fine on the emulator (Android 2.3.3. API Level 10) but when I run it on my device (Droid Razr Android 2.3.6), it does not display the image. The widget is there on the screen but its just blank. Other parts of the widget are working fine like the Configuration Activity etc. Only the image is not appearing. What could be wrong ?
Thanks for your help!
I have two suggestions of what could be wrong:
Your file may not be where specified on your device
You may not have read permission for the file; try issuing chmod a+r yourfile in an adb shell
Okay I fixed it. In my Storage class through which I store and read images from internal memory, there is a function that takes the fileName as a parameter. Now this fileName was to be used when making the final call to store it. Instead, I had written "fileName". So there was only one file in the storage named fileName. This led to problems when reading from the storage using the actual fileName.

Partitioning the filesystem on Android

I'm trying to re-partition an SDCard on Android, with root access.
I have the 512 byte MBR file, and it shows up as this:
Pos MBRndx Type/Name Size Active Hide Start Sector Sectors
--- ------ ---------- ---- ------ ---- ------------ ------------
0 0 0C-FAT32X 5.9G No No 64 12,124,096
1 1 0C-FAT32X 1.9G No No 12,124,160 3,932,160
What I'm trying to do is resize the 5.9GB partition into 3GB, and then make an EXT partition with the remaining space. I can think of two ways to do this, but I'm a bit stumped in doing either of them:
1) Cross-compile GNU parted, and run it on Android to modify the filesystem in place. This would be my preferred method, but I've been trying to statically compile parted using scratchbox and haven't had much luck, and I haven't been able to dynamically compile for Android in scratchbox either.
2) Directly modify the 512 byte MBR using some utility on my computer, and then dd the file on Android. I have a tool to view the MBR (mbrwiz), but I don't know how to edit it.
Does anybody have any suggestions for either, or possibly a third route?
Maybe I'm not seeing the problem, but it does not look like you want to automate this or make a program with that functionality. So, why not take the SD card out of the Android device and partition it in a card reader on your desktop machine? You could even do a full backup beforehand and avoid losing any data with the partitioning.
You could use fdisk instead of parted, as we used for years before the later tool came about.
Many of the android community roms include a busybox-based fdisk, which with care you could probably install without replacing the actual rom (which may not yet have a fully functional galaxy version)
Not sure how this helps the kernel changing it back problem. You could have a look in /init.rc and see if there's something you can comment out there (you would need to extract, modify, and reflash the ramdisk to make a change to that, splitting and recombining it from the kernel if they did it the same way as the htc phones)
It may also be possible to partition it with external tools when it's in usb mount mode - if the usb storage gadget just treats it as a sea of blocks, presumably you could put a partition table on it?

Categories

Resources