Skip to content

Instantly share code, notes, and snippets.

if (!CpuInfo.locked && isSustainedPerformanceModeSupported()) {
sustainedPerformanceModeInUse = true
}
private val activityLifecycleCallbacks = object : Application.ActivityLifecycleCallbacks {
@SuppressLint("NewApi") // window API guarded by [isSustainedPerformanceModeSupported]
override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
if (sustainedPerformanceModeInUse) {
activity.window.setSustainedPerformanceMode(true)
}
val dest = "/data/local/tmp/lockClocks.sh"
val source = javaClass.classLoader.getResource("scripts/lockClocks.sh")
val tmpSource = Files.createTempFile("lockClocks.sh", null).toString()
Files.copy(
source.openStream(),
Paths.get(tmpSource),
StandardCopyOption.REPLACE_EXISTING
)
adb.execSync("push $tmpSource $dest")
open class AndroidBenchmarkRunner : AndroidJUnitRunner() {
@CallSuper
override fun waitForActivitiesToComplete() {
// We don't call the super method here, since we have
// an activity we intend to persist between tests
// TODO: somehow wait for every activity but IsolationActivity
// Before/After each test, from the test thread, synchronously launch
// our IsolationActivity if it's not already resumed
package com.github.yangweigbh.traceana;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;
import java.util.concurrent.ConcurrentHashMap;
public class ThreadWatcher {
@yangweigbh
yangweigbh / SkipList.kt
Created July 14, 2017 10:07
SkipList Implemented in Kotlin
import java.util.*
/**
* Created by yangwei-ms on 2017/7/14.
*/
class SkipList<T>(private val comparator: Comparator<T>) {
private var curHeight: Int = 1
private val head: Node<T> = Node(null, MAX_HEIGHT)
private val rnd: Random = Random(System.currentTimeMillis())
@yangweigbh
yangweigbh / NetworkEventProvider.java
Last active January 18, 2021 10:35
Class to listen to network change
public interface NetworkEventProvider {
void setListener(Listener listener);
interface Listener {
/**
* @param networkStatus {@link com.birbit.android.jobqueue.network.NetworkUtil.NetworkStatus}
*/
void onNetworkChange(@NetworkUtil.NetworkStatus int networkStatus);
}
}