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: add some methods to make the WhatsApp video player functional
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
@@ -55,6 +56,8 @@ public abstract class ContentProvider {
|
||||
|
||||
public abstract ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException;
|
||||
|
||||
public abstract AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException;
|
||||
|
||||
public void attachInfo(Context context, ProviderInfo provider) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
@@ -39,6 +40,18 @@ public class ContentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
public AssetFileDescriptor openAssetFileDescriptor(Uri uri, String mode) throws FileNotFoundException {
|
||||
if ("file".equals(uri.getScheme())) {
|
||||
return new AssetFileDescriptor(ParcelFileDescriptor.open(new File(uri.getPath()), ParcelFileDescriptor.parseMode(mode)), 0, AssetFileDescriptor.UNKNOWN_LENGTH);
|
||||
} else {
|
||||
ContentProvider provider = ContentProvider.providers.get(uri.getAuthority());
|
||||
if (provider != null)
|
||||
return provider.openAssetFile(uri, mode);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
ContentProvider provider = ContentProvider.providers.get(uri.getAuthority());
|
||||
if (provider != null) {
|
||||
|
||||
@@ -54,6 +54,7 @@ import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -257,6 +258,8 @@ public class Context extends Object {
|
||||
return new AppOpsManager();
|
||||
case "user":
|
||||
return new UserManager();
|
||||
case "captioning":
|
||||
return new CaptioningManager();
|
||||
default:
|
||||
Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
|
||||
return null;
|
||||
|
||||
@@ -424,4 +424,8 @@ public class Intent implements Parcelable {
|
||||
&& Objects.equals(this.data, other.data)
|
||||
&& Objects.equals(this.type, other.type);
|
||||
}
|
||||
|
||||
public long[] getLongArrayExtra(String name) {
|
||||
return extras.getLongArray(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,8 @@ public class PathMeasure {
|
||||
public boolean getPosTan(float distance, float[] pos, float[] tan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextContour() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ public final class DisplayManager {
|
||||
public void registerDisplayListener(DisplayListener listener, Handler handler) {
|
||||
}
|
||||
|
||||
public void unregisterDisplayListener(DisplayListener listener) {}
|
||||
|
||||
public Display[] getDisplays() {
|
||||
return new Display[0];
|
||||
}
|
||||
|
||||
@@ -78,10 +78,18 @@ public class MediaCodec {
|
||||
return inputBuffers;
|
||||
}
|
||||
|
||||
public ByteBuffer getInputBuffer(int index) {
|
||||
return inputBuffers[index];
|
||||
}
|
||||
|
||||
public ByteBuffer[] getOutputBuffers() {
|
||||
return outputBuffers;
|
||||
}
|
||||
|
||||
public ByteBuffer getOutputBuffer(int index) {
|
||||
return outputBuffers[index];
|
||||
}
|
||||
|
||||
public int dequeueOutputBuffer(BufferInfo info, long timeoutUs) {
|
||||
if (!outputFormatSet) {
|
||||
outputFormatSet = true;
|
||||
@@ -107,6 +115,11 @@ public class MediaCodec {
|
||||
freeOutputBuffers.add(index);
|
||||
}
|
||||
|
||||
public void releaseOutputBuffer(int index, long presentationTimeUs) {
|
||||
native_releaseOutputBuffer(native_codec, outputBuffers[index], true);
|
||||
freeOutputBuffers.add(index);
|
||||
}
|
||||
|
||||
public MediaFormat getOutputFormat() {
|
||||
return mediaFormat;
|
||||
}
|
||||
@@ -155,6 +168,8 @@ public class MediaCodec {
|
||||
System.out.println("MediaCodec.setVideoScalingMode(" + mode + "): codecName=" + codecName);
|
||||
}
|
||||
|
||||
public void stop() {}
|
||||
|
||||
public void release() {
|
||||
System.out.println("MediaCodec.release(): codecName=" + codecName);
|
||||
if (native_codec != 0) {
|
||||
|
||||
@@ -23,10 +23,23 @@ public class MediaCodecInfo {
|
||||
}
|
||||
|
||||
public CodecCapabilities getCapabilitiesForType(String type) {
|
||||
return null;
|
||||
return new CodecCapabilities();
|
||||
}
|
||||
|
||||
public static class CodecCapabilities {}
|
||||
public static class CodecCapabilities {
|
||||
|
||||
public CodecProfileLevel[] profileLevels;
|
||||
|
||||
public boolean isFeatureSupported(String feature) {
|
||||
System.out.println("CodecCapabilities.isFeatureSupported("+feature+")");
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isFeatureRequired(String feature) {
|
||||
System.out.println("CodecCapabilities.isFeatureRequired("+feature+")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CodecProfileLevel {}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package android.media;
|
||||
|
||||
public class MediaCodecList {
|
||||
|
||||
public MediaCodecList(int kind) {}
|
||||
|
||||
public static int getCodecCount() {
|
||||
return 6;
|
||||
}
|
||||
@@ -25,4 +27,11 @@ public class MediaCodecList {
|
||||
}
|
||||
}
|
||||
|
||||
public MediaCodecInfo[] getCodecInfos() {
|
||||
MediaCodecInfo[] infos = new MediaCodecInfo[getCodecCount()];
|
||||
for (int i=0; i<infos.length; i++)
|
||||
infos[i] = getCodecInfoAt(i);
|
||||
return infos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package android.media;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
|
||||
public class MediaMetadataRetriever {
|
||||
@@ -34,4 +35,12 @@ public class MediaMetadataRetriever {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap getFrameAtTime(long time) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Bitmap getFrameAtTime() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import android.util.AttributeSet;
|
||||
|
||||
public class TextureView extends View {
|
||||
|
||||
private SurfaceTextureListener surfaceTextureListener;
|
||||
|
||||
public TextureView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -15,8 +17,18 @@ public class TextureView extends View {
|
||||
|
||||
public interface SurfaceTextureListener {}
|
||||
|
||||
public void setSurfaceTextureListener(SurfaceTextureListener surfaceTextureListener) {}
|
||||
public void setSurfaceTextureListener(SurfaceTextureListener surfaceTextureListener) {
|
||||
this.surfaceTextureListener = surfaceTextureListener;
|
||||
}
|
||||
|
||||
public void setOpaque(boolean opaque) {}
|
||||
|
||||
public SurfaceTextureListener getSurfaceTextureListener() {
|
||||
return surfaceTextureListener;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import android.R;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.GskCanvas;
|
||||
import android.graphics.Matrix;
|
||||
@@ -1765,6 +1767,8 @@ public class View implements Drawable.Callback {
|
||||
protected void onAnimationEnd() {}
|
||||
|
||||
public void startAnimation(Animation animation) {
|
||||
if (animation == null)
|
||||
return;
|
||||
onAnimationStart();
|
||||
animation.start();
|
||||
onAnimationEnd();
|
||||
@@ -2211,4 +2215,16 @@ public class View implements Drawable.Callback {
|
||||
public void setNextFocusDownId(int id) {}
|
||||
|
||||
public void setNextFocusUpId(int id) {}
|
||||
|
||||
public void setHasTransientState(boolean hasTransientState) {}
|
||||
|
||||
protected void onConfigurationChanged(Configuration newConfig) {}
|
||||
|
||||
public boolean isDrawingCacheEnabled() { return false; }
|
||||
|
||||
public void setDrawingCacheEnabled(boolean enabled) {}
|
||||
|
||||
public void buildDrawingCache(boolean autoScale) {}
|
||||
|
||||
public Bitmap getDrawingCache() { return null; }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
package android.view.accessibility;
|
||||
|
||||
public class CaptioningManager {
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getFontScale() {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ public class RelativeLayout extends ViewGroup {
|
||||
myWidth = DEFAULT_WIDTH;
|
||||
}
|
||||
View[] views = mSortedHorizontalChildren;
|
||||
int count = views.length;
|
||||
int count = views == null ? 0 : views.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
View child = views[i];
|
||||
if (child.getVisibility() != GONE) {
|
||||
@@ -421,7 +421,7 @@ public class RelativeLayout extends ViewGroup {
|
||||
}
|
||||
}
|
||||
views = mSortedVerticalChildren;
|
||||
count = views.length;
|
||||
count = views == null ? 0 : views.length;
|
||||
final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = views[i];
|
||||
|
||||
Reference in New Issue
Block a user