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
refactor source tree organization, switch to meson
This commit is contained in:
1183
src/api-impl/com/android/internal/Manifest.java
Normal file
1183
src/api-impl/com/android/internal/Manifest.java
Normal file
File diff suppressed because it is too large
Load Diff
53534
src/api-impl/com/android/internal/R.java
Normal file
53534
src/api-impl/com/android/internal/R.java
Normal file
File diff suppressed because it is too large
Load Diff
264
src/api-impl/com/android/internal/util/ArrayUtils.java
Normal file
264
src/api-impl/com/android/internal/util/ArrayUtils.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
// XXX these should be changed to reflect the actual memory allocator we use.
|
||||
// it looks like right now objects want to be powers of 2 minus 8
|
||||
// and the array size eats another 4 bytes
|
||||
|
||||
/**
|
||||
* ArrayUtils contains some methods that you can call to find out
|
||||
* the most efficient increments by which to grow arrays.
|
||||
*/
|
||||
public class ArrayUtils
|
||||
{
|
||||
private static Object[] EMPTY = new Object[0];
|
||||
private static final int CACHE_SIZE = 73;
|
||||
private static Object[] sCache = new Object[CACHE_SIZE];
|
||||
|
||||
private ArrayUtils() { /* cannot be instantiated */ }
|
||||
|
||||
public static int idealByteArraySize(int need) {
|
||||
for (int i = 4; i < 32; i++)
|
||||
if (need <= (1 << i) - 12)
|
||||
return (1 << i) - 12;
|
||||
|
||||
return need;
|
||||
}
|
||||
|
||||
public static int idealBooleanArraySize(int need) {
|
||||
return idealByteArraySize(need);
|
||||
}
|
||||
|
||||
public static int idealShortArraySize(int need) {
|
||||
return idealByteArraySize(need * 2) / 2;
|
||||
}
|
||||
|
||||
public static int idealCharArraySize(int need) {
|
||||
return idealByteArraySize(need * 2) / 2;
|
||||
}
|
||||
|
||||
public static int idealIntArraySize(int need) {
|
||||
return idealByteArraySize(need * 4) / 4;
|
||||
}
|
||||
|
||||
public static int idealFloatArraySize(int need) {
|
||||
return idealByteArraySize(need * 4) / 4;
|
||||
}
|
||||
|
||||
public static int idealObjectArraySize(int need) {
|
||||
return idealByteArraySize(need * 4) / 4;
|
||||
}
|
||||
|
||||
public static int idealLongArraySize(int need) {
|
||||
return idealByteArraySize(need * 8) / 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the beginnings of two byte arrays are equal.
|
||||
*
|
||||
* @param array1 the first byte array
|
||||
* @param array2 the second byte array
|
||||
* @param length the number of bytes to check
|
||||
* @return true if they're equal, false otherwise
|
||||
*/
|
||||
public static boolean equals(byte[] array1, byte[] array2, int length) {
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (array1 == array2) {
|
||||
return true;
|
||||
}
|
||||
if (array1 == null || array2 == null || array1.length < length || array2.length < length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (array1[i] != array2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty array of the specified type. The intent is that
|
||||
* it will return the same empty array every time to avoid reallocation,
|
||||
* although this is not guaranteed.
|
||||
*/
|
||||
public static <T> T[] emptyArray(Class<T> kind) {
|
||||
if (kind == Object.class) {
|
||||
return (T[]) EMPTY;
|
||||
}
|
||||
|
||||
int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE;
|
||||
Object cache = sCache[bucket];
|
||||
|
||||
if (cache == null || cache.getClass().getComponentType() != kind) {
|
||||
cache = Array.newInstance(kind, 0);
|
||||
sCache[bucket] = cache;
|
||||
|
||||
// Log.e("cache", "new empty " + kind.getName() + " at " + bucket);
|
||||
}
|
||||
|
||||
return (T[]) cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that value is present as at least one of the elements of the array.
|
||||
* @param array the array to check in
|
||||
* @param value the value to check for
|
||||
* @return true if the value is present in the array
|
||||
*/
|
||||
public static <T> boolean contains(T[] array, T value) {
|
||||
return indexOf(array, value) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return first index of {@code value} in {@code array}, or {@code -1} if
|
||||
* not found.
|
||||
*/
|
||||
public static <T> int indexOf(T[] array, T value) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i] == null) {
|
||||
if (value == null) return i;
|
||||
} else {
|
||||
if (value != null && array[i].equals(value)) return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if all {@code check} items are contained in {@code array}.
|
||||
*/
|
||||
public static <T> boolean containsAll(T[] array, T[] check) {
|
||||
for (T checkItem : check) {
|
||||
if (!contains(array, checkItem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean contains(int[] array, int value) {
|
||||
for (int element : array) {
|
||||
if (element == value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static long total(long[] array) {
|
||||
long total = 0;
|
||||
for (long value : array) {
|
||||
total += value;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an element to a copy of the array and returns the copy.
|
||||
* @param array The original array, or null to represent an empty array.
|
||||
* @param element The element to add.
|
||||
* @return A new array that contains all of the elements of the original array
|
||||
* with the specified element added at the end.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] appendElement(Class<T> kind, T[] array, T element) {
|
||||
final T[] result;
|
||||
final int end;
|
||||
if (array != null) {
|
||||
end = array.length;
|
||||
result = (T[])Array.newInstance(kind, end + 1);
|
||||
System.arraycopy(array, 0, result, 0, end);
|
||||
} else {
|
||||
end = 0;
|
||||
result = (T[])Array.newInstance(kind, 1);
|
||||
}
|
||||
result[end] = element;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an element from a copy of the array and returns the copy.
|
||||
* If the element is not present, then the original array is returned unmodified.
|
||||
* @param array The original array, or null to represent an empty array.
|
||||
* @param element The element to remove.
|
||||
* @return A new array that contains all of the elements of the original array
|
||||
* except the first copy of the specified element removed. If the specified element
|
||||
* was not present, then returns the original array. Returns null if the result
|
||||
* would be an empty array.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] removeElement(Class<T> kind, T[] array, T element) {
|
||||
if (array != null) {
|
||||
final int length = array.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (array[i] == element) {
|
||||
if (length == 1) {
|
||||
return null;
|
||||
}
|
||||
T[] result = (T[])Array.newInstance(kind, length - 1);
|
||||
System.arraycopy(array, 0, result, 0, i);
|
||||
System.arraycopy(array, i + 1, result, i, length - i - 1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static int[] appendInt(int[] cur, int val) {
|
||||
if (cur == null) {
|
||||
return new int[] { val };
|
||||
}
|
||||
final int N = cur.length;
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (cur[i] == val) {
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
int[] ret = new int[N + 1];
|
||||
System.arraycopy(cur, 0, ret, 0, N);
|
||||
ret[N] = val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int[] removeInt(int[] cur, int val) {
|
||||
if (cur == null) {
|
||||
return null;
|
||||
}
|
||||
final int N = cur.length;
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (cur[i] == val) {
|
||||
int[] ret = new int[N - 1];
|
||||
if (i > 0) {
|
||||
System.arraycopy(cur, 0, ret, 0, i);
|
||||
}
|
||||
if (i < (N - 1)) {
|
||||
System.arraycopy(cur, i + 1, ret, i, N - i - 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
398
src/api-impl/com/android/internal/util/FastXmlSerializer.java
Normal file
398
src/api-impl/com/android/internal/util/FastXmlSerializer.java
Normal file
@@ -0,0 +1,398 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.util;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
/**
|
||||
* This is a quick and dirty implementation of XmlSerializer that isn't horribly
|
||||
* painfully slow like the normal one. It only does what is needed for the
|
||||
* specific XML files being written with it.
|
||||
*/
|
||||
public class FastXmlSerializer implements XmlSerializer {
|
||||
private static final String ESCAPE_TABLE[] = new String[] {
|
||||
null, null, null, null, null, null, null, null, // 0-7
|
||||
null, null, null, null, null, null, null, null, // 8-15
|
||||
null, null, null, null, null, null, null, null, // 16-23
|
||||
null, null, null, null, null, null, null, null, // 24-31
|
||||
null, null, """, null, null, null, "&", null, // 32-39
|
||||
null, null, null, null, null, null, null, null, // 40-47
|
||||
null, null, null, null, null, null, null, null, // 48-55
|
||||
null, null, null, null, "<", null, ">", null, // 56-63
|
||||
};
|
||||
|
||||
private static final int BUFFER_LEN = 8192;
|
||||
|
||||
private static String sSpace = " ";
|
||||
|
||||
private final char[] mText = new char[BUFFER_LEN];
|
||||
private int mPos;
|
||||
|
||||
private Writer mWriter;
|
||||
|
||||
private OutputStream mOutputStream;
|
||||
private CharsetEncoder mCharset;
|
||||
private ByteBuffer mBytes = ByteBuffer.allocate(BUFFER_LEN);
|
||||
|
||||
private boolean mIndent = false;
|
||||
private boolean mInTag;
|
||||
|
||||
private int mNesting = 0;
|
||||
private boolean mLineStart = true;
|
||||
|
||||
private void append(char c) throws IOException {
|
||||
int pos = mPos;
|
||||
if (pos >= (BUFFER_LEN-1)) {
|
||||
flush();
|
||||
pos = mPos;
|
||||
}
|
||||
mText[pos] = c;
|
||||
mPos = pos+1;
|
||||
}
|
||||
|
||||
private void append(String str, int i, final int length) throws IOException {
|
||||
if (length > BUFFER_LEN) {
|
||||
final int end = i + length;
|
||||
while (i < end) {
|
||||
int next = i + BUFFER_LEN;
|
||||
append(str, i, next<end ? BUFFER_LEN : (end-i));
|
||||
i = next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int pos = mPos;
|
||||
if ((pos+length) > BUFFER_LEN) {
|
||||
flush();
|
||||
pos = mPos;
|
||||
}
|
||||
str.getChars(i, i+length, mText, pos);
|
||||
mPos = pos + length;
|
||||
}
|
||||
|
||||
private void append(char[] buf, int i, final int length) throws IOException {
|
||||
if (length > BUFFER_LEN) {
|
||||
final int end = i + length;
|
||||
while (i < end) {
|
||||
int next = i + BUFFER_LEN;
|
||||
append(buf, i, next<end ? BUFFER_LEN : (end-i));
|
||||
i = next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int pos = mPos;
|
||||
if ((pos+length) > BUFFER_LEN) {
|
||||
flush();
|
||||
pos = mPos;
|
||||
}
|
||||
System.arraycopy(buf, i, mText, pos, length);
|
||||
mPos = pos + length;
|
||||
}
|
||||
|
||||
private void append(String str) throws IOException {
|
||||
append(str, 0, str.length());
|
||||
}
|
||||
|
||||
private void appendIndent(int indent) throws IOException {
|
||||
indent *= 4;
|
||||
if (indent > sSpace.length()) {
|
||||
indent = sSpace.length();
|
||||
}
|
||||
append(sSpace, 0, indent);
|
||||
}
|
||||
|
||||
private void escapeAndAppendString(final String string) throws IOException {
|
||||
final int N = string.length();
|
||||
final char NE = (char)ESCAPE_TABLE.length;
|
||||
final String[] escapes = ESCAPE_TABLE;
|
||||
int lastPos = 0;
|
||||
int pos;
|
||||
for (pos=0; pos<N; pos++) {
|
||||
char c = string.charAt(pos);
|
||||
if (c >= NE) continue;
|
||||
String escape = escapes[c];
|
||||
if (escape == null) continue;
|
||||
if (lastPos < pos) append(string, lastPos, pos-lastPos);
|
||||
lastPos = pos + 1;
|
||||
append(escape);
|
||||
}
|
||||
if (lastPos < pos) append(string, lastPos, pos-lastPos);
|
||||
}
|
||||
|
||||
private void escapeAndAppendString(char[] buf, int start, int len) throws IOException {
|
||||
final char NE = (char)ESCAPE_TABLE.length;
|
||||
final String[] escapes = ESCAPE_TABLE;
|
||||
int end = start+len;
|
||||
int lastPos = start;
|
||||
int pos;
|
||||
for (pos=start; pos<end; pos++) {
|
||||
char c = buf[pos];
|
||||
if (c >= NE) continue;
|
||||
String escape = escapes[c];
|
||||
if (escape == null) continue;
|
||||
if (lastPos < pos) append(buf, lastPos, pos-lastPos);
|
||||
lastPos = pos + 1;
|
||||
append(escape);
|
||||
}
|
||||
if (lastPos < pos) append(buf, lastPos, pos-lastPos);
|
||||
}
|
||||
|
||||
public XmlSerializer attribute(String namespace, String name, String value) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
append(' ');
|
||||
if (namespace != null) {
|
||||
append(namespace);
|
||||
append(':');
|
||||
}
|
||||
append(name);
|
||||
append("=\"");
|
||||
|
||||
escapeAndAppendString(value);
|
||||
append('"');
|
||||
mLineStart = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void cdsect(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void comment(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void docdecl(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void endDocument() throws IOException, IllegalArgumentException, IllegalStateException {
|
||||
flush();
|
||||
}
|
||||
|
||||
public XmlSerializer endTag(String namespace, String name) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
mNesting--;
|
||||
if (mInTag) {
|
||||
append(" />\n");
|
||||
} else {
|
||||
if (mIndent && mLineStart) {
|
||||
appendIndent(mNesting);
|
||||
}
|
||||
append("</");
|
||||
if (namespace != null) {
|
||||
append(namespace);
|
||||
append(':');
|
||||
}
|
||||
append(name);
|
||||
append(">\n");
|
||||
}
|
||||
mLineStart = true;
|
||||
mInTag = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void entityRef(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private void flushBytes() throws IOException {
|
||||
int position;
|
||||
if ((position = mBytes.position()) > 0) {
|
||||
mBytes.flip();
|
||||
mOutputStream.write(mBytes.array(), 0, position);
|
||||
mBytes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
//Log.i("PackageManager", "flush mPos=" + mPos);
|
||||
if (mPos > 0) {
|
||||
if (mOutputStream != null) {
|
||||
CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
|
||||
CoderResult result = mCharset.encode(charBuffer, mBytes, true);
|
||||
while (true) {
|
||||
if (result.isError()) {
|
||||
throw new IOException(result.toString());
|
||||
} else if (result.isOverflow()) {
|
||||
flushBytes();
|
||||
result = mCharset.encode(charBuffer, mBytes, true);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
flushBytes();
|
||||
mOutputStream.flush();
|
||||
} else {
|
||||
mWriter.write(mText, 0, mPos);
|
||||
mWriter.flush();
|
||||
}
|
||||
mPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean getFeature(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getPrefix(String namespace, boolean generatePrefix)
|
||||
throws IllegalArgumentException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object getProperty(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void ignorableWhitespace(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void processingInstruction(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setFeature(String name, boolean state) throws IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
if (name.equals("http://xmlpull.org/v1/doc/features.html#indent-output")) {
|
||||
mIndent = true;
|
||||
return;
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setOutput(OutputStream os, String encoding) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
if (os == null)
|
||||
throw new IllegalArgumentException();
|
||||
if (true) {
|
||||
try {
|
||||
mCharset = Charset.forName(encoding).newEncoder();
|
||||
} catch (IllegalCharsetNameException e) {
|
||||
throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
|
||||
encoding).initCause(e));
|
||||
} catch (UnsupportedCharsetException e) {
|
||||
throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
|
||||
encoding).initCause(e));
|
||||
}
|
||||
mOutputStream = os;
|
||||
} else {
|
||||
setOutput(
|
||||
encoding == null
|
||||
? new OutputStreamWriter(os)
|
||||
: new OutputStreamWriter(os, encoding));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOutput(Writer writer) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
mWriter = writer;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix, String namespace) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) throws IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void startDocument(String encoding, Boolean standalone) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
append("<?xml version='1.0' encoding='utf-8' standalone='"
|
||||
+ (standalone ? "yes" : "no") + "' ?>\n");
|
||||
mLineStart = true;
|
||||
}
|
||||
|
||||
public XmlSerializer startTag(String namespace, String name) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
if (mInTag) {
|
||||
append(">\n");
|
||||
}
|
||||
if (mIndent) {
|
||||
appendIndent(mNesting);
|
||||
}
|
||||
mNesting++;
|
||||
append('<');
|
||||
if (namespace != null) {
|
||||
append(namespace);
|
||||
append(':');
|
||||
}
|
||||
append(name);
|
||||
mInTag = true;
|
||||
mLineStart = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlSerializer text(char[] buf, int start, int len) throws IOException,
|
||||
IllegalArgumentException, IllegalStateException {
|
||||
if (mInTag) {
|
||||
append(">");
|
||||
mInTag = false;
|
||||
}
|
||||
escapeAndAppendString(buf, start, len);
|
||||
if (mIndent) {
|
||||
mLineStart = buf[start+len-1] == '\n';
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlSerializer text(String text) throws IOException, IllegalArgumentException,
|
||||
IllegalStateException {
|
||||
if (mInTag) {
|
||||
append(">");
|
||||
mInTag = false;
|
||||
}
|
||||
escapeAndAppendString(text);
|
||||
if (mIndent) {
|
||||
mLineStart = text.length() > 0 && (text.charAt(text.length()-1) == '\n');
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
966
src/api-impl/com/android/internal/util/XmlUtils.java
Normal file
966
src/api-impl/com/android/internal/util/XmlUtils.java
Normal file
File diff suppressed because it is too large
Load Diff
64
src/api-impl/com/google/android/gles_jni/EGLImpl.java
Normal file
64
src/api-impl/com/google/android/gles_jni/EGLImpl.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.google.android.gles_jni;
|
||||
|
||||
import javax.microedition.khronos.egl.*;
|
||||
|
||||
public class EGLImpl implements EGL10 {
|
||||
private native long native_eglCreateContext(long egl_display, long egl_config, EGLContext share_context, int[] attrib_list);
|
||||
|
||||
public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) {
|
||||
long native_egl_context = native_eglCreateContext(display.native_egl_display, config.native_egl_config, share_context, attrib_list);
|
||||
if (native_egl_context == 0) {
|
||||
return EGL10.EGL_NO_CONTEXT;
|
||||
}
|
||||
return new EGLContext(native_egl_context);
|
||||
}
|
||||
|
||||
private native boolean native_eglChooseConfig(long egl_display, int[] attrib_list, long[] egl_configs, int config_size, int[] num_config);
|
||||
|
||||
public boolean eglChooseConfig(EGLDisplay display, int[] attrib_list, EGLConfig[] configs, int config_size, int[] num_config) {
|
||||
long[] native_egl_configs = null;
|
||||
|
||||
if(config_size != 0) {
|
||||
if(configs == null) {
|
||||
throw new java.lang.IllegalArgumentException("app error: eglChooseConfig called with non-zero 'config_size' ("+config_size+"), but with null 'configs' array");
|
||||
}
|
||||
native_egl_configs = new long[config_size];
|
||||
}
|
||||
|
||||
boolean ret = native_eglChooseConfig(display.native_egl_display, attrib_list, native_egl_configs, config_size, num_config);
|
||||
|
||||
if(configs != null) {
|
||||
for(int i = 0; i < configs.length; i++) {
|
||||
configs[i] = new EGLConfig(native_egl_configs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface, Object native_pixmap) { return false; }
|
||||
public EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list) { return null; }
|
||||
public EGLSurface eglCreatePixmapSurface(EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list) { return null; }
|
||||
public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) { return null; }
|
||||
public boolean eglDestroyContext(EGLDisplay display, EGLContext context) { return false; }
|
||||
public boolean eglDestroySurface(EGLDisplay display, EGLSurface surface) { return false; }
|
||||
public boolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, int attribute, int[] value) { return false; }
|
||||
public boolean eglGetConfigs(EGLDisplay display, EGLConfig[] configs, int config_size, int[] num_config) { return false; }
|
||||
public EGLContext eglGetCurrentContext() { return null; }
|
||||
public EGLDisplay eglGetCurrentDisplay() { return null; }
|
||||
public EGLSurface eglGetCurrentSurface(int readdraw) { return null; }
|
||||
public EGLDisplay eglGetDisplay(Object native_display) { return null; }
|
||||
public int eglGetError() { return EGL_SUCCESS; } // don't let yourself get fooled, this is also a stub :P
|
||||
public boolean eglInitialize(EGLDisplay display, int[] major_minor) { return false; }
|
||||
public boolean eglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context) { return false; }
|
||||
public boolean eglQueryContext(EGLDisplay display, EGLContext context, int attribute, int[] value) { return false; }
|
||||
public String eglQueryString(EGLDisplay display, int name) { return "FIXME"; }
|
||||
public boolean eglQuerySurface(EGLDisplay display, EGLSurface surface, int attribute, int[] value) { return false; }
|
||||
/** @hide **/
|
||||
public boolean eglReleaseThread() { return false; }
|
||||
public boolean eglSwapBuffers(EGLDisplay display, EGLSurface surface) { return false; }
|
||||
public boolean eglTerminate(EGLDisplay display) { return false; }
|
||||
public boolean eglWaitGL() { return false; }
|
||||
public boolean eglWaitNative(int engine, Object bindTarget) { return false; }
|
||||
}
|
||||
2215
src/api-impl/com/google/android/gles_jni/GLImpl.java
Normal file
2215
src/api-impl/com/google/android/gles_jni/GLImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
package com.google.android.vending.licensing;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class LicenseChecker {
|
||||
public LicenseChecker(Context context, Policy policy, String encodedPublicKey) {
|
||||
// TODO: do something here?
|
||||
}
|
||||
|
||||
public synchronized void checkAccess(LicenseCheckerCallback callback) {
|
||||
// this is not ideal, but it doesn't make sense to spend much effort on doing this "properly" when the effort required to bypass this doesn't scale with the effort spent by us
|
||||
// also, it might not be possible to do this "properly" without having the real google play store in the equation, which is not desirable for a multitude of reasons...
|
||||
callback.allow(0x0100/*Policy.LICENSED*/);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.vending.licensing;
|
||||
|
||||
/**
|
||||
* Callback for the license checker library.
|
||||
* <p>
|
||||
* Upon checking with the Market server and conferring with the {@link Policy},
|
||||
* the library calls the appropriate callback method to communicate the result.
|
||||
* <p>
|
||||
* <b>The callback does not occur in the original checking thread.</b> Your
|
||||
* application should post to the appropriate handling thread or lock
|
||||
* accordingly.
|
||||
* <p>
|
||||
* The reason that is passed back with allow/dontAllow is the base status handed
|
||||
* to the policy for allowed/disallowing the license. Policy.RETRY will call
|
||||
* allow or dontAllow depending on other statistics associated with the policy,
|
||||
* while in most cases Policy.NOT_LICENSED will call dontAllow and
|
||||
* Policy.LICENSED will Allow.
|
||||
*/
|
||||
public interface LicenseCheckerCallback {
|
||||
|
||||
/**
|
||||
* Allow use. App should proceed as normal.
|
||||
*
|
||||
* @param reason Policy.LICENSED or Policy.RETRY typically. (although in
|
||||
* theory the policy can return Policy.NOT_LICENSED here as well)
|
||||
*/
|
||||
public void allow(int reason);
|
||||
|
||||
/**
|
||||
* Don't allow use. App should inform user and take appropriate action.
|
||||
*
|
||||
* @param reason Policy.NOT_LICENSED or Policy.RETRY. (although in theory
|
||||
* the policy can return Policy.LICENSED here as well ---
|
||||
* perhaps the call to the LVL took too long, for example)
|
||||
*/
|
||||
public void dontAllow(int reason);
|
||||
|
||||
/** Application error codes. */
|
||||
public static final int ERROR_INVALID_PACKAGE_NAME = 1;
|
||||
public static final int ERROR_NON_MATCHING_UID = 2;
|
||||
public static final int ERROR_NOT_MARKET_MANAGED = 3;
|
||||
public static final int ERROR_CHECK_IN_PROGRESS = 4;
|
||||
public static final int ERROR_INVALID_PUBLIC_KEY = 5;
|
||||
public static final int ERROR_MISSING_PERMISSION = 6;
|
||||
|
||||
/**
|
||||
* Error in application code. Caller did not call or set up license checker
|
||||
* correctly. Should be considered fatal.
|
||||
*/
|
||||
public void applicationError(int errorCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.google.android.vending.licensing;
|
||||
|
||||
public interface Policy {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user