Android Important Stuffs

ANDROID  DEBUGGING  CMD's:

Super ADB Tool Lets You Debug Your Phone Graphically


ANDROID ARCHITECTURE:


Android Architecture Guides for beginners | Edureka


ANDROID VERSIONS:





COMMANDS :

-> adb
adb = android debugger
adb -> will print the complete help menu
pull, push, root, remount, logcat etc 
If adb is not connected properly, then kill and start server.
adb kill-server
adb start-server
adb logcat -b crash -> will give us the crash information.
adb logcat -c -> will clears the data
adb logcat -d  -> will dump the logs and exit
adb logcat -v time > with format

-> if logcat -c -> doesnot clear the buffer ==> kill logd .it will auto clear logcat
http://androidxref.com/ 

-> setprop and getprop is the utility to set or clear the properties in the android.
setprop persist.logd.size 250M -> change the logcat size on boot.
setprop persist.vendor.service.vhal.enable.log true

-> If the build is a security verity enabled build. Copying the files runtime is prohibited.
adb disable-verity      [use this command to disable the verity / security]

-> dumpsys -> command to dump the system information. All the services related information also is dumped here.

-> Scrcpy : It is the alternate of screen utility (open source)
    If touch is not working in the andoid, then we can use this scrcpy utility
    It is a google provided resource.
    use srccpy-noconsole

->service list -> will display only the current running services in the target.

-> screencap -> capture the screenshot of the ivi image

->developer's rc files built in target : 
System partition: /system/etc/init/*.rc 
Vendor partition: /vendor/etc/init/*.rc 

-> wifi-adb:
ADB Connection Over WIFI:

connect -> target and pc from Phone hotspot ( all three devices should be in same network)
select the settings -> wifi settings in the target -> connect to you phone hotspot
in settings -> check the "about phone" option and u will get the ip address.

In Linux :       adb connect <ip> / in latest build, the settings app is disabled. so give adb connect 192.168.43.12:5555
In Windows:  adb connect <ip>:<port>

-> procranck   -> will list the memory consumed in the android side. concentrate on pss.

-> Kitchensin app:
am start -n com.google.android.car.kitchensink/.KitchenSinkActivity
input keyevent KEYCODE_APP_SWITCH

-> pm list packages -f  -> lists all the com.android.* packages.
Then start whatever packages to start. Ex: Engineering mode / etm --> pm list packages | grep -i engineering --> am start com.gac.engineeringtestmode/.MainActivity
am start com.android.documentsui/.files.LauncherActivity -> file manager / explorer
In latest release, they ve removed file manager. Download file manager from https://apkpure.com/es-file-explorer/com.estrongs.android.pop/download?from=details
adb install <>.apk -> it will appear in all menus or restart target.

-> Start / stop the hidden applications (not auto started)
am start com.android.settings  ---> for enbling the settings app
am stopservice com.gac.diag/.service.DiagnosticService {DiagServices }
am startservice com.gac.diag/.service.DiagnosticService { DiagServices}

-> dumpsys -> command to dump the system information. All the services related information also is dumped here.
service list -> will display only the current running services in the target.
developer's rc files built in target : 
System partition: /system/etc/init/*.rc 
Vendor partition: /vendor/etc/init/*.rc
device_properties.log -> this will tell us the timing/time taken of the process. also the order of boot.

-> SERIAL name change
Change serialnumber or the device name in "adb devices" -> change serial number in /vendor/etc/init/hw/init.qcom.usb.rc 
Serial cable: Gnd to GNd(1st place). Rx and TX interchange.

-> Properties:
/vendor/build.prop has all the list of the properties avaialbale in android.

-> BUSYBOX and TELNET access:
telnet:
if telnet doesnot work, means the daemon is not running.
HOST/SOURCE to connect: telnetd -debug 23 &
ftpd &
Android: ./busybox telnet 192.168.1.1

we can copy the files from one domain to another, 
provided both node should be able to ping and ftpd daemon should be running in the destination
copy busybox to Android and run ftpd in qnx
busybox --list | grep -i ftp  -> will list the set of commands related to ftp
busybox --help will list the menu for the ftpput or ftpget
busybox is available to download in the website only 

Ex: 
busybox ftpput [OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE
busybox ftpget ipAddress startup.sh /scripts/startup.sh -u root
busybox ftpput ipAddress /etc/getevent.c getevent.c -u root

-> timezone:
adb shell settings get global time_zone -> get the timezone of the target
settings put global time_zone Asia/Shanghai -> set the timezone

-> Usb config as ADB
Older system: Slay qvm  - kill android while booting 
(or) dtach -n /tmp/vmm -r winch vmm_service
New system: comment out "VMM" lines in startup scripts
comment hostdev in /etc/linux-la.cfg file  ==> #hostdev >/dev/shmem/la_gvm.txt batch 100
Sample:
vdev vdev-pl011.so loc 0x1c090000 intr gic:37
#vdev vdev-pl011.so loc 0x1c090000 intr gic:37 sched 20 hostdev >/dev/shmem/gvm_la.txt batch 100

Runla – Boot android manually from the QNX 
You will get Android Shell instead of QNX 
su { enter to root mode}
#configure USB1 has host
echo none > /sys/bus/platform/devices/a800000.ssusb/mode
echo host > /sys/bus/platform/devices/a800000.ssusb/mode
#configure USB0 has device
echo none > /sys/bus/platform/devices/a600000.ssusb/mode
echo peripheral > /sys/bus/platform/devices/a600000.ssusb/mode
setprop sys.usb.config none
setprop sys.usb.config adb
stop adbd
start adbd

-> Fastboot commands:
for ES6:
fastboot erase la_system
fastboot flash la_system system.img
fastboot erase la_vendor
fastboot flash la_vendor vendor.img
fastboot flash la_userdata userdata.img
fastboot flash la_persist persist.img

For ES5:   
fastboot erase system_b
fastboot flash system_b system.img
fastboot erase vendor_b
fastboot flash vendor_b vendor.img
fastboot flash userdata userdata.img
fastboot flash persist persist.img

-> INFO:
Alarmmanagerservice in android framework:
http://androidxref.com/9.0.0_r3/xref/frameworks/base/services/core/java/com/android/server/AlarmManagerService.java

Init.rc file description for service etc : https://android.googlesource.com/platform/system/core/+/master/init/README.md
main startup is from init file i.e init.rc -> after that other files are imported .


-> PORTING:
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
ANDROID NDK PORTING:
-> there might be a situation, where different android versions are incompatible and throws "cannot locate symbol"
Ex: 
1|msmnile_gvmq:/system/lib64 # /vendor/bin/vsomeipd
CANNOT LINK EXECUTABLE "/vendor/bin/vsomeipd": cannot locate symbol "__sfp_handle_exceptions" referenced by "/vendor/bin/vsomeipd"...

CANNOT LINK EXECUTABLE "cli_someip_msg_sender_receiver": cannot locate symbol "_Unwind_Resume" referenced by "/system/bin/cli_someip_msg_sender_receiver"...
Above errors reason: the libs were built for androidp9(gac)==api level 27. but ford was android10 == api level 29
Link: https://source.android.com/setup/start/build-numbers 

In this case, download android-ndk 22d which has android10 release.
Then compile. But there will be a name mangling problem.
So remove the ndk name from __config file . Like below (uncommented)

#ifndef _LIBCPP_ABI_NAMESPACE
//# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__ndk,_LIBCPP_ABI_VERSION)
# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#endif

Then it will throw the problem with th lib error.
So, copy the target's libc++_shared.so and libc++.so from /lib and /lib64 and keep it in 
aarch64 and armeabi-v7a folder respectively.

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

-> Android BUILD
cd aosp-caf
source build/envsetup.sh
lunch --> if we give just lunch. it will display the list of the targets.
lunch 51      / lunch msmnile_gvmq-userdebug
make -j16
mma / mmm for building the dependent modules. Ex: mma-j8
mm -> builds just the modules. not dependent.
aosp-caf/device/qcom/common/vendorsetup.sh --> contains the target name

BUILD ALTERATIONS
adb disable-verity
reboot
You need to take some old liblog (system/lib & system/lib64) files from source code and push it into the system/lib & system/lib64
Remove the required TAGs (like log.tag.VST_VHAL=ERROR) in /vendor/default.prop and push it

for adb remount disable: (to try)
adb root
mount -o rw,remount /system
adb shell su -c "mount -o rw,remount,rw /system"
or getenforce -> setenforce 1

-> Android Startup
Init.rc file description for service etc : https://android.googlesource.com/platform/system/core/+/master/init/README.md
main init file is init.rc -> after that other files are imported.