I have created a bash script which reads notifications with command termux-notification-list
i used while loop to read continuously.
So when I recieve a call this script will read the notification of default dialler app and search for the phone number with my npm package truecallerjs and sends a notification with the name of the person who holds that number.
see the below screenshot
so, Im using mi phone which has com.android.incallui
as a default dialler app . see this below link, my script send phone number details when there is a notification from com.android.incallui
.
https://github.com/sumithemmadi/truecaller-on-termux/blob/main/run#L52
the script will work only if the user is using mi phone for other phones there will be different dialer app.
So how can I get default dialler app.
See i have used
...
if [[ $packageName == "com.android.incallui" ]]
then
...
It should be like
...
if [[ $packageName == "[Default dialer app name]" ]]
then
...
What ever the default dialer user use , [Default dialer app name] should be the name of the app which will receive calls. If the user uses the google dialer it should be
...
if [[ $packageName == "com.google.android.dialer" ]]
then
...
CodePudding user response:
For android >= 10
, grant termux DUMP permission with adb shell pm grant com.termux android.permission.DUMP
and then run /system/bin/dumpsys role | grep -A 1 android.app.role.DIALER | grep holders= | sed -E 's/[ \t] holders=(.*)/\1/'
You may get an array if more than one app assigned the role.
For android < 10
you can run cmd package resolve-activity tel://123456
with adb or root.
https://android.stackexchange.com/questions/227155/retrieve-list-of-default-apps-via-adb
You can get android version with /system/bin/getprop ro.build.version.sdk
.
https://github.com/termux/termux-packages/discussions/9987#discussioncomment-2556377