[Q] Modification of API - Android Q&A, Help & Troubleshooting

Hi, thanks for the wonderful resource here.
New to android, so a bit confused on some issues I'm interested in playing around with.
You can modify .apk files etc to customize them, you can modify and re-compile the android source.
However, is it possible to modify parts of the API (like android.location for example) without having to re-compile the entire source?
Where on a rooted system is the actual API libs stored (if accessible)?

Related

[Q] Finding APK dependencies

Hey devs.
I have a little question. Let's say I have an APK, like the TouchWiz launcher( just an example ). Obviously, if i push it to /system/app on an AOSP ROM, it won't work, because it is missing some dependencies, or my android version is too low.
So, how do I find out which dependencies an APK needs, what android version, etc.
Thanks, Joe.
Please use the Q&A Forum for questions Thanks
Moving to Q&A
That's all listed in the APKs AndroidManifest.XML. I think the minimum Android version is listed as MinSDKVersion or something.
To view an APKs AndroidManifest.XML, use a tool like Root Explorer. If you're using RE, just click on the APK and choose View, then long press on the AndroidManifest and choose the option for viewing it in a text viewer.
- chris
GodSlayer said:
Hey devs.
I have a little question. Let's say I have an APK, like the TouchWiz launcher( just an example ). Obviously, if i push it to /system/app on an AOSP ROM, it won't work, because it is missing some dependencies, or my android version is too low.
So, how do I find out which dependencies an APK needs, what android version, etc.
Thanks, Joe.
Click to expand...
Click to collapse
Google for "APK Analyzer"
Same question here. Root Explorer is not very handy for this task. And I can't find "APK Analyzer". I need a desktop application.
maximilliangreat said:
Same question here. Root Explorer is not very handy for this task. And I can't find "APK Analyzer". I need a desktop application.
Click to expand...
Click to collapse
Apk Analyzer is a windows desktop app from Sony. But its for developers. I find it easier to just read logcat for FC's which will mention a nullpointer or missing function, then do a full text search for said function in the fully decompiled ROM. Takes a while doing that but it always works if you know your way around smali.
Sent from my X10i using Tapatalk 2
Apk Analyzer is a windows desktop app from Sony.
Click to expand...
Click to collapse
Good application, but heavily developer oriented.
I need a much simpler (and faster) tool, to quickly preview required android version, application name and version. Functions used by application are less important to me.
maximilliangreat said:
Good application, but heavily developer oriented.
I need a much simpler (and faster) tool, to quickly preview required android version, application name and version. Functions used by application are less important to me.
Click to expand...
Click to collapse
All this stuff is about the dependencies scanning, for the application name/version/etc stuff see my EDIT: post at the bottom
As far as I know, there is no tool made to do this. The nature of the Java/DalvikVM programming is much like other languages, modular. When the Android OS boots up, it preloads all classes and functions into the dalvik cache and registry, and if a seperate package (APK or JAR) references that function then the system loads it when it needs it. Apart from examining the .java source, there is no "header" or "include" file to see what other packages the package depends on.
Take this example - this is taken from a smali file from deep in the framework.jar for AOSP ROM's:
Code:
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
This is from ./android/net/http/IdleCache.smali. It is requesting to run the "uptimeMillis()J" function from ./android/os/SystemClock, it does not reference which JAR or APK has it. In this case it's the same framework.jar file, but Android has no idea about this because the classes/functions are preloaded in one chunk when the OS boots. Technically, you could remove these SystemClock smali files from framework.jar and put them in a file named "scoobydoo.jar" and the function would still work fine.
What I am saying is, the names of APK's and JAR's are never referenced in the decompiled smali code of an APK - only (sometimes) in the java source. So in the case of reverse engineering i.e. porting apps from one ROM/device to another where building-from-source is not possible, you would need to search every single smali file for invokes, member classes, etc. and then do a full text search for those functions on a fully-decompiled ROM to see where those functions/classes are.
This is why it's easier to just grab the APK you want, dump it into the ROM, and see what happens. Run logcat, run the program, when it FC's then examine the Error or Warnings relating to that package. It will probably mention "nullpointer exception" or "unknown reference" or something, I can't remember the exact message - and also the name of the function, like "Lcom/android/somepackage/somefunction()L" which it couldn't find, which caused the FC. You then would do a full text-search on either all decompiled APK's/JAR's, or on the ones you have a hunch on, and merge that APK/JAR file in too. If the JAR/APK already exists though, then it gets complicated - you need to merge the function into the existing package. Sometimes this is very difficult.
As I said, if you give me an example APK and a Logcat of it crashing, I will help But what you are asking for is a Package Dependency-Walker, which currently doesn't exist for Android. Such a thing would be nice though, as it'd make hacking a kanging much easier - but its useless for android developers because the original source code/project already shows its' dependencies (or, if written properly, has its' dependencies already included in the projects' build tree).
EDIT: Finding the required Android version however is easy. Decompile the APK and open AndroidManifest.xml, near the top you'll see a line like this:
Code:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" />
Which means it's requires at least Froyo to run, but was targeted at Gingerbread MaintenanceRelease1 (2.3.3-2.3.4). For decoding the API integers, see here.
Application name and version are also in the manifest file. They commonly use values from the string table though (which looks like android:label="@string/app_name"), which means you need to search for that variable in (e.g.) ./res/values-en/strings.xml

[Q] Learning in eclipse, a few questions..

I've been searching to see if there is a way to use a clone of my phone as an android virtual device for eclipse, I've not found any answers..I'm beginning to think that it is not possible because I haven't found the "here's how to clone your phone as an AVD" thread anywhere..is this correct?
If that isn't possible, exactly how much if any modification can I make to the AVD to make it more like my phone (contacts, apps and settings etc), would I just find the AVD's files and replace them or are they packed in a zip/rar file or are they just resource files that are being called up that will change the behavior of every AVD that I create if I alter them?
Finally- what would you guys say the minimum system requirements for developing for ICS and compiling ROMs would be? Looking to get a new desktop, this 1.5ghz gateway notebook isn't going to cut it....
Thx!
(BTW..I've already started making apps..nothing useful but they worked, and I got them on my phone and functional...hopefully be able to contribute back to the community soon yay! )

[Q] Libraries and other APK, necessary for some APK

How can I find libraries and other APK, necessary for some APK?
For example, the application Google Chrome uses the library libchrome.xxxx.xxx.so.
I tried to look for a link to this library in the decompiled application (I used apktool), but unfortunately I was not able to achieve results.
So I tried to look for similar discussions, but found nothing.
Why do I need it?
I want to make easy assembly firmware for your device by removing unnecessary for me to program.
Additional experience points for skill "Science"
Thanks in advance.

[HELP] Decompile APK, fix, Recompile help

Hi, before all, sorry for my poor English.
I have buyed a new Android Watch; the SmartWatch U8. I have found many Android app to run it but nothing have great result.
After few test and search I have found the original APK for my watch, is run good but have some problems and I want improve it.
I have decompiled the APK (APK to ZIP, dex2jar and APK Tool), I have now some .jar files, the .manifest and few assets and others ressources.
Using Android Studio, I have tried to recompile, without modification of code. I have many, many errors.
Some errors is about depriciated, others is for unknown command or class.
I have tried to fix, but no chance, too many errors and my Java skill is realy low (I'm better under PHP). I have also try to copy only few codes using the error tools to known what is needed to add, but I don't known own the default structure was made (all class in same folder ?, or many folder for many class ? less class but with more actions ? not sure)
I have tried all ideas I have found, no valid result, I never build the app with success. I have made few Android App, with help of tutorials and are very basic (Web browser for my website, music player and scanner). I known the basic of Android coding and the new and old way to code them (Eclipse and Android Studio).
I search many solutions;
- [easy] Find another app with all (or the most) of needed change I want; hide the notification text but keep the icon when connected, more control of what is sending to watch (keep notice of call, but not make/answer call over the watch)
- [medium/hard] Find a good tutorial/guide for rebuild a Android app from decompiled APK.
- [hard] Build from scratch a Android app for my watch (with tutorial/guide)
The APK I try to edit: levelkro (dot) com/download/android/KHR1.3.22.apk (not available on Play Store)
Thank for your help

Using a .so file in an android app? How can I access the hardware depth sensor on my (rooted) phone?

I'm building an application that requires the use of the depth sensor on my Samsung Galaxy A80. However it seems like it's impossible to access it through Camera2 and ARCore. I asked Samsung directly and the tech support guys best guess was that Samsung has locked it from being used by third parties.
I rooted my phone and started digging through the file system and eventually found a file called 'com.samsung.sensor.imx316.so' located in /vendor/lib/camera (imx316 is the depth sensor). There are also some similar files that ends in '.bin', but .so files seems to be runnable code if I understood the google results correctly.
That file has the same name as the sensor I can't seem to access. Can this file be used somehow? Can I run it in my own app to get access to the depth data? And if not, there should be a way of getting that data right? I mean, it obviously exists somewhere in the phone since pre-installed apps are using it, and a rooted phone has access to everything?
Did you check REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT? How do you know it's impossible?
Most likely you need to reverse engineer the Camera app from your phone.
Your app can call com.samsung.sensor.imx316.so , it's really "just" a linux elf library.
The problem you face is the exported routines from the library, you won't really know
1) the parameters to the functions inside the library
2) any specific order to call functions inside the library i.e. like an init function first , release memory last...
You need to disassemble / reverse engineer the library to make some sense of it (see ghidra / radare2/ ida pro etc ).
Use strace on the current process/app which uses the library to make some sense of the order of calls into the library.
The depth data will be coming from a kernel level driver, you can likely obtain the Samsung kernel source and the driver source should be there. Then it's up to you whether you can make user space library/code to read what the driver exposes. The kernel driver source code will have an uapi header file to investigate.
idk if it helps but i used for a Huawei P30 Pro this https://github.com/Nufflee/tof-camera

Categories

Resources