Skip to content

Commit c3ba078

Browse files
committed
2 parents 18854c0 + c5f9306 commit c3ba078

File tree

2 files changed

+350
-14
lines changed

2 files changed

+350
-14
lines changed

README.md

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,109 @@
1-
# SpaceCore
2-
SpaceCore is an Application Virtualization Engine on Android. This Engine supports cloning and running multiple applications on Android, with more features such as device simulation, fake GPS, etc.
31

4-
## [中文](README_CN.md)
2+
[中文文档](https://github.com/FSpaceCore/SpaceCore/blob/main/README_CN.md)
53

6-
## Website
7-
https://spacecore.dev/
4+
# SpaceCore
5+
6+
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.
7+
8+
Official website: [https://spacecore.dev](https://spacecore.dev)
9+
10+
<br>
11+
12+
## Instructions
13+
14+
##### SpaceCore SDK
15+
* 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])
17+
18+
##### SpaceCore Demo
19+
* 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)
20+
21+
<br>
822

923
## Compatibility
10-
Android 6.0 ~ 14.0 Preview Also supports Huawei HarmonyOS
1124

12-
For technical support, feature customization, issue resolution, and SpaceCore commercial SDK, please contact Email: [email protected].
25+
| | Compatibility |
26+
|---------------------|----------------------------------|
27+
| ABIs | `armeabi-v7a / arm64-v8a` |
28+
| Android version | `6.0 ~ 14.0 and future versions` |
29+
30+
31+
## Usages
32+
33+
### 0. Dependency
34+
35+
```
36+
implementation "com.tencent:mmkv-static:1.2.10"
37+
implementation "com.google.code.gson:gson:2.9.1"
38+
39+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"
40+
```
41+
42+
### 1. Initialization
43+
44+
Put this initialization code within "Application#attachBaseContext".
45+
46+
`FCore.get().init(this);`
47+
48+
### 2. Examples
49+
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 | |
109+

README_CN.md

Lines changed: 246 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,249 @@
1-
# SpaceCore虚拟引擎内核
2-
SpaceCore是一个虚拟引擎内核,提供在Android上克隆和运行虚拟应用程序,并且已支持设备模拟、模拟定位以及其他更多的功能。本内核重新实现了现有框架的痛点,更贴合系统真实运行环境。
31

4-
## 官网
5-
https://spacecore.dev
2+
# SpaceCore
3+
4+
SpaceCore是一个基于Android系统的应用程序虚拟化引擎,一个Android系统的沙盒环境,亦可看作是轻量级的Android虚拟机。可用于APP多开、数据隔离、脚本自动化、插件化开发、谷歌商店上架等。
5+
6+
官网:[https://spacecore.dev](https://spacecore.dev)
7+
8+
9+
10+
## 使用说明
11+
12+
##### SpaceCore SDK
13+
* SpaceCore SDK 为免费产品,**非开源**,您可以自由使用而无须通知本作者,亦可作为商业用途使用 [SpaceCore SDK 下载](https://github.com/FSpaceCore/SpaceCore/releases)
14+
* **如有定制需求,请联系** [[email protected]](mailto:[email protected])
15+
16+
##### SpaceCore Demo
17+
* SpaceCore Demo 用于演示SpaceCore SDK的使用方式,即本仓库中的代码 [SpaceCore Demo Release 下载](https://github.com/FSpaceCore/SpaceCore/releases)
18+
19+
20+
## 兼容性
21+
22+
23+
| | 兼容性 |
24+
|---------------------|----------------------------------|
25+
| ABIs | `armeabi-v7a / arm64-v8a` |
26+
| Android version | `6.0 ~ 14.0 及后续版本持续兼容更新` |
27+
28+
29+
## 集成SDK
30+
31+
### Step 1. 依赖引用
32+
33+
版本根据主工程版本即可,如主工程未添加依赖则需要添加以下依赖
34+
```
35+
implementation "com.tencent:mmkv-static:1.2.10"
36+
implementation "com.google.code.gson:gson:2.9.1"
37+
```
38+
39+
如果主工程未使用kotlin,需要额外引入
40+
```
41+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"
42+
```
43+
<br>
44+
45+
### Step 2 初始化,在Application#attachBaseContext中加入以下代码初始化
46+
47+
```java
48+
FCore.get().init(this);
49+
```
50+
51+
请注意,在调用init之后,若FCore.get().isClient()条件成立,请尽量不要在Application中做其他事情的初始化,如遇到问题,请联系技术人员。
52+
```kotlin
53+
override fun attachBaseContext(base: Context) {
54+
super.attachBaseContext(base)
55+
FCore.get().init(this)
56+
// 允许与系统交互
57+
FCore.get().setAllowSystemInteraction(true)
58+
// 允许智能预加载
59+
FCore.get().setAutoPreloadApplication(true)
60+
// .....
61+
if(FCore.isClient()) {
62+
return
63+
}
64+
// do ....
65+
}
666

7-
## 兼容
8-
Android 6.0 ~ 14.0预览版 及 鸿蒙
67+
override fun onCreate() {
68+
super.onCreate()
69+
if(FCore.isClient()) {
70+
return
71+
}
72+
// do ....
73+
}
74+
```
75+
<br>
76+
77+
### Step 3. 安装
78+
79+
##### 克隆APP
80+
此方式会依赖系统已安装应用,如果系统上的应用卸载,那么空间内应用也会跟随消失
81+
```java
82+
FCore.get().installPackageAsUser("包名", USER_ID)
83+
```
84+
85+
##### 免安装运行
86+
此方式支持免安装,不会受系统安装卸载影响。
87+
```java
88+
FCore.get().installPackageAsUser(new File("/sdcard/wechat.apk"), USER_ID)
89+
```
90+
91+
### Step 4. 启动沙盒应用
92+
```java
93+
FCore.get().launchApk("包名", USER_ID)
94+
```
95+
<br>
96+
97+
## 接口文档
98+
99+
方法 | 描述 | en
100+
---|--- | ---
101+
init | 初始化内核,请在Application#attachBaseContext调用 | Initialize sandbox |
102+
isInstalled | 沙盒内是否已安装 | Check if the app is installed in the sandbox |
103+
installPackageAsUser | 提供包名克隆应用到沙盒 | Clone App into sandbox according to package name|
104+
installPackageAsUser | 提供File安装应用到沙盒 | Clone App into sandbox via apk file|
105+
uninstallPackage | 卸载沙盒中所有用户已安装的某个应用 | Uninstall an App installed in the sandbox globally |
106+
uninstallPackageAsUser | 卸载某个用户的应用 | Uninstall an App installed in the sandbox by user|
107+
getInstalledApplications | 获取已安装在沙盒內的应用 | Get all applications installed in the sandbox|
108+
getApplicationInfo | 获取沙盒內某个应用的ApplicationInfo | Get application info of an App in the sandbox|
109+
getPackageInfo | 获取沙盒內某个应用的PackageInfo | Get package info of an application in the sandbox|
110+
getLaunchIntentForPackage | 获取应用Launcher Intent | Get LauncherIntent of an App |
111+
launchApk | 启动沙盒应用 | Launch App in sandbox |
112+
launchIntent | 通过Intent启动应用 | Launch App via Intent |
113+
isRunning | 判断某个应用是否正在运行 | Check if an App is running |
114+
clearPackage | 清除沙盒APK数据 | Clear App data |
115+
stopPackage | 停止某个应用运行 | Stop an app from running|
116+
stopAllPackages | 停止所有正在运行的应用 | Stop all running applications|
117+
setApplicationCallback | 注册应用Application启动回调 | |
118+
preloadApplication | launchApk时间较长,可以使用此方法阻塞加载,加载成功后再launchApk。期间可以自己做动画或者等待启动的事件
119+
setAutoForeground | 设置自动启动/关闭通知栏,当没有进程活跃时自动关闭通知栏
120+
121+
### 内部进程:
122+
123+
方法 | 描述 | en
124+
---|--- | ---
125+
findProcessRecord | 寻找进程信息
126+
addProcessMonitor | 添加沙盒内部进程监听
127+
removeProcessMonitor | 移除沙盒内部进程监听
128+
129+
### 内核用户:
130+
131+
方法 | 描述 | en
132+
---|--- | ---
133+
getUsers | 获取沙盒中的用户
134+
createUser | 创建沙盒中的用户
135+
deleteUser | 删除沙盒中的用户(所有应用信息将被删除)
136+
137+
### 应用数据:
138+
139+
方法 | 描述 | en
140+
---|--- | ---
141+
exportAppData | 导出某个应用的所有数据
142+
importAppData | 导入某个应用的所有数据
143+
144+
### 应用规则:
145+
146+
方法 | 描述 | en
147+
---|--- | ---
148+
addRule| 加入一份配置规则
149+
setAllowSystemInteraction | 当沙盒查找不到广播、Activity等时,是否允与系统应用交互
150+
setHideRoot | 隐藏Root
151+
setHideSim | 隐藏SIM卡状态
152+
setHideVPN | 隐藏VPN状态
153+
setVisitExternalApp | 沙盒內应用可感知外部应用
154+
setDisableKill | 防止应用闪退
155+
setDisableNetwork | 禁用应用网络
156+
setHidePath | 隐藏多开路径、存储路径
157+
getSpaceLanguage | 获取某个空间的模拟语言
158+
setSpaceLanguage | 设置某个空间的模拟语言(中国:zh)
159+
getSpaceRegion | 获取某个空间的模拟地区
160+
setSpaceRegion | 设置某个空间的模拟地区(中国:CN)
161+
getSpaceTimeZone | 获取某个空间的模拟时区
162+
setSpaceTimeZone | 设置某个空间的模拟时区(上海:Asia/Shanghai)
163+
164+
### 应用权限:
165+
166+
方法 | 描述 | en
167+
---|--- | ---
168+
getPermission | 获取应用权限规则
169+
updatePermission | 更新应用权限规则
170+
revokePermission | 移除应用权限规则(应用将跟随宿主实际权限)
171+
172+
173+
### 内核配置:
174+
175+
方法 | 描述 | en
176+
---|--- | ---
177+
enableOptRule | 是否启用规则屏蔽推送、三方sdk、热更新、广告等,优化应用运行速度,如遇到应用异常,请关闭
178+
setAutoPreloadApplication | 智能预加载应用,内核自动根据应用使用情况主动加载应用,加快启动速度,默认:开
179+
preloadApplicationCount | 默认预加载应用数量,默认:2
180+
setPreloadProcessCount | 设置预加载进程数量,加快应用启动速度,默认:3
181+
setBackToHome | 当沙盒应用退出时是否返回宿主
182+
setSpaceTaskDescriptionPrefix | 设置最近任务栏的应用前缀(默认:F{用户ID})
183+
setEnableLauncherView | 是否启用 应用启动图
184+
restartCoreSystem | 重启内核(所有应用将会杀死)
185+
186+
### 内核虚拟GPS定位:
187+
188+
方法 | 描述 | en
189+
---|--- | ---
190+
disableFakeLocation | 禁用某个用户的虚拟定位
191+
enableFakeLocation | 启用某个用户的虚拟定位
192+
setLocation | 设置某个用户的虚拟定位参数
193+
getLocation | 获取某个用户的虚拟定位参数
194+
setGlobalLocation | 设置全局虚拟定位参数
195+
getGlobalLocation | 获取全局虚拟定位参数
196+
197+
198+
## 规则配置系统
199+
在面对各种应用时,支持配置不同的运行时参数,虚拟机参数来达到适配,SpaceCore支持强大的规则配置系统,能对每个应用定制专属的规则,可以通过云配置方式,动态更新规则库。规则支持的功能正在逐步开发。
200+
201+
```java
202+
PackageRule.Builder builder = new PackageRule.Builder("com.tencent.mm",
203+
/*作用域进程,如果所有进程则留空*/
204+
"com.tencent.mm", "com.tencent.mm:tools", "com.tencent.mm:appbrand1", "com.tencent.mm:appbrand2")
205+
// 禁用某个Activity
206+
.addBlackActivity("com.tencent.mm.plugin.base.stub.WXEntryActivity")
207+
// 禁用某个广播
208+
.addBlackBroadcast("com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver")
209+
// 禁用某个服务
210+
.addBlackService("com.tencent.mm.plugin.backup.backuppcmodel.BackupPcService")
211+
// 禁用某个ContentProvider
212+
.addBlackContentProvider("androidx.startup.InitializationProvider")
213+
// 预加载进程,可预先启动某个进程 加快运行时体验速度。
214+
.addPreloadProcessName("com.tencent.mm:appbrand1")
215+
// 禁止某个进程启动
216+
.addBlackProcessName("com.tencent.mm:appbrand2")
217+
// 禁止访问某文件
218+
.addBlackIO("/proc/self/maps")
219+
// 重定向某文件
220+
.addRedirectIO("/proc/self/cmdline", "/proc/self/fake-cmdline")
221+
// 隐藏Root
222+
.isHideRoot(true)
223+
// 隐藏Sim
224+
.isHideSim(true)
225+
// 隐藏VPN
226+
.isHideVpn(true)
227+
// 许多等等....
228+
// 设置环境语言
229+
.setLanguage("zh")
230+
// 设置当前所在区域
231+
.setRegion("CN")
232+
// 设置当前时区
233+
.setTimeZone("Asia/Shanghai");
234+
PackageRule build = builder.build();
235+
236+
// 加入单条规则
237+
FCore.get().addRule(build);
238+
239+
240+
// 如果多条规则请放入FRule
241+
FRule fRule = new FRule(builder.build(), builder.build(), builder.build());
242+
FCore.get().addFRule(fRule);
243+
9244

10-
如需 **技术支持、功能定制、问题修复** 、SpaceCore商业版SDK,请联系 **Email: [email protected]**
245+
// 可云下发配置内容
246+
String json = new Gson().toJson(fRule);
247+
// 客户端加载云下发json
248+
FCore.get().addFRuleContent(json);
249+
```

0 commit comments

Comments
 (0)