-
Notifications
You must be signed in to change notification settings - Fork 0
/
call.sh
54 lines (46 loc) · 1.22 KB
/
call.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Function to check if the device is rooted
is_rooted() {
[ "$(id -u)" -eq 0 ]
}
# Function to make a call in the background (requires root)
call_in_background() {
echo "Device is rooted. Attempting to make call in background..."
if svc data enable && service call phone 2 s16 "$number"; then
echo "Call initiated to $number in the background."
svc data disable
else
echo "Failed to make call in background. Falling back to normal call..."
call_normal
fi
}
# Function to make a normal call (foreground)
call_normal() {
echo "Making normal call..."
am start -a android.intent.action.CALL -d tel:$number
if [ $? -ne 0 ]; then
echo "Failed to make normal call. Falling back to termux-telephony-call..."
termux_telephony_call
fi
}
# Function to make a call using termux-telephony-call
termux_telephony_call() {
echo "Attempting to make call using termux-telephony-call..."
termux-telephony-call $number
}
# Main script execution
main() {
echo "Debug: number passed to script is $1"
number=$1
if is_rooted; then
call_in_background
else
call_normal
fi
}
# Error handling and script execution
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <phone_number>"
exit 1
fi
main "$@"