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
implement some stuff to make exaple SDL app run
NOTE: the main addition in this commit is WIP support for apps which render on an EGL surface obtained using ANativeWindow_fromSurface currently, this EGL surface is obtained by creating a 700x700 pixel window with GLFW (the 700x700 size is hardcoded in several places) and only Wayland is supported ideally, we'd want to use a wayland subsurface to position the EGL surface above the Surface widget it's associated with (and do whatever for X11)
This commit is contained in:
12
meson.build
12
meson.build
@@ -33,6 +33,7 @@ libtranslationlayer_so = shared_library('translation_layer_main', [
|
||||
'src/api-impl-jni/widgets/WrapperWidget.c',
|
||||
'src/api-impl-jni/widgets/android_widget_TextView.c',
|
||||
'src/api-impl-jni/widgets/android_widget_LinearLayout.c',
|
||||
'src/api-impl-jni/widgets/android_view_SurfaceView.c',
|
||||
'src/api-impl-jni/views/android_view_View.c',
|
||||
'src/api-impl-jni/views/android_view_ViewGroup.c',
|
||||
'src/api-impl-jni/android_graphics_Bitmap.c'
|
||||
@@ -60,11 +61,18 @@ executable('android-translation-layer', [
|
||||
|
||||
# libandroid
|
||||
shared_library('android', [
|
||||
'src/libandroid/asset_manager.c',
|
||||
'src/libandroid/media.c',
|
||||
'src/libandroid/misc.c',
|
||||
'src/libandroid/asset_manager.c'
|
||||
'src/libandroid/native_window.c',
|
||||
'src/libandroid/sensor.c',
|
||||
'src/libandroid/looper.c'
|
||||
],
|
||||
install: true,
|
||||
soversion: 0,)
|
||||
soversion: 0,
|
||||
dependencies: [
|
||||
dependency('gtk4'), dependency('jni'), dependency('glfw3')
|
||||
])
|
||||
|
||||
# hax_arsc_parser.dex (named as classes2.dex so it works inside a jar)
|
||||
subdir('src/arsc_parser')
|
||||
|
||||
163
src/api-impl-jni/generated_headers/android_view_SurfaceView.h
Normal file
163
src/api-impl-jni/generated_headers/android_view_SurfaceView.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class android_view_SurfaceView */
|
||||
|
||||
#ifndef _Included_android_view_SurfaceView
|
||||
#define _Included_android_view_SurfaceView
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef android_view_SurfaceView_NO_ID
|
||||
#define android_view_SurfaceView_NO_ID -1L
|
||||
#undef android_view_SurfaceView_NOT_FOCUSABLE
|
||||
#define android_view_SurfaceView_NOT_FOCUSABLE 0L
|
||||
#undef android_view_SurfaceView_FOCUSABLE
|
||||
#define android_view_SurfaceView_FOCUSABLE 1L
|
||||
#undef android_view_SurfaceView_FOCUSABLE_MASK
|
||||
#define android_view_SurfaceView_FOCUSABLE_MASK 1L
|
||||
#undef android_view_SurfaceView_FITS_SYSTEM_WINDOWS
|
||||
#define android_view_SurfaceView_FITS_SYSTEM_WINDOWS 2L
|
||||
#undef android_view_SurfaceView_VISIBLE
|
||||
#define android_view_SurfaceView_VISIBLE 0L
|
||||
#undef android_view_SurfaceView_INVISIBLE
|
||||
#define android_view_SurfaceView_INVISIBLE 4L
|
||||
#undef android_view_SurfaceView_GONE
|
||||
#define android_view_SurfaceView_GONE 8L
|
||||
#undef android_view_SurfaceView_VISIBILITY_MASK
|
||||
#define android_view_SurfaceView_VISIBILITY_MASK 12L
|
||||
#undef android_view_SurfaceView_ENABLED
|
||||
#define android_view_SurfaceView_ENABLED 0L
|
||||
#undef android_view_SurfaceView_DISABLED
|
||||
#define android_view_SurfaceView_DISABLED 32L
|
||||
#undef android_view_SurfaceView_ENABLED_MASK
|
||||
#define android_view_SurfaceView_ENABLED_MASK 32L
|
||||
#undef android_view_SurfaceView_WILL_NOT_DRAW
|
||||
#define android_view_SurfaceView_WILL_NOT_DRAW 128L
|
||||
#undef android_view_SurfaceView_DRAW_MASK
|
||||
#define android_view_SurfaceView_DRAW_MASK 128L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_NONE
|
||||
#define android_view_SurfaceView_SCROLLBARS_NONE 0L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_HORIZONTAL
|
||||
#define android_view_SurfaceView_SCROLLBARS_HORIZONTAL 256L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_VERTICAL
|
||||
#define android_view_SurfaceView_SCROLLBARS_VERTICAL 512L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_MASK
|
||||
#define android_view_SurfaceView_SCROLLBARS_MASK 768L
|
||||
#undef android_view_SurfaceView_FILTER_TOUCHES_WHEN_OBSCURED
|
||||
#define android_view_SurfaceView_FILTER_TOUCHES_WHEN_OBSCURED 1024L
|
||||
#undef android_view_SurfaceView_OPTIONAL_FITS_SYSTEM_WINDOWS
|
||||
#define android_view_SurfaceView_OPTIONAL_FITS_SYSTEM_WINDOWS 2048L
|
||||
#undef android_view_SurfaceView_FADING_EDGE_NONE
|
||||
#define android_view_SurfaceView_FADING_EDGE_NONE 0L
|
||||
#undef android_view_SurfaceView_FADING_EDGE_HORIZONTAL
|
||||
#define android_view_SurfaceView_FADING_EDGE_HORIZONTAL 4096L
|
||||
#undef android_view_SurfaceView_FADING_EDGE_VERTICAL
|
||||
#define android_view_SurfaceView_FADING_EDGE_VERTICAL 8192L
|
||||
#undef android_view_SurfaceView_FADING_EDGE_MASK
|
||||
#define android_view_SurfaceView_FADING_EDGE_MASK 12288L
|
||||
#undef android_view_SurfaceView_CLICKABLE
|
||||
#define android_view_SurfaceView_CLICKABLE 16384L
|
||||
#undef android_view_SurfaceView_DRAWING_CACHE_ENABLED
|
||||
#define android_view_SurfaceView_DRAWING_CACHE_ENABLED 32768L
|
||||
#undef android_view_SurfaceView_SAVE_DISABLED
|
||||
#define android_view_SurfaceView_SAVE_DISABLED 65536L
|
||||
#undef android_view_SurfaceView_SAVE_DISABLED_MASK
|
||||
#define android_view_SurfaceView_SAVE_DISABLED_MASK 65536L
|
||||
#undef android_view_SurfaceView_WILL_NOT_CACHE_DRAWING
|
||||
#define android_view_SurfaceView_WILL_NOT_CACHE_DRAWING 131072L
|
||||
#undef android_view_SurfaceView_FOCUSABLE_IN_TOUCH_MODE
|
||||
#define android_view_SurfaceView_FOCUSABLE_IN_TOUCH_MODE 262144L
|
||||
#undef android_view_SurfaceView_DRAWING_CACHE_QUALITY_LOW
|
||||
#define android_view_SurfaceView_DRAWING_CACHE_QUALITY_LOW 524288L
|
||||
#undef android_view_SurfaceView_DRAWING_CACHE_QUALITY_HIGH
|
||||
#define android_view_SurfaceView_DRAWING_CACHE_QUALITY_HIGH 1048576L
|
||||
#undef android_view_SurfaceView_DRAWING_CACHE_QUALITY_AUTO
|
||||
#define android_view_SurfaceView_DRAWING_CACHE_QUALITY_AUTO 0L
|
||||
#undef android_view_SurfaceView_DRAWING_CACHE_QUALITY_MASK
|
||||
#define android_view_SurfaceView_DRAWING_CACHE_QUALITY_MASK 1572864L
|
||||
#undef android_view_SurfaceView_LONG_CLICKABLE
|
||||
#define android_view_SurfaceView_LONG_CLICKABLE 2097152L
|
||||
#undef android_view_SurfaceView_DUPLICATE_PARENT_STATE
|
||||
#define android_view_SurfaceView_DUPLICATE_PARENT_STATE 4194304L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_INSIDE_OVERLAY
|
||||
#define android_view_SurfaceView_SCROLLBARS_INSIDE_OVERLAY 0L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_INSIDE_INSET
|
||||
#define android_view_SurfaceView_SCROLLBARS_INSIDE_INSET 16777216L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_OUTSIDE_OVERLAY
|
||||
#define android_view_SurfaceView_SCROLLBARS_OUTSIDE_OVERLAY 33554432L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_OUTSIDE_INSET
|
||||
#define android_view_SurfaceView_SCROLLBARS_OUTSIDE_INSET 50331648L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_INSET_MASK
|
||||
#define android_view_SurfaceView_SCROLLBARS_INSET_MASK 16777216L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_OUTSIDE_MASK
|
||||
#define android_view_SurfaceView_SCROLLBARS_OUTSIDE_MASK 33554432L
|
||||
#undef android_view_SurfaceView_SCROLLBARS_STYLE_MASK
|
||||
#define android_view_SurfaceView_SCROLLBARS_STYLE_MASK 50331648L
|
||||
#undef android_view_SurfaceView_KEEP_SCREEN_ON
|
||||
#define android_view_SurfaceView_KEEP_SCREEN_ON 67108864L
|
||||
#undef android_view_SurfaceView_SOUND_EFFECTS_ENABLED
|
||||
#define android_view_SurfaceView_SOUND_EFFECTS_ENABLED 134217728L
|
||||
#undef android_view_SurfaceView_HAPTIC_FEEDBACK_ENABLED
|
||||
#define android_view_SurfaceView_HAPTIC_FEEDBACK_ENABLED 268435456L
|
||||
#undef android_view_SurfaceView_PARENT_SAVE_DISABLED
|
||||
#define android_view_SurfaceView_PARENT_SAVE_DISABLED 536870912L
|
||||
#undef android_view_SurfaceView_PARENT_SAVE_DISABLED_MASK
|
||||
#define android_view_SurfaceView_PARENT_SAVE_DISABLED_MASK 536870912L
|
||||
#undef android_view_SurfaceView_FOCUSABLES_ALL
|
||||
#define android_view_SurfaceView_FOCUSABLES_ALL 0L
|
||||
#undef android_view_SurfaceView_FOCUSABLES_TOUCH_MODE
|
||||
#define android_view_SurfaceView_FOCUSABLES_TOUCH_MODE 1L
|
||||
#undef android_view_SurfaceView_FOCUS_BACKWARD
|
||||
#define android_view_SurfaceView_FOCUS_BACKWARD 1L
|
||||
#undef android_view_SurfaceView_FOCUS_FORWARD
|
||||
#define android_view_SurfaceView_FOCUS_FORWARD 2L
|
||||
#undef android_view_SurfaceView_FOCUS_LEFT
|
||||
#define android_view_SurfaceView_FOCUS_LEFT 17L
|
||||
#undef android_view_SurfaceView_FOCUS_UP
|
||||
#define android_view_SurfaceView_FOCUS_UP 33L
|
||||
#undef android_view_SurfaceView_FOCUS_RIGHT
|
||||
#define android_view_SurfaceView_FOCUS_RIGHT 66L
|
||||
#undef android_view_SurfaceView_FOCUS_DOWN
|
||||
#define android_view_SurfaceView_FOCUS_DOWN 130L
|
||||
#undef android_view_SurfaceView_MEASURED_SIZE_MASK
|
||||
#define android_view_SurfaceView_MEASURED_SIZE_MASK 16777215L
|
||||
#undef android_view_SurfaceView_MEASURED_STATE_MASK
|
||||
#define android_view_SurfaceView_MEASURED_STATE_MASK -16777216L
|
||||
#undef android_view_SurfaceView_MEASURED_HEIGHT_STATE_SHIFT
|
||||
#define android_view_SurfaceView_MEASURED_HEIGHT_STATE_SHIFT 16L
|
||||
#undef android_view_SurfaceView_MEASURED_STATE_TOO_SMALL
|
||||
#define android_view_SurfaceView_MEASURED_STATE_TOO_SMALL 16777216L
|
||||
#undef android_view_SurfaceView_PFLAG2_DRAG_CAN_ACCEPT
|
||||
#define android_view_SurfaceView_PFLAG2_DRAG_CAN_ACCEPT 1L
|
||||
#undef android_view_SurfaceView_PFLAG2_DRAG_HOVERED
|
||||
#define android_view_SurfaceView_PFLAG2_DRAG_HOVERED 2L
|
||||
#undef android_view_SurfaceView_LAYOUT_DIRECTION_LTR
|
||||
#define android_view_SurfaceView_LAYOUT_DIRECTION_LTR 0L
|
||||
#undef android_view_SurfaceView_LAYOUT_DIRECTION_RTL
|
||||
#define android_view_SurfaceView_LAYOUT_DIRECTION_RTL 1L
|
||||
#undef android_view_SurfaceView_LAYOUT_DIRECTION_INHERIT
|
||||
#define android_view_SurfaceView_LAYOUT_DIRECTION_INHERIT 2L
|
||||
#undef android_view_SurfaceView_LAYOUT_DIRECTION_LOCALE
|
||||
#define android_view_SurfaceView_LAYOUT_DIRECTION_LOCALE 3L
|
||||
#undef android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT
|
||||
#define android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT 2L
|
||||
#undef android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_MASK
|
||||
#define android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_MASK 12L
|
||||
#undef android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL
|
||||
#define android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL 16L
|
||||
#undef android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED
|
||||
#define android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED 32L
|
||||
#undef android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK
|
||||
#define android_view_SurfaceView_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK 48L
|
||||
/*
|
||||
* Class: android_view_SurfaceView
|
||||
* Method: native_constructor
|
||||
* Signature: (Landroid/content/Context;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_view_SurfaceView_native_1constructor
|
||||
(JNIEnv *, jobject, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -27,7 +27,8 @@ void set_up_handle_cache(JNIEnv *env, char *apk_main_activity_class)
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
handle_cache.apk_main_activity.onCreate = _METHOD(handle_cache.apk_main_activity.class, "onCreate", "(Landroid/os/Bundle;)V");
|
||||
// handle_cache.apk_main_activity.onWindowFocusChanged = _METHOD(handle_cache.apk_main_activity.class, "onWindowFocusChanged", "(B)V");
|
||||
handle_cache.apk_main_activity.onWindowFocusChanged = _METHOD(handle_cache.apk_main_activity.class, "onWindowFocusChanged", "(Z)V");
|
||||
handle_cache.apk_main_activity.onResume = _METHOD(handle_cache.apk_main_activity.class, "onResume", "()V");
|
||||
handle_cache.apk_main_activity.onDestroy = _METHOD(handle_cache.apk_main_activity.class, "onDestroy", "()V");
|
||||
handle_cache.apk_main_activity.set_window = _METHOD((*env)->FindClass(env, "android/app/Activity"), "set_window", "(J)V");
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ struct handle_cache {
|
||||
jclass class;
|
||||
jobject object;
|
||||
jmethodID onCreate;
|
||||
jmethodID onResume;
|
||||
jmethodID onWindowFocusChanged;
|
||||
jmethodID onDestroy;
|
||||
jmethodID set_window;
|
||||
|
||||
@@ -192,7 +192,7 @@ static void draw_function(GtkDrawingArea *area, cairo_t *cr, int width, int heig
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
|
||||
void on_mapped(GtkWidget* self, struct jni_callback_data *d)
|
||||
static void on_mapped(GtkWidget* self, struct jni_callback_data *d)
|
||||
{
|
||||
JNIEnv *env;
|
||||
(*d->jvm)->GetEnv(d->jvm, (void**)&env, JNI_VERSION_1_6);
|
||||
@@ -200,6 +200,7 @@ void on_mapped(GtkWidget* self, struct jni_callback_data *d)
|
||||
(*env)->CallVoidMethod(env, d->this, _METHOD(d->this_class, "onMeasure", "(II)V"), gtk_widget_get_width(self), gtk_widget_get_height(self));
|
||||
}
|
||||
|
||||
// FIXME: this is used in one other place as well, should probably go in util.c or gtk_util.c?
|
||||
gboolean tick_callback(GtkWidget* widget, GdkFrameClock* frame_clock, gpointer user_data)
|
||||
{
|
||||
gtk_widget_queue_draw(widget);
|
||||
|
||||
38
src/api-impl-jni/widgets/android_view_SurfaceView.c
Normal file
38
src/api-impl-jni/widgets/android_view_SurfaceView.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../defines.h"
|
||||
#include "../util.h"
|
||||
|
||||
#include "WrapperWidget.h"
|
||||
|
||||
#include "../generated_headers/android_view_SurfaceView.h"
|
||||
|
||||
struct jni_callback_data { JavaVM *jvm; jobject this; jclass this_class;};
|
||||
|
||||
static void on_mapped(GtkWidget* self, struct jni_callback_data *d)
|
||||
{
|
||||
JNIEnv *env;
|
||||
(*d->jvm)->GetEnv(d->jvm, (void**)&env, JNI_VERSION_1_6);
|
||||
|
||||
(*env)->CallVoidMethod(env, d->this, _METHOD(d->this_class, "surfaceChanged", "(Landroid/view/SurfaceHolder;III)V"), _GET_OBJ_FIELD(d->this, "mSurfaceHolder", "Landroid/view/SurfaceHolder;"), 1 /*RGBA_8888*/, /*FIXME*/700, /*FIXME*/700);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_view_SurfaceView_native_1constructor(JNIEnv *env, jobject this, jobject context)
|
||||
{
|
||||
GtkWidget *wrapper = wrapper_widget_new();
|
||||
GtkWidget *dummy = gtk_fixed_new();
|
||||
gtk_widget_set_name(dummy, "dummy widget for SurfaceView");
|
||||
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), dummy);
|
||||
|
||||
JavaVM *jvm;
|
||||
(*env)->GetJavaVM(env, &jvm);
|
||||
|
||||
struct jni_callback_data *callback_data = malloc(sizeof(struct jni_callback_data));
|
||||
callback_data->jvm = jvm;
|
||||
callback_data->this = _REF(this);
|
||||
callback_data->this_class = _REF(_CLASS(this));
|
||||
|
||||
g_signal_connect(dummy, "map", G_CALLBACK(on_mapped), callback_data);
|
||||
|
||||
_SET_LONG_FIELD(this, "widget", _INTPTR(dummy));
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import java.io.StringReader;
|
||||
public class Activity extends Context {
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window();
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
|
||||
protected void set_window(long native_window) {
|
||||
window.native_window = native_window;
|
||||
@@ -49,6 +50,14 @@ public class Activity extends Context {
|
||||
// return new Intent();
|
||||
}
|
||||
|
||||
public int getRequestedOrientation() {
|
||||
return requested_orientation;
|
||||
}
|
||||
|
||||
public void setRequestedOrientation (int orientation) {
|
||||
requested_orientation = orientation;
|
||||
}
|
||||
|
||||
public boolean isFinishing() {
|
||||
return false; // FIXME
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ public class AlertDialog extends Dialog {
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setTitle (CharSequence title) {
|
||||
System.out.println("AlertDialog.Builder setTitle called with: '"+title+"'");
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setMessage (CharSequence message) {
|
||||
System.out.println("AlertDialog.Builder setMessage called with: '"+message+"'");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@ package android.content;
|
||||
import android.util.Log;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.Intent;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -23,6 +27,8 @@ import android.app.KeyguardManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.media.AudioManager;
|
||||
import android.app.ActivityManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Vibrator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -55,6 +61,10 @@ public class Context extends Object {
|
||||
System.out.println("new Context! this one is: " + this);
|
||||
}
|
||||
|
||||
public ApplicationInfo getApplicationInfo () {
|
||||
return new ApplicationInfo();
|
||||
}
|
||||
|
||||
public Context getApplicationContext() {
|
||||
return (Context)this_application;
|
||||
}
|
||||
@@ -81,12 +91,20 @@ public class Context extends Object {
|
||||
return new AudioManager();
|
||||
case "activity":
|
||||
return new ActivityManager();
|
||||
case "usb":
|
||||
return new UsbManager();
|
||||
case "vibrator":
|
||||
return new Vibrator();
|
||||
default:
|
||||
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||
return new Intent();
|
||||
}
|
||||
|
||||
public Looper getMainLooper() {
|
||||
System.out.println("returning the main Looper, most definitely doing just that!");
|
||||
return new Looper();
|
||||
|
||||
5
src/api-impl/android/content/IntentFilter.java
Normal file
5
src/api-impl/android/content/IntentFilter.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package android.content;
|
||||
|
||||
public class IntentFilter {
|
||||
public void addAction(String action) {}
|
||||
}
|
||||
@@ -339,7 +339,8 @@ public final class AssetManager {
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException("Asset file: " + fileName);*/
|
||||
return null; // FIXME
|
||||
throw new IOException("FIXME: 'public final AssetFileDescriptor openFd(String fileName)': throwing an exception, which makes e.g SDL2 fall back to using something that we actually have implemented");
|
||||
// return null; // FIXME
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package android.hardware;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
public class SensorManager {
|
||||
public Sensor getDefaultSensor(int type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean registerListener (SensorEventListener listener, Sensor sensor, int samplingPeriodUs, Handler handler) {
|
||||
return true; // we could try saying that the sensor doesn't exist and hope the app just doesn't use it then, but as long as we never call the handler the app should leave this alone
|
||||
}
|
||||
}
|
||||
|
||||
9
src/api-impl/android/hardware/usb/UsbManager.java
Normal file
9
src/api-impl/android/hardware/usb/UsbManager.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package android.hardware.usb;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class UsbManager {
|
||||
public HashMap getDeviceList() {
|
||||
return new HashMap();
|
||||
}
|
||||
}
|
||||
5
src/api-impl/android/os/Vibrator.java
Normal file
5
src/api-impl/android/os/Vibrator.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package android.os;
|
||||
|
||||
public class Vibrator {
|
||||
|
||||
}
|
||||
@@ -17,4 +17,8 @@ public final class Display {
|
||||
public int getRotation() {
|
||||
return 0/*ROTATION_0*/;
|
||||
}
|
||||
|
||||
public float getRefreshRate() {
|
||||
return 60; // FIXME
|
||||
}
|
||||
}
|
||||
|
||||
11
src/api-impl/android/view/InputDevice.java
Normal file
11
src/api-impl/android/view/InputDevice.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package android.view;
|
||||
|
||||
public class InputDevice {
|
||||
public static int[] getDeviceIds() {
|
||||
return new int[]{0}; // might work?
|
||||
}
|
||||
|
||||
public static InputDevice getDevice(int id) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,6 @@ package android.view;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
class InputDevice {}
|
||||
|
||||
/**
|
||||
* Common base class for input events.
|
||||
*/
|
||||
|
||||
@@ -6,187 +6,191 @@ import android.graphics.Rect;
|
||||
import android.content.Context;
|
||||
|
||||
public class SurfaceView extends View {
|
||||
|
||||
public SurfaceView(Context context) {
|
||||
super(context);
|
||||
|
||||
// native_constructor(context);
|
||||
native_constructor(context);
|
||||
}
|
||||
|
||||
private native void native_constructor(Context context);
|
||||
|
||||
public SurfaceHolder getHolder() {
|
||||
return mSurfaceHolder;
|
||||
return mSurfaceHolder;
|
||||
}
|
||||
|
||||
void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {}
|
||||
|
||||
final Surface mSurface = new Surface();
|
||||
|
||||
private final SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
|
||||
private static final String LOG_TAG = "SurfaceHolder";
|
||||
|
||||
private static final String LOG_TAG = "SurfaceHolder";
|
||||
|
||||
@Override
|
||||
public boolean isCreating() {
|
||||
// return mIsCreating;
|
||||
@Override
|
||||
public boolean isCreating() {
|
||||
// return mIsCreating;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCallback(Callback callback) {
|
||||
/* synchronized (mCallbacks) {
|
||||
// This is a linear search, but in practice we'll
|
||||
// have only a couple callbacks, so it doesn't matter.
|
||||
if (mCallbacks.contains(callback) == false) {
|
||||
mCallbacks.add(callback);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@Override
|
||||
public void addCallback(Callback callback) {
|
||||
/* synchronized (mCallbacks) {
|
||||
// This is a linear search, but in practice we'll
|
||||
// have only a couple callbacks, so it doesn't matter.
|
||||
if (mCallbacks.contains(callback) == false) {
|
||||
mCallbacks.add(callback);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCallback(Callback callback) {
|
||||
/* synchronized (mCallbacks) {
|
||||
mCallbacks.remove(callback);
|
||||
}*/
|
||||
}
|
||||
@Override
|
||||
public void removeCallback(Callback callback) {
|
||||
/* synchronized (mCallbacks) {
|
||||
mCallbacks.remove(callback);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFixedSize(int width, int height) {
|
||||
/* if (mRequestedWidth != width || mRequestedHeight != height) {
|
||||
mRequestedWidth = width;
|
||||
mRequestedHeight = height;
|
||||
requestLayout();
|
||||
}*/
|
||||
}
|
||||
@Override
|
||||
public void setFixedSize(int width, int height) {
|
||||
/* if (mRequestedWidth != width || mRequestedHeight != height) {
|
||||
mRequestedWidth = width;
|
||||
mRequestedHeight = height;
|
||||
requestLayout();
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSizeFromLayout() {
|
||||
/* if (mRequestedWidth != -1 || mRequestedHeight != -1) {
|
||||
mRequestedWidth = mRequestedHeight = -1;
|
||||
requestLayout();
|
||||
}*/
|
||||
}
|
||||
@Override
|
||||
public void setSizeFromLayout() {
|
||||
/* if (mRequestedWidth != -1 || mRequestedHeight != -1) {
|
||||
mRequestedWidth = mRequestedHeight = -1;
|
||||
requestLayout();
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(int format) {
|
||||
/*
|
||||
// for backward compatibility reason, OPAQUE always
|
||||
// means 565 for SurfaceView
|
||||
if (format == PixelFormat.OPAQUE)
|
||||
format = PixelFormat.RGB_565;
|
||||
@Override
|
||||
public void setFormat(int format) {
|
||||
/*
|
||||
// for backward compatibility reason, OPAQUE always
|
||||
// means 565 for SurfaceView
|
||||
if (format == PixelFormat.OPAQUE)
|
||||
format = PixelFormat.RGB_565;
|
||||
|
||||
mRequestedFormat = format;
|
||||
if (mWindow != null) {
|
||||
updateWindow(false, false);
|
||||
}*/
|
||||
}
|
||||
mRequestedFormat = format;
|
||||
if (mWindow != null) {
|
||||
updateWindow(false, false);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated setType is now ignored.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setType(int type) { }
|
||||
/**
|
||||
* @deprecated setType is now ignored.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setType(int type) { }
|
||||
|
||||
@Override
|
||||
public void setKeepScreenOn(boolean screenOn) {
|
||||
// Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG);
|
||||
// msg.arg1 = screenOn ? 1 : 0;
|
||||
// mHandler.sendMessage(msg);
|
||||
}
|
||||
@Override
|
||||
public void setKeepScreenOn(boolean screenOn) {
|
||||
// Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG);
|
||||
// msg.arg1 = screenOn ? 1 : 0;
|
||||
// mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link Canvas} for drawing into the SurfaceView's Surface
|
||||
*
|
||||
* After drawing into the provided {@link Canvas}, the caller must
|
||||
* invoke {@link #unlockCanvasAndPost} to post the new contents to the surface.
|
||||
*
|
||||
* The caller must redraw the entire surface.
|
||||
* @return A canvas for drawing into the surface.
|
||||
*/
|
||||
@Override
|
||||
public Canvas lockCanvas() {
|
||||
// return internalLockCanvas(null);
|
||||
/**
|
||||
* Gets a {@link Canvas} for drawing into the SurfaceView's Surface
|
||||
*
|
||||
* After drawing into the provided {@link Canvas}, the caller must
|
||||
* invoke {@link #unlockCanvasAndPost} to post the new contents to the surface.
|
||||
*
|
||||
* The caller must redraw the entire surface.
|
||||
* @return A canvas for drawing into the surface.
|
||||
*/
|
||||
@Override
|
||||
public Canvas lockCanvas() {
|
||||
// return internalLockCanvas(null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link Canvas} for drawing into the SurfaceView's Surface
|
||||
*
|
||||
* After drawing into the provided {@link Canvas}, the caller must
|
||||
* invoke {@link #unlockCanvasAndPost} to post the new contents to the surface.
|
||||
*
|
||||
* @param inOutDirty A rectangle that represents the dirty region that the caller wants
|
||||
* to redraw. This function may choose to expand the dirty rectangle if for example
|
||||
* the surface has been resized or if the previous contents of the surface were
|
||||
* not available. The caller must redraw the entire dirty region as represented
|
||||
* by the contents of the inOutDirty rectangle upon return from this function.
|
||||
* The caller may also pass <code>null</code> instead, in the case where the
|
||||
* entire surface should be redrawn.
|
||||
* @return A canvas for drawing into the surface.
|
||||
*/
|
||||
@Override
|
||||
public Canvas lockCanvas(Rect inOutDirty) {
|
||||
// return internalLockCanvas(inOutDirty);
|
||||
/**
|
||||
* Gets a {@link Canvas} for drawing into the SurfaceView's Surface
|
||||
*
|
||||
* After drawing into the provided {@link Canvas}, the caller must
|
||||
* invoke {@link #unlockCanvasAndPost} to post the new contents to the surface.
|
||||
*
|
||||
* @param inOutDirty A rectangle that represents the dirty region that the caller wants
|
||||
* to redraw. This function may choose to expand the dirty rectangle if for example
|
||||
* the surface has been resized or if the previous contents of the surface were
|
||||
* not available. The caller must redraw the entire dirty region as represented
|
||||
* by the contents of the inOutDirty rectangle upon return from this function.
|
||||
* The caller may also pass <code>null</code> instead, in the case where the
|
||||
* entire surface should be redrawn.
|
||||
* @return A canvas for drawing into the surface.
|
||||
*/
|
||||
@Override
|
||||
public Canvas lockCanvas(Rect inOutDirty) {
|
||||
// return internalLockCanvas(inOutDirty);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final Canvas internalLockCanvas(Rect dirty) {
|
||||
/* mSurfaceLock.lock();
|
||||
private final Canvas internalLockCanvas(Rect dirty) {
|
||||
/* mSurfaceLock.lock();
|
||||
|
||||
if (DEBUG) Log.i(TAG, "Locking canvas... stopped="
|
||||
+ mDrawingStopped + ", win=" + mWindow);
|
||||
if (DEBUG) Log.i(TAG, "Locking canvas... stopped="
|
||||
+ mDrawingStopped + ", win=" + mWindow);
|
||||
|
||||
Canvas c = null;
|
||||
if (!mDrawingStopped && mWindow != null) {
|
||||
try {
|
||||
c = mSurface.lockCanvas(dirty);
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Exception locking surface", e);
|
||||
}
|
||||
}
|
||||
Canvas c = null;
|
||||
if (!mDrawingStopped && mWindow != null) {
|
||||
try {
|
||||
c = mSurface.lockCanvas(dirty);
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Exception locking surface", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) Log.i(TAG, "Returned canvas: " + c);
|
||||
if (c != null) {
|
||||
mLastLockTime = SystemClock.uptimeMillis();
|
||||
return c;
|
||||
}
|
||||
if (DEBUG) Log.i(TAG, "Returned canvas: " + c);
|
||||
if (c != null) {
|
||||
mLastLockTime = SystemClock.uptimeMillis();
|
||||
return c;
|
||||
}
|
||||
|
||||
// If the Surface is not ready to be drawn, then return null,
|
||||
// but throttle calls to this function so it isn't called more
|
||||
// than every 100ms.
|
||||
long now = SystemClock.uptimeMillis();
|
||||
long nextTime = mLastLockTime + 100;
|
||||
if (nextTime > now) {
|
||||
try {
|
||||
Thread.sleep(nextTime-now);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
now = SystemClock.uptimeMillis();
|
||||
}
|
||||
mLastLockTime = now;
|
||||
mSurfaceLock.unlock();
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts the new contents of the {@link Canvas} to the surface and
|
||||
* releases the {@link Canvas}.
|
||||
*
|
||||
* @param canvas The canvas previously obtained from {@link #lockCanvas}.
|
||||
*/
|
||||
@Override
|
||||
public void unlockCanvasAndPost(Canvas canvas) {
|
||||
// mSurface.unlockCanvasAndPost(canvas);
|
||||
// mSurfaceLock.unlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Surface getSurface() {
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rect getSurfaceFrame() {
|
||||
// return mSurfaceFrame;
|
||||
// If the Surface is not ready to be drawn, then return null,
|
||||
// but throttle calls to this function so it isn't called more
|
||||
// than every 100ms.
|
||||
long now = SystemClock.uptimeMillis();
|
||||
long nextTime = mLastLockTime + 100;
|
||||
if (nextTime > now) {
|
||||
try {
|
||||
Thread.sleep(nextTime-now);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
now = SystemClock.uptimeMillis();
|
||||
}
|
||||
mLastLockTime = now;
|
||||
mSurfaceLock.unlock();
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts the new contents of the {@link Canvas} to the surface and
|
||||
* releases the {@link Canvas}.
|
||||
*
|
||||
* @param canvas The canvas previously obtained from {@link #lockCanvas}.
|
||||
*/
|
||||
@Override
|
||||
public void unlockCanvasAndPost(Canvas canvas) {
|
||||
// mSurface.unlockCanvasAndPost(canvas);
|
||||
// mSurfaceLock.unlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Surface getSurface() {
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rect getSurfaceFrame() {
|
||||
// return mSurfaceFrame;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -525,6 +525,14 @@ public class View extends Object {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public interface OnGenericMotionListener {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public interface OnSystemUiVisibilityChangeListener {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public static interface OnKeyListener {
|
||||
// TODO
|
||||
// boolean onKey(View v, int keyCode, KeyEvent event);
|
||||
@@ -741,6 +749,7 @@ public class View extends Object {
|
||||
public native void setGravity(int gravity);
|
||||
public native void setOnTouchListener(OnTouchListener l);
|
||||
public native void setOnClickListener(OnClickListener l);
|
||||
public /*native*/ void setOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l) {}
|
||||
public native final int getWidth();
|
||||
public native final int getHeight();
|
||||
|
||||
|
||||
@@ -28,5 +28,9 @@ public class Window {
|
||||
set_widget_as_root(native_window, view.widget);
|
||||
}
|
||||
|
||||
public View getDecorView() {
|
||||
return new View(); // FIXME: this can probably backfire
|
||||
}
|
||||
|
||||
private native void set_widget_as_root(long native_window, long widget);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user