如何在从 Android 6 到 Android 12 的所有版本上使用 adb shell 命令发送短信?
How do I send SMS using the adb shell command on all versions from Android 6 to Android 12?
我正在尝试使用 adb shell 命令发送消息。我在 Android 10 上发送但没有在 Android 11 上发送。我尝试了所有方法但没有成功。我找到了 android 11 here. I have 2 more Android 11 phones and when I test them the result is the same. To test that my shell commands are working on the device, I tried the input command and it does. I read this 的 isms 服务源代码,但仍然没有帮助。
我使用的命令:
adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "%number%" s16 "null" s16 "%message%" s16 "null" s16 "null"
此命令的输出:
Result: Parcel(00000000 '....')
谁能帮忙,我如何在 Android 11 上使用 adb shell 命令发送消息?
(我试过 Android 12 结果是一样的)
以下内容将使用默认的短信应用编写短信,但不会发送:
adb shell am start -a android.intent.action.SENDTO -d sms:+1234567890 --es sms_body "Test" --ez exit_on_sent false
。
如果您想完全在后台发送消息,这将无济于事。
Android10 之后:
adb shell service call isms 5 i32 1 s16 "com.android.mms" s16 "null" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null" i32 0 i64 0
Android10 之前:
adb shell service call isms 7 i32 1 s16 "com.android.mms" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null"
对于未来的证明方式 - 由于数字 (5,7) 发生变化,您最好直接使用 isms AIDL。以 isms 为例,我们看到:
redfin:/ $ service list | grep isms
104 isms: [com.android.internal.telephony.ISms]
因此,查看 isms.aidl (frameworks/base/telephony/java/com/android/internal/telephony/ISms.aidl) 您会发现“5”现在是
void sendTextForSubscriber(in int subId, String callingPkg, String callingAttributionTag,
in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent,
in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp,
in long messageId);
所以建议的答案:
call isms 5 i32 1 s16 "com.android.mms" s16 "null" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null" i32 0 i64 0
基本上伪造了参数(并不完全正确):
in int subId = 1
String callingPkg = "com.android.mms"
String callingAttributionTag = "null"
in String destAddr = "number"
in String scAddr = "16"
in String text = "text"
in PendingIntent sentIntent ="null" (should be i32 0)
in PendingIntent deliveryIntent = "null" (should be i32 0 also)
in boolean persistMessageForNonDefaultSmsApp = 0 = false,
in long messageId = 0 (the i64)
如果可以,请参考 AIDL。它更安全,并且还确保您序列化正确的参数。不幸的是,这些在版本之间经常变化。
(来源:“Android 内幕”,第二卷(http://NewAndroidBook.com))
我正在尝试使用 adb shell 命令发送消息。我在 Android 10 上发送但没有在 Android 11 上发送。我尝试了所有方法但没有成功。我找到了 android 11 here. I have 2 more Android 11 phones and when I test them the result is the same. To test that my shell commands are working on the device, I tried the input command and it does. I read this 的 isms 服务源代码,但仍然没有帮助。
我使用的命令:
adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "%number%" s16 "null" s16 "%message%" s16 "null" s16 "null"
此命令的输出:
Result: Parcel(00000000 '....')
谁能帮忙,我如何在 Android 11 上使用 adb shell 命令发送消息?
(我试过 Android 12 结果是一样的)
以下内容将使用默认的短信应用编写短信,但不会发送:
adb shell am start -a android.intent.action.SENDTO -d sms:+1234567890 --es sms_body "Test" --ez exit_on_sent false
。
如果您想完全在后台发送消息,这将无济于事。
Android10 之后:
adb shell service call isms 5 i32 1 s16 "com.android.mms" s16 "null" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null" i32 0 i64 0
Android10 之前:
adb shell service call isms 7 i32 1 s16 "com.android.mms" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null"
对于未来的证明方式 - 由于数字 (5,7) 发生变化,您最好直接使用 isms AIDL。以 isms 为例,我们看到:
redfin:/ $ service list | grep isms
104 isms: [com.android.internal.telephony.ISms]
因此,查看 isms.aidl (frameworks/base/telephony/java/com/android/internal/telephony/ISms.aidl) 您会发现“5”现在是
void sendTextForSubscriber(in int subId, String callingPkg, String callingAttributionTag,
in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent,
in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp,
in long messageId);
所以建议的答案:
call isms 5 i32 1 s16 "com.android.mms" s16 "null" s16 "number" s16 "null" s16 "message" s16 "null" s16 "null" i32 0 i64 0
基本上伪造了参数(并不完全正确):
in int subId = 1
String callingPkg = "com.android.mms"
String callingAttributionTag = "null"
in String destAddr = "number"
in String scAddr = "16"
in String text = "text"
in PendingIntent sentIntent ="null" (should be i32 0)
in PendingIntent deliveryIntent = "null" (should be i32 0 also)
in boolean persistMessageForNonDefaultSmsApp = 0 = false,
in long messageId = 0 (the i64)
如果可以,请参考 AIDL。它更安全,并且还确保您序列化正确的参数。不幸的是,这些在版本之间经常变化。
(来源:“Android 内幕”,第二卷(http://NewAndroidBook.com))