Amazfit 1.2.8 source code app/priv-app (decompiled) - Other SmartWatches

Last night I decided to decompile all the apps of our beloved amazfit, I started to look at the source to find some interesting information. (Like how to turn off the standby mode or as add new watchfaces with even the standby mode)
I found interesting information but I have to do many tests and I don't have too much time at the moment, I leave the link to download all sources divided by folders (Gradle project)
Amazfit 1.2.8 decompiled apps
Enjoy!

Cracklydisc said:
Last night I decided to decompile all the apps of our beloved amazfit, I started to look at the source to find some interesting information. (Like how to turn off the standby mode or as add new watchfaces with even the standby mode)
Amazfit 1.2.8 decompiled apps
Enjoy!
Click to expand...
Click to collapse
Hi @Cracklydisc, which toolchain are you using to decompile amazfit system apps? baksmali 2.2.0 fails to deodex:
Code:
java -jar ../tools/smali/baksmali/build/libs/baksmali.jar deodex HuamiWatchFaces.odex -b framework/
Exception in thread "main" org.jf.dexlib2.DexFileFactory$UnsupportedOatVersionException: Unsupported oat version: 45
Tried also https://github.com/pxb1988/dex2jar, which gives smali files, but they fail to re-compile with apktool:
Code:
apktool b HuamiWatchFaces
I: Using Apktool 2.2.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
HuamiWatchFaces/smali/android/support/v4/media/MediaMetadataCompat.smali[73,45] Error for input '@': Invalid text
HuamiWatchFaces/smali/android/support/v4/media/MediaMetadataCompat.smali[73,39] mismatched input 'vtable' expecting VTABLE_INDEX
[...]
Many thanks in advance!

drbourbon said:
Hi @Cracklydisc, which toolchain are you using to decompile amazfit system apps? baksmali 2.2.0 fails to deodex:
Code:
java -jar ../tools/smali/baksmali/build/libs/baksmali.jar deodex HuamiWatchFaces.odex -b framework/
Exception in thread "main" org.jf.dexlib2.DexFileFactory$UnsupportedOatVersionException: Unsupported oat version: 45
Tried also https://github.com/pxb1988/dex2jar, which gives smali files, but they fail to re-compile with apktool:
Code:
apktool b HuamiWatchFaces
I: Using Apktool 2.2.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
HuamiWatchFaces/smali/android/support/v4/media/MediaMetadataCompat.smali[73,45] Error for input '@': Invalid text
HuamiWatchFaces/smali/android/support/v4/media/MediaMetadataCompat.smali[73,39] mismatched input 'vtable' expecting VTABLE_INDEX
[...]
Many thanks in advance!
Click to expand...
Click to collapse
Project ref:
- https://forum.xda-developers.com/and...batch-t2980857
- https://github.com/skylot/jadx
i use this 2 software for extract the source code.
How?
0. Extract from Amazfit the directory /app /priv-app /framework
adb pull /app
adb pull /priv-app
adb pull /framework
1. Create dir System and put the 3 dir inside.
2. Rename all mips dir in arm (one dir for any apk and one dir for framework )
3. Use JoelDroidLollipopBatchDeodexer.exe, select dir System and click start process (the software changes original file!)
4. Use Jadx for decompile apk in source code
example
jadx.bat -e app/Alipay/Alipay.apk -d decompiledApp/Alipay
If you have any questions please ask

Thank you for your suggestions @Cracklydisc !
I ended up doing things manually with oat2dex, apktool and smali/baksmali.
My idea is to replace one existing system watch face from HuamiWatchfaces.apk (and HuamiWatchfaces.odex) by replacing the relevant smali files with my custom compiled smali classes (with same java package name) in it. For example:
Code:
SunriseDigitalSlptClock.smali
SunriseDigitalWatchFace$1.smali
SunriseDigitalWatchFace$Engine$1.smali
SunriseDigitalWatchFace$Engine$2.smali
SunriseDigitalWatchFace$Engine$3.smali
SunriseDigitalWatchFace$Engine$4.smali
SunriseDigitalWatchFace$Engine$5.smali
SunriseDigitalWatchFace$Engine.smali
SunriseDigitalWatchFace.smali
I am struggling with basic permission and signing issues that I am sure have already been solved by you guys, so that I ask you for basic directions.
Here's the steps I made to decompile and recompile back everything in order to test the process. This results in "HuamiWatchFaces stopped" after reboot .
adb pull /system/framework
adb pull /system/app
java -jar oat2dex.jar -a 22 odex HuamiWatchFaces.odex
java -jar baksmali.jar d odex/HuamiWatchFaces.dex -o Faces
apktool d -c HuamiWatchFaces.apk
cp -r Faces HuamiWatchFaces/smali
(here relevant smali files will be replaced with custom ones in HuamiWatchFaces/smali)
apktool b -c HuamiWatchFaces/
adb push HuamiWatchFaces.apk /system/app/HuamiWatchFaces/HuamiWatchFaces.apk
delete /system/app/HuamiWatchFaces/mips/HuamiWatchFaces.odex from adb shell (apk is now deodexed)
rm /data/dalvik-cache/mips/[email protected]@HuamiWatch*
adb reboot

drbourbon said:
Thank you for your suggestions @Cracklydisc !
I ended up doing things manually with oat2dex, apktool and smali/baksmali.
My idea is to replace one existing system watch face from HuamiWatchfaces.apk (and HuamiWatchfaces.odex) by replacing the relevant smali files with my custom compiled smali classes (with same java package name) in it. For example:
Code:
SunriseDigitalSlptClock.smali
SunriseDigitalWatchFace$1.smali
SunriseDigitalWatchFace$Engine$1.smali
SunriseDigitalWatchFace$Engine$2.smali
SunriseDigitalWatchFace$Engine$3.smali
SunriseDigitalWatchFace$Engine$4.smali
SunriseDigitalWatchFace$Engine$5.smali
SunriseDigitalWatchFace$Engine.smali
SunriseDigitalWatchFace.smali
I am struggling with basic permission and signing issues that I am sure have already been solved by you guys, so that I ask you for basic directions.
Here's the steps I made to decompile and recompile back everything in order to test the process. This results in "HuamiWatchFaces stopped" after reboot .
adb pull /system/framework
adb pull /system/app
java -jar oat2dex.jar -a 22 odex HuamiWatchFaces.odex
java -jar baksmali.jar d odex/HuamiWatchFaces.dex -o Faces
apktool d -c HuamiWatchFaces.apk
cp -r Faces HuamiWatchFaces/smali
(here relevant smali files will be replaced with custom ones in HuamiWatchFaces/smali)
apktool b -c HuamiWatchFaces/
adb push HuamiWatchFaces.apk /system/app/HuamiWatchFaces/HuamiWatchFaces.apk
delete /system/app/HuamiWatchFaces/mips/HuamiWatchFaces.odex from adb shell (apk is now deodexed)
rm /data/dalvik-cache/mips/[email protected]@HuamiWatch*
adb reboot
Click to expand...
Click to collapse
Why do you want to replace a native Watchface?
They have implemented the wfz engine and with the current dev version you can create both analog and digital Watchface and change shape to widgets.

Cracklydisc said:
Why do you want to replace a native Watchface?
They have implemented the wfz engine and with the current dev version you can create both analog and digital Watchface and change shape to widgets.
Click to expand...
Click to collapse
Good question
Even thought configurable watch faces are nice and powerful, coming from the Pebble world I'd like to open up the option to former Pebble developers to deliver radically custom watch faces like https://apps.getpebble.com/en_US/application/533966299820be90ed0000c5?hardware=chalk, https://apps.getpebble.com/en_US/application/52de476d6094ff6bf0000046?hardware=chalk or https://apps.getpebble.com/en_US/ap...5e1c8000118?hardware=chalk&section=watchfaces

Thank you for the decompiled version!!
I have a question for you, on the version you decompiled, could you please guide me to the file path/method used for the GATT profile to access the raw data from the device?
Thank you again!
Best,

Related

[tip] install, sign apk, ..etc on right click (windows)

I've been hesitating on posting this for a while now (as its quite simple) but It may save you a ton of time like it continues to save for me.
1) write a batch file to do what you want, %1 is the file name+path argument passed to it
2) associate .apk files with the batch file. right click on apk-> open with-> choose program ->select the batch file
Many possibilities:
sign, install, decompile etc
here is the code for install.bat which I keep at x:\android-sdk\tools (same folder as adb)
Code:
adb install -r %1
pause
For sign: (creates a new .apk with -signed appended at the same location)
Code:
cd "x:\path\to\signapk.jar\"
java -jar signapk.jar testkey.x509.pem testkey.pk8 %1 %1-signed.apk
pause
For decompile: (decodes to a new folder with the same name+"-decoded" as the .apk
Code:
cd x:\path\to\apktool.jar\
java -jar apktool.jar d %1 %1-decoded
pause
thats pretty neat, nice tip
I'm dumb. I didn't read the first part of what you typed, figured the rest didn't work, searched google to come up with my own routine, figured out yours is extremely easy once you actually read it haha.
Oh well, at least I learned a little more DOS.
APK install bat with a prompt:
Code:
@echo off
set /p userinp=Do you want to install %1 y/n:
if "%userinp%"=="y" goto ADBINSTALL
exit
:ADBINSTALL
adb install -r %1
pause
EDIT: Forgot to say thanks.
yeah simple dos batch files can automated lot of monotonous tasks, I use them a lot for work

Decompiling/Recompiling Launcher2.apk [HELP!]

Hey everyone. I'd like to decompile/recompile the Launcher2.apk from Paul (MoDaCo)'s rip of the Gingerbread system. I'm trying to fix the annoying fade time on the 2D app drawer for the launcher. However, I'm running into problems.
Here's my process:
apktool d -f com.modaco.android.launchergb-1.apk
Move through the com.modaco.android.launchergb-1 folder to res/values/integers.xml
Change fade in and fade out time to "300" instead of "700".
apktool b -f com.modaco.android.launchergb-1
Copy build/apk/resources.arsc to the original com.modaco.android.launchergb-1.apk using WinRAR.
Attempts to install all fail. When I try "adb install" I get this error: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
You try ApkManager by daneshm90?
Sent from my phone
tnpapadakos said:
You try ApkManager by daneshm90?
Click to expand...
Click to collapse
Doesn't seem to work either.
You need to sign the package first.
jarsigner -verbose modradio.apk mykey
Check the METAINF/ folder in the apk of the newly built one and delete the extra files from the original one. Then you need to resign the edited apk. I think there should just be MANIFEST.MF, delete the CERT.* files. And when you resign it it should make new ones, in this case above it would be MYKEY.RSA and MYKEY.SF. Not too familir with it, but try that out.
Keep in mind that you have to resign it after any modifications, so do it last and it should work.
This thread does a good job guiding you though compiling/decompiling an apk.
http://forum.xda-developers.com/showthread.php?t=725870
trimeijer said:
You need to sign the package first.
jarsigner -verbose modradio.apk mykey
Check the METAINF/ folder in the apk of the newly built one and delete the extra files from the original one. Then you need to resign the edited apk. I think there should just be MANIFEST.MF, delete the CERT.* files. And when you resign it it should make new ones, in this case above it would be MYKEY.RSA and MYKEY.SF. Not too familir with it, but try that out.
Keep in mind that you have to resign it after any modifications, so do it last and it should work.
This thread does a good job guiding you though compiling/decompiling an apk.
http://forum.xda-developers.com/showthread.php?t=725870
Click to expand...
Click to collapse
Thank you so much for the help. In the thread you mentioned, I'm stuck at this point:
now type the following commands in this order:
this command changes all occurances of htc/fm to htc/modradio in your xml and .java files.
find ./ -type f | xargs perl -pi -e 's/htc\/fm/htc\/modradio/g'
this command changes all occurances of htc.fm to htc.modradio
find ./ -type f | xargs perl -pi -e 's/htc.fm/htc.modradio/g'
Click to expand...
Click to collapse
If my filename is com.modaco.android.launchergb-1 and the application name is com.modaco.android.launchergb, what do I do to make these commands work.
Would it be:
find ./ -type f | xargs perl -pi -e 's/modaco\/launchergb/modaco\/launchermod/g'
??

[Tool\Script] Sign, Zipalign and adb push apk's

Sign, Zip align and ADB push Apk's
What's different about this script?
*It's simple, easy to understand
*It can be used with any JDK. All that is required is replacing the PATH
This was intended to be used on HTC Skins; however, it can be used for any APK.
About
I wrote this batch file because the tools currently on XDA seem very complex or are based on JDK 7. People like myself that prefer to use JDK 6 are at a loss. This batch file assumes you already know how to sign APK's, Zipalign and ADB push Apk's. I've included some of my other threads below if you need further instructions.
Other threads a noob might need
Noobs guide to signing an APK
Noobs guide to installing and running zipalign
****All that is required to make this run, is replacing the directory paths with YOUR OWN Directory paths.
Source Code below, below that is the Multi to the .bat file.
Code:
@ECHO OFF
C:
CD\
CLS
cd c:\Program Files\Java\jdk1.6.0_26\bin (This can be replaced with whatever JDK you're using. Simply, replace the path)
jarsigner -verbose -keystore skin.keystore -signedjar C:\Users\Reynolds\ANDROID\SKINS\Rezound\Pitch_Black\dist\New-Pitchblack.apk C:\Users\Reynolds\ANDROID\SKINS\Rezound\Pitch_Black\dist\Pitchblack.apk [B]REPLACE-THESE-CAPS-W-YOUR-ALIAS[/B]
DEL C:\Users\Reynolds\ANDROID\SKINS\Rezound\Pitch_Black\dist\New-Pitchblack.apk
C:
CD\
CLS
cd C:\Users\Reynolds\ANDROID\SKINS\Rezound\Pitch_Black\dist
zipalign -fv 4 New-Pitchblack.apk Pitchblack.apk
cd c:\android-sdk-windows\platform-tools
C:
CD\
CLS
cd c:\android-sdk-windows\platform-tools [B](Your directory might be different)[/B]
adb install -r C:\Users\Reynolds\ANDROID\SKINS\Rezound\Pitch_Black\dist\Pitchblack.apk [B]( This Path can be replaced with whatever your apk is located in order to push the apk to your device[/B]
Media Fire DL Link: http://www.mediafire.com/?c3f0thcv6cmdwws

Exchange mail without device adminstrator

One of the things I miss when changing to a new stock or custom ROM is having the option of installing an exchange client which doesn't require a device administrator.
Turns out it's fairly easy to change the Email application to disregard an security requirements. Note that the info below can be found spread over several threads on XDA so I did not discover this myself.
Root the device
You will make changes in /system/app so root is required.
Get smali and baksmali
Smali and baksmali can decode and encode the classes.dex file containing the source code for the Mail application. They can be found at http://code.google.com/p/smali/
Copy Email.apk (and Email.odex if existing) from /system/app
Odex files will be there in stock ROMs or other odexed ROMs
Copy files from /system/framework
Framework files are needed for baksmali to be able to deodex the odex file.
Download java.awt.jar
Java.awt.jar can be found from http://forum.xda-developers.com/showthread.php?t=1132724
Decompile the odex file
Code:
java -jar baksmali-1.3.2.jar -x Email.odex -c :com.google.android.maps.jar:twframework.jar:java.awt.jar
Make necessary changes in out\com\android\email\SecurityPolicy.smali
Function isActive should always return 1. Easiest by changing:
Code:
const/4 v1, 0x0
to:
Code:
const/4 v1, 0x1
Recompile code into out.dex
Code:
java -jar smali-1.3.2.jar out
Deodex the apk
Put out.dex into apk as classes.dex (the apk is a zip)
Push apk to phone
Clear data for Email
Delete/backup old Email.apk and Email.odex
Put new Email.apk in /system/app
Reboot

[GUIDE] How to build CM10.2 for the HTC One with OS X 10.8.X

This is a guide to build CyanogenMOD 10.2 (Android 4.3) for the HTC One. This guide is for OS X Mountain Lion (10.8.X).
[size=+1]Pre Requirements:[/size]
1) go to App Store on your OS X and Download Xcode 4. Once that is installed, open Xcode and go to preferences. There you find a tab “DOWNLOADS”, open it and there you can find “Command line tools” and next to it click INSTALL. It will take a few minutes to download and install
2) Make sure you have the android-sdk downloaded and setup adb and fastboot, so they work. It is recommended to place the android-sdk to /usr/local/
[size=+1]Initializing the build environment[/size]
First we need to set up our OS X to be able to build Android. This needs some extra things compared to for example, building in Linux, but the main stuff is pretty much the same. So let’s get started then, shall we?
Open up Terminal and type
Code:
java
If you don’t have java installed you will get a prompt to install it.
Next we will install homebrew (you can also use macports if you like)
Code:
ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
Now make sure android-sdk and homebrew are in $PATH
Code:
touch ~/.bash_profile && echo "PATH=/usr/local/bin:/usr/local/sbin:$PATH:/usr/local/android-sdk/tools:/usr/local/android-sdk/platform-tools" >> ~/.bash_profile
I also recommend to add this edit to the .bash_profile file:
Code:
nano –w ~/.bash_profile
Code:
export BUILD_MAC_SDK_EXPERIMENTAL=1
Now run this and see if you need to update anything.
Code:
brew doctor
If you do (and you probably will once a day) type:
Code:
brew update
Now we need to get our dev packages
Code:
brew install git coreutils findutils gnu-sed gnupg pngcrush repo
Once that is done, run
Code:
brew outdated
if it shows anything, run
Code:
brew upgrade
Now run this the correct a few symlinks [Not sure if these are needed anymore]:
Code:
ln -s /usr/local/bin/gfind /usr/local/bin/find && ln -s /usr/local/bin/gsed /usr/local/bin/sed
Now to create our case sensitive image for our CM work [NOTE: the 60g can be changed to anything. It only takes up what it needs but I used 60GB]:
Code:
hdiutil create -type SPARSE -fs "Case-sensitive Journaled HFS+" -size 60g -volname "android" -attach ~/Desktop/Android
Now to create our working directory
Code:
cd /Volumes/Android && mkdir cm10.2 && cd cm10.2
[size=+1]Getting the source[/size]
Now to initialize the git and to download it
Code:
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
Download the sources:
Code:
repo sync
Wait until it is finished. It will take a long time, depending on your internet connection.
[size=+1]Obtain the device build files and proprietary files:[/size]
To do this we will use CyanogenMods "tool" called roomservice. Roomservice is replacing the old local_manifest.xml file. Just run the code below to create the file directly into the folder.
Code:
nano -w /Volumes/android/cm10.2/.repo/local_manifests/roomservice.xml
Paste the following lines into the file:
Code:
<manifest>
<project name="TheMuppets/proprietary_vendor_htc.git" path="vendor/htc" remote="github" revision="cm-10.2"/>
</manifest>
It seems that nowadays you only need to have the TheMuppets repo there, the roomservice process takes care of the rest and downloads the needed mako bits automatically. And actually it doesn't matter what you name the xml file under the local_manifests directory. The process loads every xml file from there in a alphabetical order. If you still have that local_manifest.xml file in your .repo directory, i suggest you remove that, because at that case that file will be read first and after that all the other from the local_manifests folder
Save the file. And rerun the code:
Code:
repo sync
Download the necessary pre-builts:
Code:
/Volumes/android/cm10.2/vendor/cm/get-prebuilts
That is all. The sources are now ready.
[size=+1]Building CyanogenMOD[/size]
If you build now, you're probably gonna get kernel build errors regarding the missing elf.h header (this error might be device specific). Fortunately, we already have this file downloaded, so we only need to copy it to /usr/local/include:
Code:
cp /Volumes/android/cm10.2/external/elfutils/libelf/elf.h /usr/local/include
FINALLY, we are ready to build:
Code:
cd /Volumes/android/cm10.2 && source build/envsetup.sh && brunch m7ul
The upper command will start the build for the international version for the HTC One (m7ul). Just change the m7ul part to the right codename (check it from f.ex www.get.cm webpage).
Then we just let the Mac do the rest. Remember that it will take a while to do the build, and meantime you Macs fans will scream for mercy while CM punishes your system ☺
After the build is finished successfully you can find your newly created flashable zip by typing:
Code:
cd $out
Look for .zip file with a tag UNOFFICIAL
Happy building!
donk
I just might give this a try. Thanks for the tutorial!
Sent from my One using Tapatalk 4
inffy said:
Hey there!
Only Thing that comes to mind is that you forgot to get the prebuilts. Or you flashed incompatible kernel
Click to expand...
Click to collapse
Not that I'm aware of, but I must've messed something up. I nuked it all and started over.
It works fine now (and more importantly I got myself a new "theme aware" aapt that doesn't think that drawable-xxhdpi is an invalid folder name )
Thanks again for a nice guide.
i can add packages of apk github
help
thanks
packhex said:
i can add packages of apk github
help
thanks
Click to expand...
Click to collapse
What do you mean, sry
Strange error
I get this error when I try to save the manifests xml file.
[ Error writing /Volumes/android/cm10.2/.repo/local_manifests/roomservice.xml: ]
Please help me figure this out...
Okay, I figured I hade the wrong directory..
now when I try to brunch, I get this error:
Don't have a product spec for: 'cm_m7ul'
Do you have the right repo manifest?
Please help!

Categories

Resources