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
src/api-impl: misc stubbing
This commit is contained in:
@@ -137,14 +137,6 @@ JNIEXPORT jint JNICALL Java_android_os_Process_getUidForName
|
||||
JNIEXPORT jint JNICALL Java_android_os_Process_getGidForName
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: android_os_Process
|
||||
* Method: setThreadPriority
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_os_Process_setThreadPriority
|
||||
(JNIEnv *, jclass, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: android_os_Process
|
||||
* Method: setCanSelfBackground
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.media.AudioManager;
|
||||
import android.app.ActivityManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Vibrator;
|
||||
import android.hardware.display.DisplayManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -38,6 +39,12 @@ import java.io.FileOutputStream;
|
||||
public class Context extends Object {
|
||||
private final static String TAG = "Context";
|
||||
|
||||
public static final int MODE_PRIVATE = 0;
|
||||
public static final String LOCATION_SERVICE = "location";
|
||||
public static final String AUDIO_SERVICE = "audio";
|
||||
public static final String DISPLAY_SERVICE = "display";
|
||||
public static final String MEDIA_ROUTER_SERVICE = "media_router";
|
||||
|
||||
static AssetManager assets;
|
||||
static DisplayMetrics dm;
|
||||
static Configuration config;
|
||||
@@ -67,6 +74,10 @@ public class Context extends Object {
|
||||
System.out.println("new Context! this one is: " + this);
|
||||
}
|
||||
|
||||
public int checkPermission (String permission, int pid, int uid) {
|
||||
return getPackageManager().checkPermission(permission, "dummy");
|
||||
}
|
||||
|
||||
public Resources.Theme getTheme() {
|
||||
return r.newTheme();
|
||||
}
|
||||
@@ -109,6 +120,8 @@ public class Context extends Object {
|
||||
return new Vibrator();
|
||||
case "power":
|
||||
return new PowerManager();
|
||||
case "display":
|
||||
return new DisplayManager();
|
||||
default:
|
||||
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet");
|
||||
return null;
|
||||
@@ -191,6 +204,10 @@ public class Context extends Object {
|
||||
return obb_dir;
|
||||
}
|
||||
|
||||
public File[] getObbDirs() {
|
||||
return new File[]{getObbDir()};
|
||||
}
|
||||
|
||||
// FIXME: should be something like /tmp/cache, but may need to create that directory
|
||||
public File getCacheDir() {
|
||||
if (cache_dir == null) {
|
||||
|
||||
@@ -653,4 +653,6 @@ public class ApplicationInfo extends PackageItemInfo {
|
||||
@Override protected ApplicationInfo getApplicationInfo() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] splitPublicSourceDirs = new String[0];
|
||||
}
|
||||
|
||||
@@ -1797,7 +1797,17 @@ public class PackageManager {
|
||||
* @see #PERMISSION_DENIED
|
||||
*/
|
||||
public int checkPermission(String permName, String pkgName) {
|
||||
return -1;
|
||||
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":
|
||||
return PERMISSION_GRANTED;
|
||||
case "android.permission.READ_EXTERNAL_STORAGE":
|
||||
return PERMISSION_GRANTED;
|
||||
default:
|
||||
System.out.println("PackageManager.checkPermission: >"+permName+"< not handled\n");
|
||||
return PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,56 +3,125 @@ package android.graphics;
|
||||
public class Paint {
|
||||
private int color = 0xFF000000;
|
||||
|
||||
public void setColor(int color) {
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean aa) {}
|
||||
public void setStrokeWidth(float width) {}
|
||||
public void setTextSize(float textSize) {}
|
||||
public void setTextSize(float textSize) {}
|
||||
|
||||
public Typeface setTypeface(Typeface typeface) {
|
||||
return null;
|
||||
public Typeface setTypeface(Typeface typeface) {
|
||||
return new Typeface();
|
||||
}
|
||||
public void getTextBounds(String text, int start, int end, Rect bounds) {}
|
||||
public void getTextBounds(char[] text, int index, int count, Rect bounds) {}
|
||||
public void getTextBounds(String text, int start, int end, Rect bounds) {}
|
||||
public void getTextBounds(char[] text, int index, int count, Rect bounds) {}
|
||||
public void setFlags(int flags) {}
|
||||
public void setFilterBitmap(boolean filter) {}
|
||||
public void setStyle(Style style) {}
|
||||
public float ascent() { return 0; }
|
||||
public void setStyle(Style style) {}
|
||||
public float ascent() { return 0; }
|
||||
|
||||
public float measureText(char[] text, int index, int count) { return 10; }
|
||||
public float measureText(String text, int start, int end) { return 10; }
|
||||
public float measureText(String text) { return 10; }
|
||||
public float measureText(CharSequence text, int start, int end) { return 10; }
|
||||
public float measureText(char[] text, int index, int count) { return 10; }
|
||||
public float measureText(String text, int start, int end) { return 10; }
|
||||
public float measureText(String text) { return 10; }
|
||||
public float measureText(CharSequence text, int start, int end) { return 10; }
|
||||
|
||||
public enum Style {
|
||||
/**
|
||||
* Geometry and text drawn with this style will be filled, ignoring all
|
||||
* stroke-related settings in the paint.
|
||||
*/
|
||||
FILL (0),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be stroked, respecting
|
||||
* the stroke-related fields on the paint.
|
||||
*/
|
||||
STROKE (1),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be both filled and
|
||||
* stroked at the same time, respecting the stroke-related fields on
|
||||
* the paint. This mode can give unexpected results if the geometry
|
||||
* is oriented counter-clockwise. This restriction does not apply to
|
||||
* either FILL or STROKE.
|
||||
*/
|
||||
FILL_AND_STROKE (2);
|
||||
|
||||
Style(int nativeInt) {
|
||||
this.nativeInt = nativeInt;
|
||||
}
|
||||
final int nativeInt;
|
||||
}
|
||||
|
||||
public static class FontMetrics {
|
||||
/**
|
||||
* The maximum distance above the baseline for the tallest glyph in
|
||||
* the font at a given text size.
|
||||
*/
|
||||
public float top;
|
||||
/**
|
||||
* The recommended distance above the baseline for singled spaced text.
|
||||
*/
|
||||
public float ascent;
|
||||
/**
|
||||
* The recommended distance below the baseline for singled spaced text.
|
||||
*/
|
||||
public float descent;
|
||||
/**
|
||||
* The maximum distance below the baseline for the lowest glyph in
|
||||
* the font at a given text size.
|
||||
*/
|
||||
public float bottom;
|
||||
/**
|
||||
* The recommended additional space to add between lines of text.
|
||||
*/
|
||||
public float leading;
|
||||
}
|
||||
|
||||
public static class FontMetricsInt {
|
||||
public int top;
|
||||
public int ascent;
|
||||
public int descent;
|
||||
public int bottom;
|
||||
public int leading;
|
||||
|
||||
@Override public String toString() {
|
||||
return "FontMetricsInt: top=" + top + " ascent=" + ascent +
|
||||
" descent=" + descent + " bottom=" + bottom +
|
||||
" leading=" + leading;
|
||||
}
|
||||
}
|
||||
|
||||
public /*native*/ int getFlags() {return 0;}
|
||||
|
||||
public /*native*/ int getHinting() {return 0;}
|
||||
public /*native*/ void setHinting(int mode) {}
|
||||
|
||||
public /*native*/ void setDither(boolean dither) {}
|
||||
public /*native*/ void setLinearText(boolean linearText) {}
|
||||
public /*native*/ void setSubpixelText(boolean subpixelText) {}
|
||||
public /*native*/ void setUnderlineText(boolean underlineText) {}
|
||||
public /*native*/ void setStrikeThruText(boolean strikeThruText) {}
|
||||
public /*native*/ void setFakeBoldText(boolean fakeBoldText) {}
|
||||
|
||||
public /*native*/ int getAlpha() {return 0;}
|
||||
public /*native*/ void setAlpha(int a) {}
|
||||
public /*native*/ float getStrokeWidth() {return 0;}
|
||||
|
||||
public /*native*/ float getStrokeMiter() {return 0;}
|
||||
public /*native*/ void setStrokeMiter(float miter) {}
|
||||
public /*native*/ float getTextSize() {return 0;}
|
||||
|
||||
public /*native*/ float getTextScaleX() {return 0;}
|
||||
public /*native*/ void setTextScaleX(float scaleX) {}
|
||||
public /*native*/ float getTextSkewX() {return 0;}
|
||||
public /*native*/ void setTextSkewX(float skewX) {}
|
||||
|
||||
public /*native*/ float descent() {return 0;}
|
||||
public /*native*/ float getFontMetrics(FontMetrics metrics) {return 0;}
|
||||
public /*native*/ int getFontMetricsInt(FontMetricsInt fmi) {return 0;}
|
||||
|
||||
public enum Style {
|
||||
/**
|
||||
* Geometry and text drawn with this style will be filled, ignoring all
|
||||
* stroke-related settings in the paint.
|
||||
*/
|
||||
FILL (0),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be stroked, respecting
|
||||
* the stroke-related fields on the paint.
|
||||
*/
|
||||
STROKE (1),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be both filled and
|
||||
* stroked at the same time, respecting the stroke-related fields on
|
||||
* the paint. This mode can give unexpected results if the geometry
|
||||
* is oriented counter-clockwise. This restriction does not apply to
|
||||
* either FILL or STROKE.
|
||||
*/
|
||||
FILL_AND_STROKE (2);
|
||||
|
||||
Style(int nativeInt) {
|
||||
this.nativeInt = nativeInt;
|
||||
}
|
||||
final int nativeInt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,28 @@ import android.content.res.AssetManager;
|
||||
|
||||
public class Typeface {
|
||||
|
||||
/** The default NORMAL typeface object */
|
||||
public static final Typeface DEFAULT = new Typeface();
|
||||
/**
|
||||
* The default BOLD typeface object. Note: this may be not actually be
|
||||
* bold, depending on what fonts are installed. Call getStyle() to know
|
||||
* for sure.
|
||||
*/
|
||||
public static final Typeface DEFAULT_BOLD = new Typeface();
|
||||
/** The NORMAL style of the default sans serif typeface. */
|
||||
public static final Typeface SANS_SERIF = new Typeface();
|
||||
/** The NORMAL style of the default serif typeface. */
|
||||
public static final Typeface SERIF = new Typeface();
|
||||
/** The NORMAL style of the default monospace typeface. */
|
||||
public static final Typeface MONOSPACE = new Typeface();
|
||||
|
||||
// Style
|
||||
public static final int NORMAL = 0;
|
||||
public static final int BOLD = 1;
|
||||
public static final int ITALIC = 2;
|
||||
public static final int BOLD_ITALIC = 3;
|
||||
|
||||
public static Typeface createFromAsset(AssetManager mgr, String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
package android.hardware.display;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.view.Display;
|
||||
|
||||
public final class DisplayManager {
|
||||
public static interface DisplayListener {}
|
||||
|
||||
public Display getDisplay(int dummy) {
|
||||
return new Display();
|
||||
}
|
||||
|
||||
public void registerDisplayListener(DisplayListener listener, Handler handler) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
package android.media;
|
||||
|
||||
public class AudioManager {
|
||||
public static final String PROPERTY_OUTPUT_FRAMES_PER_BUFFER = "android.media.property.OUTPUT_FRAMES_PER_BUFFER";
|
||||
public static final String PROPERTY_OUTPUT_SAMPLE_RATE = "android.media.property.OUTPUT_SAMPLE_RATE";
|
||||
|
||||
public static final int STREAM_MUSIC = 0x3;
|
||||
|
||||
public boolean isBluetoothA2dpOn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getProperty(String name) {
|
||||
switch(name) {
|
||||
case PROPERTY_OUTPUT_FRAMES_PER_BUFFER:
|
||||
return "256"; // FIXME arbitrary
|
||||
case PROPERTY_OUTPUT_SAMPLE_RATE:
|
||||
return "44100"; // FIXME arbitrary
|
||||
default:
|
||||
System.out.println("AudioManager.getProperty: >"+name+"< not handled");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnAudioFocusChangeListener {
|
||||
}
|
||||
|
||||
|
||||
@@ -622,8 +622,8 @@ public class Environment {
|
||||
* {@link #MEDIA_BAD_REMOVAL}, or {@link #MEDIA_UNMOUNTABLE}.
|
||||
*/
|
||||
public static String getExternalStorageState() {
|
||||
final File externalDir = sCurrentUser.getExternalDirsForApp()[0];
|
||||
return getStorageState(externalDir);
|
||||
// we don't do stupid stuff like having this on a separate partition, so it should always be "mounted"
|
||||
return MEDIA_MOUNTED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -505,8 +505,10 @@ public class Process {
|
||||
* not have permission to modify the given thread, or to use the given
|
||||
* priority.
|
||||
*/
|
||||
public static final native void setThreadPriority(int tid, int priority)
|
||||
throws IllegalArgumentException, SecurityException;
|
||||
public static final /*native*/ void setThreadPriority(int tid, int priority)
|
||||
throws IllegalArgumentException, SecurityException {
|
||||
// TODO - this is clearly not critical
|
||||
}
|
||||
|
||||
/**
|
||||
* Call with 'false' to cause future calls to {@link #setThreadPriority(int)} to
|
||||
|
||||
@@ -41,6 +41,8 @@ public class Settings {
|
||||
switch(key) {
|
||||
case "accelerometer_rotation":
|
||||
return 0; // degrees? no clue
|
||||
case "always_finish_activities":
|
||||
return 0; // we certainly don't aggressively kill activities :P
|
||||
default:
|
||||
java.lang.System.out.println("!!!! Settings$System.getInt: unknown key: >"+key+"<");
|
||||
return 0; // TODO: should be -1 probably?
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package android.support.v7.app;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
public class AppCompatActivity extends Activity {
|
||||
|
||||
}
|
||||
@@ -14,6 +14,14 @@ public final class Display {
|
||||
outMetrics.heightPixels = this.window_height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return window_width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return window_height;
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return 0/*ROTATION_0*/;
|
||||
}
|
||||
@@ -21,4 +29,16 @@ public final class Display {
|
||||
public float getRefreshRate() {
|
||||
return 60; // FIXME
|
||||
}
|
||||
|
||||
public long getAppVsyncOffsetNanos() {
|
||||
return 0; // what else would we return here?
|
||||
}
|
||||
|
||||
public int getDisplayId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getPresentationDeadlineNanos() {
|
||||
return 0; // what else...
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ public interface WindowManager {
|
||||
public android.view.Display getDefaultDisplay();
|
||||
|
||||
public class LayoutParams {
|
||||
public static final int FLAG_KEEP_SCREEN_ON = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ hax_jar = jar('hax', [
|
||||
'android/R.java',
|
||||
'android/support/multidex/MultiDexApplication.java',
|
||||
'android/support/v4/app/FragmentActivity.java',
|
||||
'android/support/v7/app/AppCompatActivity.java',
|
||||
'android/telephony/PhoneStateListener.java',
|
||||
'android/telephony/TelephonyManager.java',
|
||||
'android/text/ClipboardManager.java',
|
||||
|
||||
Reference in New Issue
Block a user