Android
Récupérer la base de donnée d'une app non debug sans root
1/ Récupération d'un backup de l'application
adb backup --apk <package_name>
2/ Transformer le .ab en .tar
dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar
3/ untar de backup.tar
tar xfv backup.tar
4/ Déplacement dans le dossier qu va bien
cd apps/<package_name>
Print Backtrace | Callstack
The the gnu Backtraces function is not available in bionic.
To be able to print the backtrace, you could use the CallStack class defined in the lib utils :
system/core/include/utils/CallStack.h
e.g from http://yongbingchen.github.io/blog/2013/05/09/dump-stack-in-android-native-c-code/
#include <utils/CallStack.h>
using namespace android;
extern "C" void dump_stack_android(void)
{
CallStack stack;
stack.update();
stack.dump();
}
or
#include <utils/CallStack.h>
...
using namespace android;
...
//in the function I wanna trace
CallStack stack("TAG_LOGCAT_YOU_WANNA_USE");
// And voila !
...
Callback from C code
Having the ROM sources, you can use the following patch
And call the ccall_stack function from your C Code.
#include <utils/CCallStack.h>
....
//Dump here
ccall_stack();
You also need to link to libutils
LOCAL_SHARED_LIBRARIES += libutils
To have the complete stack information, you can push lib with debug symbole on the target
Just in Time debugger
Have a look here : https://github.com/keesj/gomo/wiki/AndroidGdbDebugging
adb shell setprop debug.db.uid 32767
Modify system properties
Add into the manifest
coreApp="true" android:sharedUserId="android.uid.system"
permet de modifier les properties system du coup j'ai un apk qui change les settings de debug juste en lui envoyant un broadcast via adb
Depending on another Package source
From the author:
I recently submitted and had merged this change to the AOSP. I was prompted by a question on the android-platform group and also my own requirement to make use of the zlib headers in a new Android.mk I was creating ....
The patch adds
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
to the libraries built by external/zlib/Android.mk fragment. Include this variable creates an entry in the export_includes of the libz (in this case ) intermediates output directory. The effect of this means you no longer need to include LOCAL_C_INCLUDES := external/zlib in the Android.mk of a project that depend on libz, just LOCAL_SHARED_LIBRARIES := libz is sufficient.
Obviously zlib is just the example here and LOCAL_EXPORT_C_INCLUDE_DIRS should be used wherever you have a project interdependencies. It means your makefiles will be more "portable" due to less hardcoded paths as well as reducing the Maintenance should a project you are referencing be moved at any point 9 which from experience is not a uncommon occurrence..
https://android-review.googlesource.com/#/c/116708/
https://plus.google.com/u/0/105455411977452054122/posts/bh7dFttAt5a
std{err/out} in logcat
$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start
Replace an Android application included by the buildsystem by yours
Use
LOCAL_PACKAGE_OVERRIDES with BUILD_PHONY_PACKAGE
In latter version it's
LOCAL_OVERRIDES_PACKAGES
eg. form https://github.com/DennisBold/Google_Apps/blob/master/app/Android.mk
#In a Android.mk
LOCAL_PATH:= $(call my-dir)
# Calendar Provider
include $(CLEAR_VARS)
LOCAL_PACKAGE_OVERRIDES := CalendarProvider
LOCAL_MODULE := CalendarProvider
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#Repeat for other packages
Or with no existing apk
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
LOCAL_MODULE := CalendarProvider LOCAL_MODULE := CalendarProvider LOCAL_MODULE_TAGS := optional
include $(BUILD_PHONY_PACKAGE)
Kernel debug
In BoardConfig.mk
BOARD_KERNEL_CMDLINE +=debug ignore_loglevel log_buf_len=10M LOGLEVEL=8
more on Arch wiki
Shell in recovery
After rebooting in recovery
cd $OUT adb push ./system/bin/sh /system/bin/sh adb push ./system/bin/linker /system/bin/linker adb push ./system/lib/libc.so /system/lib/libc.so
Then you can use
adb shell
To use toolbox
adb push ./system/lib/libcrypto.so /system/lib/ adb push ./system/lib/libcutils.so /system/lib/ adb push ./system/lib/libm.so /system/lib/ adb push ./system/lib/libselinux.so /system/lib/ adb push ./system/lib/libstdc++.so /system/lib/ adb push ./system/lib/liblog.so /system/lib/ adb push ./system/lib/libpcre.so /system/lib/ adb push ./system/bin/toolbox /system/bin/
cd system/bin for link in $(find -type l); do adb push $link /system/bin; done
Button on display
setprop qemu.hw.mainkeys 0
Force build property rebuild
rm -rf out/target/product/TARGET/obj/ETC/system_build_prop_intermediates/