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
add APIs needed for non legacy NewPipe version
This commit is contained in:
96
src/api-impl/android/os/BaseBundle.java
Normal file
96
src/api-impl/android/os/BaseBundle.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package android.os;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
public class BaseBundle {
|
||||
protected static final String TAG = "Bundle";
|
||||
|
||||
// Invariant - exactly one of mMap / mParcelledData will be null
|
||||
// (except inside a call to unparcel)
|
||||
|
||||
/* package */ ArrayMap<String, Object> mMap = null;
|
||||
|
||||
// Log a message if the value was non-null but not of the expected type
|
||||
void typeWarning(String key, Object value, String className,
|
||||
Object defaultValue, ClassCastException e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Key ");
|
||||
sb.append(key);
|
||||
sb.append(" expected ");
|
||||
sb.append(className);
|
||||
sb.append(" but value was a ");
|
||||
sb.append(value.getClass().getName());
|
||||
sb.append(". The default value ");
|
||||
sb.append(defaultValue);
|
||||
sb.append(" was returned.");
|
||||
Log.w(TAG, sb.toString());
|
||||
Log.w(TAG, "Attempt to cast generated internal exception:", e);
|
||||
}
|
||||
|
||||
void typeWarning(String key, Object value, String className,
|
||||
ClassCastException e) {
|
||||
typeWarning(key, value, className, "<null>", e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mapping of this Bundle is empty, false otherwise.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return mMap.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set containing the Strings used as keys in this Bundle.
|
||||
*
|
||||
* @return a Set of String keys
|
||||
*/
|
||||
public Set<String> keySet() {
|
||||
return mMap.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given key is contained in the mapping
|
||||
* of this Bundle.
|
||||
*
|
||||
* @param key a String key
|
||||
* @return true if the key is part of the mapping, false otherwise
|
||||
*/
|
||||
public boolean containsKey(String key) {
|
||||
return mMap.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or null if
|
||||
* no mapping of the desired type exists for the given key or a null
|
||||
* value is explicitly associated with the key.
|
||||
*
|
||||
* @param key a String, or null
|
||||
* @return a String value, or null
|
||||
*/
|
||||
public String getString(String key) {
|
||||
final Object o = mMap.get(key);
|
||||
try {
|
||||
return (String)o;
|
||||
} catch (ClassCastException e) {
|
||||
typeWarning(key, o, "String", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, or null
|
||||
* @param defaultValue Value to return if key does not exist
|
||||
* @return the String value associated with the given key, or defaultValue
|
||||
* if no valid String object is currently mapped to that key.
|
||||
*/
|
||||
public String getString(String key, String defaultValue) {
|
||||
final String s = getString(key);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
}
|
||||
4
src/api-impl/android/os/BatteryManager.java
Normal file
4
src/api-impl/android/os/BatteryManager.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package android.os;
|
||||
|
||||
public class BatteryManager {
|
||||
}
|
||||
@@ -22,14 +22,12 @@ import android.util.SparseArray;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A mapping from String values to various Parcelable types.
|
||||
*
|
||||
*/
|
||||
public final class Bundle implements Cloneable {
|
||||
private static final String TAG = "Bundle";
|
||||
public final class Bundle extends BaseBundle implements Cloneable {
|
||||
static final boolean DEBUG = false;
|
||||
public static final Bundle EMPTY;
|
||||
|
||||
@@ -40,11 +38,6 @@ public final class Bundle implements Cloneable {
|
||||
EMPTY.mMap = ArrayMap.EMPTY;
|
||||
}
|
||||
|
||||
// Invariant - exactly one of mMap / mParcelledData will be null
|
||||
// (except inside a call to unparcel)
|
||||
|
||||
/* package */ ArrayMap<String, Object> mMap = null;
|
||||
|
||||
/*
|
||||
* If mParcelledData is non-null, then mMap will be null and the
|
||||
* data are stored as a Parcel containing a Bundle. When the data
|
||||
@@ -195,13 +188,6 @@ public final class Bundle implements Cloneable {
|
||||
return mMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mapping of this Bundle is empty, false otherwise.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return mMap.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all elements from the mapping of this Bundle.
|
||||
*/
|
||||
@@ -211,17 +197,6 @@ public final class Bundle implements Cloneable {
|
||||
mFdsKnown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given key is contained in the mapping
|
||||
* of this Bundle.
|
||||
*
|
||||
* @param key a String key
|
||||
* @return true if the key is part of the mapping, false otherwise
|
||||
*/
|
||||
public boolean containsKey(String key) {
|
||||
return mMap.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entry with the given key as an object.
|
||||
*
|
||||
@@ -254,15 +229,6 @@ public final class Bundle implements Cloneable {
|
||||
mFdsKnown = mFdsKnown && map.mFdsKnown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set containing the Strings used as keys in this Bundle.
|
||||
*
|
||||
* @return a Set of String keys
|
||||
*/
|
||||
public Set<String> keySet() {
|
||||
return mMap.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether the bundle contains any parcelled file descriptors.
|
||||
*/
|
||||
@@ -706,28 +672,6 @@ public final class Bundle implements Cloneable {
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
// Log a message if the value was non-null but not of the expected type
|
||||
private void typeWarning(String key, Object value, String className,
|
||||
Object defaultValue, ClassCastException e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Key ");
|
||||
sb.append(key);
|
||||
sb.append(" expected ");
|
||||
sb.append(className);
|
||||
sb.append(" but value was a ");
|
||||
sb.append(value.getClass().getName());
|
||||
sb.append(". The default value ");
|
||||
sb.append(defaultValue);
|
||||
sb.append(" was returned.");
|
||||
Log.w(TAG, sb.toString());
|
||||
Log.w(TAG, "Attempt to cast generated internal exception:", e);
|
||||
}
|
||||
|
||||
private void typeWarning(String key, Object value, String className,
|
||||
ClassCastException e) {
|
||||
typeWarning(key, value, className, "<null>", e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or defaultValue if
|
||||
* no mapping of the desired type exists for the given key.
|
||||
@@ -978,38 +922,6 @@ public final class Bundle implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or null if
|
||||
* no mapping of the desired type exists for the given key or a null
|
||||
* value is explicitly associated with the key.
|
||||
*
|
||||
* @param key a String, or null
|
||||
* @return a String value, or null
|
||||
*/
|
||||
public String getString(String key) {
|
||||
final Object o = mMap.get(key);
|
||||
try {
|
||||
return (String)o;
|
||||
} catch (ClassCastException e) {
|
||||
typeWarning(key, o, "String", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, or null
|
||||
* @param defaultValue Value to return if key does not exist
|
||||
* @return the String value associated with the given key, or defaultValue
|
||||
* if no valid String object is currently mapped to that key.
|
||||
*/
|
||||
public String getString(String key, String defaultValue) {
|
||||
final String s = getString(key);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the given key, or null if
|
||||
* no mapping of the desired type exists for the given key or a null
|
||||
|
||||
@@ -2,4 +2,6 @@ package android.os;
|
||||
|
||||
public interface Parcelable {
|
||||
public static interface Creator<T> {}
|
||||
|
||||
public static interface ClassLoaderCreator<T> extends Creator<T> {}
|
||||
}
|
||||
|
||||
4
src/api-impl/android/os/UserManager.java
Normal file
4
src/api-impl/android/os/UserManager.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package android.os;
|
||||
|
||||
public class UserManager {
|
||||
}
|
||||
Reference in New Issue
Block a user