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

@@ -113,6 +113,8 @@ void activity_close_all(void)
g_list_free(activities);
}
static jobject activity_not_created = NULL;
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
{
/* -- run the activity's onCreate -- */
@@ -120,6 +122,12 @@ void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
if((*env)->ExceptionCheck(env))
(*env)->ExceptionDescribe(env);
if ((*env)->IsSameObject(env, activity_object, activity_not_created)) { // finish() was called before the activity was created
_UNREF(activity_not_created);
activity_not_created = NULL;
return;
}
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
else
@@ -146,9 +154,12 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobje
}
}
activity_update_current(env);
activity_close(env, this);
if (removed_activity)
if (removed_activity) {
activity_close(env, removed_activity);
_UNREF(removed_activity);
} else {
activity_not_created = _REF(this);
}
if (activity_backlog == NULL && window)
gtk_window_close(GTK_WINDOW(_PTR(window)));
}

View File

@@ -190,6 +190,8 @@ JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1mapPoints(JNIEnv *en
dst[dst_idx + i * 2] = res.x;
dst[dst_idx + i * 2 + 1] = res.y;
}
(*env)->ReleaseFloatArrayElements(env, src_ref, src, 0);
(*env)->ReleaseFloatArrayElements(env, dst_ref, dst, 0);
}
JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setTranslate(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
@@ -213,3 +215,12 @@ JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1invert(JNIEnv *e
{
return graphene_matrix_inverse((graphene_matrix_t *)_PTR(matrix_ptr), (graphene_matrix_t *)_PTR(inverse_ptr));
}
JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1preScale__JFF(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
{
graphene_matrix_t *matrix = (graphene_matrix_t *)_PTR(matrix_ptr);
graphene_matrix_t scale;
graphene_matrix_init_scale(&scale, x, y, 1);
graphene_matrix_multiply(&scale, matrix, matrix);
return true;
}

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();
}
}

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