Get a SDK

For the latest documentation, please refer to: https://github.com/FSpaceCore/SpaceCore

SDK Integration

Step 1. Dependency

implementation "com.tencent:mmkv-static:1.2.10"
implementation "com.google.code.gson:gson:2.9.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"

Step 2. Initialization

Add the following code to initialize in 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.

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

override fun onCreate() {
    super.onCreate()
    if(FCore.isClient()) {
        return
    }
    // do something...
}

Step 3. Installation

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(new File("/sdcard/wechat.apk"), USER_ID)

Step 4. Launch sandboxed application

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

API Documentation

FCore
Method Description
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
Method Description
findProcessRecordFinding process information
addProcessMonitorAdding sandboxed internal process listeners
removeProcessMonitorRemoving sandboxed internal process listeners
Kernel User
Method Description
getUsersGetting users in the sandbox
createUserCreate users in the sandbox
deleteUserDelete users in the sandbox (all application information will be deleted)
APP Data
Method Description
exportAppDataExport all data of a certain application
importAppDataImport all data of a certain application
APP Rules
Method Description
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
Method Description
getPermissionGet app permission rules
updatePermissionUpdate app permission rules
revokePermissionRemove app permission rules (the app will follow the actual permissions of the host APP)
Kernel Configuration
Method Description
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)
Kernel Virtual GPS Location
Method Description
disableFakeLocationDisable virtual location for a certain user
enableFakeLocationEnable virtual location for a certain user
setLocationSet virtual location parameters for a certain user
getLocationGet virtual location parameters for a certain user
setGlobalLocationSet global virtual location parameters
getGlobalLocationGet global virtual location parameters

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.Builder builder = new PackageRule.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");

PackageRule build = builder.build();

// add a rule
FCore.get().addRule(build);

// if there are multiple rules, put them in FRule
FRule fRule = new FRule(builder.build(), builder.build(), builder.build());
FCore.get().addFRule(fRule);

// support fetching configuration content from remote cloud
String json = new Gson().toJson(fRule);
// load json rule
FCore.get().addFRuleContent(json);