multiple additions and fixes for the Java APIs

Stuff needed for WhatsApp support
This commit is contained in:
Julian Winkler
2024-06-24 18:44:31 +02:00
committed by Mis012
parent ef77bb287a
commit 3c5a21357d
53 changed files with 357 additions and 43 deletions

View File

@@ -166,3 +166,15 @@ JNIEXPORT void JNICALL Java_android_graphics_Path_native_1rMoveTo(JNIEnv *env, j
sk_path_t *path = (sk_path_t *)_PTR(path_ptr); sk_path_t *path = (sk_path_t *)_PTR(path_ptr);
sk_path_rmove_to(path, dx, dy); sk_path_rmove_to(path, dx, dy);
} }
JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JLandroid_graphics_RectF_2_3FI(JNIEnv *env, jclass class, jlong path_ptr, jobject rect, jfloatArray radii, jint dir)
{
sk_path_t *path = (sk_path_t *)_PTR(path_ptr);
float left = _GET_FLOAT_FIELD(rect, "left");
float top = _GET_FLOAT_FIELD(rect, "top");
float right = _GET_FLOAT_FIELD(rect, "right");
float bottom = _GET_FLOAT_FIELD(rect, "bottom");
jfloat *radii_array = (*env)->GetFloatArrayElements(env, radii, 0);
sk_path_add_rounded_rect(path, &(sk_rect_t){left, top, right, bottom}, radii_array[0], radii_array[1], (sk_path_direction_t)dir);
(*env)->ReleaseFloatArrayElements(env, radii, radii_array, 0);
}

View File

@@ -1,5 +1,24 @@
package android.accounts; package android.accounts;
import android.content.Context;
import android.os.Bundle;
public class AccountManager { public class AccountManager {
public static AccountManager get(Context context) {
return new AccountManager();
}
public Account[] getAccountsByType(String type) {
return new Account[0];
}
public Account[] getAccounts() {
return new Account[0];
}
public boolean addAccountExplicitly(Account account, String password, Bundle extras) {
System.out.println("addAccountExplicitly(" + account + ", " + password + ", " + extras + ") called");
return false;
}
} }

View File

@@ -27,7 +27,9 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class Activity extends ContextThemeWrapper implements Window.Callback { public class Activity extends ContextThemeWrapper implements Window.Callback {
LayoutInflater layout_inflater; LayoutInflater layout_inflater;
@@ -337,8 +339,30 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
setResult(resultCode, null); setResult(resultCode, null);
} }
protected Dialog onCreateDialog(int id) {
System.out.println("Activity.onCreateDialog(" + id + ") called");
return null;
}
protected void onPrepareDialog(int id, Dialog dialog) {
System.out.println("Activity.onPrepareDialog(" + id + ") called");
}
private Map<Integer, Dialog> dialogs = new HashMap<Integer, Dialog>();
public final void showDialog(int id) { public final void showDialog(int id) {
System.out.println("Activity.showDialog(" + id + ") called"); System.out.println("Activity.showDialog(" + id + ") called");
Dialog dialog = dialogs.get(id);
if (dialog == null)
dialogs.put(id, dialog = onCreateDialog(id));
onPrepareDialog(id, dialog);
dialog.show();
}
public void removeDialog(int id) {
Dialog dialog = dialogs.remove(id);
if (dialog != null)
dialog.dismiss();
} }
public void finish() { public void finish() {
@@ -501,6 +525,8 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
finish(); finish();
} }
public void overridePendingTransition(int enterAnim, int exitAnim) {}
private native void nativeFinish(long native_window); private native void nativeFinish(long native_window);
public static native void nativeRecreateActivity(Activity activity); public static native void nativeRecreateActivity(Activity activity);
public static native void nativeStartActivity(Activity activity); public static native void nativeStartActivity(Activity activity);

View File

@@ -34,4 +34,6 @@ public class ActivityManager {
public int getMemoryClass() {return 20;} // suggested heap size in MB public int getMemoryClass() {return 20;} // suggested heap size in MB
public static void getMyMemoryState(RunningAppProcessInfo outInfo) {} public static void getMyMemoryState(RunningAppProcessInfo outInfo) {}
public boolean clearApplicationUserData() {return false;}
} }

View File

@@ -6,4 +6,6 @@ public class AlarmManager {
public void setInexactRepeating(int type, long triggerTime, long interval, PendingIntent operation) {} public void setInexactRepeating(int type, long triggerTime, long interval, PendingIntent operation) {}
public void setExact(int type, long triggerTime, PendingIntent operation) {} public void setExact(int type, long triggerTime, PendingIntent operation) {}
public void set(int type, long triggerTime, PendingIntent operation) {}
} }

View File

@@ -47,9 +47,13 @@ public class AlertDialog extends Dialog implements DialogInterface {
public AlertDialog.Builder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener) { public AlertDialog.Builder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener) {
System.out.println("AlertDialog.Builder setNegativeButton called with text: '" + text + "'"); System.out.println("AlertDialog.Builder setNegativeButton called with text: '" + text + "'");
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, text, listener);
return this; return this;
} }
public AlertDialog.Builder setNegativeButton(int textId, DialogInterface.OnClickListener listener) {
return setNegativeButton(dialog.getContext().getText(textId), listener);
}
public AlertDialog.Builder setCancelable(boolean cancelable) { public AlertDialog.Builder setCancelable(boolean cancelable) {
return this; return this;
@@ -95,5 +99,10 @@ public class AlertDialog extends Dialog implements DialogInterface {
public AlertDialog create() { public AlertDialog create() {
return dialog; return dialog;
} }
public AlertDialog show() {
dialog.show();
return dialog;
}
} }
} }

View File

@@ -0,0 +1,10 @@
package android.app;
import android.content.Context;
public class AppGlobals {
public static Application getInitialApplication() {
return Context.this_application;
}
}

View File

@@ -1,5 +1,5 @@
package android.app; package android.app;
public abstract class IntentService { public abstract class IntentService extends Service {
} }

View File

@@ -38,6 +38,8 @@ public class PendingIntent {
+ new String[] { "activity", "service", "broadcast" }[type] + "]"; + new String[] { "activity", "service", "broadcast" }[type] + "]";
} }
public void cancel() {}
public class CanceledException extends Exception { public class CanceledException extends Exception {
} }
} }

View File

@@ -16,7 +16,10 @@ public abstract class Service extends Context {
public abstract IBinder onBind(Intent intent); public abstract IBinder onBind(Intent intent);
public abstract int onStartCommand(Intent intent, int flags, int startId); public int onStartCommand(Intent intent, int flags, int startId) {
System.out.println("Service.onStartCommand(" + intent + ", " + flags + ", " + startId + ") called");
return 0;
}
public void startForeground(int id, Notification notification) { public void startForeground(int id, Notification notification) {
System.out.println("startForeground(" + id + ", " + notification + ") called"); System.out.println("startForeground(" + id + ", " + notification + ") called");

View File

@@ -1,4 +1,10 @@
package android.appwidget; package android.appwidget;
import android.content.Context;
public class AppWidgetManager { public class AppWidgetManager {
public static AppWidgetManager getInstance(Context context) {
return new AppWidgetManager();
}
} }

View File

@@ -44,4 +44,8 @@ public class ContentResolver {
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) { public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
return query(uri, projection, selection, selectionArgs, sortOrder); return query(uri, projection, selection, selectionArgs, sortOrder);
} }
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
} }

View File

@@ -405,17 +405,24 @@ public class Context extends Object {
return null; return null;
} }
try { new Handler(Looper.getMainLooper()).post(new Runnable() {
Class<? extends Service> cls = Class.forName(component.getClassName()).asSubclass(Service.class); @Override
if (!runningServices.containsKey(cls)) { public void run() {
Service service = cls.getConstructor().newInstance(); try {
service.onCreate(); Class<? extends Service> cls = Class.forName(component.getClassName()).asSubclass(Service.class);
runningServices.put(cls, service); if (!runningServices.containsKey(cls)) {
Service service = cls.getConstructor().newInstance();
service.onCreate();
runningServices.put(cls, service);
}
runningServices.get(cls).onStartCommand(intent, 0, 0);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
} }
runningServices.get(cls).onStartCommand(intent, 0, 0); });
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
return component; return component;
} }
@@ -603,4 +610,12 @@ public class Context extends Object {
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler) { public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler) {
return registerReceiver(receiver, filter); return registerReceiver(receiver, filter);
} }
public String[] fileList() {
return new String[0];
}
public void revokeUriPermission(Uri uri, int mode) {
System.out.println("revokeUriPermission(" + uri + ", " + mode + ") called");
}
} }

View File

@@ -25,4 +25,6 @@ public interface DialogInterface {
} }
public interface OnMultiChoiceClickListener { public interface OnMultiChoiceClickListener {
} }
public interface OnKeyListener {
}
} }

View File

@@ -318,4 +318,15 @@ public class Intent {
public String getPackage() { public String getPackage() {
return component.getPackageName(); return component.getPackageName();
} }
public String getScheme() {
return data == null ? null : data.getScheme();
}
public static class ShortcutIconResource {
public static ShortcutIconResource fromContext(Context context, int id) {
return new ShortcutIconResource();
}
}
} }

View File

@@ -40,4 +40,6 @@ public class IntentFilter {
public String getAction(int index) { public String getAction(int index) {
return actions.get(index); return actions.get(index);
} }
public void setPriority(int priority) {}
} }

View File

@@ -2411,13 +2411,14 @@ public class PackageManager {
* else null. * else null.
* @throws Exception * @throws Exception
*/ */
public ProviderInfo resolveContentProvider(String authority, int flags) throws Exception { public ProviderInfo resolveContentProvider(String authority, int flags) {
for (PackageParser.Provider p : Context.pkg.providers) { for (PackageParser.Provider p : Context.pkg.providers) {
if (p.info.authority.equals(authority)) if (p.info.authority.equals(authority))
return p.info; return p.info;
} }
throw new Exception("Provider not found: " + authority); Slog.w(TAG, "Provider not found: " + authority);
return null;
} }
/** /**

View File

@@ -3031,6 +3031,7 @@ public class PackageParser {
outError)) == null) { outError)) == null) {
return null; return null;
} }
s.info.metaData = s.metaData;
} else { } else {
if (!RIGID_PARSER) { if (!RIGID_PARSER) {
Slog.w(TAG, "Unknown element under <service>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); Slog.w(TAG, "Unknown element under <service>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription());

View File

@@ -337,7 +337,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* @return The value of the field as a string. * @return The value of the field as a string.
*/ */
public String getString(int row, int column) { public String getString(int row, int column) {
return (String)rows.get(row - startPos)[column]; return String.valueOf(rows.get(row - startPos)[column]);
} }
/** /**

View File

@@ -272,6 +272,12 @@ public class Paint {
return new FontMetrics(); return new FontMetrics();
} }
public void setFontMetricsInt(FontMetricsInt fmi) {}
public FontMetricsInt getFontMetricsInt() {
return new FontMetricsInt();
}
private native long native_constructor(); private native long native_constructor();
private native void native_set_antialias(long skia_paint, boolean aa); private native void native_set_antialias(long skia_paint, boolean aa);
private native void native_set_color(long skia_paint, int color); private native void native_set_color(long skia_paint, int color);

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