api-impl: misc stubs and fixes for several apps including F-Droid and AuroraStore

This commit is contained in:
Julian Winkler
2025-03-25 19:24:06 +01:00
parent 7b0341123b
commit 4a4b4a4722
36 changed files with 296 additions and 27 deletions

View File

@@ -267,3 +267,11 @@ JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setValues(JNIEnv *en
graphene_matrix_init_from_float(matrix, *values4x4);
(*env)->ReleaseFloatArrayElements(env, values_ref, values, 0);
}
JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setRotate__JFFF(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat degrees, jfloat px, jfloat py)
{
graphene_matrix_t *matrix = (graphene_matrix_t *)_PTR(matrix_ptr);
graphene_matrix_init_translate(matrix, &GRAPHENE_POINT3D_INIT(-px, -py, 0));
graphene_matrix_rotate_z(matrix, degrees);
graphene_matrix_translate(matrix, &GRAPHENE_POINT3D_INIT(px, py, 0));
}

View File

@@ -0,0 +1,16 @@
package android.app;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;
public class ActivityOptions {
public static ActivityOptions makeSceneTransitionAnimation(Activity activity, Pair<View, String>... pairs) {
return new ActivityOptions();
}
public Bundle toBundle() {
return null;
}
}

View File

@@ -1,4 +1,12 @@
package android.app;
public class AppOpsManager {
public static String permissionToOp(String permission) {
return permission;
}
public int noteProxyOpNoThrow(String op, String pkg) {
return 0;
}
}

View File

@@ -3,8 +3,10 @@ package android.app;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Parcelable;
public class PendingIntent {
public class PendingIntent implements Parcelable {
private int requestCode;
Intent intent;
@@ -25,6 +27,17 @@ public class PendingIntent {
public void send(Context context, int code, Intent intent) {}
public void send() {
Context context = Context.this_application;
if (type == 0) { // type Activity
context.startActivity(intent);
} else if (type == 1) { // type Service
context.startService(intent);
} else if (type == 2) { // type Broadcast
context.sendBroadcast(intent);
}
}
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags) {
return new PendingIntent(requestCode, intent, 0);
}
@@ -33,6 +46,10 @@ public class PendingIntent {
return new PendingIntent(requestCode, intent, 1);
}
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags, Bundle options) {
return new PendingIntent(requestCode, intents[0], 0);
}
public String toString() {
return "PendingIntent [requestCode=" + requestCode + ", intent=" + intent + ", type="
+ new String[] { "activity", "service", "broadcast" }[type] + "]";

View File

@@ -1,6 +1,7 @@
package android.app.job;
import android.content.ComponentName;
import android.os.PersistableBundle;
public class JobInfo {
@@ -21,6 +22,26 @@ public class JobInfo {
return this;
}
public Builder setExtras(PersistableBundle extras) {
return this;
}
public Builder setRequiresCharging(boolean requiresCharging) {
return this;
}
public Builder setRequiresDeviceIdle(boolean requiresDeviceIdle) {
return this;
}
public Builder setBackoffCriteria(long initialBackoffMillis, int backoffPolicy) {
return this;
}
public Builder setPersisted(boolean persisted) {
return this;
}
public JobInfo build() {
return new JobInfo();
}

View File

@@ -17,4 +17,8 @@ public class JobScheduler {
public int enqueue(JobInfo job, JobWorkItem work) {
return 1; //RESULT_SUCCESS
}
public int schedule(JobInfo job) {
return 1; //RESULT_SUCCESS
}
}

View File

@@ -245,6 +245,8 @@ public class Context extends Object {
}
public final Object getSystemService(Class<?> serviceClass) throws InstantiationException, IllegalAccessException, InvocationTargetException {
if (serviceClass == LayoutInflater.class)
return layout_inflater;
return serviceClass.getConstructors()[0].newInstance();
}
@@ -706,4 +708,13 @@ public class Context extends Object {
public Drawable getWallpaper() {
return null;
}
public String[] databaseList() {
File databaseDir = new File(getDataDirFile(), "databases");
if (databaseDir.exists()) {
return databaseDir.list();
} else {
return new String[0];
}
}
}

View File

@@ -1,8 +1,13 @@
package android.content;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import org.xmlpull.v1.XmlPullParser;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@@ -378,4 +383,12 @@ public class Intent implements Parcelable {
public int filterHashCode() {
return 0;
}
public static Intent parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs) {
return new Intent();
}
public ComponentName resolveActivity(PackageManager pm) {
return component;
}
}

View File

@@ -0,0 +1,11 @@
package android.content.pm;
import java.util.Collections;
import java.util.List;
public class PackageInstaller {
public List getMySessions() {
return Collections.emptyList();
}
}

View File

@@ -1385,7 +1385,11 @@ public class PackageManager {
* @see #GET_UNINSTALLED_PACKAGES
*/
public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException {
return PackageParser.generatePackageInfo(Context.pkg, new int[0], flags, 0, 0, new HashSet<>(), new PackageUserState());
if (packageName.equals(Context.pkg.packageName)) {
return PackageParser.generatePackageInfo(Context.pkg, new int[0], flags, 0, 0, new HashSet<>(), new PackageUserState());
} else {
throw new NameNotFoundException();
}
}
/**
@@ -1820,15 +1824,15 @@ public class PackageManager {
* @see #PERMISSION_DENIED
*/
public int checkPermission(String permName, String pkgName) {
if (permName != null && permName.endsWith(".DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"))
return PERMISSION_GRANTED;
switch (permName) {
// TODO: we shouldn't just automatically grant these once we have bubblewrap set up
// for now, the app can access anything it wants, so no point telling it otherwise
case "android.permission.WRITE_EXTERNAL_STORAGE":
case "android.permission.READ_EXTERNAL_STORAGE":
case "com.google.android.c2dm.permission.SEND":
case "com.fsck.k9.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION":
case "net.thunderbird.android.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION":
case "de.danoeh.antennapod.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION":
return PERMISSION_GRANTED;
default:
System.out.println("PackageManager.checkPermission: >" + permName + "< not handled\n");
@@ -2094,7 +2098,7 @@ public class PackageManager {
* that are available on the system, or null if there are none(!!).
*/
public FeatureInfo[] getSystemAvailableFeatures() {
return null;
return new FeatureInfo[0];
}
/**
@@ -3454,4 +3458,8 @@ public class PackageManager {
// TODO: This should be shared with Installer's knowledge of user directory
return Environment.getDataDirectory().toString() + "/user/" + userId + "/" + packageName;
}
public PackageInstaller getPackageInstaller() {
return new PackageInstaller();
}
}

View File

@@ -217,6 +217,10 @@ public final class Bitmap {
public void setPremultiplied(boolean premultiplied) {}
public Bitmap extractAlpha() {
return this.copy(config, mutable);
}
@SuppressWarnings("deprecation")
@Override
protected void finalize() throws Throwable {

View File

@@ -482,6 +482,10 @@ public class Canvas {
return false;
}
public boolean clipRect(RectF rect, Region.Op op) {
return false;
}
public void drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean includeCenter, Paint paint) {}
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint) {}

View File

@@ -158,4 +158,25 @@ public class Color {
}
hsv[2] = max;
}
public static int HSVToColor(float[] hsv) {
float h = hsv[0];
float s = hsv[1];
float v_ = hsv[2];
int hi = (int)Math.floor(h / 60) % 6;
float f = (h / 60 - (float)Math.floor(h / 60)) * 6;
int p = (int)(v_ * (1 - s) * 255.f + 0.5f);
int q = (int)(v_ * (1 - f * s) * 255.f + 0.5f);
int t = (int)(v_ * (1 - (1 - f) * s) * 255.f + 0.5f);
int v = (int)(v_ * 255.f + 0.5f);
switch (hi) {
case 0: return Color.rgb(v, t, p);
case 1: return Color.rgb(q, v, p);
case 2: return Color.rgb(p, v, t);
case 3: return Color.rgb(p, q, v);
case 4: return Color.rgb(t, p, v);
case 5: return Color.rgb(v, p, q);
}
return 0;
}
}

View File

@@ -53,7 +53,8 @@ public class GskCanvas extends Canvas {
@Override
public void drawPath(Path path, Paint paint) {
native_drawPath(snapshot, path.getGskPath(), paint != null ? paint.paint : default_paint.paint);
if (path != null)
native_drawPath(snapshot, path.getGskPath(), paint != null ? paint.paint : default_paint.paint);
}
@Override

View File

@@ -191,6 +191,12 @@ public class Path {
addPath(src);
}
public void offset(float dx, float dy) {
Matrix matrix = new Matrix();
matrix.setTranslate(dx, dy);
transform(matrix);
}
@SuppressWarnings("deprecation")
@Override
protected void finalize() throws Throwable {

View File

@@ -24,6 +24,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.LayoutDirection;
import android.util.TypedValue;
public class Drawable {
@@ -323,6 +324,10 @@ public class Drawable {
public void setHotspot(float x, float y) {}
public int getLayoutDirection() {
return LayoutDirection.LTR;
}
protected static native long native_paintable_from_path(String path);
protected native long native_constructor();
protected native void native_invalidate(long paintable);

View File

@@ -1,8 +1,14 @@
package android.graphics.drawable;
import android.graphics.Bitmap;
public class Icon {
public static Icon createWithResource(String packageName, int resourceId) {
return null;
}
public static Icon createWithBitmap(Bitmap bitmap) {
return null;
}
}

View File

@@ -2,6 +2,8 @@ package android.net;
import android.os.Handler;
class NetworkCapabilities {}
public class ConnectivityManager {
public class NetworkCallback {
@@ -19,6 +21,8 @@ public class ConnectivityManager {
public native void registerNetworkCallback(NetworkRequest request, NetworkCallback callback);
public void unregisterNetworkCallback(NetworkCallback callback) {}
public native boolean isActiveNetworkMetered();
protected native boolean nativeGetNetworkAvailable();
@@ -33,4 +37,8 @@ public class ConnectivityManager {
public void registerDefaultNetworkCallback(NetworkCallback cb, Handler hdl) {}
public NetworkCapabilities getNetworkCapabilities(Network network) {
return null;
}
}

View File

@@ -1,7 +1,7 @@
package android.net.http;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.X509TrustManager;
@@ -12,6 +12,6 @@ public class X509TrustManagerExtensions {
public List<X509Certificate> checkServerTrusted (X509Certificate[] chain,
String authType, String host) {
return new ArrayList<>();
return Arrays.asList(chain);
}
}

View File

@@ -12,7 +12,7 @@ public class BaseBundle {
// Invariant - exactly one of mMap / mParcelledData will be null
// (except inside a call to unparcel)
/* package */ ArrayMap<String, Object> mMap = null;
/* package */ ArrayMap<String, Object> mMap = new ArrayMap<>();
// Log a message if the value was non-null but not of the expected type
void typeWarning(String key, Object value, String className,

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