api-impl: misc stubs and fixes for Spotify II

This commit is contained in:
Daniel Panero
2024-11-03 01:04:40 +01:00
committed by Dani Pani
parent 4b36bca4c6
commit f48fce5932
9 changed files with 85 additions and 16 deletions

View File

@@ -0,0 +1,17 @@
package android.app.job;
import android.content.ComponentName;
public class JobInfo {
public static final class Builder {
public Builder(int jobId, ComponentName jobService) {}
public Builder setMinimumLatency(long minLatencyMillis) {
return this;
}
public Builder setRequiredNetworkType(int networkType) {
return this;
}
}
}

View File

@@ -1,4 +1,16 @@
package android.app.job; package android.app.job;
import java.util.ArrayList;
import java.util.List;
public class JobScheduler { public class JobScheduler {
/**
* Retrieve all jobs that have been scheduled by the calling application.
*
* @return a list of all of the app's scheduled jobs. This includes jobs that are
* currently started as well as those that are still waiting to run.
*/
public List<JobInfo> getAllPendingJobs() {
return new ArrayList<JobInfo>();
};
} }

View File

@@ -10,6 +10,7 @@ import android.app.NotificationManager;
import android.app.Service; import android.app.Service;
import android.app.SharedPreferencesImpl; import android.app.SharedPreferencesImpl;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.app.job.JobScheduler;
import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothManager;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@@ -22,9 +23,9 @@ import android.content.res.XmlResourceParser;
import android.database.DatabaseErrorHandler; import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.hardware.input.InputManager;
import android.hardware.SensorManager; import android.hardware.SensorManager;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.hardware.input.InputManager;
import android.hardware.usb.UsbManager; import android.hardware.usb.UsbManager;
import android.location.LocationManager; import android.location.LocationManager;
import android.media.AudioManager; import android.media.AudioManager;
@@ -48,17 +49,16 @@ import android.view.LayoutInflater;
import android.view.WindowManagerImpl; import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.io.IOException;
public class Context extends Object { public class Context extends Object {
private final static String TAG = "Context"; private final static String TAG = "Context";
@@ -80,7 +80,7 @@ public class Context extends Object {
public static Resources r; public static Resources r;
static ApplicationInfo application_info; static ApplicationInfo application_info;
static Resources.Theme theme; static Resources.Theme theme;
private static Map<Class<? extends Service>,Service> runningServices = new HashMap<>(); private static Map<Class<? extends Service>, Service> runningServices = new HashMap<>();
public static PackageParser.Package pkg; public static PackageParser.Package pkg;
public static PackageManager package_manager; public static PackageManager package_manager;
@@ -111,7 +111,7 @@ public class Context extends Object {
Slog.e(TAG, parseError[0]); Slog.e(TAG, parseError[0]);
System.exit(1); System.exit(1);
} }
packageParser.collectCertificates(pkg, 0); packageParser.collectCertificates(pkg, 0);
application_info = pkg.applicationInfo; application_info = pkg.applicationInfo;
} catch (Exception e) { } catch (Exception e) {
@@ -145,7 +145,8 @@ public class Context extends Object {
// HACK: Set WhatsApp's custom logging mechanism to verbose for easier debugging. Should be removed again once WhatsApp is fully supported // HACK: Set WhatsApp's custom logging mechanism to verbose for easier debugging. Should be removed again once WhatsApp is fully supported
try { try {
Class.forName("com.whatsapp.util.Log").getField("level").setInt(null, 5); Class.forName("com.whatsapp.util.Log").getField("level").setInt(null, 5);
} catch (Exception e) {} // ignore for other apps } catch (Exception e) {
} // ignore for other apps
return application; return application;
} }
@@ -221,6 +222,9 @@ public class Context extends Object {
return new WifiManager(); return new WifiManager();
case "bluetooth": case "bluetooth":
return new BluetoothManager(); return new BluetoothManager();
case "jobscheduler":
return new JobScheduler();
default: default:
Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet"); Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
return null; return null;
@@ -256,7 +260,7 @@ public class Context extends Object {
return r.getString(resId); return r.getString(resId);
} }
public final String getString (int resId, Object... formatArgs) { public final String getString(int resId, Object... formatArgs) {
return r.getString(resId, formatArgs); return r.getString(resId, formatArgs);
} }
@@ -422,7 +426,7 @@ public class Context extends Object {
public ComponentName startService(Intent intent) { public ComponentName startService(Intent intent) {
ComponentName component = intent.getComponent(); ComponentName component = intent.getComponent();
if(component == null) { if (component == null) {
Slog.w(TAG, "startService: component is null"); Slog.w(TAG, "startService: component is null");
return null; return null;
} }
@@ -438,7 +442,7 @@ public class Context extends Object {
service.onCreate(); service.onCreate();
runningServices.put(cls, service); runningServices.put(cls, service);
} }
runningServices.get(cls).onStartCommand(intent, 0, 0); runningServices.get(cls).onStartCommand(intent, 0, 0);
} catch (ReflectiveOperationException e) { } catch (ReflectiveOperationException e) {
e.printStackTrace(); e.printStackTrace();
@@ -471,7 +475,7 @@ public class Context extends Object {
public void registerComponentCallbacks(ComponentCallbacks callbacks) {} public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int dummy3) { public boolean bindService(final Intent intent, final ServiceConnection serviceConnection, int dummy3) {
if(intent.getComponent() == null) { if (intent.getComponent() == null) {
Slog.w(TAG, "Context.bindService: intent.getComponent() is null"); Slog.w(TAG, "Context.bindService: intent.getComponent() is null");
return false; return false;
} }
@@ -498,10 +502,10 @@ public class Context extends Object {
public void startActivity(Intent intent) { public void startActivity(Intent intent) {
Slog.i(TAG, "startActivity(" + intent + ") called"); Slog.i(TAG, "startActivity(" + intent + ") called");
if (intent.getAction() != null && intent.getAction().equals("android.intent.action.CHOOSER")) { if (intent.getAction() != null && intent.getAction().equals("android.intent.action.CHOOSER")) {
intent = (Intent) intent.getExtras().get("android.intent.extra.INTENT"); intent = (Intent)intent.getExtras().get("android.intent.extra.INTENT");
} }
if (intent.getComponent() == null) { if (intent.getComponent() == null) {
if(intent.getAction() != null && intent.getAction().equals("android.intent.action.SEND")) { if (intent.getAction() != null && intent.getAction().equals("android.intent.action.SEND")) {
Slog.i(TAG, "starting extern activity with intent: " + intent); Slog.i(TAG, "starting extern activity with intent: " + intent);
String text = intent.getStringExtra("android.intent.extra.TEXT"); String text = intent.getStringExtra("android.intent.extra.TEXT");
if (text == null) if (text == null)
@@ -575,7 +579,7 @@ public class Context extends Object {
return getResources().getDrawable(resId); return getResources().getDrawable(resId);
} }
public boolean isRestricted() {return false;} public boolean isRestricted() { return false; }
public File getDatabasePath(String dbName) { public File getDatabasePath(String dbName) {
File databaseDir = new File(getDataDirFile(), "databases"); File databaseDir = new File(getDataDirFile(), "databases");
@@ -620,7 +624,7 @@ public class Context extends Object {
public SQLiteDatabase openOrCreateDatabase(String filename, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) { public SQLiteDatabase openOrCreateDatabase(String filename, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
int flags = SQLiteDatabase.CREATE_IF_NECESSARY; int flags = SQLiteDatabase.CREATE_IF_NECESSARY;
if ((mode & (1 <<3) /*MODE_ENABLE_WRITE_AHEAD_LOGGING*/) != 0) { if ((mode & (1 << 3) /*MODE_ENABLE_WRITE_AHEAD_LOGGING*/) != 0) {
flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING; flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
} }
SQLiteDatabase db = SQLiteDatabase.openDatabase(filename, factory, flags, errorHandler); SQLiteDatabase db = SQLiteDatabase.openDatabase(filename, factory, flags, errorHandler);

View File

@@ -23,4 +23,8 @@ public final class Debug {
public static long getNativeHeapAllocatedSize() { public static long getNativeHeapAllocatedSize() {
return 0; return 0;
} }
public static boolean waitingForDebugger() {
return false;
}
} }

View File

@@ -22,7 +22,7 @@ package android.os;
* processes, by creating a Messenger pointing to a Handler in one process, * processes, by creating a Messenger pointing to a Handler in one process,
* and handing that Messenger to another process. * and handing that Messenger to another process.
*/ */
public final class Messenger { public final class Messenger implements Parcelable {
private final IMessenger mTarget; private final IMessenger mTarget;
/** /**
@@ -83,4 +83,18 @@ public final class Messenger {
public int describeContents() { public int describeContents() {
return 0; return 0;
} }
/**
* Create a Messenger from a raw IBinder, which had previously been
* retrieved with {@link #getBinder}.
*
* @param target The IBinder this Messenger should communicate with.
*/
public Messenger(IBinder target) {
mTarget = new IMessenger() {
@Override
public void send(Message msg) {
}
};
}
} }

View File

@@ -0,0 +1,4 @@
package android.os;
public class PersistableBundle extends BaseBundle {
}

View File

@@ -8,4 +8,13 @@ public class URLUtil {
filename = filename.substring(0, filename.indexOf('?')); filename = filename.substring(0, filename.indexOf('?'));
return filename; return filename;
} }
/**
* @return {@code true} if the url is an https: url.
*/
public static boolean isHttpsUrl(String url) {
return (null != url)
&& (url.length() > 7)
&& url.substring(0, 8).equalsIgnoreCase("https://");
}
} }

View File

@@ -51,6 +51,7 @@ hax_jar = jar('hax', [
'android/app/UiModeManager.java', 'android/app/UiModeManager.java',
'android/app/WallpaperManager.java', 'android/app/WallpaperManager.java',
'android/app/admin/DevicePolicyManager.java', 'android/app/admin/DevicePolicyManager.java',
'android/app/job/JobInfo.java',
'android/app/job/JobScheduler.java', 'android/app/job/JobScheduler.java',
'android/app/job/JobService.java', 'android/app/job/JobService.java',
'android/app/usage/UsageStatsManager.java', 'android/app/usage/UsageStatsManager.java',
@@ -302,6 +303,7 @@ hax_jar = jar('hax', [
'android/os/ParcelFileDescriptor.java', 'android/os/ParcelFileDescriptor.java',
'android/os/Parcelable.java', 'android/os/Parcelable.java',
'android/os/PatternMatcher.java', 'android/os/PatternMatcher.java',
'android/os/PersistableBundle.java',
'android/os/PowerManager.java', 'android/os/PowerManager.java',
'android/os/Process.java', 'android/os/Process.java',
'android/os/RemoteCallbackList.java', 'android/os/RemoteCallbackList.java',
@@ -557,7 +559,7 @@ hax_jar = jar('hax', [
'com/google/android/vending/licensing/LicenseChecker.java', 'com/google/android/vending/licensing/LicenseChecker.java',
'com/google/android/vending/licensing/LicenseCheckerCallback.java', 'com/google/android/vending/licensing/LicenseCheckerCallback.java',
'com/google/android/vending/licensing/Policy.java', 'com/google/android/vending/licensing/Policy.java',
'com/android/server/am/DumpHeapProvider.java', 'com/android/server/am/DumpHeapProvider.java',
'com/htc/util/htcresutil/resutil.java', 'com/htc/util/htcresutil/resutil.java',
'javax/microedition/khronos/egl/EGL.java', 'javax/microedition/khronos/egl/EGL.java',
'javax/microedition/khronos/egl/EGL10.java', 'javax/microedition/khronos/egl/EGL10.java',

View File

@@ -163,6 +163,9 @@ extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER;
extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE; extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE;
extern const char* AMEDIAFORMAT_KEY_WIDTH; extern const char* AMEDIAFORMAT_KEY_WIDTH;
extern const char* AMEDIAFORMAT_KEY_STRIDE; extern const char* AMEDIAFORMAT_KEY_STRIDE;
const char* AMEDIAFORMAT_KEY_MIME = "mime";
const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT = "channel-count";
const char* AMEDIAFORMAT_KEY_SAMPLE_RATE = "sample-rate";