implement more APIs

This commit is contained in:
Julian Winkler
2024-03-20 23:05:17 +01:00
parent e8dc6e2f0d
commit 494605932c
18 changed files with 119 additions and 36 deletions

View File

@@ -156,4 +156,36 @@ public class BaseBundle {
public int size() {
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 an int value
*/
public int getInt(String key, int defaultValue) {
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Integer)o;
} catch (ClassCastException e) {
typeWarning(key, o, "Integer", defaultValue, e);
return defaultValue;
}
}
/**
* Returns the value associated with the given key, or 0 if
* no mapping of the desired type exists for the given key.
*
* @param key a String
* @return an int value
*/
public int getInt(String key) {
return getInt(key, 0);
}
}

View File

@@ -3,4 +3,6 @@ package android.os;
public class Binder extends IBinder {
public void attachInterface(IInterface owner, String descriptor) {}
public static void flushPendingCommands() {}
}

View File

@@ -752,38 +752,6 @@ public final class Bundle extends BaseBundle implements Cloneable {
}
}
/**
* Returns the value associated with the given key, or 0 if
* no mapping of the desired type exists for the given key.
*
* @param key a String
* @return an int value
*/
public int getInt(String key) {
return getInt(key, 0);
}
/**
* 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 an int value
*/
public int getInt(String key, int defaultValue) {
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Integer)o;
} catch (ClassCastException e) {
typeWarning(key, o, "Integer", defaultValue, e);
return defaultValue;
}
}
/**
* Returns the value associated with the given key, or 0L if
* no mapping of the desired type exists for the given key.

View File

@@ -0,0 +1,11 @@
package android.os;
public class FileObserver {
public FileObserver(String path, int mask) {}
public void startWatching() {}
public void stopWatching() {}
}