Skip to content

Commit

Permalink
add android section
Browse files Browse the repository at this point in the history
  • Loading branch information
aetonsi committed Dec 29, 2023
1 parent 9789a12 commit 5e93a49
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions sysadmin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SysAdmin notions, tools and procedures.

- [Linux](linux/README.md)
- [Android](android/README.md)
- [Raspberry PI Setup](rpi-setup.md)
- [OpenSSH for Windows](win-openssh.md)
- [Microsoft SQL Server](ms-sqlserver.md)
Expand Down
5 changes: 5 additions & 0 deletions sysadmin/android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Android world

- [adb snippets](adb-snippets.md)
- [fastboot snippets](fastboot-snippets.md)
- [emulator](emulator.md)
57 changes: 57 additions & 0 deletions sysadmin/android/adb-snippets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Android Debug Bridge (adb) snippets

## Poweroff the phone

```shell
adb shell reboot -p
```

## Kill the running ADB server

```shell
adb kill-server
```

## List devices

```shell
adb devices
```

## Run a command specifically for the running emulator or the connected physical device

```shell
adb -d <command> # command for device
adb -e <command> # command for emulator
adb -s <deviceid> # specify target
# or just set an environment variable ANDROID_SERIAL='<deviceid>'
```

## Shell commands

### Open the shell

```shell
adb shell
```

### (Un)Install an app

```shell
adb install file.apk
adb uninstall com.app.www
```

### Start (open) an app

```shell
adb shell monkey -p com.app.www 1 # starts main activity (opens the app, usually)
```

## Wifi ADB

```powershell
# 192.168.1.34 is the LAN IP of the android device
adb pair 192.168.1.34:38437
adb connect 192.168.1.34:35645
```
56 changes: 56 additions & 0 deletions sysadmin/android/emulator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Android Emulator

References

> - <https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels>
> - <https://apilevels.com/>
## Setup

One time setup.
In the examples, "Pixel4_api30_android11_x64" is the name of the emulator being created.
In the examples, android api level 30 is used, which is android 11 (see references above).

All commands are in Powershell syntax.

### Install tools, platform, system image

```Powershell
sdkmanager platform-tools
sdkmanager "build-tools;30.0.3"
sdkmanager "platforms;android-30"
sdkmanager "system-images;android-30;google_apis;x86_64"
```

### Create emulator

```powershell
# avdmanager create avd -n <name> -k "system-images;android-<api level>;google_apis;x86_64"
avdmanager create avd -n Pixel4_api30_android11_x64 -k "system-images;android-30;google_apis;x86_64"
# check if all is well
emulator -list-avds
```

### `config.ini` useful settings

Add the following settings to the emulator's configuration file, located at:

> `<$env:USERPROFILE>\.android\avd\<emulator name>\config.ini`
So, in the example:

> `C:\Users\username\.android\avd\Pixel4_api30_android11_x64.avd\config.ini`
- `nhw.lcd.width = 720` and `nhw.lcd.height = 1280` set the resolution to 720p
- `nhw.lcd.density = 240` sets DPI to an acceptable level
- `nhw.keyboard = yes` is needed for full functioning of the computer keyboard (eg. copy-pasting)

## Run the emulator

Just run this command every time you have to start the emulator.

```powershell
# emulator -avd <emulator name>
emulator -avd Pixel4_api30_android11_x64
```
9 changes: 9 additions & 0 deletions sysadmin/android/fastboot-snippets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# fastboot-snippets.md

## Poweroff the phone

NB: works only if the OEM command is supported.

```shell
fastboot oem poweroff
```

0 comments on commit 5e93a49

Please sign in to comment.