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
api-impl: misc stubs and fixes for Spotify
This commit is contained in:
@@ -7,6 +7,7 @@ import android.util.Log;
|
||||
|
||||
public class BaseBundle {
|
||||
protected static final String TAG = "Bundle";
|
||||
static final boolean DEBUG = false;
|
||||
|
||||
// Invariant - exactly one of mMap / mParcelledData will be null
|
||||
// (except inside a call to unparcel)
|
||||
@@ -198,6 +199,57 @@ public class BaseBundle {
|
||||
return mMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or defaultValue if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
*
|
||||
* @param key a String
|
||||
* @param defaultValue Value to return if key does not exist
|
||||
* @return a boolean value
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
Object o = mMap.get(key);
|
||||
System.out.println("bundle.getBoolean(" + key + ", " + defaultValue + ") called");
|
||||
/* the default for this is very scummy */
|
||||
if(key.equals("com.facebook.sdk.AutoLogAppEventsEnabled")) {
|
||||
return false;
|
||||
}
|
||||
if (o == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return (Boolean)o;
|
||||
} catch (ClassCastException e) {
|
||||
typeWarning(key, o, "Boolean", defaultValue, e);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or false if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
*
|
||||
* @param key a String
|
||||
* @return a boolean value
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
if (DEBUG)
|
||||
Log.d(TAG, "Getting boolean in " + Integer.toHexString(System.identityHashCode(this)));
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a Boolean value into the mapping of this Bundle, replacing
|
||||
* any existing value for the given key. Either key or value may be null.
|
||||
*
|
||||
* @param key a String, or null
|
||||
* @param value a Boolean, or null
|
||||
*/
|
||||
public void putBoolean(String key, boolean value) {
|
||||
mMap.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or defaultValue if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
|
||||
@@ -262,17 +262,6 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a Boolean value into the mapping of this Bundle, replacing
|
||||
* any existing value for the given key. Either key or value may be null.
|
||||
*
|
||||
* @param key a String, or null
|
||||
* @param value a Boolean, or null
|
||||
*/
|
||||
public void putBoolean(String key, boolean value) {
|
||||
mMap.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a byte value into the mapping of this Bundle, replacing
|
||||
* any existing value for the given key.
|
||||
@@ -587,45 +576,6 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
|
||||
mMap.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or false if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
*
|
||||
* @param key a String
|
||||
* @return a boolean value
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
if (DEBUG)
|
||||
Log.d(TAG, "Getting boolean in " + Integer.toHexString(System.identityHashCode(this)));
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or defaultValue if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
*
|
||||
* @param key a String
|
||||
* @param defaultValue Value to return if key does not exist
|
||||
* @return a boolean value
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
Object o = mMap.get(key);
|
||||
System.out.println("bundle.getBoolean(" + key + ", " + defaultValue + ") called");
|
||||
/* the default for this is very scummy */
|
||||
if(key.equals("com.facebook.sdk.AutoLogAppEventsEnabled")) {
|
||||
return false;
|
||||
}
|
||||
if (o == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return (Boolean)o;
|
||||
} catch (ClassCastException e) {
|
||||
typeWarning(key, o, "Boolean", defaultValue, e);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or (byte) 0 if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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) {}
|
||||
@@ -9,9 +11,50 @@ public final class StrictMode {
|
||||
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;
|
||||
}
|
||||
@@ -24,11 +67,14 @@ public final class StrictMode {
|
||||
public Builder permitDiskWrites() {
|
||||
return this;
|
||||
}
|
||||
public Builder detectResourceMismatches() {
|
||||
return this;
|
||||
}
|
||||
public Builder penaltyLog() {
|
||||
return this;
|
||||
}
|
||||
public ThreadPolicy build() {
|
||||
return new ThreadPolicy();
|
||||
return new ThreadPolicy(mask, listener, executor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user