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;
import java.util.ArrayList;
import java.util.List;
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.SharedPreferencesImpl;
import android.app.UiModeManager;
import android.app.job.JobScheduler;
import android.bluetooth.BluetoothManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -22,9 +23,9 @@ import android.content.res.XmlResourceParser;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;
import android.hardware.input.InputManager;
import android.hardware.SensorManager;
import android.hardware.display.DisplayManager;
import android.hardware.input.InputManager;
import android.hardware.usb.UsbManager;
import android.location.LocationManager;
import android.media.AudioManager;
@@ -48,17 +49,16 @@ import android.view.LayoutInflater;
import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.io.IOException;
public class Context extends Object {
private final static String TAG = "Context";
@@ -80,7 +80,7 @@ public class Context extends Object {
public static Resources r;
static ApplicationInfo application_info;
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 PackageManager package_manager;
@@ -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
try {
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;
}
@@ -221,6 +222,9 @@ public class Context extends Object {
return new WifiManager();
case "bluetooth":
return new BluetoothManager();
case "jobscheduler":
return new JobScheduler();
default:
Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
return null;
@@ -256,7 +260,7 @@ public class Context extends Object {
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);
}
@@ -422,7 +426,7 @@ public class Context extends Object {
public ComponentName startService(Intent intent) {
ComponentName component = intent.getComponent();
if(component == null) {
if (component == null) {
Slog.w(TAG, "startService: component is null");
return null;
}
@@ -471,7 +475,7 @@ public class Context extends Object {
public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
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");
return false;
}
@@ -498,10 +502,10 @@ public class Context extends Object {
public void startActivity(Intent intent) {
Slog.i(TAG, "startActivity(" + intent + ") called");
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.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);
String text = intent.getStringExtra("android.intent.extra.TEXT");
if (text == null)
@@ -575,7 +579,7 @@ public class Context extends Object {
return getResources().getDrawable(resId);
}
public boolean isRestricted() {return false;}
public boolean isRestricted() { return false; }
public File getDatabasePath(String dbName) {
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) {
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;
}
SQLiteDatabase db = SQLiteDatabase.openDatabase(filename, factory, flags, errorHandler);

View File

@@ -23,4 +23,8 @@ public final class Debug {
public static long getNativeHeapAllocatedSize() {
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,
* and handing that Messenger to another process.
*/
public final class Messenger {
public final class Messenger implements Parcelable {
private final IMessenger mTarget;
/**
@@ -83,4 +83,18 @@ public final class Messenger {
public int describeContents() {
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('?'));
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/WallpaperManager.java',
'android/app/admin/DevicePolicyManager.java',
'android/app/job/JobInfo.java',
'android/app/job/JobScheduler.java',
'android/app/job/JobService.java',
'android/app/usage/UsageStatsManager.java',
@@ -302,6 +303,7 @@ hax_jar = jar('hax', [
'android/os/ParcelFileDescriptor.java',
'android/os/Parcelable.java',
'android/os/PatternMatcher.java',
'android/os/PersistableBundle.java',
'android/os/PowerManager.java',
'android/os/Process.java',
'android/os/RemoteCallbackList.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_WIDTH;
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";