Add some missing APIs.

android.widget.Filter and android.webkit.MimeTypeMap are copied from
AOSP. Other new classes are only stub implementations.
This commit is contained in:
Julian Winkler
2023-09-01 12:55:04 +02:00
parent 6c2a3adae6
commit 97f8c2ed0f
30 changed files with 1165 additions and 38 deletions

View File

@@ -290,6 +290,10 @@ public class Activity extends Context implements Window.Callback {
}
}
public void setResult(int resultCode) {
setResult(resultCode, null);
}
public void startActivity(Intent intent) {
System.out.println("startActivity(" + intent + ") called");
try {
@@ -392,4 +396,12 @@ public class Activity extends Context implements Window.Callback {
onOptionsMenuClosed(menu);
}
}
public void setTitle(CharSequence title) {}
public void onBackPressed() {
finish();
}
public void unregisterReceiver(BroadcastReceiver receiver) {}
}

View File

@@ -1,4 +1,10 @@
package android.app;
import android.content.Context;
public class ProgressDialog extends Dialog {
public ProgressDialog(Context context, int themeResId) {
super(context, themeResId);
}
}

View File

@@ -7,10 +7,6 @@ import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.SharedPreferencesImpl;
import android.app.UiModeManager;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
@@ -32,8 +28,10 @@ import android.telephony.TelephonyManager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
@@ -171,6 +169,10 @@ public class Context extends Object {
return new LocationManager();
case "uimode":
return new UiModeManager();
case "input_method":
return new InputMethodManager();
case "accessibility":
return new AccessibilityManager();
default:
System.out.println("!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
return null;
@@ -367,4 +369,10 @@ public class Context extends Object {
databaseDir.mkdirs();
return new File(databaseDir, dbName);
}
public void sendBroadcast(Intent intent) {}
public boolean stopService(Intent intent) {return false;}
public void unbindService(ServiceConnection serviceConnection) {}
}

View File

@@ -4,8 +4,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class Intent {
private ComponentName component;
@@ -193,6 +191,18 @@ public class Intent {
return (Serializable)extras.get(name);
}
public Parcelable getParcelableExtra(String name) {
return extras.getParcelable(name);
}
public String[] getStringArrayExtra(String name) {
return extras.getStringArray(name);
}
public int getIntExtra(String name, int def) {
return extras.getInt(name, def);
}
public Bundle getExtras() {
return extras;
}

View File

@@ -37,6 +37,9 @@ import com.reandroid.arsc.value.ResValue;
import com.reandroid.arsc.value.ResValueMap;
import com.reandroid.arsc.value.ValueItem;
import com.reandroid.arsc.value.ValueType;
import com.reandroid.arsc.value.plurals.PluralsBag;
import com.reandroid.arsc.value.plurals.PluralsQuantity;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FileReader;
@@ -219,17 +222,20 @@ public final class AssetManager {
* identifier for the current configuration / skin.
*/
/*package*/ final CharSequence getResourceBagText(int ident, int bagEntryId) {
synchronized (this) {
TypedValue tmpValue = mValue;
int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
PluralsBag pluralsBag = PluralsBag.create(tableBlockSearch(ident).pickOne());
return pluralsBag.getQuantityString(PluralsQuantity.valueOf((short)bagEntryId));
// synchronized (this) {
// TypedValue tmpValue = mValue;
// int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true);
// if (block >= 0) {
// if (tmpValue.type == TypedValue.TYPE_STRING) {
// return mStringBlocks[block].get(tmpValue.data);
// }
// return tmpValue.coerceToString();
// }
// }
// return null;
}
/**
@@ -240,7 +246,13 @@ public final class AssetManager {
/*package*/ final String[] getResourceStringArray(final int id) {
ArrayList<String> values = new ArrayList<String>();
for (ResValueMap map : tableBlockSearch(id).pickOne().getResValueMapArray().getChildes()) {
values.add(map.getValueAsString());
if (map.getType() == TypedValue.TYPE_REFERENCE) {
values.add(String.valueOf(getResourceText(map.getData())));
} else if (map.getType() == TypedValue.TYPE_STRING) {
values.add(map.getValueAsString());
} else {
values.add("value of unknown type " + map.getType());
}
}
return values.toArray(new String[0]);
}

View File

@@ -260,13 +260,13 @@ public class Matrix {
* specified transformation.
*/
public void setScale(float sx, float sy, float px, float py) {
native_setScale(native_instance, sx, sy, px, py);
// native_setScale(native_instance, sx, sy, px, py);
}
/**
* Set the matrix to scale by sx and sy.
*/
public void setScale(float sx, float sy) {
native_setScale(native_instance, sx, sy);
// native_setScale(native_instance, sx, sy);
}
/**
* Set the matrix to rotate by the specified number of degrees, with a pivot

View File

@@ -19,4 +19,8 @@ public class BitmapDrawable extends Drawable {
canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getWidth()), new RectF(getBounds()), null);
}
public Bitmap getBitmap() {
return bitmap;
}
}

View File

@@ -4,6 +4,9 @@ import android.graphics.Canvas;
public class ColorDrawable extends Drawable {
public ColorDrawable(int color) {
}
@Override
public void draw(Canvas canvas) {
// TODO Auto-generated method stub

View File

@@ -24,7 +24,9 @@ public abstract class Drawable {
public abstract class ConstantState {
public abstract Drawable newDrawable(Resources res);
public abstract Drawable newDrawable(Resources res);
public abstract Drawable newDrawable();
}
public void setBounds(int left, int top, int right, int bottom) {

View File

@@ -0,0 +1,13 @@
package android.graphics.drawable;
import android.graphics.Canvas;
public class DrawableContainer extends Drawable {
@Override
public void draw(Canvas canvas) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'draw'");
}
}

View File

@@ -13,5 +13,7 @@ public class GradientDrawable extends Drawable {
public void setColor(int color) {}
public void setCornerRadius(float cornerRadius) {}
public void setShape(int shape) {}
}

View File

@@ -0,0 +1,13 @@
package android.graphics.drawable;
import android.graphics.Canvas;
public class ScaleDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'draw'");
}
}

View File

@@ -0,0 +1,15 @@
package android.graphics.drawable;
import android.graphics.Canvas;
public class StateListDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'draw'");
}
public void addState(int[] stateSet, Drawable drawable) {}
}

View File

@@ -307,7 +307,7 @@ public class KeyCharacterMap {
}
}
return inputDevice.getKeyCharacterMap();*/
return null;
return new KeyCharacterMap(0);
}
/**
@@ -609,7 +609,8 @@ public class KeyCharacterMap {
* @return The keyboard type.
*/
public int getKeyboardType() {
return nativeGetKeyboardType(mPtr);
return FULL;
// return nativeGetKeyboardType(mPtr);
}
/**

View File

@@ -9,8 +9,11 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.LayoutDirection;
import android.util.SparseArray;
import android.view.animation.Animation;
import java.util.ArrayList;
import java.util.HashMap;
@@ -779,6 +782,7 @@ public class View extends Object {
protected ViewGroup.LayoutParams layout_params;
private Context context;
private Map<Integer,Object> tags = new HashMap<>();
private Object tag;
int measuredWidth = 0;
int measuredHeight = 0;
@@ -1019,7 +1023,10 @@ public class View extends Object {
public static class AccessibilityDelegate {}
public Drawable getBackground() {
return null;
return new Drawable() {
@Override
public void draw(Canvas canvas) {}
};
}
public void setClickable(boolean clickable) {}
@@ -1090,6 +1097,10 @@ public class View extends Object {
return result | (childMeasuredState&MEASURED_STATE_MASK);
}
public static int resolveSize(int size, int measureSpec) {
return resolveSizeAndState(size, measureSpec, 0) & MEASURED_SIZE_MASK;
}
public final int getMeasuredWidth() {
return this.measuredWidth & MEASURED_SIZE_MASK;
}
@@ -1168,6 +1179,13 @@ public class View extends Object {
return tags.get(key);
}
public void setTag(Object tag) {
this.tag = tag;
}
public Object getTag() {
return tag;
}
public void addOnLayoutChangeListener(OnLayoutChangeListener listener) {}
public boolean isSelected() {return false;}
@@ -1250,5 +1268,44 @@ public class View extends Object {
return result;
}
public static class BaseSavedState extends AbsSavedState {
}
public void clearFocus() {}
public void setRotation(float rotation) {}
public void setScaleX(float scaleX) {}
public void setScaleY(float scaleY) {}
public static View inflate(Context context, int resource, ViewGroup root) {
LayoutInflater factory = LayoutInflater.from(context);
return factory.inflate(resource, root);
}
public void saveHierarchyState(SparseArray<Parcelable> array) {}
public void setDuplicateParentStateEnabled(boolean enabled) {}
public boolean performClick() {
return false;
}
public void playSoundEffect(int soundConstant) {}
public void computeScroll() {}
public void jumpDrawablesToCurrentState() {}
public void setOnFocusChangeListener (View.OnFocusChangeListener l) {}
public boolean hasWindowFocus() {return true;}
public void setSaveEnabled (boolean enabled) {}
public boolean willNotDraw() {return false;}
public void setOnCreateContextMenuListener (View.OnCreateContextMenuListener l) {}
public void startAnimation(Animation animation) {}
}

View File

@@ -103,6 +103,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
}
public void attachViewToParent(View view, int index, LayoutParams params) {
addViewInternal(view, index, params);
}
protected void removeDetachedView(View child, boolean animate) {
@@ -131,6 +132,9 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
}
protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
return p;
}
public void bringChildToFront(View child) {
// TODO: actually implement this (might make sense to implement it in the subclasses instead), when applicable
@@ -150,7 +154,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
public void setOnHierarchyChangeListener(OnHierarchyChangeListener listener) {}
public boolean checkLayoutParams(LayoutParams params) {
protected boolean checkLayoutParams(LayoutParams params) {
return true;
}
@@ -233,12 +237,30 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
protected void measureChild(View child, int parentWidthMeasureSpec,
int parentHeightMeasureSpec) {
final LayoutParams lp = child.getLayoutParams();
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
/*mPaddingLeft + mPaddingRight*/0, lp.width);
final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec,
/*mPaddingTop + mPaddingBottom*/0, lp.height);
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
public void setAddStatesFromChildren(boolean addsStates) {}
public View getFocusedChild() {return null;}
public int getDescendantFocusability() {return 0;}
public void startViewTransition(View view) {}
public void endViewTransition(View view) {}
protected LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
public void focusableViewAvailable(View v) {}
public static class LayoutParams {
public static final int FILL_PARENT = -1;
public static final int MATCH_PARENT = -1;

View File

@@ -2,4 +2,6 @@ package android.view;
public interface ViewParent {
public abstract ViewParent getParent();
public boolean isLayoutRequested();
}

View File

@@ -0,0 +1,16 @@
package android.view;
import android.content.Context;
import android.util.AttributeSet;
public class ViewStub extends View {
public ViewStub(Context context) {
super(context);
}
public ViewStub(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
}

View File

@@ -1,5 +1,16 @@
package android.view.accessibility;
import java.util.ArrayList;
import java.util.List;
public class AccessibilityManager {
public boolean isTouchExplorationEnabled() {return false;}
public boolean isEnabled() {return false;}
public List getEnabledAccessibilityServiceList(int feedbackTypeFlags) {
return new ArrayList<>();
}
}

View File

@@ -1,5 +1,9 @@
package android.view.inputmethod;
import android.os.IBinder;
public class InputMethodManager {
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) {return false;}
}

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