implement/stub some stuff to make SmashHit launch

This commit is contained in:
Mis012
2022-11-24 16:05:38 +01:00
parent b0d6045254
commit 75187b01d5
8 changed files with 64 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
package android.accounts;
import android.os.Parcelable;
public class Account implements Parcelable {
public static final Creator<Account> CREATOR = null;
public final String name;
public final String type;
public Account(String name, String type) {
this.name = name;
this.type = type;
}
}

View File

@@ -16,6 +16,7 @@ import android.util.DisplayMetrics;
import android.content.SharedPreferences;
import android.app.SharedPreferencesImpl;
import android.os.Looper;
import android.os.PowerManager;
import android.app.Application;
import android.view.WindowManager;
@@ -42,6 +43,8 @@ public class Context extends Object {
static Configuration config;
static Resources r;
static String apk_path = "/tmp/APK_PATH_SHOULD_HAVE_BEEN_FILLED_IN_BY_CODE_IN_main.c/";
public /*← FIXME?*/ static Application this_application;
File data_dir = null;
@@ -96,6 +99,8 @@ public class Context extends Object {
return new UsbManager();
case "vibrator":
return new Vibrator();
case "power":
return new PowerManager();
default:
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet");
return null;
@@ -115,6 +120,10 @@ public class Context extends Object {
return "com.example.demo_app";
}
public String getPackageCodePath() {
return apk_path;
}
public final String getString(int resId) {
return r.getString(resId);
}

View File

@@ -0,0 +1,5 @@
package android.content.pm;
public class ResolveInfo {
}

View File

@@ -1,5 +1,5 @@
package android.os;
public interface Parcelable {
public static interface Creator<T> {}
}

View File

@@ -0,0 +1,9 @@
package android.os;
public final class PowerManager {
public final class WakeLock {}
public WakeLock newWakeLock(int levelAndFlags, String tag) {
return new WakeLock();
}
}

View File

@@ -61,4 +61,8 @@ public class TextUtils {
final CharSequence delimiter = ","; // ????
return join(delimiter, list);
}
public static boolean isEmpty(CharSequence str) {
return str.equals(""); // presumably?
}
}

View File

@@ -1,4 +1,5 @@
hax_jar = jar('hax', [
'android/accounts/Account.java',
'android/annotation/PrivateApi.java',
'android/annotation/SdkConstant.java',
'android/annotation/SuppressLint.java',
@@ -44,6 +45,7 @@ hax_jar = jar('hax', [
'android/content/pm/PermissionGroupInfo.java',
'android/content/pm/PermissionInfo.java',
'android/content/pm/ProviderInfo.java',
'android/content/pm/ResolveInfo.java',
'android/content/pm/ServiceInfo.java',
'android/content/pm/Signature.java',
'android/content/pm/VerifierInfo.java',
@@ -114,6 +116,7 @@ hax_jar = jar('hax', [
'android/os/Parcelable.java',
'android/os/ParcelFileDescriptor.java',
'android/os/PatternMatcher.java',
'android/os/PowerManager.java',
'android/os/Process.java',
'android/os/RemoteException.java',
'android/os/ResultReceiver.java',

View File

@@ -23,6 +23,25 @@ typedef void * jobject;
#define ASSET_DIR "assets/"
char *get_app_data_dir();
int AAsset_openFileDescriptor(struct AAsset *asset, off_t *out_start, off_t *out_length)
{
int ret;
int fd = asset->fd;
printf("openning asset's file descriptor: : %d\n", fd);
struct stat statbuf;
ret = fstat(fd, &statbuf);
if(ret)
printf("oopsie, fstat failed on fd: %d with errno: %d\n", fd, errno);
*out_start = 0; // on android, we would be returning the fd of the app's apk, and this would be the offet to a non-compressed archive member
*out_length = statbuf.st_size; // similarly, this would be the size of the section of memory containing the non-compressed archive member
return fd;
}
struct AAsset* AAssetManager_open(struct AAssetManager *amgr, const char *file_name, int mode)
{
char *app_data_dir = get_app_data_dir();