You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
116 lines
2.5 KiB
Java
116 lines
2.5 KiB
Java
package android.os;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
public final class StrictMode {
|
|
public static void setThreadPolicy(final ThreadPolicy policy) {}
|
|
public static void setVmPolicy(final VmPolicy policy) {}
|
|
public static ThreadPolicy allowThreadDiskWrites() {
|
|
return new ThreadPolicy();
|
|
}
|
|
public static ThreadPolicy allowThreadDiskReads() {
|
|
return new ThreadPolicy();
|
|
}
|
|
public static ThreadPolicy getThreadPolicy() {
|
|
return new ThreadPolicy();
|
|
}
|
|
|
|
public interface OnThreadViolationListener {
|
|
}
|
|
|
|
public static final class ThreadPolicy {
|
|
final int mask;
|
|
final OnThreadViolationListener listener;
|
|
final Executor callbackExecutor;
|
|
|
|
private ThreadPolicy(int mask, OnThreadViolationListener listener, Executor executor) {
|
|
this.mask = mask;
|
|
this.listener = listener;
|
|
this.callbackExecutor = executor;
|
|
}
|
|
|
|
private ThreadPolicy() {
|
|
this.mask = 0;
|
|
this.listener = new OnThreadViolationListener() {};
|
|
this.callbackExecutor = new Executor() {
|
|
@Override
|
|
public void execute(Runnable command) {}
|
|
};
|
|
}
|
|
|
|
public static final class Builder {
|
|
private int mask = 0;
|
|
private OnThreadViolationListener listener;
|
|
private Executor executor;
|
|
|
|
public Builder() {
|
|
mask = 0;
|
|
}
|
|
|
|
public Builder(ThreadPolicy policy) {
|
|
if(policy != null) {
|
|
mask = policy.mask;
|
|
listener = policy.listener;
|
|
executor = policy.callbackExecutor;
|
|
}
|
|
}
|
|
|
|
public Builder detectAll() {
|
|
return this;
|
|
}
|
|
public Builder detectNetwork() {
|
|
return this;
|
|
}
|
|
public Builder permitDiskReads() {
|
|
return this;
|
|
}
|
|
public Builder permitDiskWrites() {
|
|
return this;
|
|
}
|
|
public Builder detectResourceMismatches() {
|
|
return this;
|
|
}
|
|
public Builder penaltyLog() {
|
|
return this;
|
|
}
|
|
public ThreadPolicy build() {
|
|
return new ThreadPolicy(mask, listener, executor);
|
|
}
|
|
}
|
|
}
|
|
public static final class VmPolicy {
|
|
public static final class Builder {
|
|
public Builder detectActivityLeaks() {
|
|
return this;
|
|
}
|
|
public Builder detectAll() {
|
|
return this;
|
|
}
|
|
public Builder detectLeakedSqlLiteObjects() {
|
|
return this;
|
|
}
|
|
public Builder detectLeakedClosableObjects() {
|
|
return this;
|
|
}
|
|
public Builder detectLeakedRegistrationObjects() {
|
|
return this;
|
|
}
|
|
public Builder detectFileUriExposure() {
|
|
return this;
|
|
}
|
|
public Builder penaltyDeath() {
|
|
return this;
|
|
}
|
|
public Builder penaltyLog() {
|
|
return this;
|
|
}
|
|
public Builder penaltyDropBox() {
|
|
return this;
|
|
}
|
|
public VmPolicy build() {
|
|
return new VmPolicy();
|
|
}
|
|
}
|
|
}
|
|
}
|