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
api-impl: misc stubs and fixes for several apps including F-Droid and AuroraStore
This commit is contained in:
@@ -267,3 +267,11 @@ JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setValues(JNIEnv *en
|
|||||||
graphene_matrix_init_from_float(matrix, *values4x4);
|
graphene_matrix_init_from_float(matrix, *values4x4);
|
||||||
(*env)->ReleaseFloatArrayElements(env, values_ref, values, 0);
|
(*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));
|
||||||
|
}
|
||||||
|
|||||||
16
src/api-impl/android/app/ActivityOptions.java
Normal file
16
src/api-impl/android/app/ActivityOptions.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
public class AppOpsManager {
|
public class AppOpsManager {
|
||||||
|
|
||||||
|
public static String permissionToOp(String permission) {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int noteProxyOpNoThrow(String op, String pkg) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package android.app;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class PendingIntent {
|
public class PendingIntent implements Parcelable {
|
||||||
|
|
||||||
private int requestCode;
|
private int requestCode;
|
||||||
Intent intent;
|
Intent intent;
|
||||||
@@ -25,6 +27,17 @@ public class PendingIntent {
|
|||||||
|
|
||||||
public void send(Context context, int code, Intent intent) {}
|
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) {
|
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags) {
|
||||||
return new PendingIntent(requestCode, intent, 0);
|
return new PendingIntent(requestCode, intent, 0);
|
||||||
}
|
}
|
||||||
@@ -33,6 +46,10 @@ public class PendingIntent {
|
|||||||
return new PendingIntent(requestCode, intent, 1);
|
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() {
|
public String toString() {
|
||||||
return "PendingIntent [requestCode=" + requestCode + ", intent=" + intent + ", type="
|
return "PendingIntent [requestCode=" + requestCode + ", intent=" + intent + ", type="
|
||||||
+ new String[] { "activity", "service", "broadcast" }[type] + "]";
|
+ new String[] { "activity", "service", "broadcast" }[type] + "]";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package android.app.job;
|
package android.app.job;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
|
|
||||||
public class JobInfo {
|
public class JobInfo {
|
||||||
|
|
||||||
@@ -21,6 +22,26 @@ public class JobInfo {
|
|||||||
return this;
|
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() {
|
public JobInfo build() {
|
||||||
return new JobInfo();
|
return new JobInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,8 @@ public class JobScheduler {
|
|||||||
public int enqueue(JobInfo job, JobWorkItem work) {
|
public int enqueue(JobInfo job, JobWorkItem work) {
|
||||||
return 1; //RESULT_SUCCESS
|
return 1; //RESULT_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int schedule(JobInfo job) {
|
||||||
|
return 1; //RESULT_SUCCESS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ public class Context extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final Object getSystemService(Class<?> serviceClass) throws InstantiationException, IllegalAccessException, InvocationTargetException {
|
public final Object getSystemService(Class<?> serviceClass) throws InstantiationException, IllegalAccessException, InvocationTargetException {
|
||||||
|
if (serviceClass == LayoutInflater.class)
|
||||||
|
return layout_inflater;
|
||||||
return serviceClass.getConstructors()[0].newInstance();
|
return serviceClass.getConstructors()[0].newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -706,4 +708,13 @@ public class Context extends Object {
|
|||||||
public Drawable getWallpaper() {
|
public Drawable getWallpaper() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] databaseList() {
|
||||||
|
File databaseDir = new File(getDataDirFile(), "databases");
|
||||||
|
if (databaseDir.exists()) {
|
||||||
|
return databaseDir.list();
|
||||||
|
} else {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package android.content;
|
package android.content;
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -378,4 +383,12 @@ public class Intent implements Parcelable {
|
|||||||
public int filterHashCode() {
|
public int filterHashCode() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs) {
|
||||||
|
return new Intent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentName resolveActivity(PackageManager pm) {
|
||||||
|
return component;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/api-impl/android/content/pm/PackageInstaller.java
Normal file
11
src/api-impl/android/content/pm/PackageInstaller.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1385,7 +1385,11 @@ public class PackageManager {
|
|||||||
* @see #GET_UNINSTALLED_PACKAGES
|
* @see #GET_UNINSTALLED_PACKAGES
|
||||||
*/
|
*/
|
||||||
public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException {
|
public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException {
|
||||||
|
if (packageName.equals(Context.pkg.packageName)) {
|
||||||
return PackageParser.generatePackageInfo(Context.pkg, new int[0], flags, 0, 0, new HashSet<>(), new PackageUserState());
|
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
|
* @see #PERMISSION_DENIED
|
||||||
*/
|
*/
|
||||||
public int checkPermission(String permName, String pkgName) {
|
public int checkPermission(String permName, String pkgName) {
|
||||||
|
if (permName != null && permName.endsWith(".DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"))
|
||||||
|
return PERMISSION_GRANTED;
|
||||||
|
|
||||||
switch (permName) {
|
switch (permName) {
|
||||||
// TODO: we shouldn't just automatically grant these once we have bubblewrap set up
|
// 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
|
// for now, the app can access anything it wants, so no point telling it otherwise
|
||||||
case "android.permission.WRITE_EXTERNAL_STORAGE":
|
case "android.permission.WRITE_EXTERNAL_STORAGE":
|
||||||
case "android.permission.READ_EXTERNAL_STORAGE":
|
case "android.permission.READ_EXTERNAL_STORAGE":
|
||||||
case "com.google.android.c2dm.permission.SEND":
|
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;
|
return PERMISSION_GRANTED;
|
||||||
default:
|
default:
|
||||||
System.out.println("PackageManager.checkPermission: >" + permName + "< not handled\n");
|
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(!!).
|
* that are available on the system, or null if there are none(!!).
|
||||||
*/
|
*/
|
||||||
public FeatureInfo[] getSystemAvailableFeatures() {
|
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
|
// TODO: This should be shared with Installer's knowledge of user directory
|
||||||
return Environment.getDataDirectory().toString() + "/user/" + userId + "/" + packageName;
|
return Environment.getDataDirectory().toString() + "/user/" + userId + "/" + packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PackageInstaller getPackageInstaller() {
|
||||||
|
return new PackageInstaller();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ public final class Bitmap {
|
|||||||
|
|
||||||
public void setPremultiplied(boolean premultiplied) {}
|
public void setPremultiplied(boolean premultiplied) {}
|
||||||
|
|
||||||
|
public Bitmap extractAlpha() {
|
||||||
|
return this.copy(config, mutable);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
|
|||||||
@@ -482,6 +482,10 @@ public class Canvas {
|
|||||||
return false;
|
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 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) {}
|
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint) {}
|
||||||
|
|||||||
@@ -158,4 +158,25 @@ public class Color {
|
|||||||
}
|
}
|
||||||
hsv[2] = max;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class GskCanvas extends Canvas {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPath(Path path, Paint paint) {
|
public void drawPath(Path path, Paint paint) {
|
||||||
|
if (path != null)
|
||||||
native_drawPath(snapshot, path.getGskPath(), paint != null ? paint.paint : default_paint.paint);
|
native_drawPath(snapshot, path.getGskPath(), paint != null ? paint.paint : default_paint.paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,12 @@ public class Path {
|
|||||||
addPath(src);
|
addPath(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void offset(float dx, float dy) {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.setTranslate(dx, dy);
|
||||||
|
transform(matrix);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.graphics.PorterDuff;
|
|||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.LayoutDirection;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
public class Drawable {
|
public class Drawable {
|
||||||
@@ -323,6 +324,10 @@ public class Drawable {
|
|||||||
|
|
||||||
public void setHotspot(float x, float y) {}
|
public void setHotspot(float x, float y) {}
|
||||||
|
|
||||||
|
public int getLayoutDirection() {
|
||||||
|
return LayoutDirection.LTR;
|
||||||
|
}
|
||||||
|
|
||||||
protected static native long native_paintable_from_path(String path);
|
protected static native long native_paintable_from_path(String path);
|
||||||
protected native long native_constructor();
|
protected native long native_constructor();
|
||||||
protected native void native_invalidate(long paintable);
|
protected native void native_invalidate(long paintable);
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package android.graphics.drawable;
|
package android.graphics.drawable;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
public class Icon {
|
public class Icon {
|
||||||
|
|
||||||
public static Icon createWithResource(String packageName, int resourceId) {
|
public static Icon createWithResource(String packageName, int resourceId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Icon createWithBitmap(Bitmap bitmap) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package android.net;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
class NetworkCapabilities {}
|
||||||
|
|
||||||
public class ConnectivityManager {
|
public class ConnectivityManager {
|
||||||
|
|
||||||
public class NetworkCallback {
|
public class NetworkCallback {
|
||||||
@@ -19,6 +21,8 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
public native void registerNetworkCallback(NetworkRequest request, NetworkCallback callback);
|
public native void registerNetworkCallback(NetworkRequest request, NetworkCallback callback);
|
||||||
|
|
||||||
|
public void unregisterNetworkCallback(NetworkCallback callback) {}
|
||||||
|
|
||||||
public native boolean isActiveNetworkMetered();
|
public native boolean isActiveNetworkMetered();
|
||||||
|
|
||||||
protected native boolean nativeGetNetworkAvailable();
|
protected native boolean nativeGetNetworkAvailable();
|
||||||
@@ -33,4 +37,8 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
public void registerDefaultNetworkCallback(NetworkCallback cb, Handler hdl) {}
|
public void registerDefaultNetworkCallback(NetworkCallback cb, Handler hdl) {}
|
||||||
|
|
||||||
|
public NetworkCapabilities getNetworkCapabilities(Network network) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package android.net.http;
|
package android.net.http;
|
||||||
|
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
@@ -12,6 +12,6 @@ public class X509TrustManagerExtensions {
|
|||||||
|
|
||||||
public List<X509Certificate> checkServerTrusted (X509Certificate[] chain,
|
public List<X509Certificate> checkServerTrusted (X509Certificate[] chain,
|
||||||
String authType, String host) {
|
String authType, String host) {
|
||||||
return new ArrayList<>();
|
return Arrays.asList(chain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class BaseBundle {
|
|||||||
// Invariant - exactly one of mMap / mParcelledData will be null
|
// Invariant - exactly one of mMap / mParcelledData will be null
|
||||||
// (except inside a call to unparcel)
|
// (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
|
// Log a message if the value was non-null but not of the expected type
|
||||||
void typeWarning(String key, Object value, String className,
|
void typeWarning(String key, Object value, String className,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user