termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.35k stars 460 forks source link

Setup system alarm using `am` failed #682

Closed HusniMuhammad closed 5 months ago

HusniMuhammad commented 5 months ago

Problem description

Setup system alarm using am failed

Inspired from open-source Android app Timer+X from f-droid

Possible Due to this missing permission IMG_20240531_115037

Starting: Intent { act=android.intent.action.SET_ALARM (has extras) }
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.termux.termuxam.CrossVersionReflectedMethod.invoke(CrossVersionReflectedMethod.java:175)
        at com.termux.termuxam.IActivityManager.startActivityAsUser(IActivityManager.java:250)
        at com.termux.termuxam.Am.runStart(Am.java:823)
        at com.termux.termuxam.Am.onRun(Am.java:437)
        at com.termux.termuxam.BaseCommand.run(BaseCommand.java:46)
        at com.termux.termuxam.Am.main(Am.java:120)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:410)
Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SET_ALARM flg=0x10000000 cmp=com.google.android.deskclock/com.android.deskclock.HandleSetApiCalls (has extras) } from null (pid=27367, uid=10472) requires com.android.alarm.permission.SET_ALARM
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2374)
        at android.os.Parcel.createException(Parcel.java:2358)
        at android.os.Parcel.readException(Parcel.java:2341)
        at android.os.Parcel.readException(Parcel.java:2283)
        at android.app.IActivityManager$Stub$Proxy.startActivityAsUser(IActivityManager.java:8300)
        ... 9 more
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1057)
        at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1030)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:684)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1118)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1090)

Steps to reproduce

am start -a android.intent.action.SET_ALARM --ei android.intent.extra.alarm.HOUR 7 --ei android.intent.extra.alarm.MINUTES 30  --es android.intent.extra.alarm.MESSAGE "Wake up!" --ez android.intent.extra.alarm.SKIP_UI true

Expected behavior

Trigger a alarm to system clock app

Additional information

Termux App Info

APP_NAME: Termux
PACKAGE_NAME: com.termux
VERSION_NAME: 0.118.0
VERSION_CODE: 118
TARGET_SDK: 28
IS_DEBUGGABLE_BUILD: true
APK_RELEASE: Github
SIGNING_CERTIFICATE_SHA256_DIGEST: B6DA01480EEFD5FBF2CD3771B8D1021EC791304BDD6C4BF41D3FAABAD48EE5E1

Termux:API App Info

APP_NAME: Termux:API
PACKAGE_NAME: com.termux.api
VERSION_NAME: 0.50.1
VERSION_CODE: 51
TARGET_SDK: 28
IS_DEBUGGABLE_BUILD: true
APK_RELEASE: Github
SIGNING_CERTIFICATE_SHA256_DIGEST: B6DA01480EEFD5FBF2CD3771B8D1021EC791304BDD6C4BF41D3FAABAD48EE5E1

Termux:Widget App Info

APP_NAME: Termux:Widget
PACKAGE_NAME: com.termux.widget
VERSION_NAME: 0.13.0
VERSION_CODE: 13
TARGET_SDK: 28
IS_DEBUGGABLE_BUILD: true
APK_RELEASE: Github
SIGNING_CERTIFICATE_SHA256_DIGEST: B6DA01480EEFD5FBF2CD3771B8D1021EC791304BDD6C4BF41D3FAABAD48EE5E1

Device Info

Software

OS_VERSION: 4.14.193+-ab475
SDK_INT: 30
RELEASE: 11
ID: RP1A.201005.001
DISPLAY: RMX3231_11.A.123
INCREMENTAL: 475
SECURITY_PATCH: 2024-02-05
IS_DEBUGGABLE: 0
IS_TREBLE_ENABLED: true
TYPE: user
TAGS: release-keys

Hardware

MANUFACTURER: realme
BRAND: realme
MODEL: RMX3231
PRODUCT: RMX3231
BOARD: RMX3231
HARDWARE: RMX3231
DEVICE: RMX3231
SUPPORTED_ABIS: armeabi-v7a, armeabi

agnostic-apollo commented 5 months ago

Duplicate of termux/termux-app#3990