diff --git a/src/api-impl/android/app/Activity.java b/src/api-impl/android/app/Activity.java index d76f62ac..e00fd2db 100644 --- a/src/api-impl/android/app/Activity.java +++ b/src/api-impl/android/app/Activity.java @@ -97,6 +97,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback { break; } } + app_label = r.getText(pkg.applicationInfo.labelRes); if (label != null) { setTitle(label); @@ -568,4 +569,6 @@ public class Activity extends ContextThemeWrapper implements Window.Callback { public static native void nativeOpenURI(String uri); public native void nativeFileChooser(int action, String type, String title, int requestCode); public void reportFullyDrawn() {} + public void setVisible(boolean visible) {} + public Uri getReferrer() { return null; } } diff --git a/src/api-impl/android/app/ActivityManager.java b/src/api-impl/android/app/ActivityManager.java index ff0ada83..93f4ce6d 100644 --- a/src/api-impl/android/app/ActivityManager.java +++ b/src/api-impl/android/app/ActivityManager.java @@ -2,7 +2,11 @@ package android.app; import android.content.pm.ConfigurationInfo; import android.graphics.Bitmap; +import android.os.IBinder; +import android.os.Parcel; +import android.os.Parcelable; +import java.util.ArrayList; import java.util.List; public class ActivityManager { @@ -46,4 +50,32 @@ public class ActivityManager { public static void getMyMemoryState(RunningAppProcessInfo outInfo) {} public boolean clearApplicationUserData() {return false;} + + public static class AppTask {} + public List getAppTasks() { + return new ArrayList<>(); + } + + public static class RunningServiceInfo implements Parcelable { + public RunningServiceInfo() { + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + return; + } + + public void readFromParcel(Parcel source) { + return; + } + } + + + public List getRunningServices(int maxNum) + throws SecurityException { + return new ArrayList<>(); + } } diff --git a/src/api-impl/android/bluetooth/BluetoothManager.java b/src/api-impl/android/bluetooth/BluetoothManager.java index 3188cfbe..1ee1aeab 100644 --- a/src/api-impl/android/bluetooth/BluetoothManager.java +++ b/src/api-impl/android/bluetooth/BluetoothManager.java @@ -1,4 +1,7 @@ package android.bluetooth; public class BluetoothManager { + public BluetoothAdapter getAdapter(){ + return new BluetoothAdapter(); + } } diff --git a/src/api-impl/android/content/Context.java b/src/api-impl/android/content/Context.java index 62bca927..96c7d4e4 100644 --- a/src/api-impl/android/content/Context.java +++ b/src/api-impl/android/content/Context.java @@ -10,6 +10,7 @@ import android.app.NotificationManager; import android.app.Service; import android.app.SharedPreferencesImpl; import android.app.UiModeManager; +import android.bluetooth.BluetoothManager; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageParser; @@ -104,7 +105,13 @@ public class Context extends Object { application_info = new ApplicationInfo(); try (XmlResourceParser parser = assets.openXmlResourceParser("AndroidManifest.xml")) { PackageParser packageParser = new PackageParser(native_get_apk_path()); - pkg = packageParser.parsePackage(r, parser, 0, new String[1]); + String[] parseError = new String[1]; + pkg = packageParser.parsePackage(r, parser, 0, parseError); + if (parseError[0] != null) { + Slog.e(TAG, parseError[0]); + System.exit(1); + } + packageParser.collectCertificates(pkg, 0); application_info = pkg.applicationInfo; } catch (Exception e) { @@ -212,12 +219,18 @@ public class Context extends Object { return new LayoutInflater(getApplicationContext()); case "wifi": return new WifiManager(); + case "bluetooth": + return new BluetoothManager(); default: Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet"); return null; } } + public final T getSystemService(Class serviceClass) { + return null; + } + public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { receiverMap.put(filter, receiver); return new Intent(); diff --git a/src/api-impl/android/content/Intent.java b/src/api-impl/android/content/Intent.java index d791a29e..70363a34 100644 --- a/src/api-impl/android/content/Intent.java +++ b/src/api-impl/android/content/Intent.java @@ -342,4 +342,9 @@ public class Intent implements Parcelable { return new ShortcutIconResource(); } } + + public void setExtrasClassLoader(ClassLoader loader) {} + public Intent setClassName(Context packageContext, String className) { + return this; + } } diff --git a/src/api-impl/android/content/pm/PackageInfo.java b/src/api-impl/android/content/pm/PackageInfo.java index dbb094f5..edcc029d 100644 --- a/src/api-impl/android/content/pm/PackageInfo.java +++ b/src/api-impl/android/content/pm/PackageInfo.java @@ -28,6 +28,11 @@ public class PackageInfo { */ public String packageName = "com.example.app"; // FIXME + /** + * The names of any installed split APKs for this package. + */ + public String[] splitNames; + /** * The version number of this package, as specified by the <manifest> * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode} diff --git a/src/api-impl/android/content/res/Resources.java b/src/api-impl/android/content/res/Resources.java index 6fb7f400..1fe223ef 100644 --- a/src/api-impl/android/content/res/Resources.java +++ b/src/api-impl/android/content/res/Resources.java @@ -831,6 +831,11 @@ public class Resources { return csl.getDefaultColor(); } + public int getColor(int id, Theme theme) throws NotFoundException { + // TODO fix it + return 0; + } + /** * Return a color state list associated with a particular resource ID. The * resource may contain either a single raw color value, or a complex @@ -1594,7 +1599,7 @@ public class Resources { mConfiguration.smallestScreenWidthDp, mConfiguration.screenWidthDp, mConfiguration.screenHeightDp, mConfiguration.screenLayout, mConfiguration.uiMode, - 24); + 25); if (DEBUG_CONFIG) { Slog.i(TAG, "**** Updating config of " + this + ": final config is " + mConfiguration + " final compat is " + mCompatibilityInfo); @@ -2310,50 +2315,50 @@ public class Resources { throw new RuntimeException(e); } /* if (id != 0) { - try { - // These may be compiled... - synchronized (mCachedXmlBlockIds) { - // First see if this block is in our cache. - final int num = mCachedXmlBlockIds.length; - for (int i=0; i= num) pos = 0; + mLastCachedXmlBlockIndex = pos; + XmlBlock oldBlock = mCachedXmlBlocks[pos]; + if (oldBlock != null) { + oldBlock.close(); + } + mCachedXmlBlockIds[pos] = id; + mCachedXmlBlocks[pos] = block; + //System.out.println("**** CACHING NEW XML BLOCK! id=" + // + id + ", index=" + pos); + return block.newParser(); + } + } + } catch (Exception e) { + NotFoundException rnf = new NotFoundException( + "File " + file + " from xml type " + type + " resource ID #0x" + + Integer.toHexString(id)); + rnf.initCause(e); + throw rnf; + } + } - throw new NotFoundException( - "File " + file + " from xml type " + type + " resource ID #0x" - + Integer.toHexString(id)); + throw new NotFoundException( + "File " + file + " from xml type " + type + " resource ID #0x" + + Integer.toHexString(id)); */ } private TypedArray getCachedStyledAttributes(int len) { diff --git a/src/api-impl/android/graphics/LinearGradient.java b/src/api-impl/android/graphics/LinearGradient.java index 42e112cc..ae614a96 100644 --- a/src/api-impl/android/graphics/LinearGradient.java +++ b/src/api-impl/android/graphics/LinearGradient.java @@ -3,4 +3,6 @@ package android.graphics; public class LinearGradient extends Shader { public LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions, TileMode mode) {} + public LinearGradient(float x0, float y0, float x1, float y1, long[] colors, float[] positions, TileMode tile) {} + public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, TileMode tile) {} } diff --git a/src/api-impl/android/graphics/Paint.java b/src/api-impl/android/graphics/Paint.java index e1275f7c..ebf6bc1c 100644 --- a/src/api-impl/android/graphics/Paint.java +++ b/src/api-impl/android/graphics/Paint.java @@ -68,6 +68,10 @@ public class Paint { } public void getTextBounds(String text, int start, int end, Rect bounds) {} public void getTextBounds(char[] text, int index, int count, Rect bounds) {} + public int getTextWidths(String text, int start, int end, float[] widths) { + // TODO fix it + return 0; + } public void setFilterBitmap(boolean filter) {} public void setFlags(int flags) { diff --git a/src/api-impl/android/graphics/Typeface.java b/src/api-impl/android/graphics/Typeface.java index 153648ba..71838c94 100644 --- a/src/api-impl/android/graphics/Typeface.java +++ b/src/api-impl/android/graphics/Typeface.java @@ -50,6 +50,10 @@ public class Typeface { return typeface; } + public static Typeface createFromFile(String path) { + return DEFAULT; + } + private static native long native_create(CharSequence family_name, int style); public int getStyle() { diff --git a/src/api-impl/android/os/BaseBundle.java b/src/api-impl/android/os/BaseBundle.java index bfa1989c..40969453 100644 --- a/src/api-impl/android/os/BaseBundle.java +++ b/src/api-impl/android/os/BaseBundle.java @@ -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. diff --git a/src/api-impl/android/os/Bundle.java b/src/api-impl/android/os/Bundle.java index ef37b21e..0ce6ea09 100644 --- a/src/api-impl/android/os/Bundle.java +++ b/src/api-impl/android/os/Bundle.java @@ -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. diff --git a/src/api-impl/android/os/StrictMode.java b/src/api-impl/android/os/StrictMode.java index 25cb8637..074f271c 100644 --- a/src/api-impl/android/os/StrictMode.java +++ b/src/api-impl/android/os/StrictMode.java @@ -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); } } } diff --git a/src/api-impl/android/text/Html.java b/src/api-impl/android/text/Html.java index 1414f06f..d0a80983 100644 --- a/src/api-impl/android/text/Html.java +++ b/src/api-impl/android/text/Html.java @@ -1,5 +1,7 @@ package android.text; +import org.xml.sax.XMLReader; + import android.graphics.drawable.Drawable; public class Html { @@ -29,4 +31,12 @@ public class Html { } return out.toString(); } + + public static interface TagHandler { + /** + * This method will be called whenn the HTML parser encounters + * a tag that it does not know how to interpret. + */ + public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader); + } }