{"id":20279032,"url":"https://github.com/t-vk/android-svc","last_synced_at":"2025-04-11T06:14:43.137Z","repository":{"id":52544900,"uuid":"298569444","full_name":"T-vK/android-svc","owner":"T-vK","description":"Easy to use Android service wrapper","archived":false,"fork":false,"pushed_at":"2024-04-10T08:26:28.000Z","size":2296,"stargazers_count":84,"open_issues_count":2,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T06:14:37.026Z","etag":null,"topics":["adb","aidl","android","android-svc","android-svc-lib","bash","linux","service","service-call","shell","terminal","termux","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/T-vK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-25T12:41:52.000Z","updated_at":"2025-03-19T13:18:55.000Z","dependencies_parsed_at":"2024-11-14T13:29:32.610Z","dependency_job_id":"75b64c1d-b481-4965-a84b-850b3d2013aa","html_url":"https://github.com/T-vK/android-svc","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2Fandroid-svc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2Fandroid-svc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2Fandroid-svc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2Fandroid-svc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T-vK","download_url":"https://codeload.github.com/T-vK/android-svc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351393,"owners_count":21089272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adb","aidl","android","android-svc","android-svc-lib","bash","linux","service","service-call","shell","terminal","termux","wrapper"],"created_at":"2024-11-14T13:27:48.745Z","updated_at":"2025-04-11T06:14:43.115Z","avatar_url":"https://github.com/T-vK.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commandline wrapper for Android's serivce utility\n\n## About\n`android-svc` aims at making it easier to call service methods over ADB or using a terminal emulator on your Android device directly.  \nUsing Android's built-in `service` utility forces you to manually go through the Android source code and its AIDL files.  \nYou can for example simply call  \n``` Bash\nandroid-svc call 'android.content.pm.IPackageManager.getInstallerPackageName(\"com.nononsenseapps.feeder\");'\n#or\nandroid-svc call 'package.getInstallerPackageName(\"com.nononsenseapps.feeder\");'\n```\ninstead of\n``` Bash\nservice call package 65 s16 'com.nononsenseapps.feeder'\n```\nwhich would have required you to understand how to get values like `65` or `s16` and write different code for every device and Android version you want to use it on.  \n\n## Demo\n![demo](./demo.gif)\n\n## Features\n\n- [x] Call service methods\n- [x] List available service packages\n- [x] List available methods for service packages\n- [x] Show method signatures (including data types for arguments and return values)\n- [x] Convert given service method calls into a bash commands\n- [x] Offline mode\n- [x] Works over ADB (from Linux host)\n- [x] Works directly on the phone (requires Termux)\n- [x] Supports the following data types: void, boolean, char, int, long, float, double, String\n\n## Limitations\n\n- Requires root\n- I need help decoding/encoding all complex datatypes like arrays, Lists, ParceledListSlice etc.\n- String are decoded ignoring the first 8 bits of every char. This works fine as long as only UTF-8 characters are being used. When a string contains a UTF-16 character the decoded output will be incorrect. Any help properly decoding utf-16 hex code in bash would be appreciated.\n- String decoding is slow. Any help improving the performance would be apperciated.\n\n## Disclaimer\n**Use at own risk!**\n- May call incorrect service methods on ROMs that have added/removed methods to/from the aidl files as they appear in AOSP. I recommend using LineageOS to reduce that risk. If you use another open source ROM, we can probably add support for detecting that by scanning its source code, just like I've done it for LineageOS.\n- Only tested with ARM64-based devices.\n\n## How to install (in Termux)\n- Download the deb package from the [latest release](https://github.com/T-vK/android-svc/releases).\n- Install it using `apt install path/to/android-svc_x.x.x_all.deb` (replaceing x.x.x with the actual version)\n\n## How to install (in Linux)\n- Download the standalone executable from the [latest release](https://github.com/T-vK/android-svc/releases). (It's the `android-svc` file.)\n- Make it executable by running `chmod +x ./android-svc`.\n- Optional: Add the containing folder to your PATH or copy android-svc into a folder that's in PATH already.\n  Otherwise you'll have to use it like `path/to/android-svc help` instead of `android-svc help`\n\nAlternatively you can of course clone the repo with git and execute android-svc.sh directly.\n\n## How to build\nIf you want to build it yourself instead of using a release, you can do it like this:\n\n```\ngit clone https://github.com/T-vK/android-svc.git\ncd ./android-svc\n./build.sh\n```\n\nThis will create a folder called 'build' in which you'll find the standalone executable and the deb package for Termux.\n\n\n## How to use\n\nRun `android-svc help` to get the following help message:\n``` Bash\nandroid-svc [options] download\nDescription: Enable offline usage by downloading required Android source code files for the current device.\nExample: android-svc download\n\nandroid-svc [options] call 'SERVICE_PACKAGE_NAME.METHOD_NAME(arguments)'\nDescription: Call a service method.\nExample: android-svc call 'com.android.internal.telephony.ITelephony.dial(\"555-0199\")'\n\nandroid-svc [options] convert 'SERVICE_PACKAGE_NAME.METHOD_NAME(arguments)'\nDescription: Convert a service method call to a bash command. THE RESULTING COMMAND WILL ONLY WORK FOR THE EXACT ANDROID VERSION OF YOUR DEVICE!\nExample: android-svc convert 'com.android.internal.telephony.ITelephony.dial(\"555-0199\")'\n\nandroid-svc [options] list-packages\nDescription: List all service package names.\nExample: android-svc list-packages\n\nandroid-svc [options] list-methods SERVICE_PACKAGE_NAME\nDescription: List all methods for a service package.\nExample: android-svc list-methods android.content.pm.IPackageManager\n\nandroid-svc [options] method-signature SERVICE_PACKAGE_NAME.METHOD_NAME\nDescription: Get method-signature for a specific method.\nExample: android-svc method-signature android.media.IAudioService.isMasterMute\n\nSupported options are --adb or --adb=\u003cdevice-id\u003e\n(You only need this in order to use this from a Linux machine via ADB.)\n\nandroid-svc help\nDescription: Print this message.\nExample: android-svc help\n```\n\n## Examples with example output:\n\n``` Bash\n# Example 1 (Enables offline usage):\n$ android-svc download\nDownloading 'core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl'\nDownloading 'core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl'\nDownloading 'core/java/android/accounts/IAccountAuthenticator.aidl'\nDownloading 'core/java/android/accounts/IAccountAuthenticatorResponse.aidl'\nDownloading 'core/java/android/accounts/IAccountManager.aidl'\nDownloading 'core/java/android/accounts/IAccountManagerResponse.aidl'\n...\n\n\n\n# Example 2 (Find out which App installed another app):\n$ android-svc call 'android.content.pm.IPackageManager.getInstallerPackageName(\"com.nononsenseapps.feeder\");'\norg.fdroid.fdroid.privileged\n\n\n\n# Example 3 (Find out if the master volume is muted):\n$ android-svc call 'android.media.IAudioService.isMasterMute();'\nfalse\n\n\n\n# Example 4 (Dial a given phone number):\n$ android-svc call 'com.android.internal.telephony.ITelephony.dial(\"555-0199\")'\n\n\n\n# Example 5 (Convert the given package-method-call into a shell command (which only works for the exact same Android version):\n$ android-svc convert 'android.content.pm.IPackageManager.getInstallerPackageName(\"com.nononsenseapps.feeder\");'\nservice call package 65 s16 'com.nononsenseapps.feeder'\n\n\n\n# Example 6 (Get info about arguments and return data types about a given method from a given package):\n$ android-svc info android.content.pm.IPackageManager.getInstallerPackageName\nString getInstallerPackageName(in String packageName);\n\n\n\n# Example 7 (List all methods available for a given package):\n$ android-svc methods 'android.media.IAudioService'\nint trackPlayer(in PlayerBase.PlayerIdCard pic);\noneway void playerAttributes(in int piid, in AudioAttributes attr);\noneway void playerEvent(in int piid, in int event);\noneway void releasePlayer(in int piid);\noneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,String callingPackage, String caller);\nvoid adjustStreamVolume(int streamType, int direction, int flags, String callingPackage);\nvoid setStreamVolume(int streamType, int index, int flags, String callingPackage);\nboolean isStreamMute(int streamType);\nvoid forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb);\nboolean isMasterMute();\nvoid setMasterMute(boolean mute, int flags, String callingPackage, int userId);\nint getStreamVolume(int streamType);\nint getStreamMinVolume(int streamType);\nint getStreamMaxVolume(int streamType);\nint getLastAudibleStreamVolume(int streamType);\nvoid setMicrophoneMute(boolean on, String callingPackage, int userId);\nvoid setRingerModeExternal(int ringerMode, String caller);\nvoid setRingerModeInternal(int ringerMode, String caller);\nint getRingerModeExternal();\nint getRingerModeInternal();\nboolean isValidRingerMode(int ringerMode);\nvoid setVibrateSetting(int vibrateType, int vibrateSetting);\nint getVibrateSetting(int vibrateType);\nboolean shouldVibrate(int vibrateType); ROM, we can probably add support for detecting that by scanning its source code, just like I've done it for LineageOS.\n- Only tested with arm6\nvoid setMode(int mode, IBinder cb, String callingPackage);\nint getMode();\noneway void playSoundEffect(int effectType);\noneway void playSoundEffectVolume(int effectType, float volume);\nboolean loadSoundEffects();\noneway void unloadSoundEffects();\noneway void reloadAudioSettings();\noneway void avrcpSupportsAbsoluteVolume(String address, boolean support);\nvoid setSpeakerphoneOn(boolean on);\nboolean isSpeakerphoneOn();\nvoid setBluetoothScoOn(boolean on);\nvoid setBluetoothA2dpOn(boolean on);\nboolean isBluetoothA2dpOn();\nint requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb,IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags,IAudioPolicyCallback pcb, int sdk);\nint abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa,in String callingPackageName);\nvoid unregisterAudioFocusClient(String clientId);\nint getCurrentAudioFocus();\nvoid startBluetoothSco(IBinder cb, int targetSdkVersion);\nvoid startBluetoothScoVirtualCall(IBinder cb);\nvoid stopBluetoothSco(IBinder cb);\nvoid forceVolumeControlStream(int streamType, IBinder cb);\nvoid setRingtonePlayer(IRingtonePlayer player);\nIRingtonePlayer getRingtonePlayer();\nint getUiSoundsStreamType();\nvoid setWiredDeviceConnectionState(int type, int state, String address, String name,String caller);\nint setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile);\nvoid handleBluetoothA2dpDeviceConfigChange(in BluetoothDevice device);\nAudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer);\nboolean isCameraSoundForced();\nvoid setVolumeController(in IVolumeController controller);\nvoid notifyVolumeControllerVisible(in IVolumeController controller, boolean visible);\nboolean isStreamAffectedByRingerMode(int streamType);\nboolean isStreamAffectedByMute(int streamType);\nvoid disableSafeMediaVolume(String callingPackage);\nint setHdmiSystemAudioSupported(boolean on);\nboolean isHdmiSystemAudioSupported();\nString registerAudioPolicy(in AudioPolicyConfig policyConfig,in IAudioPolicyCallback pcb, boolean hasFocusListener, boolean isFocusPolicy,boolean isVolumeController);\noneway void unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb);\nint addMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb);\nint removeMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb);\nint setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb);\nvoid setVolumePolicy(in VolumePolicy policy);\nvoid registerRecordingCallback(in IRecordingConfigDispatcher rcdb);\noneway void unregisterRecordingCallback(in IRecordingConfigDispatcher rcdb);\nList\u003cAudioRecordingConfiguration\u003e getActiveRecordingConfigurations();\nvoid registerPlaybackCallback(in IPlaybackConfigDispatcher pcdb);\noneway void unregisterPlaybackCallback(in IPlaybackConfigDispatcher pcdb);\nList\u003cAudioPlaybackConfiguration\u003e getActivePlaybackConfigurations();\nvoid disableRingtoneSync(in int userId);\nint getFocusRampTimeMs(in int focusGain, in AudioAttributes attr);\nint dispatchFocusChange(in AudioFocusInfo afi, in int focusChange,in IAudioPolicyCallback pcb);\noneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio);\nint setBluetoothHearingAidDeviceConnectionState(in BluetoothDevice device,int state, boolean suppressNoisyIntent, int musicDevice);\nint setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device,int state, int profile, boolean suppressNoisyIntent, int a2dpVolume);\noneway void setFocusRequestResultFromExtPolicy(in AudioFocusInfo afi, int requestResult,in IAudioPolicyCallback pcb);\nvoid registerAudioServerStateDispatcher(IAudioServerStateDispatcher asd);\noneway void unregisterAudioServerStateDispatcher(IAudioServerStateDispatcher asd);\nboolean isAudioServerRunning();\n```\n\n## Further information\nIn order to add support for certain binary data types, it will be necessary to create a custom build of Android's service utility.  \nThe official instructions on how to build that utility are incredibly time consuming and require downloading more than 600 GIGABYTES of source code. (If you read this in 2023 it has probably grown to \u003e1TB of data.) \nI have thus been working on a minimal setup only requiring a couple of MB of storage and ended up with this:\n\n``` Bash\n# Download required source code\ngit clone https://android.googlesource.com/platform/superproject\ncd superproject\ngit submodule init\ngit submodule update frameworks/native\ngit submodule update system/libbase\ngit submodule update system/core\ngit submodule update system/logging\ngit submodule update bionic\n# Set required include directories in CPATH\nexport CPATH=\"./frameworks/native/include:./system/libbase/include:./system/core/libcutils/include:./system/core/libutils/include:./system/logging/liblog/include:./system/core/libsystem/include:./frameworks/native/libs/binder/include:./bionic/libc/include\"\n# Build\ng++ -DXP_UNIX -Wall -Werror -o service ./frameworks/native/cmds/service/service.cpp\n```\n\n(I'm not sure on how to cross compile yet.)\n\n### Interesting code to further inspect in order to find the aidl files for packages that have missing data in `serivce list`\n(This is just a note for me)\n\n - https://github.com/aosp-mirror/platform_frameworks_base/blob/a4ddee215e41ea232340c14ef92d6e9f290e5174/core/java/android/content/Context.java#L4056\n - https://github.com/aosp-mirror/platform_frameworks_base/blob/master/media/java/android/media/IAudioService.aidl\n - https://android.googlesource.com/platform/frameworks/native/+/android-8.0.0_r36/services/audiomanager/IAudioManager.cpp\n - https://android.googlesource.com/platform/frameworks/native/+/android-8.0.0_r36/include/audiomanager/IAudioManager.h\n - https://github.com/aosp-mirror/platform_frameworks_base/blob/a4ddee215e41ea232340c14ef92d6e9f290e5174/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java#L66\n\n## Credits\nCredits to @ktnr74 for his [get_android_service_call_numbers.sh](https://gist.github.com/ktnr74/ac6b34f11d1e781db089#file-get_android_service_call_numbers-sh)\nCredits to @bashenk for [his fork](https://gist.github.com/bashenk/b538ce0a60efe6a9c3b446683744d598#file-get_android_service_call_numbers-sh) of ktnr74's work, which adds some improvements.\n\n`android-svc` is based on that work, although most of the code has been rewritten and a lot of new features and fixes have been implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-vk%2Fandroid-svc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-vk%2Fandroid-svc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-vk%2Fandroid-svc/lists"}