Skip to content

Instantly share code, notes, and snippets.

View esafirm's full-sized avatar
🏠
Working from home

Esa Firman esafirm

🏠
Working from home
View GitHub Profile
/**
* Parse the result from [apkanalyzer dex packages <apk>] and give us summary about the data
*
* Author @esafirm
*/
// (type/state/defined methods/referenced methods /byte size/name)
// P, C, M, and F indicate packages, classes, methods, and fields, respectively. And x, k, r, and d indicate removed, kept, referenced and defined nodes, respectively.
enum Type {

Multi Flavor App

Using BuildConfig

if (BuildConfig.Theme == "red") {
	RedTheme { ... }
}else {
	GreenTheme { ... }
}
@esafirm
esafirm / instruction.md
Last active April 17, 2023 00:22
Android Nougat Above - Install Certificate to System

For more information https://blog.jeroenhd.nl/article/android-7-nougat-and-certificate-authorities


Ran into this issue as well while trying to check for privacy implications of an app. The blog post and docs linked above does explain what happened, but not how. Source code references follows based on nougat-mr2.3.

The change was made in commit aosp-mirror/platform_frameworks_base@32d2a10, see frameworks/base:core/java/android/security/net/config/NetworkSecurityConfig.java. After that change, only the [system root store](https://github.com/android/platform_frameworks_base/blob/nougat-m

@esafirm
esafirm / jetify.sh
Last active September 23, 2020 03:11
Download AAR and jetify it. Unix only!
#!/usr/bin/env bash
TARGET=temp_target
AAR_URL=$1
TARGET_NAME=$2
ZIP_NAME=jetifier.zip
# Download Jetifier
curl "https://dl.google.com/dl/android/studio/jetifier-zips/1.0.0-beta09/jetifier-standalone.zip" -o $ZIP_NAME
@esafirm
esafirm / drafter.rb
Created May 18, 2020 03:26
Drafter Forumula
require 'formula'
class Drafter < Formula
homepage 'http://apiblueprint.org'
head 'https://github.com/apiaryio/drafter.git', :tag => 'v4.1.0'
def install
system "./configure", "--shared"
system "make", "drafter"
bin.install Dir["bin/drafter"]
class MemoryProfilerRule : TestRule {
override fun apply(base: Statement?, description: Description?): Statement {
return MemoryProfilerWatcher().apply(base, description)
}
private inner class MemoryProfilerWatcher : TestWatcher() {
private val runtime = Runtime.getRuntime()
private var before: Long = 0
@esafirm
esafirm / test_checker.rb
Created February 19, 2020 03:08
Script to test check
#!/usr/bin/env ruby
# frozen_string_literal: true
TARGET_DIR = ARGV[0]
@failing_module = []
@no_test_module = []
def fail_number(file_path)
file = IO.read(file_path)
@esafirm
esafirm / puzzler.ipynb
Last active July 19, 2018 06:33
ADB Meetup #4 - Kotlin Puzzler
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@esafirm
esafirm / GagSsl.java
Last active May 7, 2018 19:34 — forked from chalup/GagSsl.java
Get OkHttpClient which ignores all SSL errors.
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public class LruStorage extends LinkedHashMap<String, byte[]>
implements KV.Storage {
private final ExecutorService mService = Executors.newSingleThreadExecutor();
private final KV.Storage mStorage;
private final int mMaxSize;
public LruStorage(KV.Storage storage, int size) {
super(size/2, 0.75f, true);
mStorage = storage;