Skip to content

Instantly share code, notes, and snippets.

View logcat's full-sized avatar

Sergii Golub logcat

View GitHub Profile
@logcat
logcat / service.md
Created May 23, 2023 17:30 — forked from tniessen/service.md
Using the "service" tool with ADB and why to avoid it

As it turns out, it is not trivial to control the audio volume of an Android device using ADB. At the time of writing, the only way appears to be using the service tool. Actually, the service command allows to "connect" to a number of services (104 on Android 6.0.1) and invoke functions. Not knowing much about this tool, I managed to completely mute all sounds and speakers of my Nexus 5, and I was stuck without any sound for quite some time. I did not find a way to unmute the sound from within the system UI, so I got to dive a little deeper into this.

If you know which service you want to use, you then need to find its interface declaration. The command

service list

gives you a list of all services with the associated interfaces, if applicable:

...

26 backup: [android.app.backup.IBackupManager]

if [[ "$TERM_PROGRAM" == 'vscode' ]]; then
alias 'rg'='rg --smart-case --hidden --no-heading --column'
else
alias 'rg'='rg --smart-case --hidden'
fi
@logcat
logcat / Android_Emulator_AWS_EC2_ARM64_2022.txt
Created October 18, 2022 15:04 — forked from atyachin/Android_Emulator_AWS_EC2_ARM64_2022.txt
Running headless android emulator on AWS EC2 Ubuntu instance (ARM64 / aarch64) - 2022
Android Emulator (ARM64) on EC2 - 2022
---------------------------------------
1. Launch EC2 ARM based Instance (a1.metal / a1.2xlarge): (16 Gb RAM, 32Gb Disk), Ubuntu Server 22.04 LTS (HVM) ARM x64
2. sudo apt update && sudo apt upgrade
3. sudo apt install default-jdk python3-pip repo python-is-python3 unzip libpcre2-dev adb
4. wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
5. unzip commandlinetools-linux-8512546_latest.zip -d android-sdk
6. sudo mv android-sdk /opt/
7. mkdir /opt/android-sdk/cmdline-tools/latest
8. mv /opt/android-sdk/cmdline-tools/* /opt/android-sdk/cmdline-tools/latest (ignore the error)
@logcat
logcat / devenv.sh
Created July 28, 2017 11:01
algo1 devenv
export CLASSPATH=${CLASSPATH}:libs/algs4.jar:out/production/algo1
@logcat
logcat / mount_android.sh
Created May 9, 2017 09:34
case sensitive image for android building on osx
android_folder=/Users/user/mount_point
function mountAndroid { hdiutil attach /Users/user/android.dmg.sparseimage -mountpoint $android_folder; }
function umountAndroid() { hdiutil detach $android_folder; }
@logcat
logcat / ghci.conf
Created April 20, 2017 17:57
ghci prompt
:set prompt "\ESC[38;5;161m❯\ESC[1;34mλ= \ESC[0m"
@logcat
logcat / redfox.py
Last active April 1, 2017 14:37
Sends word from Sublime Text 3 to open redfoxsanakirja tab in chrome (works on OSX, depends on https://github.com/prasmussen/chrome-cli/)
import sublime
import sublime_plugin
import subprocess
import re
class RedfoxCommand(sublime_plugin.TextCommand):
def run(self, edit):
redfox(word(self.view))
def word(view):
import android.app.Activity;
import android.support.annotation.Nullable;
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import java.util.Collection;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.runner.lifecycle.Stage.RESUMED;
public final class CurrentActivityUtil {
@logcat
logcat / heap_dump.sh
Created January 10, 2017 16:33
android dump heap with adb help
heap_dump_location='/data/local/tmp/tmp.hprof'
dump_heap() {
adb shell rm $heap_dump_location
pid=`adb shell ps | grep 'com.example.packagename' | grep -v 'packagename\.' | cut -c10-15`
adb shell am dumpheap $pid $heap_dump_location
echo "Heap dump started, we have no idea when it's done, so take a look at logs, and when is done use pull_heap_dump"
}
pull_heap_dump() {
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import java.util.concurrent.CountDownLatch;
public class ServiceConnector<T> {