Android bootanimation doesn't work (permissions error) - android

Recently I designed my own android bootanimation.zip file. I'm very proud of it and would like to make it my boot animation (the graphic that shows up when you start up your phone). However, I ran into a complication that I can't seem to solve or find any solutions to online.
Info: I'm running Cyanogen 12 on a Motorola Nexus 6. I placed my bootanimation.zip in the /system/media folder (and /data/local, but that didn't work).
The issue (read carefully please!):
I have confirmed that my bootanimation.zip file IS formatted correctly and DOES display properly. When I enter my phone's shell as root I can properly execute the /system/bin/bootanimation command. This command simply previews bootanimation. However, I can't execute the binary as non-root (which I should be able to do). I even went as far as changing the ownership of bootanimation to the shell (non-root account). Basically, I see something like this.
shell> bootanimation #/system/bin/bootanimation should by in my $PATH
/system/bin/sh: bootanimation: not found
shell> cd /system/bin
shell:/system/bin> ls bootanimation
bootanimation: Permission denied
shell:system/bin> ./bootanimation
/system/bin/sh: ./bootanimation: not found
shell:system/bin> su #log in as root
root> cd /system/bin
root:/system/bin> ls -l bootanimation
-rwxr-xr-x shell shell 34252 2015-11-03 11:07 bootanimation
Finally, the device is clearly unable to execute this on startup because the boot animation is never displayed, instead a silver 'google' is displayed.
I appreciate any input, thanks.

Related

Which Android Emulator image do contain 'su'?

How to know which Emulator image will contain su?
I can see that often it only contains su or google play
Run adb root and you get a root shell ... otherwise su needs to be manually installed.
However, when already having a root shell available, installing it isn't much of a problem.
All images are rooted, but SDK apps requesting escalation of privileges do rely upon su.
This question here generally duplicates: How to get root access on Android emulator?
adb shell scripting must:
start the emulator
run adb root
run adb shell
remount system partition
adb push the su binary
chmod to set permissions
exit
Or to answer the question:
start the emulator
and check if the file exists, eg. with adb shell stat /usr/bin/su
Where stat gives this response, when it's not installed:
stat: '/usr/bin/su': No such file or directory
One could even loop all Android images installed in $ANDROID_SDK_HOME...
there's no "one click" solution, but adb can be fully automated with Bash or Batch. And one wouldn't even have to run the emulator, but can mount QCOW2 as a nbd network block device.

Copy folder from Android app to local Windows directory

I'm trying to use the Android Adb Command Prompt to copy a folder inside the app container to a local Windows folder. The device is running Android 5.1.1 and is not rooted.
adb pull or cp aren't working. How can I copy a folder?
The following approaches aren't working:
Approach 1
adb shell
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
error: device not found
Inside the shell you can't see to do adb pull. See here.
Approach 2
DDMS can't access the data folder.
Approach 3
adb shell
run-as DroidSample.DroidSample
cp /files/MetroLog/MetroLogs/ C:/temp/test
cp: /files/MetroLog/MetroLogs/: No such file or directory
Approach 4
adb shell
run-as DroidSample.DroidSample
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs/ C:/temp/test
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs is a directory (not copied).
This is also not working.
Approach 5
adb shell
run-as DroidSample.DroidSample
chmod 777 /files/MetroLog/MetroLogs
exit
exit
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
adb shell run-as DroidSample.DroidSample
chmod 700 /files/MetroLog/Metrologs
remote object '/data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs' does not exist
So also this isn't working.
Approach 6
adb shell
mkdir /sdcard/tmp
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs /sdcard/tmp
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs: Permission denied
This is also not working.
Approach 7
The only thing which half work is this
adb exec-out run-as DroidSample.DroidSample cat "files/MetroLog/MetroLogs/Log - 20160509.log" > C:/temp/test/test.log
But here I don't get the original file and I also have to know the exact file name. Additionally, that I loose line breaks and I have to do this for each file. Not that what I want.
So I'm running out of ideas. How can I access the internal stored files and copy them over?
You have almost solved the problem. As the storage of this kind is secured, you need to do one additional step. You need to copy the file from secured location to sdcard of the device. And then you can copy it anywhere via usb or android pull. Here are the command sequence I executed successfully.
adb shell
run-as DroidSample.DroidSample
cd shared_prefs
cp DroidSample.DroidSample_preferences.xml /sdcard/DroidSample.DroidSample_preferences.xml
exit
exit
adb pull /sdcard/DroidSample.DroidSample_preferences.xml C:/test/
That's it.
And I really appreciate the way you posted your question. Best of luck.
You're trying to gain read access to /data partition on actual android device. Such thing is not possible without root access, even if the app folder is yours. For the reason that permissions to read /data partition are not granted and cannot be granted, unless you're using an emulator. On emulator, which by default is with admin privileges for developer, you can access the data partition to read and write. On actual device you cannot. Not with adb, not with DDMS.
So basically speaking, anything that requires access to those files under /data is not going to work. Whether you sue cp command or pull command. The moment your kernel reads the beginning of your path which starts with /data/... it says: Oops, no can do.
You are trying to access /data folder of android device which is not accessible in unrooted device.

How can I get a working adb shell on android when /system/bin/sh is missing?

I'm trying to build Android Jellybean from source for the Measy U2C HDMI stick. I've managed to build and install all the partitions (boot, kernel, misc, recovery, system...). The problem I'm having is that the system partition doesn't seem to be mounting. When I run
adb ls /system
I get the following output:
000041ed 00000400 51301410 .
000041c0 00000800 00000003 lost+found
000041ed 00000000 00000001 ..
I'd like to adb shell into the device and try to debug why the system partition is not mounting but adb wants there to be a working shell in /system/bin/sh.
$ adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
My question is, how can I get adb to look elsewhere for the shell command so i can get this working? Or is there an alternate way to remote into the device and debug this? There is a busybox install at /sbin/busybox so if I can just invoke that somehow, I can figure this out.
"SHELL_COMMAND" appears to be hardcoded in adb/services.c an unofficial copy of which is browsable at
https://github.com/android/platform_system_core/blob/master/adb/services.c
Given that you are building from source you should be able to change this. But since you want to point it to a shorter path, you could also probably edit the binary and move up the terminating null.
Another approach to investigating your problem could be to see if you can get a working adb shell after booting to the recovery partition, and try manually mounting the problematic system partition there to see what errors result.
Still another idea would be to put something in the startup scripts which launches an alternate shell listening on something which you could forward a socket to using adb - I'm not thinking of an obvious reason why setting up adb forwards would depend on the device side shell, but I haven't verified that by experiment or examining the code.
If you wanted to get really clever, I believe that you could create a /system/bin containing a copy of sh on the root filesystem. My recollection is that you can mount a filesystem over a non-empty directory - not sure if there would be an issue with open file descriptors to that directory, such as for the running sh itself, but your mount is failing anyway, and you could try doing a manual mount elsewhere in order to debug that issue.

Android getExternalStorageDirectory() returns invalid directory

I am trying to add OBB file support and I have run into a bizare situation. When I call getExternalStorageDirectory(), it returns a path that does not exist on my device.
I call this at the start of my app:
Log.i( LOG_ID, "XXXXXXXXXXXXXXXX <--- "+Environment.getExternalStorageDirectory().getAbsolutePath() );
It returns:
XXXXXXXXXXXXXXXX <--- /storage/emulated/0
But when I connect via adb -d shell and run ls -al /storage/emulated I get:
lrwxrwxrwx root root 2013-12-04 15:17 legacy -> /mnt/shell/emulated/0
As you can see the path getExternalStorageDirectory() returned is not valid on my device. Any idea why this would be and how I can locate the OBB files without hard coding /mnt/sdcard/?
EDIT:
I have just run some further testing:
Works - stat( "/sdcard/Android/obb" );
Fails - stat( "/sdcard/Android/obb/uk.co.mycomp.myapp" );
shell#android:/mnt/shell $ ls -ald /sdcard/Android/obb/
drwxrwxr-x root sdcard_rw 2013-12-18 16:42
shell#android:/mnt/shell $ ls -ald /sdcard/Android/obb/uk.co.mycomp.myapp
drwxrwxr-x root sdcard_rw 2013-12-18 18:36
As you can see the two directories are identical yet I can only access the parent. This may or may not have any relevance to my issue...
In recent Android versions, the mounts are actually different for different user ID's, which invalidates the way you are trying to investigate this.
Your attempt at investigating the storage paths is frustrated by the fact that recent Android versions leverage the "Per-process namespaces" feature of the Linux kernel to provide different sets of mounts to different process ancestries. This is likely connected to the efforts towards supporting multiple (human) user accounts, with both unique and shared sub-sections of External Storage.
When you run an adb shell, you get a set of mounts inherited from adbd.
But in contrast, code run by an application (either in it's process, or a child process) gets a different set of mounts, apparently either inherited from zygote or configured soon thereafter by the process differentiation code which turns a freshly budded zygote into your app's process.
To get an idea of what mounts your app sees, install something like connectbot which you can use to get a local shell descended from an application process, and run the mount command, or any other investigation of interest. For example:
u0_a99#build:/ $ mount
/dev/fuse /storage/emulated/0 fuse rw....
/dev/fuse /storage/emulated/legacy fuse rw.....
In comparison, checking from the adb shell:
shell#build:/mnt $ mount
/dev/fuse /mnt/shell/emulated fuse rw.....
Confusingly, because the mounts are determined by the processes's ancestry rather than it's user id, using the run-as tool from adb will not get you the same view as an application process or it's child, but rather instead will give you adb's view.
However, if you have the pid of a running app's process, you can use run-as to look in it's /proc/pid##/mounts file, without having to actually get a shell descended from the app.

ADB error=13, Permission denied from ADB, exists=true - Android SDK Setup

This is a recurrent question, and it seems it has several reasons. I cannot discover mine, even after googling. Several people had answered this question, though.
The problem is that when I try to run an android project with Eclipse and ADB, I get:
Failed to get the adb version: Cannot run program "/extraHD/android/android-sdk-linux/platform-tools/adb":
error=13, Permission denied from '/extraHD/android/android-sdk-linux/platform-tools/adb'
- exists=true
Some data:
1) /extraHD is my second HD, 180GB free, where I have full permissions
2) adb executable has full permission 777
3) If, after 'cd /extraHD/android/android-sdk-linux/platform-tools', I run any of these (no adb process running):
./adb
./adb shell
./adb start-server
./adb kill-server
./adb shell kill you
./adb root
./adb remount
I get the very same answer:
bash: ./adb: Permission denied
And same answer when executing as root! I can create/delete files in that directory, even as a normal user...
Same problem after reinstalling ADB, both through Eclipse and zip file.
Rebooting didn't work either.
I get the same problem with /extraHD/android/android-sdk-linux//tools/emulator.
Tried fsck, reinstalled Eclipse, reinstalled Tools and Platform-tools (adb in particular), reinstalled the APIs. Same thing.
Clues??
I had a similar problem and I solved it by doing the following (mounting the sdk partition at boot time and changing permissions in fstab in order to allow writing in Windows NTFS partition):
Open a terminal, you can use Ctrl+Alt+t
Use 'blkid' to list the block devices and print the universally unique identifiers (UUID)
sudo blkid
Locate the line with the label of your SDK partition and copy the UUID value:
/dev/sXX: LABEL="secondHD" UUID="copy_this" TYPE="ntfs"
Add a new line at the end of the fstab file so the partition will be mounted during boot:
sudo gedit /etc/fstab
Remember to customize the "your.." values, the order it's important, fields on each line are separated by tabs or space; type man fstab for further information). Save and exit.
UUID="yourValueCopied" "yourPartitionPath&Name" ntfs users,uid="YourGroup",gid="YourUserGroup",umask=0022,exec,permissions,auto 0 2
Restart the computer and try another time adb :)
Seems that It's a ntfs partition issue:
https://askubuntu.com/questions/207180/changing-permissions-in-fstab-in-order-to-allow-writing-in-windows-ntfs-partitio
A very good explanation of fstab-permission-masks:
http://www.omaroid.com/fstab-permission-masks-explained/

Categories

Resources