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 Spotify
This commit is contained in:
@@ -10,6 +10,7 @@ import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.app.SharedPreferencesImpl;
|
||||
import android.app.UiModeManager;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageParser;
|
||||
@@ -104,7 +105,13 @@ public class Context extends Object {
|
||||
application_info = new ApplicationInfo();
|
||||
try (XmlResourceParser parser = assets.openXmlResourceParser("AndroidManifest.xml")) {
|
||||
PackageParser packageParser = new PackageParser(native_get_apk_path());
|
||||
pkg = packageParser.parsePackage(r, parser, 0, new String[1]);
|
||||
String[] parseError = new String[1];
|
||||
pkg = packageParser.parsePackage(r, parser, 0, parseError);
|
||||
if (parseError[0] != null) {
|
||||
Slog.e(TAG, parseError[0]);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
packageParser.collectCertificates(pkg, 0);
|
||||
application_info = pkg.applicationInfo;
|
||||
} catch (Exception e) {
|
||||
@@ -212,12 +219,18 @@ public class Context extends Object {
|
||||
return new LayoutInflater(getApplicationContext());
|
||||
case "wifi":
|
||||
return new WifiManager();
|
||||
case "bluetooth":
|
||||
return new BluetoothManager();
|
||||
default:
|
||||
Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final <T> T getSystemService(Class<T> serviceClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||
receiverMap.put(filter, receiver);
|
||||
return new Intent();
|
||||
|
||||
@@ -342,4 +342,9 @@ public class Intent implements Parcelable {
|
||||
return new ShortcutIconResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtrasClassLoader(ClassLoader loader) {}
|
||||
public Intent setClassName(Context packageContext, String className) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ public class PackageInfo {
|
||||
*/
|
||||
public String packageName = "com.example.app"; // FIXME
|
||||
|
||||
/**
|
||||
* The names of any installed split APKs for this package.
|
||||
*/
|
||||
public String[] splitNames;
|
||||
|
||||
/**
|
||||
* The version number of this package, as specified by the <manifest>
|
||||
* tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
|
||||
|
||||
@@ -831,6 +831,11 @@ public class Resources {
|
||||
return csl.getDefaultColor();
|
||||
}
|
||||
|
||||
public int getColor(int id, Theme theme) throws NotFoundException {
|
||||
// TODO fix it
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a color state list associated with a particular resource ID. The
|
||||
* resource may contain either a single raw color value, or a complex
|
||||
@@ -1594,7 +1599,7 @@ public class Resources {
|
||||
mConfiguration.smallestScreenWidthDp,
|
||||
mConfiguration.screenWidthDp, mConfiguration.screenHeightDp,
|
||||
mConfiguration.screenLayout, mConfiguration.uiMode,
|
||||
24);
|
||||
25);
|
||||
|
||||
if (DEBUG_CONFIG) {
|
||||
Slog.i(TAG, "**** Updating config of " + this + ": final config is " + mConfiguration + " final compat is " + mCompatibilityInfo);
|
||||
@@ -2310,50 +2315,50 @@ public class Resources {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
/* if (id != 0) {
|
||||
try {
|
||||
// These may be compiled...
|
||||
synchronized (mCachedXmlBlockIds) {
|
||||
// First see if this block is in our cache.
|
||||
final int num = mCachedXmlBlockIds.length;
|
||||
for (int i=0; i<num; i++) {
|
||||
if (mCachedXmlBlockIds[i] == id) {
|
||||
//System.out.println("**** REUSING XML BLOCK! id="
|
||||
// + id + ", index=" + i);
|
||||
return mCachedXmlBlocks[i].newParser();
|
||||
}
|
||||
}
|
||||
try {
|
||||
// These may be compiled...
|
||||
synchronized (mCachedXmlBlockIds) {
|
||||
// First see if this block is in our cache.
|
||||
final int num = mCachedXmlBlockIds.length;
|
||||
for (int i=0; i<num; i++) {
|
||||
if (mCachedXmlBlockIds[i] == id) {
|
||||
//System.out.println("**** REUSING XML BLOCK! id="
|
||||
// + id + ", index=" + i);
|
||||
return mCachedXmlBlocks[i].newParser();
|
||||
}
|
||||
}
|
||||
|
||||
// Not in the cache, create a new block and put it at
|
||||
// the next slot in the cache.
|
||||
XmlBlock block = mAssets.openXmlBlockAsset(
|
||||
assetCookie, file);
|
||||
if (block != null) {
|
||||
int pos = mLastCachedXmlBlockIndex+1;
|
||||
if (pos >= num) pos = 0;
|
||||
mLastCachedXmlBlockIndex = pos;
|
||||
XmlBlock oldBlock = mCachedXmlBlocks[pos];
|
||||
if (oldBlock != null) {
|
||||
oldBlock.close();
|
||||
}
|
||||
mCachedXmlBlockIds[pos] = id;
|
||||
mCachedXmlBlocks[pos] = block;
|
||||
//System.out.println("**** CACHING NEW XML BLOCK! id="
|
||||
// + id + ", index=" + pos);
|
||||
return block.newParser();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NotFoundException rnf = new NotFoundException(
|
||||
"File " + file + " from xml type " + type + " resource ID #0x"
|
||||
+ Integer.toHexString(id));
|
||||
rnf.initCause(e);
|
||||
throw rnf;
|
||||
}
|
||||
}
|
||||
// Not in the cache, create a new block and put it at
|
||||
// the next slot in the cache.
|
||||
XmlBlock block = mAssets.openXmlBlockAsset(
|
||||
assetCookie, file);
|
||||
if (block != null) {
|
||||
int pos = mLastCachedXmlBlockIndex+1;
|
||||
if (pos >= num) pos = 0;
|
||||
mLastCachedXmlBlockIndex = pos;
|
||||
XmlBlock oldBlock = mCachedXmlBlocks[pos];
|
||||
if (oldBlock != null) {
|
||||
oldBlock.close();
|
||||
}
|
||||
mCachedXmlBlockIds[pos] = id;
|
||||
mCachedXmlBlocks[pos] = block;
|
||||
//System.out.println("**** CACHING NEW XML BLOCK! id="
|
||||
// + id + ", index=" + pos);
|
||||
return block.newParser();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NotFoundException rnf = new NotFoundException(
|
||||
"File " + file + " from xml type " + type + " resource ID #0x"
|
||||
+ Integer.toHexString(id));
|
||||
rnf.initCause(e);
|
||||
throw rnf;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundException(
|
||||
"File " + file + " from xml type " + type + " resource ID #0x"
|
||||
+ Integer.toHexString(id));
|
||||
throw new NotFoundException(
|
||||
"File " + file + " from xml type " + type + " resource ID #0x"
|
||||
+ Integer.toHexString(id));
|
||||
*/ }
|
||||
|
||||
private TypedArray getCachedStyledAttributes(int len) {
|
||||
|
||||
Reference in New Issue
Block a user