Skip to content

Repository files navigation

中文文档

SpaceCore

SpaceCore is an "Application Virtualization Engine" on Android, also known as a lightweight Android virtual machine, which creates a sandbox environment for the Android system. It can be used for multiple app instances, data isolation, script automation, plug-in development, and Google Play Store deployment.

Official website: https://spacecore.dev

Telegram:@android_spacecore


Instructions

SpaceCore SDK
  • The SpaceCore SDK is a free product that is NOT open-source, and you are free to use it without notifying the author. It can also be used for commercial purposes. SpaceCore SDK Download
  • For any customization, please contact support@spacecore.dev
SpaceCore Demo
  • The SpaceCore Demo is intended to demonstrate the usage of the SpaceCore SDK, which can be found in the code within this repository. SpaceCore Demo Release Download

Compatibility

Compatibility
ABIsarmeabi-v7a / arm64-v8a
Android version6.0 ~ 14.0 and future versions

SDK Integration

0. Dependency

The version is based on the main project version, if the main project does not add dependencies, you need to add the following dependencies

implementation "com.tencent:mmkv-static:1.2.10"
implementation "com.google.code.gson:gson:2.9.1"

If the main project does not use kotlin, you need to additionally introduce

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"

1. Initialization

Put this initialization code within "Application#attachBaseContext".

FCore.get().init(this);

Please note that after calling init(), if the FCore.get().isClient() condition is true, please try not to do other initialization in the Application. If you encounter any problems, please contact technical support.

overridefunattachBaseContext(base:Context) {
super.attachBaseContext(base)
FCore.get().init(this)
FCore.get().setAllowSystemInteraction(true)
FCore.get().setAutoPreloadApplication(true)
if(FCore.isClient()) {
return
}
// do something...
}
overridefunonCreate() {
super.onCreate()
if(FCore.isClient()) {
return
}
// do something...
}

2. Examples

Method 1: App Clone

This method relies on the application that is already installed on the system. If the application is uninstalled from the system, the cloned app will also disappear.

FCore.get().installPackageAsUser("package_name", USER_ID)

Method 2: Running without installation

This method supports running without installation and will not be affected by system installation or uninstallation.

FCore.get().installPackageAsUser(newFile("/sdcard/wechat.apk"), USER_ID)

3. Launch sandboxed application

FCore.get().launchApk("package_name", USER_ID)

API Documentation

METHODDESCRIPTION
initInitialize sandbox
isInstalledCheck if the app is installed in the sandbox
installPackageAsUserClone App into sandbox according to package name
installPackageAsUserClone App into sandbox via apk file
uninstallPackageUninstall an App installed in the sandbox globally
uninstallPackageAsUserUninstall an App installed in the sandbox by user
getInstalledApplicationsGet all applications installed in the sandbox
getApplicationInfoGet application info of an App in the sandbox
getPackageInfoGet package info of an application in the sandbox
getLaunchIntentForPackageGet LauncherIntent of an App
launchApkLaunch App in sandbox
launchIntentLaunch App via Intent
isRunningCheck if an App is running
clearPackageClear App data
stopPackageStop an app from running
stopAllPackagesStop all running applications
setAutoForegroundSet auto start/close notification bar to automatically close notification bar when no process is active

Internal Process:

METHODDESCRIPTION
findProcessRecordFinding process information
addProcessMonitorAdding sandboxed internal process listeners
removeProcessMonitorRemoving sandboxed internal process listeners

SandBox User:

METHODDESCRIPTION
getUsersGetting users in the sandbox
createUserCreate users in the sandbox
deleteUserDelete users in the sandbox (all application information will be deleted)

APP Data:

METHODDESCRIPTION
exportAppDataExport all data of a certain application
importAppDataImport all data of a certain application

APP Rules:

METHODDESCRIPTION
addRuleAdd a rule
setAllowSystemInteractionWhether to allow interaction with system applications when the sandbox cannot find broadcasts, activities, etc
setHideRootHide root status
setHideSimHide SIM card status
setHideVPNHide VPN status
setVisitExternalAppAllow sandboxed applications to perceive external applications
setDisableKillPrevent application crashes
setDisableNetworkDisable application network
setHidePathHide multi-open path and storage path
getSpaceLanguageGet the simulated language of a certain space
setSpaceLanguageSet the simulated language of a certain space (e.g. Chinese: zh)
getSpaceRegionGet the simulated region of a certain space
setSpaceRegionSet the simulated region of a certain space (e.g. China: CN)
getSpaceTimeZoneGet the simulated time zone of a certain space
setSpaceTimeZoneSet the simulated time zone of a certain space (e.g. Shanghai: Asia/Shanghai)

App Permissions:

METHODDESCRIPTION
getPermissionGet app permission rules
updatePermissionUpdate app permission rules
revokePermissionRemove app permission rules (the app will follow the actual permissions of the host APP)

SandBox Configuration:

METHODDESCRIPTION
enableOptRuleWhether to enable rule-based blocking of push notifications, third-party SDKs, hot updates, ads, etc. to optimize app running speed. If an application exception occurs, please turn off
setAutoPreloadApplicationIntelligent preloading of applications, where the kernel automatically loads applications based on usage to accelerate startup speed. Default: on
preloadApplicationCountDefault number of preloaded applications: 2
setPreloadProcessCountSet the number of preloading processes to speed up application startup. Default: 3
setBackToHomeWhether to return to the host app when the sandbox app exits
setSpaceTaskDescriptionPrefixSet the application prefix in the recent tasks list (default: F{user ID})
setEnableLauncherViewWhether to enable splash screen
restartCoreSystemRestart the kernel (all applications will be killed)

Rule Configuration System

When dealing with various applications, SpaceCore supports configuring different runtime parameters and virtual machine parameters to achieve adaptation. SpaceCore supports a powerful rule configuration system that can customize exclusive rules for each application. The rule library can be dynamically updated through cloud configuration. The supported rule functions are gradually under development.

PackageRule.Builderbuilder = newPackageRule.Builder("com.tencent.mm",
/* Scoped process. Leave blank if the scope is all processes */"com.tencent.mm", "com.tencent.mm:tools", "com.tencent.mm:appbrand1", "com.tencent.mm:appbrand2")
// disable a Activity
.addBlackActivity("com.tencent.mm.plugin.base.stub.WXEntryActivity")
// disable a broadcast
.addBlackBroadcast("com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver")
// disable a service
.addBlackService("com.tencent.mm.plugin.backup.backuppcmodel.BackupPcService")
// disable a ContentProvider
.addBlackContentProvider("androidx.startup.InitializationProvider")
// preloading process, can pre-start a certain process to speed up the runtime experience
.addPreloadProcessName("com.tencent.mm:appbrand1")
// disable a process from starting
.addBlackProcessName("com.tencent.mm:appbrand2")
// deny access to a file
.addBlackIO("/proc/self/maps")
// redirect a certain file
.addRedirectIO("/proc/self/cmdline", "/proc/self/fake-cmdline")
// hide root
.isHideRoot(true)
// hide SIM
.isHideSim(true)
// hide VPN
.isHideVpn(true)
// many more...// set language
.setLanguage("zh")
// set region
.setRegion("CN")
// set timezone
.setTimeZone("Asia/Shanghai");
PackageRulebuild = builder.build();
// add a ruleFCore.get().addRule(build);
// if there are multiple rules, put them in FRuleFRulefRule = newFRule(builder.build(), builder.build(), builder.build());
FCore.get().addFRule(fRule);
// support fetching configuration content from remote cloudStringjson = newGson().toJson(fRule);
// load json ruleFCore.get().addFRuleContent(json);

About

SpaceCore is a virtual Android system engine that can engage users clone and run dual applications,this engine can also support device simulation, fake GPS and many other features.SpaceCore是一个虚拟引擎内核,提供在Android上克隆和运行虚拟应用程序,并且已支持设备模拟、模拟定位以及其他更多的功能。

Topics

Resources

Stars

850 stars

Watchers

16 watching

Forks

Releases

Packages

Contributors

Languages