[TOOL] Fix TWRP Backup Dates / Find Your Phone's Birthday - Nexus 5 Android Development

Well, a week into my Nexus 5 and the dates on backups got to me. "Was that the one before or after I pooched my phone?"
I was doing rough conversions at first, then convinced myself that there was a reasonably fixed offset between "real time" and what TWRP was labeling things. @helicopter88 let me know that there was a missing ability in the chip, so I looked for a run-time solution. Unfortunately, adjtimex wouldn't take a large enough offset.
Since the reasonably useless date stamps on backups were, well, reasonably useless, I did write a little script that converted the dates on the backups to something that matched my local time, given the offset.
Looks like @Dees_Troy has saved me a bunch of coding inside TWRP as there is a going-forward fix in the TWRP sources now. Since he found the magic file where the offset is stored, you don't have to try to "guess" it from looking at your clock and your phone's (though $ date && adb shell date will get you the information you need).
For those backups you already have, here's how you can get the dates and times fixed up on them.
Edit -- Shell scripts made up for on-phone use:
sh birthday.sh while on the phone will give you offset and your phone's birthday (Yes, Korean time, of course!)
Code:
[email protected]:/ # sh /data/media/0/twrp-dates-tool/birthday.sh <
1386550085
Mon Dec 9 09:48:05 KST 2013
sh spew-twrp-rename.sh /path/to/TWRP/BACKUPS will write the commands to move the directories to the terminal (stdout)
The "spew" script finds the offset itself.
It will rewrite both old (20th century) dates and current ones, but only time-shift the older ones.
It will also convert spaces in the file names to underscore characters.
See attached files (.txt added to allow upload)
No, there isn't a "zip" for this -- checking that the right things are being done with your backups before they can't be undone is important
Read on only if you want to do this using perl.
Now, you can adb pull /data/system/time/ to get two files, ats_1 and ats_2 that have the offset in milliseconds as a 64-bit unsigned integer. Pick one or the other, get the human-readable output trim off the last three digits, and there is your offset (within a second). Mine drifts a second each week or so, but hey, this is a lot closer than 1970 something!
Once you have the offset, this script will take a list of files and spit out the commands to rename them, if they match a TWRP-format date in the 1970s. (Edit $offset to match yours.)
Code:
#!/usr/bin/perl
use strict;
use Date::Parse;
use Date::Format;
my $offset = 1386550084; # Edit this to match your offset
my $line;
my ($year,$mo,$day,$h,$m,$s);
my $twrp_time;
my $new_time_string;
my $before;
my $after;
LINE:
while ( defined ( $line = <> ) ) {
chomp $line; chomp $line;
next LINE unless $line =~ m/((197\d)-(\d\d)-(\d\d)--(\d\d)-(\d\d)-(\d\d))/;
$before = $`; $after = $';
$twrp_time = str2time("$2/$3/$4 $5:$6:$7 GMT");
$new_time_string = time2str("%Y-%m-%d_%H%M%S%z", $twrp_time + $offset);
$before =~ s/ /_/g;
$after =~ s/ /_/g;
print "mv '$line' ${before}${new_time_string}${after}\n";
}
Output looks like
Code:
mv '1970-02-22--23-02-13 omni_hammerhead-userdebug 4.4.2 KOT49H 128' 2014-01-30_155017-0800_omni_hammerhead-userdebug_4.4.2_KOT49H_128
mv '1970-02-23--13-50-29 omni_hammerhead-userdebug 4.4.2 KOT49H 128' 2014-01-31_063833-0800_omni_hammerhead-userdebug_4.4.2_KOT49H_128
mv '1970-02-23--15-22-06 omni_hammerhead-userdebug 4.4.2 KOT49H 126' 2014-01-31_081010-0800_omni_hammerhead-userdebug_4.4.2_KOT49H_126
mv '1970-02-23--16-10-01 omni_hammerhead-userdebug 4.4.2 KOT49H 126' 2014-01-31_085805-0800_omni_hammerhead-userdebug_4.4.2_KOT49H_126
mv '1970-02-25--17-11-08 omni_hammerhead-userdebug 4.4.2 KOT49H 127' 2014-02-02_095912-0800_omni_hammerhead-userdebug_4.4.2_KOT49H_127
which you can copy and paste into a shell on your device, or other places you have your TWRP backups backed up.
.

Whoa! Nice one man! A bit of extra work is just fine rather than renaming each of the backups! Thanks a bunch
Sent from my Nexus 5 using Tapatalk

good work bro.
Possible a zip file to flash for this ?
tks

jonata said:
Possible a zip file to flash for this ?
Click to expand...
Click to collapse
Let me look into what options there are in toolbox/busybox for the date parsing. As this was a quick-and-dirty solution, I didn't dive into trying to get it to run on the device.

Umm,, huh?
NEXUS 5

dave2metz said:
Umm,, huh?
Click to expand...
Click to collapse
To be clear, the perl scripts run on something that has perl installed, like your laptop or desktop. The output runs just fine over adb shell to rename files on your phone. It also works just fine to rename the backup copies that you are keeping on your Mac, Linux, FreeBSD box. For Windows without Cygwin or similar, you'd want to change "mv" to "move"
Edit -- shell scripts for on-phone use added to lead post

So open in terminal on phone and run ?
sent from my hammerhead

Yes, or over "adb shell" which makes cut-and-paste a lot easier.
Posted from whatever phone booted today.

Mine has it on the box!
Sent by mobile telephone.

Related

How to compile native android code

Hi everyone,
There has been a few questions on how to compile native android code (for exploits and such). Easy enough.
Go to http://source.android.com/download. You will need to be running Linux. Ubuntu is easiest. Follow the directions to get the source code for android downloaded and compiled.
Run this command
export PATH=/path/to/android/source/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin
Run arm-aebi-gcc or arm-aebi-g++ (depending on the language, c or c++) followed by
-o (OUTPUT) (INPUT)
So, for example, test.c would be:
arm-aebi-gcc -o test test.c
And test.cpp would be
arm-aebi-g++ -o test test.cpp
Just a note, this will make STATICALLY linked files. Meaning any headers will be included INSIDE the executable. Simply put, this means the files will be HUGE for large projects. There is a program, named agcc, which fixes this and can be found here:
http://plausible.org/andy/agcc
Put it in /bin by:
Code:
cd /bin
sudo wget http://plausible.org/andy/agcc
chmod 755 agcc
chmod +x agcc
Run agcc -o (OUTFILE) (INPUT) to compile. Be warned though, if a header is in the file that isn't in bionic (android's smaller libc) it won't compile.
Hope this helps!
+1
Awesome
............(stuipid mistake >>was<< here)..............
Thanks man...
now i can break out my bootable 50 meg linux disc and play around.
love that thing used to use it to crack windows passwords
should see the guys face when you crack his 20 char password in 5 mins without ever needing to use it.
well not really cracking but changing it. used to work at the pentagon. this one guys who used to be support for one dept. thought it would be funny to change all the admin passwords in his office. so when one of the pc's was beyond his repair. i showed up and he was like give me 10 min and i'll log you in. well 5 mins later i was fixing the machine while he was screwing off. boy was he pissed.
how big's gcc? cause i'll need to compile it for my linux.
rigamrts said:
how big's gcc? cause i'll need to compile it for my linux.
Click to expand...
Click to collapse
Massive. You're definitely better off using the prebuilt toolchain found in the Android (N|S)DK.
I would like to add something to this.
libc is essentially derived from the kernel. So, if you take agcc, and make changes to use the libc directory (I don't remember it atm) and NOT bionic, the app won't compile. Simple enough, libc is based of the kernel, so bionic is based of the android kernel. Things missing in bionic that are in libc WON"T work simply because certain kernel calls in glibc DON'T exist on the Android platform.
My exploit relied on the fact that I would be able to compile exploits using glibc, instead of using bionic. So it failed. Thats what I've figured out so far anyways.
zifnab06 said:
My exploit relied on the fact that I would be able to compile exploits using glibc, instead of using bionic. So it failed. Thats what I've figured out so far anyways.
Click to expand...
Click to collapse
Would you be willing to share the code for that exploit, even if it doesn't work? (sorry if you already have, I didn't see it anywhere)
I may be able to help.
Look up anything in our old thread, especially when we were talking about "sys/personality.h". The one I was working with exploited a hole that was patched (min_map_addr).
This blog post
honeypod.blogspot.com/2007/12/dynamically-linked-hello-world-for.html
(Sorry, my account isn't allowed to post links yet.)
gives a minimalist approach to using dynamically linked executables. (In particular, see steps #2 and #3 for the sources for hello.c and start.c) I gave it a try, and it seemed to work without agcc, e.g. with a makefile like the following (and with the arm-eabi- executables in the PATH of the user invoking the make) :
Code:
AR = arm-eabi-ar
AS = arm-eabi-as
CC = arm-eabi-gcc
CXX = arm-eabi-c++
LD = arm-eabi-ld
NDK_KIT = /opt/android/android-ndk-1.5_r1
PLATF_KIT = build/platforms/android-1.5
ARM_INC = $(NDK_KIT)/$(PLATF_KIT)/arch-arm/usr/include
ARM_LIB = $(NDK_KIT)/$(PLATF_KIT)/arch-arm/usr/lib
PLATF_INC = $(NDK_KIT)/$(PLATF_KIT)/common/include
OBJS = hello.o start.o
EXES = hello
hello: hello.o start.o
$(LD) \
--entry=_start \
--dynamic-linker /system/bin/linker -nostdlib \
-rpath /system/lib -rpath $(ARM_LIB) \
-L $(ARM_LIB) -lc -o hello hello.o start.o
hello.o: hello.c
$(CC) -I $(ARM_INC) -I $(PLATF_INC) -c hello.c
start.o: start.c
$(CC) -I $(ARM_INC) -I $(PLATF_INC) -c start.c
clean:
rm -f $(OBJS) $(EXES)
HTH
bftb0
Just curious, but I'm trying to get some native code that I've compiled to run on the Incredible. I've followed the instructions to download the the arm gcc, compiled my C code, and adb push'ed the executable over to /sdcard but I get a "permission denied" error when I try running it from my phone and adb shell. Does the phone have to be rooted in order to run native C compiled executables?
Thanks!
zebdor44 said:
Just curious, but I'm trying to get some native code that I've compiled to run on the Incredible. I've followed the instructions to download the the arm gcc, compiled my C code, and adb push'ed the executable over to /sdcard but I get a "permission denied" error when I try running it from my phone and adb shell. Does the phone have to be rooted in order to run native C compiled executables?
Thanks!
Click to expand...
Click to collapse
On an unrooted phone, push your code to /system/local or another place that you can write to and chmod it to be executable. By default the sdcard is mounted no execute. You will either need to add the directory you put it in to the path or execute it implicitly by specifying it is in the local directory.
for example ./myprogram
I hope that helps. I re-read it and it doesn't make much sense unless you have a firm grasp of the things that happen between the lines.
best of luck.
Thanks. Good stuff.
rigamrts said:
now i can break out my bootable 50 meg linux disc and play around.
love that thing used to use it to crack windows passwords
should see the guys face when you crack his 20 char password in 5 mins without ever needing to use it.
well not really cracking but changing it. used to work at the pentagon. this one guys who used to be support for one dept. thought it would be funny to change all the admin passwords in his office. so when one of the pc's was beyond his repair. i showed up and he was like give me 10 min and i'll log you in. well 5 mins later i was fixing the machine while he was screwing off. boy was he pissed.
how big's gcc? cause i'll need to compile it for my linux.
Click to expand...
Click to collapse
This is one of the most unbelievable stories ive read in a while. The fact that the pentagon had an administration department without policies or security in place to prevent such a widely known method, is comical.
btw, such a linux cd is no secret. Its called pnordahl.
Useful information
I'm surprised to see that many of you don't use the Forum's search function and simply start new topics over and over again. What funny is that the info you put here is old and useless.
I've posted an article on how to compile native C code for Android months ago, with several examples and tools:
http://forum.xda-developers.com/showthread.php?t=514803
or direct link herE:
http://www.pocketmagic.net/?p=682
However this technique is now too old.
The best approach is to simply use the NDK and build a custom Makefile for Cygwin's make under windows or easier under linux, see:
http://betelco.blogspot.com/2010/01/buildingdebugging-android-native-c.html
radhoo said:
I'm surprised to see that many of you don't use the Forum's search function and simply start new topics over and over again. What funny is that the info you put here is old and useless.
I've posted an article on how to compile native C code for Android months ago, with several examples and tools:
http://forum.xda-developers.com/showthread.php?t=514803
or direct link herE:
http://www.pocketmagic.net/?p=682
However this technique is now too old.
The best approach is to simply use the NDK and build a custom Makefile for Cygwin's make under windows or easier under linux, see:
http://betelco.blogspot.com/2010/01/buildingdebugging-android-native-c.html
Click to expand...
Click to collapse
Thank you for your very informative links. I'll take a look tonight, since I find this very interesting and would love to compile a few things for Android.
"What funny is that the info you put here is old and useless." - This was posted almost 10 months ago. That's a long time in smart phone years. By the same token, if it were January 2010 and I was looking for this info, I would assume that a post from May 2009 would be dated too.
"I'm surprised to see that many of you don't use the Forum's search function and simply start new topics over and over again." - Maybe zifnab did search and find your post and deemed your technique too old for Jan. 2010, so he created a new post with newer information. Or maybe he wanted to show a different way to do the same thing. Or maybe he figured that many users only have/take the time to look in their phone-specific forum. No one knows other than zifnab.
Personally, I welcome multiple posts by different people on the same topic. Everyone is different and often have different takes on the same thing. I find it easier to understand many techniques/topics if I get multiple perspectives.
Again, thank you for your contribution.
I need to compile the library with some modifications. how to do it as simple as possible? what will it take?
vlad072 said:
I need to compile the <library> with some modifications. how to do it as simple as possible? what will it take?
Click to expand...
Click to collapse
Did you get any thing in this regard ? Even i want to compile a part for library for the Android 5.1.1 device but not able to find any resource. Help will be appreciated.

[Q] TZDATA problem on WebTop

After some google action, I'm posting my problem here:
Scenary:
Gear: Motorola Atrix 4G AT&T - stock ROM (4.5.91, Android 2.3.4, WebTop version WT-1.2.0-110)
1. run webtop2sd (1.1.2) - OK
2. running web scripts - OK
Then when trying to install for example openoffice.org or trying to do:
# sudo dpkg-reconfigure tzdata
(setting to Europe/Ljubljana - or any other location for that matters)
Current default timezone: 'Europe/Ljubljana/
date: invalid date 'Wed Oct 5 07:06:25 UTC 2011'
This is the reason why packages that update or configure tzdata (tzdata-java) fail with apt-get or synaptic.
What I tried:
probably all locations with reconfiguring tzdata.. fail
manualy edited timezone.. fail
removing&reinstaling tzdata.. epic fail
Anybody else has this issue... solved ?
Same here! Any help would be greatly appreciated.
Not the right answer, but this works...
I was having the same problem, and after a few hours of struggling, here's what I eventually did.
Edit the file /var/lib/dpkg/info/tzdata.postinst and on the first blank line (3 rows down) just put exit 0 which makes the script stop and return a success. This isn't a good solution, but it does work.
Now i can go on my merry way installing things to my hearts content, but I'd love to hear if someone has a proper solution...
conundri said:
I was having the same problem, and after a few hours of struggling, here's what I eventually did.
Edit the file /var/lib/dpkg/info/tzdata.postinst and on the first blank line (3 rows down) just put exit 0 which makes the script stop and return a success. This isn't a good solution, but it does work.
Now i can go on my merry way installing things to my hearts content, but I'd love to hear if someone has a proper solution...
Click to expand...
Click to collapse
thanks a millon man,that totally fixed my problem I was having with my webtop
I took another look at this and has anyone tried adding exit 0 to just after the second to last fi close of the if then part at the bottom, I use dthe workaround posted above and went back looked over it more after having installed a few programs and added exit 0 to line 46 and it seems to be working fine. Can some one confirm this for me if they are looking at it for the first time on their version of webtop.
Hi there, I have a new install webtop2sd, and the script still failed after adding exit 0 at line 46. I have put exit 0 at line 3 afterwards to get past the problem.
I figured out the cause of the 'invalid date' problem. Actually the bug is on the end of the file in the following lines:
Code:
UTdate=$(LC_ALL=C TZ=UTC0 date -d "$TZBase")
TZdate=$(unset TZ ; LANG=C date -d "$TZBase")
The problem is that webtop uses Busybox instead of the 'original' tools. Busybox has an incomplete implementation of 'date -d'. Replacing it with an alternative like GNU Tools is the best solution for this problem. But this could be complicated and I have not much time. Adapting this script to Busybox is easier and still better than the 'exit' workaround.
All you have to do is replacing the line
Code:
TZBase=$(LC_ALL=C TZ=UTC0 date)
with
Code:
TZBase=$(LC_ALL=C TZ=UTC0 date +%m%d%H%M%Y.%S)

Snowball Mod

I ran the Snowball Mod without a hitch. I then tried to run the update but it won't run for some reason. The window flashes some text quickly but then closes so I'm not even really sure why it's not working. Anyone run into this or have any ideas. Thanks in advance!
I haven't had the time to try out the snowball mod, yet -- so I can't offer any advice. But, I would post the issue in the development thread, that's where the most help will be.
Swyped from my B&N Nook Tablet.
Try running it from a command line to keep it up and be able to read any text.
Also, there is a log.txt, if you post that, it can be more helpful.
Yeah I was goin to but I don't have enough posts. I was hoping someone would see it here.
Well... if you post your log.txt and start it from a command-line window rather than double clicking the update.bat, then we can take a look at what's up.
Log file says:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
Command line:
Snowball is reporting: v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an "outdate"?
Thanks a lot!
There is no v2.0.2 update package in the zip folder. I renamed v2.0.1 to v2.0.2 and ran. Not sure if this was a good thing to do or not. Any help or direction would be appreciated. Thanks.
No write permissions
Tried to install snowball mod from a macbook pro by just running the snowball.sh. Started up and the B&N stuff was all there, although it looked like it ran without a hitch.
Looked at the log file in the snowball-mod folder and saw a lot of "Read-only file system" business. The first few lines being:
unzip: can't open nook-update-package.zip, nook-update-package.zip.zip, nook-update-package.zip.ZIP^M
rm failed for nook-update-package.zip, Read-only file system^M
Installing nook-update-package...
cd: can't cd to /mnt/media/nook-update-package^M
sh: Can't open install^M
rm failed for /mnt/media/nook-update-package, No such file or directory^M
Click to expand...
Click to collapse
How do you suggest I get around that?
conundrum768 said:
I haven't had the time to try out the snowball mod, yet -- so I can't offer any advice. But, I would post the issue in the development thread, that's where the most help will be.
Swyped from my B&N Nook Tablet.
Click to expand...
Click to collapse
We need 10 legit posts before we are allowed to post in the dev forum
Robotronik said:
Tried to install snowball mod from a macbook pro by just running the snowball.sh. Started up and the B&N stuff was all there, although it looked like it ran without a hitch.
Looked at the log file in the snowball-mod folder and saw a lot of "Read-only file system" business. The first few lines being:
How do you suggest I get around that?
Click to expand...
Click to collapse
Huh... this is weird... /mnt/media should not be read-only... although, I suppose, perhaps if you had it USB mounted, it might end up read-only.
Ensure that you have Automatic USB mounting turned off before you run the script.
You can actually push this update via wifi if you mod the update.bat (or update.sh for linux users) file.
Just turn on ADB Wifi (I prefer adbWireless app) and add the following to your bat file:
Code:
echo Waiting for device...
[B]adb connect XXX.XXX.XXX.XXX:XXXX[/B]
adb wait-for-device
...
adb shell "chmod 755 /data/local/tmp/update-package.sh ; su -c /data/local/tmp/update-package.sh" >> log.txt
if exist reboot adb reboot
[B]adb connect XXX.XXX.XXX.XXX:XXXX[/B]
echo INSTALLATION SUCCESSFUL
Use your IPort given to you by your ADB Wifi app in place of XXXs. Then just run the .bat!
Run from cmd if you don't want the output to vanish right away.
cfoesch said:
Ensure that you have Automatic USB mounting turned off before you run the script.
Click to expand...
Click to collapse
Okay, that got me a little further. Now:
Extracting nook-update-package...
Archive: nook-update-package.zip
creating: nook-update-package/data/
unzip: can't set permissions of directory 'nook-update-package': Operation not permitted
unzip: exiting
Installing nook-update-package...
sh: Can't open install
Click to expand...
Click to collapse
More permissions issues...
Still posting here because I don't have the 10 total posts to go in the Dev forum...
Anyway, I did the factory reinstall, and reran the snowballmod update. It said the root was still there, so I commented out that check from the snowball.sh, reran the package and everything went swimmingly.
Now, for the update:
The terminal spits out this:
Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
7 KB/s (46 bytes in 0.006s)
Snowball is reporting: v2.0.2
.zipte-package-v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an 'outdate'?
Click to expand...
Click to collapse
Where the log file gives me:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
Click to expand...
Click to collapse
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
same
Robotronik said:
Still posting here because I don't have the 10 total posts to go in the Dev forum...
Anyway, I did the factory reinstall, and reran the snowballmod update. It said the root was still there, so I commented out that check from the snowball.sh, reran the package and everything went swimmingly.
Now, for the update:
The terminal spits out this:
Where the log file gives me:
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
Click to expand...
Click to collapse
I AM HAVING THE SAME PROBLEM.MYBE..I need help some plz make a better howtos for dummies m
The first thing you need to do, if you have no clue what you're doing, is post the contents of the log file in the snowballmod folder.
The ".zipte-package-v2.0.2" seems to be related to adb shell "snowball-ver" returning DOS formatted text, even though you're in a *nix. I really did not expect this to happen with the linux and osx versions of adb, but apparently, they perform the same as cygwin... (cygwin I expected, after all, the adb.exe is a windows program). I will fix the update scripts to take that into account.
Code:
unzip: can't set permissions of directory 'nook-update-package': Operation not permitted
This message is reported by unzip when it is run by a non-root user on the /mnt/media partition.
You do _NOT_ have to run snowball-update though if you've installed snowball-mod fresh with the most recent version.
robtlebel said:
I AM HAVING THE SAME PROBLEM.MYBE..I need help some plz make a better howtos for dummies m
Click to expand...
Click to collapse
The changes made to the script were posted here:
Robotronik said:
Now, for the update:
The terminal spits out this:
Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
7 KB/s (46 bytes in 0.006s)
Snowball is reporting: v2.0.2
.zipte-package-v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an 'outdate'?
Where the log file gives me:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
Click to expand...
Click to collapse
I had the same issue with the name of the update file being called incorrectly: ".zipte-package-v2.0.2". With that output the script is looking for a file of that name and it's not finding it. I just changed the value of the variable ${VERSION} to v2.0.2 (since that was what was being reported by Snowball as my current version) and all worked after that.
Easy to fix temporarily:
-open "update.sh" in a text editor
-go to line 66 and change
VERSION=`awk '//{ print $2 }' snowball.version`
Click to expand...
Click to collapse
to
VERSION=v2.0.2
Click to expand...
Click to collapse
or whatever version yours shows to be running (v2.0.1, etc). Something tells me it might be important to input the correct current version number in
-save and close the file and rerun it.
EDIT: or wait until cfoesch fixes the scripts
Scripts should be updated. I changed the awk program from just "//{ print $2 }" to "//{ sub('\r', '', $2); print $2 }" ... this means that it works both ways... *insert your favorite "both ways" joke here*
It should also detect if you haven't turned off automount, and warn you about it. If the nook ends up rebooting, then it would tear the USB mount and could cause file corruption. I got around it by putting things in /data rather than /mnt/media, but then realized, if it has to reboot, then it could cause trouble. So better, to just warn them that automount was on, and quit out.
It also detects better if something went wrong in the installation process, and should report that installation has failed, rather than successful under all cases.
Things may have gotten broken in the process, so keep up the bug reports.
I just can't stop Nookin' Around.........god i need to sleep
I decided to check out the update.sh script (can only go so far currently since I have the latest update).
At least for me, (Ubuntu Linux 11.10) I figured something out about the $OSTYPE call to set the $adb variable. I could echo $OSTYPE in the terminal and got a response, but could not echo it in any scripts. Ended up finding the "uname -o" call and that seems to have gotten it to work, although the printout is different.
snowball-update# echo $OSTYPE
linux-gnu
snowball-update# uname -o
GNU/Linux
Changed lines 7 & 8 and seems to have worked:
case `uname -o` in
GNU*|linux*|Linux*)
Now this last part is probably something on my end but: update.sh: 62: ./adblinux: Permission denied
Thanks again for the work (and everyone else involved in rooting/hacking these things )
Indeed. $OSTYPE seems to be specific to bash, and not all sh implementations.
If you don't mind could you do this command and give me the output? "ls -l /bin/sh" and "sh --version" Those two commands should explain exactly which implementation of sh you have. (For instance, on the NT with snowball-mod, the sh is a minimal implementation, and does not support $OSTYPE. But on most OSes I've seen sh is actually a statically linked bash, as it is the most widely used shell scripting language.)
The case on that you provided though could be a poor choice, as GNU*) would match GNU/freebsd, or GNU/openbsd, or GNU/anykernel. Sure it is unlikely, but it is possible.
The permissions issue is not entirely your end, but it is an expected artifact of extracting from a zip file. Although, is suppose performing a chmod 755 on it prior to use would be a good idea in general.

[Q] Script for automatic File deletion accoring to date (last month)

Hey Guys.
Don't know were to post this so I did it here...
I'm not an scripting/Unix pro and struggeling a bit with my folloing script:
Code:
FOLDER="/data/system/"
DAT1=$(date --date="$(date +%Y-%m-15) -1 month" +%Y%m)
FILE1="packages.xml-RW-"
FILE2="*.bak"
DELETE="$FOLDER$FILE1$DAT1$FILE2"
echo $DELETE
OUTPUT: /data/system/packages.xml-RW-201609*.bak (but only with UBUNTU)
File format is packages.xml-RW-201610161339144.bak - Bold is just an unusefull number for me....
Goal is to delete (I use for now echo for testing) specific file which having an specific format. I want to delete all files from last month!
So for this month all files containing "packages.xml-RW-201609*.bak"
Obove script is working under UBUNTU but Android has problems with "-1 month".
DATE command (of Android 6.0.1) is not accepting this...
Maybe one of you have a glue?
Thanks for help.
fluffi444 said:
Hey Guys.
Don't know were to post this so I did it here...
I'm not an scripting/Unix pro and struggeling a bit with my folloing script:
OUTPUT: /data/system/packages.xml-RW-201609*.bak (but only with UBUNTU)
File format is packages.xml-RW-201610161339144.bak - Bold is just an unusefull number for me....
Goal is to delete (I use for now echo for testing) specific file which having an specific format. I want to delete all files from last month!
So for this month all files containing "packages.xml-RW-201609*.bak"
Obove script is working under UBUNTU but Android has problems with "-1 month".
DATE command (of Android 6.0.1) is not accepting this...
Maybe one of you have a glue?
Thanks for help.
Click to expand...
Click to collapse
Instead of using a script have you taken a look at Tasker? It can do pretty much everything and scheduling the deletion of files with specific extensions is definitely something it can do. Let me know if you have any additional questions!
Thanks for your suggestion. I know Tasker. But I do not use it anymore. I want to keep the system as clean as possible... Don't like apps running in background all the time...
So only script is the way for me...
Question is still active ?
As it happens quite often I did it for myself But with an a bit different approach because of limited DATE functions of Android.
This set premonth correctly and also year switching to the year before if we are in JAN is working....
Code:
#!/system/bin/sh
FOLDER="/data/system/"
FILE1="packages.xml-RW-"
FILE2="*.bak"
YEAR=`date +%Y`
MONTH=`date +%m`
set -A MTH '12' '01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12'
PREMONTH=${MTH[$((MONTH - 1))]}
if [ "$PREMONTH" == 12 ]; then
NEWYEAR=`expr $YEAR - 1`
else
NEWYEAR=$YEAR
fi
rm -rf $FOLDER$FILE1$NEWYEAR$PREMONTH$FILE2
#

[WIP][MOD][SPLASH][OP6] Splash Screen Image Injector

Hey folks, thanks to @iElvis sharing his or her logo 'data' from the OP6. I have adapted my previous OnePlus programs that let you change the splash screen to work with the OP6. This means that the encoding of the data structure and the encoding of the image data are done. I do not have a OP6 and can not test certain things like where to put the modified file. In the past, flashing was always easy (and always has been especially with the OnePlus models).
My holdup and why I need the XDA/OP6 community support is to find out where to exactly put this modified file. In the past I haphazardly made a super fast in-memory program for altering the splash screen for the Nexus 6p that was (and is currently) at a roadblock for one reason. That reason was Google used ELFs to populate partitions (not short people with pointy ears and green clothing), and at that time utilized separate partitions that the ELFs populate. Not all were ELF generated, but that is outside of the scope of what I do because to a certain point the ones that I wanted to change were generated that way.
This concept of splitting partitions, back then, was just trying to grab a footing on seamless upgrades initially from what I have read up until this newer style. I have put some research into some things involving this, but Google is kind of bland in it's description of what this all means. This is different than the Nexus 6P that I mentioned previously, and if you read that last link, it may be just as easy as flashing it to both partitions logo_a & logo_b. One partition is always active and has two different statuses, which make the device 'ideally' always bootable after an OS update.
Most of my research was done through reading a lot of the open source code put out by the AOSP for "fastboot". You can learn more than you can ever derive from documentation in this realm. I hope to hear some feedback of attempts so that I can delete all of this up above
Please read below so you can better understand this type of encoding being used:
What Is A Raw Image?
A raw image, whether it be a file or an image in memory, is simply pixel data. There is no extra information like width, height, name, end of line... Absolutely nothing, just pixel data. If you have an image that is raw and the resolution is 1080x1920 and you are using a typical RGB24 or BGR24 (like the ones used here), then your exact filesize or size in memory will be 1080x1920x3! We use 3 here because there is one byte for the R or red component, one for the G (green), and one for the B(blue).
What Is A Run Length Encoded Image?
A run length image encoding uses a count ;usually a single byte (char), 2 bytes (short int), or 4 bytes (long int); and then the pixel components. So instead of writing out 300 bytes of '0's to make a line of 100 black pixels. Black is RGB(0,0,0). You could encode this as 100, 0, 0, 0. And only use 4 bytes of data to get the exact same image as the 300 byte raw image. All the run length encoding I've found, except the Motorola style which is a little different, use a run length encoding that is pixel-oriented like this.
Now I've found this new one and it is a byte-oriented run length encoding. This is for runs of bytes, not pixels. You may think, well whats the big deal? When you add a little area of color, you increase the run length encoded image in you logo.bin immensely! You use 6 bytes per pixel if there aren't any runs of color data. If you had an image that was a 1080x1920 black image with a 25 pixel horizontal line in the middle. The encoder would be doing runs of black data efficiently until it reached the red area.
.....0 255 0 255 0 255 0 255 0 255 0 133 /// we've reached the top left corner of the red line /// 13 1 30 1 255 1 // << that was just one red pixel!! in bgr color order (13, 30, 255) <<// And it keeps going through the rest of the red pixels on that line using 6 bytes per pixel, which is the opposite of compression. Before reaching the red line the encoding was decoding to 255 zeros over and over, until finally 133 zeros. 255 zeros is 85 black pixels stored in just 2 bytes!
This type of encoding is ONLY good for grey scale images. It is not good with color, but it still will handle color of course. In grey scale, the Red, Blue, and Green data components are always the same values. All the way from black (0,0,0) to white (255, 255, 255); including every shade of grey in between>>>(1,1,1) (2,2,2) (3,3,3)....(243, 243, 243) (254, 254, 254)<<<
One other difference in this method of run length encoding is that the color byte is before the count, which is backwards from all of the other methods.​
The attachment contains the executable that was compiled using mingw32 on a 64 bit Windows 10 PC. The awesome PNG library that I used for generating the pngs is LodePng, the source can be found here.
To use the OnePlus 6 Logo Injector:
Decode your logo.bin:
Code:
OP6Logo -i logo.bin -d
All the PNG 's will be extracted from logo.bin. Edit the PNG(s) that you want to change...
Note:
Your original "logo.bin" file is never changed, it is just read. If the file you try to load isn't a logo file, or a different style, then the program will tell you and exit.​
Inject the image(s) back in to the logo.bin:
Code:
OP6Logo -i logo.bin -j fhd_oppo fhd_at
To list whats in your logo file:
Code:
OP6Logo -i logo.bin -l
For a more detailed list:
Code:
OP6Logo -i logo.bin -L
If the colors are messed up use the "-s" switch while decoding.
Code:
OP6tLogo -i logo.bin -d -s
If you had to use the "-s" switch to decode properly, you'll have to use it to inject also:
Code:
OP6Logo -i logo.bin -j image_name -s
Note:
You can put as many names after "-j" as you want, and it's not case sensitive. You also don't have to put the whole name. If you just put "-j fhd" every image in the logo.bin that starts with "fhd" will be injected. There has to be a PNG with the name in the directory though​
The size of your modified.logo.bin will displayed along with the original size, if everything went good. The 'splash' partition is 16 MB on the OP6. If you use too much color on too many of the images you will easily go over 16 MB. The program will tell you and delete the "modified.logo.bin" that was created. If for some strange reason you would like to keep it, use the "-B" flag on the command.
The last step is to flash the modified logo file via fastboot with the command
Code:
fastboot flash LOGO modified.logo.bin
Use this at your own risk.
Always make backups.
Always.
Source
Source:
I haven't had a chance to work up a custom splash and flash it just yet, in part because I realized that on this phone, the splash screen only shows up for a split second before it's replaced by the "Your phone is unlocked and insecure, don't put sensitive files on it blah blah" warning. So I'm not sure this is going to do a whole lot for us. I'm going to try later tonight or this weekend and report back. Pretty sure "flash logo" should work fine, but it will flash only to the active partition. We may need to "flash logo_a" and "flash logo_b" to get it on both partitions.
Also, thanks for posting the source. I'm going to see if I can get this to compile in Xcode so we have an OSX version.
Edit 6/10: I can't get it to compile in Xcode, but I'm sure it's something I'm doing wrong.
Anyone tested it splash screen
Okay, welp, I'm throwing in the towel on this one. The bootloader warning is not in text like it was on the HTC phones I've modded to remove it. On those phones, the text showed up in the bootloader file in a hex editor, and could be replaced with empty spaces to remove it.
I pulled the boot file from /dev/block/bootdevice/by-name/ and searched through it. None of the text in the warning can be found with a simple search. As I suspected, that warning screen looks like it's a function coded into the boot process, which means removing it is probably impossible.
work Fine !
file :
lodepng.h
lodepng.c
OP6Logo.c
# gcc lodepng.c -c
# gcc OP6Logo.c -c
# gcc *.o -o OP6_prog OR # gcc lodepng.o OP6Logo.o -o OP6_prog
# ./adb shell
# su
# cd /dev/block/bootdevice/by-name
# ls --color --all
lrwxrwxrwx 1 root root 16 1970-01-06 04:29:20.549999999 +0100 LOGO_a -> /dev/block/sde20
# dd if=LOGO_a of=/sdcard/LOGO_a
exit
# ./adb pull /sdcar/LOGO_a ./
# OP6_prog -i LOGO_a -d
MODIFY YOUR PICTURE .....
# ./OP6logo -i LOGO_a -j fhd_
you have modified.logo.bin
Just dd if of and work fine !
And for the Real Splash :
./adb pull /system/media/bootanimation.zip ../
God bless
gao0309 said:
file :
lodepng.h
lodepng.c
OP6Logo.c
# gcc lodepng.c -c
# gcc OP6Logo.c -c
# gcc *.o -o OP6_prog OR # gcc lodepng.o OP6Logo.o -o OP6_prog
# ./adb shell
# su
# cd /dev/block/bootdevice/by-name
# ls --color --all
lrwxrwxrwx 1 root root 16 1970-01-06 04:29:20.549999999 +0100 LOGO_a -> /dev/block/sde20
# dd if=LOGO_a of=/sdcard/LOGO_a
exit
# ./adb pull /sdcar/LOGO_a ./
# OP6_prog -i LOGO_a -d
MODIFY YOUR PICTURE .....
# ./OP6logo -i LOGO_a -j fhd_
you have modified.logo.bin
Just dd if of and work fine !
And for the Real Splash :
./adb pull /system/media/bootanimation.zip ../
God bless
Click to expand...
Click to collapse
Way to remove bootloader unlocked warning?
NO
Please create flashable zip. Of splash screen
I'm trying this on linux on a 6T boot splash screen but I get a segmentation fault:
Code:
__________________________________________________________-_-
OP6 Logo Injector v1
Written By Makers_Mark @ XDA-DEVELOPERS.COM
_____________________________________________________________
FILE: logo.bin
_____________________________________________________________
RGB is the color order. Use "-s" switch to change it to BGR.
#01: Offset:0
Header=SPLASH!!
Width=1080
Height=1920
Data Length=81798
Special=1
Name=
Metadata=
Segmentation fault
Any idea why?
foobar66 said:
I'm trying this on linux on a 6T boot splash screen but I get a segmentation fault:
Any idea why?
Click to expand...
Click to collapse
For 6T, maybe you need look at this thread
https://forum.xda-developers.com/oneplus-6t/development/tool-splash-screen-modification-t3874158
Sent from my ONEPLUS A6000 using XDA Labs
I tried to report that the error memory could not be read under Windows 10 and wimdows7. Then I executed the following instructions under Linux and still reported the error. What can I do, oneplus 6, Android 9.0?
gcc lodepng.c -c
gcc OP6Logo.c -c
gcc *.o -o a.out
./a.out -i logo.bin -d
The following are the results of implementation:
__________________________________________________________-_-
OP6 Logo Injector v1
Written By Makers_Mark @ XDA-DEVELOPERS.COM _____________________________________________________________
FILE: logo.bin _____________________________________________________________
BGR is the color order. Use "-s" switch to change it to RGB.
#01: Offset:0
Header=SPLASH!!
Width=1080
Height=1920
Data Length=77716
Special=1
Name=
Metadata=
Segmentation fault
Code:
C:\Users\denie\Documents\logo>OP6Logo -i logo.bin -d
__________________________________________________________-_-
OP6 Logo Injector v1
Written By Makers_Mark @ XDA-DEVELOPERS.COM
_____________________________________________________________
FILE: logo.bin
_____________________________________________________________
BGR is the color order. Use "-s" switch to change it to RGB.
#01: Offset:0
Header=SPLASH!!
Width=1080
Height=1920
Data Length=81798
Special=1
Name=
Metadata=
C:\Users\denie\Documents\logo>
Any ideas?
Does this work?
Prakyy said:
Does this work?
Click to expand...
Click to collapse
There's no way to hide the Google warning about unlocked bootloaders, if that's what you mean.
iElvis said:
There's no way to hide the Google warning about unlocked bootloaders, if that's what you mean.
Click to expand...
Click to collapse
Really... This is what I've been searching all over for for my 6t... Get rid of the stupid bootloader unlock warning. On all my other devices we always used a custom made boot-logo.bin and installed it on slot a and slot b using fastboot.. I guess if it could be covered up it definitely would have by now. ?
Edit added: I just read the thread. From what I've gathered basically this device (6&6t) is designed different and that's why we can't tamper with/cover up the bootloader warning message.
flash713 said:
Really... This is what I've been searching all over for for my 6t... Get rid of the stupid bootloader unlock warning. On all my other devices we always used a custom made boot-logo.bin and installed it on slot a and slot b using fastboot.. I guess if it could be covered up it definitely would have by now. ?
Edit added: I just read the thread. From what I've gathered basically this device (6&6t) is designed different and that's why we can't tamper with/cover up the bootloader warning message.
Click to expand...
Click to collapse
I gave up after a lot of experimenting. I'm not aware of anyone managing it.
iElvis said:
I gave up after a lot of experimenting. I'm not aware of anyone managing it.
Click to expand...
Click to collapse
You should get an award for your XDA signature. ?? It's funny because it's real and oh so true! The way some people comment on things never ceases to blow me away. I see some posts and I think to myself, "what the hell?" "Who raised this person!?" There are definitely many different types of humans out there in the world that's a fact. I try and stay out of it as much as possible. ? lol.
It sucks we can't just make a ton of boot logos and cover that up. Oh well the 6 & 6t are awesome devices!! Usually whenever I end up on down the road selling my phone and purchasing another one from eBay or swappa things similar to this begin to be solved and then 15 custom roms all drop outa nowhere all at once. ? Happens every...single...time...haha!! Thanks for giving it a shot! :good:

Categories

Resources