implement some APIs needed for OctoDroid

This commit is contained in:
Julian Winkler
2024-03-29 23:56:28 +01:00
parent 0352a307b9
commit 2f4cd3917f
36 changed files with 329 additions and 25 deletions

View File

@@ -18,5 +18,13 @@ public class Animator {
public void addListener(AnimatorListener listener) {
this.listener = listener;
}
public void cancel() {}
public long getStartDelay() { return 0; }
public long getDuration() { return 0; }
public Animator setDuration(long duration) { return this; }
}

View File

@@ -1,5 +1,7 @@
package android.animation;
import java.util.Collection;
public class AnimatorSet extends Animator {
public class Builder {
@@ -17,4 +19,14 @@ public class AnimatorSet extends Animator {
public void playSequentially(Animator[] animators) {}
public boolean isStarted() {
return false;
}
public void playTogether(Collection<Animator> animators) {}
public AnimatorSet setDuration(long duration) { return this; }
public void playTogether(Animator[] animators) {}
}

View File

@@ -16,6 +16,10 @@ public class ObjectAnimator extends ValueAnimator {
return new ObjectAnimator();
}
public static <T> ObjectAnimator ofInt(T target, String propertyName, int... values) {
return new ObjectAnimator();
}
public ObjectAnimator setDuration(long duration) {return this;}
public void setAutoCancel(boolean autoCancel) {}

View File

@@ -12,6 +12,10 @@ public class ValueAnimator extends Animator {
return new ValueAnimator();
}
public static ValueAnimator ofInt(int... values) {
return new ValueAnimator();
}
public ValueAnimator setDuration(long duration) {
return this;
}
@@ -38,6 +42,7 @@ public class ValueAnimator extends Animator {
public void setRepeatCount(int value) {}
public void setRepeatMode(int value) {}
public void cancel() {}
public void setEvaluator(TypeEvaluator evaluator) {}
/**
* Implementors of this interface can add themselves as update listeners

View File

@@ -62,13 +62,18 @@ public class Dialog implements Window.Callback, DialogInterface {
public void show() {
System.out.println("showing the Dialog " + this);
new Handler(Looper.getMainLooper()).post(new Runnable() {
Runnable action = new Runnable() {
@Override
public void run() {
onCreate(null);
nativeShow(nativePtr);
}
});
};
if(Looper.myLooper() == Looper.getMainLooper()) {
action.run();
} else {
new Handler(Looper.getMainLooper()).post(action);
}
}
public boolean isShowing() {
@@ -142,4 +147,9 @@ public class Dialog implements Window.Callback, DialogInterface {
System.out.println("hiding the Dialog " + this);
nativeClose(nativePtr);
}
@Override
public void cancel() {
dismiss();
}
}

View File

@@ -7,6 +7,7 @@ import android.database.AbstractCursor;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
public class ContentResolver {
@@ -39,4 +40,8 @@ public class ContentResolver {
public boolean isNull(int column) { throw new IndexOutOfBoundsException(); }
};
}
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
return query(uri, projection, selection, selectionArgs, sortOrder);
}
}

View File

@@ -26,6 +26,7 @@ import android.media.MediaRouter;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
@@ -443,6 +444,10 @@ public class Context extends Object {
}
}
public void startActivity(Intent intent, Bundle options) {
startActivity(intent);
}
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) {
return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
}

View File

@@ -10,6 +10,8 @@ public interface DialogInterface {
public void dismiss();
public void cancel();
public interface OnDismissListener {
void onDismiss(DialogInterface dialog);
}

View File

@@ -35,6 +35,7 @@ import android.util.DisplayMetrics;
import android.util.Slog;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
@@ -2226,7 +2227,9 @@ public class PackageManager {
*/
public List<ResolveInfo> queryIntentActivities(Intent intent,
int flags) {
return new ArrayList<ResolveInfo>();
ResolveInfo info = new ResolveInfo();
info.activityInfo.exported = true;
return Arrays.asList(info);
}
/**

View File

@@ -2,4 +2,10 @@ package android.content.pm;
public class ResolveInfo {
public ActivityInfo activityInfo = new ActivityInfo();
public static class DisplayNameComparator {
public DisplayNameComparator(PackageManager pm) {}
}
}

View File

@@ -0,0 +1,8 @@
package android.graphics;
public class BitmapShader extends Shader {
public BitmapShader(Bitmap bitmap, TileMode tileX, TileMode tileY) {}
public void setLocalMatrix(Matrix matrix) {}
}

View File

@@ -402,6 +402,20 @@ public class Canvas {
public void drawCircle(float cx, float cy, float radius, Paint paint) {}
public Rect getClipBounds() {
return new Rect(0, 0, 10, 10);
}
public boolean clipRect(Rect rect, Region.Op op) {
return false;
}
public void concat(Matrix matrix) {}
public boolean clipPath(Path path, Region.Op op) {
return false;
}
private static native long native_canvas_from_bitmap(long pixbuf);
private static native void native_save(long skia_canvas, long widget);

View File

@@ -0,0 +1,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) {}
}

View File

@@ -209,6 +209,12 @@ public class Paint {
private Join(int nativeInt) {}
}
public enum Align {
CENTER,
LEFT,
RIGHT,
}
public void setStrokeCap(Cap cap) {}
public void setStrokeJoin(Join join) {}
@@ -217,6 +223,12 @@ public class Paint {
return new Typeface();
}
public void setTextAlign(Align align) {}
public Shader getShader() {
return new Shader();
}
private native long native_constructor();
private native void native_set_color(long skia_paint, int color);
private native int native_get_color(long skia_paint);

View File

@@ -0,0 +1,6 @@
package android.graphics;
public class RadialGradient extends Shader {
public RadialGradient(float x, float y, float radius, int[] colors, float[] positions, android.graphics.Shader.TileMode tileMode) {}
}

View File

@@ -1,5 +1,11 @@
package android.graphics;
public class Shader {
public enum TileMode {
CLAMP,
MIRROR,
REPEAT
}
}

View File

@@ -60,7 +60,10 @@ public class Drawable {
}
public void setBounds(int left, int top, int right, int bottom) {
boolean changed = left != mBounds.left || top != mBounds.top || right != mBounds.right || bottom != mBounds.bottom;
mBounds.set(left, top, right, bottom);
if (changed)
onBoundsChange(mBounds);
}
public final Rect getBounds() {
@@ -206,6 +209,8 @@ public class Drawable {
bounds.set(mBounds);
}
protected void onBoundsChange(Rect bounds) {}
protected static native long native_paintable_from_path(String path);
protected native long native_constructor();
}

View File

@@ -1,4 +1,10 @@
package android.graphics.drawable.shapes;
import android.graphics.RectF;
public class Shape {
protected RectF rect() {
return new RectF();
}
}

View File

@@ -20,7 +20,7 @@ public class Uri implements Parcelable {
public static Uri parse(String s) {
Uri ret = new Uri();
try {
ret.uri = URI.create(s);
ret.uri = URI.create(s.trim());
} catch (IllegalArgumentException e) {
}
return ret;
@@ -145,15 +145,22 @@ public class Uri implements Parcelable {
}
public Builder buildUpon() {
return new Builder();
Builder builder = new Builder();
builder.scheme = getScheme();
builder.authority = getAuthority();
builder.path = getPath();
builder.query = uri.getQuery();
return builder;
}
public static final class Builder {
private String scheme;
private String authority;
private String path;
private String query;
public Builder appendQueryParameter(String key, String value) {
this.query = (this.query != null ? this.query + "&" : "") + key + "=" + value;
return this;
}
@@ -172,6 +179,11 @@ public class Uri implements Parcelable {
return this;
}
public Builder appendPath(String path) {
this.path = (this.path != null ? this.path : "") + "/" + path;
return this;
}
public Uri build() throws URISyntaxException {
if ("content".equals(scheme)) { // hack: content providers not yet supported
scheme = "file";
@@ -179,9 +191,17 @@ public class Uri implements Parcelable {
path = path.substring(path.indexOf("/"));
}
Uri ret = new Uri();
ret.uri = new URI(scheme, authority, path, null, null);
ret.uri = new URI(scheme, authority, path, query, null);
return ret;
}
public String toString() {
try {
return build().toString();
} catch (URISyntaxException e) {
return super.toString();
}
}
}
public String getScheme() {
@@ -211,4 +231,13 @@ public class Uri implements Parcelable {
String[] segments = uri.getPath().split("/");
return segments[segments.length - 1];
}
public String getQueryParameter(String key) {
for (String pair : uri.getQuery().split("&")) {
if (pair.startsWith(key + "=")) {
return pair.substring(key.length() + 1);
}
}
return null;
}
}

View File

@@ -0,0 +1,3 @@
package android.provider;
public interface BaseColumns {}

Some files were not shown because too many files have changed in this diff Show More