Skip to content

Instantly share code, notes, and snippets.

View chris-piekarski's full-sized avatar

Christopher Piekarski chris-piekarski

  • Boulder, CO
  • 05:47 (UTC)
View GitHub Profile
@chris-piekarski
chris-piekarski / wsl_read_only
Created March 5, 2024 19:10
WSL stuck in read only filesystem
# https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-repair-a-vhd-mounting-error
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq 'Ubuntu' }).GetValue("BasePath") + "\ext4.vhdx"
wsl --shutdwon
wsl.exe --mount <path-to-ext4.vhdx> --vhd --bare
wsl -d Ubuntu -e sudo fsck -y /dev/sda
@chris-piekarski
chris-piekarski / adb_aosp_content
Last active December 27, 2023 19:52
ADB Content Command
adb shell content delete --uri content://settings/settings/pointer_speed
adb shell content query --uri content://settings/settings
adb shell content insert --uri content://settings/secure --bind name:s:my_number --bind value:i:24
See "package com.android.commands.content;" in /frameworks/base/cmds/content/
Usese "final class ContentProviderProxy implements IContentProvider" in ContentProviderProxy.java
@chris-piekarski
chris-piekarski / man_in_the_arena.py
Created August 26, 2023 22:22
Apex Engineers In The Arena
import re
import random
def binary_logic_choice(options):
# Randomly choose option A or B
choice_A_or_B = random.choice(["A", "B"])
choice = options.get(choice_A_or_B, "")
# Implementing binary digital logic to decide if option C should be picked
pick_A = random.choice([True, False])
@chris-piekarski
chris-piekarski / aosp_dimension_types
Created September 3, 2014 16:41
AOSP Dimension Types (dp, sp, pt, px, mm, in)
A dimension value defined in XML. A dimension is specified with a number followed by a unit of measure. For example: 10px, 2in, 5sp. The following units of measure are supported by Android:
dp
Density-independent Pixels - An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, on which 1dp is roughly equal to 1px. When running on a higher density screen, the number of pixels used to draw 1dp is scaled up by a factor appropriate for the screen's dpi. Likewise, when on a lower density screen, the number of pixels used for 1dp is scaled down. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Using dp units (instead of px units) is a simple solution to making the view dimensions in your layout resize properly for different screen densities. In other words, it provides consistency for the real-world sizes of your UI elements across different devices.
sp
Scale-independent Pixels - This
@chris-piekarski
chris-piekarski / system_aosp_libs
Created August 4, 2014 17:36
Adding system shared lib to AOSP
See device/sample/frameworks/PlatformLibrary/README.txt
Platform Library Example
~~~~~~~~~~~~~~~~~~~~~~~~
This directory contains a full example of writing your own Android platform
shared library, without changing the Android framework. It also shows how to
write JNI code for incorporating native code into the library, and a client
application that uses the library.
ipython
import rglob

android-1.6_r1.4

rglob.lcount("/home/chris/aosp_android-1.6_r1.4/", "*.java")
2687649
rglob.lcount("/home/chris/aosp_android-1.6_r1.4/", "*.cpp")
1994029
@chris-piekarski
chris-piekarski / pre_commit_reject_wildcard_imports
Created February 27, 2019 19:10
Git pre-commit hook to check for wildcard imports
#!/bin/sh
#
# cp to .git/hooks
# chomd +x .git/hooks/pre_commit
#
# This hook checks for wildcard imports (other than kotlinx) when added to staging.
# TODO: add ktlint check
RED='\033[0;31m'
GREEN='\033[0;32m'
@chris-piekarski
chris-piekarski / aosp_app_start_profiler
Last active January 31, 2022 10:25
Android app startup profiler
From AOSP page:
"Analyzing app startup time
Use $ adb shell am start with the -P or --start-profiler option to run the profiler when your app starts.
This will start the profiler almost immediately after your process is forked from zygote, before any of your code is loaded into it."
@chris-piekarski
chris-piekarski / aosp_meminfo_commands
Last active January 27, 2022 07:07
AOSP Memory/Content Related ADB Commands/Call Logs
adb shell dumpsys procstats --hours 3
adb shell dumpsys meminfo
adb shell dumpsys activity
#get com.android content providers
adb shell dumpsys | grep Provider{ | grep com.android
#call logs
adb shell content query --uri content://call_log/calls
@chris-piekarski
chris-piekarski / start_stop_services_via_adb
Last active December 22, 2021 06:50
android am force-stop and start services
adb -d shell am force-stop com.android.Settings
adb -d shell am startservice com.android.Settings/com.android.Settings.ServiceName
#list intent receivers
adb shell dumpsys package com.ubnt.restapi | grep intent
adb shell pm list packages
#force factory reset
adb shell "am broadcast -n "com.android.server/com.android.server.MasterClearReceiver" -a android.intent.action.FACTORY_RESET"