Skip to content

Commit 11b73cd

Browse files
committed
2 parents 9ed7cff + aff04b0 commit 11b73cd

File tree

2 files changed

+192
-72
lines changed

2 files changed

+192
-72
lines changed

README.md

Lines changed: 191 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ SpaceCore is an "Application Virtualization Engine" on Android, also known as a
77

88
Official website: [https://spacecore.dev](https://spacecore.dev)
99

10+
Telegram:[@android_spacecore](https://t.me/android_spacecore)
11+
1012
<br>
1113

1214
## Instructions
1315

1416
##### SpaceCore SDK
1517
* 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](https://github.com/FSpaceCore/SpaceCore/releases)
16-
* ** For any customization **, please contact [[email protected]](mailto:[email protected])
18+
* **For any customization**, please contact [[email protected]](mailto:[email protected])
1719

1820
##### SpaceCore Demo
1921
* 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](https://github.com/FSpaceCore/SpaceCore/releases)
@@ -28,14 +30,18 @@ Official website: [https://spacecore.dev](https://spacecore.dev)
2830
| Android version | `6.0 ~ 14.0 and future versions` |
2931

3032

31-
## Usages
33+
## SDK Integration
3234

3335
### 0. Dependency
36+
The version is based on the main project version, if the main project does not add dependencies, you need to add the following dependencies
3437

3538
```
3639
implementation "com.tencent:mmkv-static:1.2.10"
3740
implementation "com.google.code.gson:gson:2.9.1"
41+
```
3842

43+
If the main project does not use kotlin, you need to additionally introduce
44+
```
3945
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"
4046
```
4147

@@ -45,65 +51,189 @@ Put this initialization code within "Application#attachBaseContext".
4551

4652
`FCore.get().init(this);`
4753

54+
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.
55+
56+
```kotlin
57+
override fun attachBaseContext(base: Context) {
58+
super.attachBaseContext(base)
59+
FCore.get().init(this)
60+
FCore.get().setAllowSystemInteraction(true)
61+
FCore.get().setAutoPreloadApplication(true)
62+
if(FCore.isClient()) {
63+
return
64+
}
65+
// do something...
66+
}
67+
68+
override fun onCreate() {
69+
super.onCreate()
70+
if(FCore.isClient()) {
71+
return
72+
}
73+
// do something...
74+
}
75+
```
76+
4877
### 2. Examples
4978

50-
App clone
51-
52-
`FCore.get().installPackageAsUser("package_name", USER_ID)`
53-
54-
App running without installing
55-
56-
`FCore.get().installPackageAsUser(new File("/sdcard/some_app.apk"), USER_ID)`
57-
58-
Launch App in sandbox
59-
60-
`FCore.get().launchApk("package_name", USER_ID)`
61-
62-
### 3. Interfaces
63-
64-
| METHOD | DESCRIPTION |
65-
|-----|----|
66-
| init | Initialize sandbox |
67-
| isInstalled | Check if the App is installed in the sandbox |
68-
| installPackageAsUser | Clone App into sandbox according to package name |
69-
| installPackageAsUser | Clone App into sandbox via apk file |
70-
| uninstallPackage | Uninstall an App installed in the sandbox globally |
71-
| uninstallPackageAsUser | Uninstall an App installed in the sandbox by user |
72-
| getInstalledApplications | Get all applications installed in the sandbox |
73-
| getApplicationInfo | Get application info of an App in the sandbox |
74-
| getPackageInfo | Get package info of an application in the sandbox |
75-
| getLaunchIntentForPackage | Get LauncherIntent of an App |
76-
| launchApk | Launch App in sandbox |
77-
| launchIntent | Launch App via Intent |
78-
| isRunning | Check if an App is running |
79-
| clearPackage | Clear App data |
80-
| stopPackage | Stop an app from running |
81-
| stopAllPackages | Stop all running applications |
82-
| setApplicationCallback | |
83-
| disableFakeLocation | |
84-
| enableFakeLocation | |
85-
| setLocation | |
86-
| getLocation | |
87-
| setGlobalLocation | |
88-
| getGlobalLocation | |
89-
| getUsers | |
90-
| createUser | |
91-
| deleteUser | |
92-
| exportAppData | |
93-
| importAppData | |
94-
| setPreloadProcessCount | |
95-
| setHideRoot | |
96-
| setHideSim | |
97-
| setHideVPN | |
98-
| setVisitExternalApp | |
99-
| setDisableKill | |
100-
| setDisableNetwork | |
101-
| setHidePath | |
102-
| getSpaceLanguage | |
103-
| setSpaceLanguage | |
104-
| getSpaceRegion | |
105-
| setSpaceRegion | |
106-
| getSpaceTimeZone | |
107-
| setSpaceTimeZone | |
108-
| getSpaceTaskDescriptionPrefix | |
79+
**Method 1: App Clone**
80+
81+
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.
82+
83+
```java
84+
FCore.get().installPackageAsUser("package_name", USER_ID)
85+
```
86+
87+
**Method 2: Running without installation**
88+
89+
This method supports running without installation and will not be affected by system installation or uninstallation.
90+
91+
```java
92+
FCore.get().installPackageAsUser(new File("/sdcard/wechat.apk"), USER_ID)
93+
```
94+
95+
### 3. Launch sandboxed application
96+
97+
```java
98+
FCore.get().launchApk("package_name", USER_ID)
99+
```
109100

101+
### API Documentation
102+
103+
METHOD | DESCRIPTION
104+
---|---
105+
init | Initialize sandbox |
106+
isInstalled | Check if the app is installed in the sandbox |
107+
installPackageAsUser | Clone App into sandbox according to package name|
108+
installPackageAsUser | Clone App into sandbox via apk file|
109+
uninstallPackage | Uninstall an App installed in the sandbox globally |
110+
uninstallPackageAsUser | Uninstall an App installed in the sandbox by user|
111+
getInstalledApplications | Get all applications installed in the sandbox|
112+
getApplicationInfo | Get application info of an App in the sandbox|
113+
getPackageInfo | Get package info of an application in the sandbox|
114+
getLaunchIntentForPackage | Get LauncherIntent of an App |
115+
launchApk | Launch App in sandbox |
116+
launchIntent | Launch App via Intent |
117+
isRunning | Check if an App is running |
118+
clearPackage | Clear App data |
119+
stopPackage | Stop an app from running|
120+
stopAllPackages | Stop all running applications|
121+
setAutoForeground | Set auto start/close notification bar to automatically close notification bar when no process is active
122+
123+
### Internal Process:
124+
125+
METHOD | DESCRIPTION
126+
---|---
127+
findProcessRecord | Finding process information
128+
addProcessMonitor | Adding sandboxed internal process listeners
129+
removeProcessMonitor | Removing sandboxed internal process listeners
130+
131+
### SandBox User:
132+
133+
METHOD | DESCRIPTION
134+
---|---
135+
getUsers | Getting users in the sandbox
136+
createUser | Create users in the sandbox
137+
deleteUser | Delete users in the sandbox (all application information will be deleted)
138+
139+
### APP Data:
140+
141+
METHOD | DESCRIPTION
142+
---|---
143+
exportAppData | Export all data of a certain application
144+
importAppData | Import all data of a certain application
145+
146+
### APP Rules:
147+
148+
METHOD | DESCRIPTION
149+
---|---
150+
addRule| Add a rule
151+
setAllowSystemInteraction | Whether to allow interaction with system applications when the sandbox cannot find broadcasts, activities, etc
152+
setHideRoot | Hide root status
153+
setHideSim | Hide SIM card status
154+
setHideVPN | Hide VPN status
155+
setVisitExternalApp | Allow sandboxed applications to perceive external applications
156+
setDisableKill | Prevent application crashes
157+
setDisableNetwork | Disable application network
158+
setHidePath | Hide multi-open path and storage path
159+
getSpaceLanguage | Get the simulated language of a certain space
160+
setSpaceLanguage | Set the simulated language of a certain space (e.g. Chinese: zh)
161+
getSpaceRegion | Get the simulated region of a certain space
162+
setSpaceRegion | Set the simulated region of a certain space (e.g. China: CN)
163+
getSpaceTimeZone | Get the simulated time zone of a certain space
164+
setSpaceTimeZone | Set the simulated time zone of a certain space (e.g. Shanghai: Asia/Shanghai)
165+
166+
### App Permissions:
167+
168+
METHOD | DESCRIPTION
169+
---|---
170+
getPermission | Get app permission rules
171+
updatePermission | Update app permission rules
172+
revokePermission | Remove app permission rules (the app will follow the actual permissions of the host APP)
173+
174+
175+
### SandBox Configuration:
176+
177+
METHOD | DESCRIPTION
178+
---|---
179+
enableOptRule | Whether 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
180+
setAutoPreloadApplication | Intelligent preloading of applications, where the kernel automatically loads applications based on usage to accelerate startup speed. Default: on
181+
preloadApplicationCount | Default number of preloaded applications: 2
182+
setPreloadProcessCount | Set the number of preloading processes to speed up application startup. Default: 3
183+
setBackToHome | Whether to return to the host app when the sandbox app exits
184+
setSpaceTaskDescriptionPrefix | Set the application prefix in the recent tasks list (default: F{user ID})
185+
setEnableLauncherView | Whether to enable splash screen
186+
restartCoreSystem | Restart the kernel (all applications will be killed)
187+
188+
189+
## Rule Configuration System
190+
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.
191+
192+
```java
193+
PackageRule.Builder builder = new PackageRule.Builder("com.tencent.mm",
194+
/* Scoped process. Leave blank if the scope is all processes */
195+
"com.tencent.mm", "com.tencent.mm:tools", "com.tencent.mm:appbrand1", "com.tencent.mm:appbrand2")
196+
// disable a Activity
197+
.addBlackActivity("com.tencent.mm.plugin.base.stub.WXEntryActivity")
198+
// disable a broadcast
199+
.addBlackBroadcast("com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver")
200+
// disable a service
201+
.addBlackService("com.tencent.mm.plugin.backup.backuppcmodel.BackupPcService")
202+
// disable a ContentProvider
203+
.addBlackContentProvider("androidx.startup.InitializationProvider")
204+
// preloading process, can pre-start a certain process to speed up the runtime experience
205+
.addPreloadProcessName("com.tencent.mm:appbrand1")
206+
// disable a process from starting
207+
.addBlackProcessName("com.tencent.mm:appbrand2")
208+
// deny access to a file
209+
.addBlackIO("/proc/self/maps")
210+
// redirect a certain file
211+
.addRedirectIO("/proc/self/cmdline", "/proc/self/fake-cmdline")
212+
// hide root
213+
.isHideRoot(true)
214+
// hide SIM
215+
.isHideSim(true)
216+
// hide VPN
217+
.isHideVpn(true)
218+
// many more...
219+
// set language
220+
.setLanguage("zh")
221+
// set region
222+
.setRegion("CN")
223+
// set timezone
224+
.setTimeZone("Asia/Shanghai");
225+
226+
PackageRule build = builder.build();
227+
228+
// add a rule
229+
FCore.get().addRule(build);
230+
231+
// if there are multiple rules, put them in FRule
232+
FRule fRule = new FRule(builder.build(), builder.build(), builder.build());
233+
FCore.get().addFRule(fRule);
234+
235+
// support fetching configuration content from remote cloud
236+
String json = new Gson().toJson(fRule);
237+
// load json rule
238+
FCore.get().addFRuleContent(json);
239+
```

README_CN.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SpaceCore是一个基于Android系统的应用程序虚拟化引擎,一个Andr
55

66
官网:[https://spacecore.dev](https://spacecore.dev)
77

8+
Telegram:[@android_spacecore](https://t.me/android_spacecore)
89

910

1011
## 使用说明
@@ -183,17 +184,6 @@ setSpaceTaskDescriptionPrefix | 设置最近任务栏的应用前缀(默认:
183184
setEnableLauncherView | 是否启用 应用启动图
184185
restartCoreSystem | 重启内核(所有应用将会杀死)
185186

186-
### 内核虚拟GPS定位:
187-
188-
方法 | 描述 | en
189-
---|--- | ---
190-
disableFakeLocation | 禁用某个用户的虚拟定位
191-
enableFakeLocation | 启用某个用户的虚拟定位
192-
setLocation | 设置某个用户的虚拟定位参数
193-
getLocation | 获取某个用户的虚拟定位参数
194-
setGlobalLocation | 设置全局虚拟定位参数
195-
getGlobalLocation | 获取全局虚拟定位参数
196-
197187

198188
## 规则配置系统
199189
在面对各种应用时,支持配置不同的运行时参数,虚拟机参数来达到适配,SpaceCore支持强大的规则配置系统,能对每个应用定制专属的规则,可以通过云配置方式,动态更新规则库。规则支持的功能正在逐步开发。

0 commit comments

Comments
 (0)