Sunday, June 26, 2016

Android: User profile data location (root required)

To find users on a device:
adb shell pm list users

you should see something like this:
Users:
        UserInfo{0:Alice:13}
        UserInfo{11:Bob:10}


Bob's user ID is 11. His data files can be found at:
/mnt/shell/emulated/11

P.S. If you are using ES File Explorer, first install SuperSU, then enable Root Explorer within ES File Explorer. You should be prompted to grant root access to ES File Explorer.


Bonus:
To run an app as Bob for example:
adb shell am start --user 11 \ -n "com.example.myapp/com.example.myapp.testactivity" \ -a android.intent.action.MAIN -c android.intent.category.LAUNCHER


Ref:
Set up Managed Profiles | Android Developers

Saturday, June 25, 2016

Android: Screen recording via ADB

To start a screen recording (requires Android 4.4 (KitKat) or above):
adb shell screenrecord /sdcard/example.mp4

Stop the screen recording by pressing Ctrl-C, otherwise the recording stops automatically at three minutes or the time limit set by --time-limit. The default and maximum value is 180 (3 minutes).

To take a screenshot:
adb shell screencap /sdcard/screen.png


Ref:
ADB Shell Commands | Android Studio

Saturday, June 18, 2016

Android: What are the application-icon-* in aapt dump badging?

Question:
When running aapt dump badging, there is a list of application-icon.*
application-icon-120:'res/drawable-ldpi-v4/icon.png'
application-icon-160:'res/drawable-mdpi-v4/icon.png'
application-icon-213:'res/drawable-tvdpi-v4/icon.png'
application-icon-240:'res/drawable-hdpi-v4/icon.png'
application-icon-320:'res/drawable-xhdpi-v4/icon.png'
application-icon-480:'res/drawable-xxhdpi-v4/icon.png'
application-icon-640:'res/drawable-xxxhdpi-v4/icon.png'


What are those numbers 120, 160, 213...etc.?

Answer:
Each number represent a screen density, e.g.
120 = DENSITY_LOW = ldpi
160 = DENSITY_MEDIUM = mdpi
213 = DENSITY_TV = tvdpi

...etc.


Ref:
DisplayMetrics | Android Developers

Sunday, June 12, 2016

Python: pyenv vs pyvenv vs venv vs virtualenv

What's the difference between pyenv, pyvenv, venv, and virtualenv?

pyenv - a 3rd party tool for switching between multiple versions of Python (e.g. change the global Python version between Python 2 and 3).

pyvenv - a built-in command line tool for creating “virtual environments”. It helps separate packages dependence between projects. Added since Python 3.3.

venv - a built-in API module for creating "virtual environments". Added since Python 3.3.

virtualenv -a 3rd party tool for creating "virtual environments".


Ref:
Python: pyenv, pyvenv, virtualenv – What’s the difference? | Abu Ashraf Masnun
PEP 405 -- Python Virtual Environments | Python.org

Tuesday, May 10, 2016

Mac: Default email reader keep resetting to Mail

Problem:
On Mac OS X El Capitan (10.11.4), I was trying to change the default email reader to MS Outlook. So I went to Mail > Preferences > General, and changed Default email reader to Outlook. However, if I re-open the Preferences dialog, I noticed the setting is reverted back to Mail.


Solution:
I was able to resolve the issue by resetting LaunchServices. Open Terminal and run the following command:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed


Ref:
OS X 10.11.4 - Setting the default email to one... | Apple Support Communities

Wednesday, March 30, 2016

Wireshark: Search for GET and POST requests

When analyzing a packet capture file (*.pcap) with Wireshark, it can be handy to view just the GET and POST requests.

To view GET requests, set display filter to:
http.request.method == "GET"

To view POST requests, set display filter to:
http.request.method == "POST"

To view both GET and POST requests, use the or operator:
http.request.method == "GET" or http.request.method == "POST"

Thursday, March 24, 2016

Mac: How to connect to a Windows shared folder

To connect to a Windows shared folder:
1. Open Finder
2. Open the Go menu > Connect to Server...
3. Enter smb://, followed by the shared folder path. Note that you should replace all the backslash '\' with forward-slash '/'.
e.g. smb://domain-or-ip-address/shared/folder/path


Ref:
How to mount a Windows shared folder on your Mac