加了一点函数
This commit is contained in:
parent
d68f42c368
commit
7f36a1ff3c
|
@ -11,6 +11,7 @@
|
|||
| version | API 版本 |
|
||||
| updateTime | 更新时间 |
|
||||
| websize | 程序官网 |
|
||||
| home | 用户 home(用户文件)目录 |
|
||||
|
||||
## Check
|
||||
用于检查 API 所需的东西是否完整,详细如下:
|
||||
|
@ -41,11 +42,13 @@ xxx = api.APK("APK 所在路径")
|
|||
| xxx.chineseLabel() | 获取 APK 中文名称 |
|
||||
| xxx.saveApkIcon("图标保存路径") | 保存 APK 的图标到指定路径 |
|
||||
| xxx.version() | 获取 APK 版本号 |
|
||||
| xxx.saveDesktopFile("图标保存路径", "快捷方式保存路径") | 保存支持 UEngine 启动的 APK 快捷方式 |
|
||||
|
||||
## UEngine
|
||||
用于对 UEngine 进行一点点操控,详细如下:
|
||||
| 函数名 | 函数介绍 |
|
||||
|:-:|:-:|
|
||||
| RemoveUengineCheck() | 删除 UEngine 的检查脚本 |
|
||||
| CPUCheck() | 检查 CPU 是否支持运行 UEngine |
|
||||
| Services | 用于操控 UEngine 服务的类,见下 |
|
||||
| InternetBridge | 用于操控 UEngine 网络桥接的类,见下 |
|
||||
|
@ -64,4 +67,26 @@ xxx = api.APK("APK 所在路径")
|
|||
| InternetBridge.Close() | 关闭 UEngine 网络桥接 |
|
||||
| InternetBridge.Restart() | 重启 UEngine 网络桥接 |
|
||||
| InternetBridge.Reload() | 重新加载 UEngine 网络桥接 |
|
||||
| InternetBridge.ForceReload() | 强制加载 UEngine 网络桥接 |
|
||||
| InternetBridge.ForceReload() | 强制加载 UEngine 网络桥接 |
|
||||
## Adb
|
||||
用于对 Adb 的部分操控
|
||||
| 函数名 | 函数介绍 |
|
||||
|:-:|:-:|
|
||||
| Services | 用于操控 Adb 服务的类,见下 |
|
||||
### Service
|
||||
关于 Adb 的服务控制:
|
||||
| 函数名 | 函数介绍 |
|
||||
|:-:|:-:|
|
||||
| Services.Open() | 打开 Adb 服务 |
|
||||
| Services.Close() | 关闭 Adb 服务 |
|
||||
| Services.Kill() | 杀死 Adb 进程 |
|
||||
## File
|
||||
关于文件的读取和写入,这是面向对象的写法,所以应用方式也不一样:
|
||||
```python
|
||||
import api
|
||||
xxx = api.File("文件所在路径")
|
||||
```
|
||||
| 函数名 | 函数介绍 |
|
||||
|:-:|:-:|
|
||||
| xxx.read() | 读取这个文件 |
|
||||
| xxx.write("写入内容") | 写入这个文件 |
|
|
@ -10,6 +10,7 @@ class ProgramInformation:
|
|||
version = "1.6.0Alpha1"
|
||||
updateTime = "2022年05月15日"
|
||||
websize = ["https://gitee.com/gfdgd-xi/uengine-runner", "https://github.com/gfdgd-xi/uengine-runner"]
|
||||
home = os.path.expanduser('~')
|
||||
|
||||
# 判断程序以正确方式运行
|
||||
class Check:
|
||||
|
@ -110,7 +111,29 @@ class APK:
|
|||
line = line.replace("'", "")
|
||||
line = line.replace(" ", "")
|
||||
return line
|
||||
|
||||
def saveDesktopFile(self, desktopPath, iconPath):
|
||||
showName = self.chineseLabel()
|
||||
if showName == "" or showName == None:
|
||||
showName = "未知应用"
|
||||
self.saveApkIcon(iconPath)
|
||||
things = '''[Desktop Entry]
|
||||
Categories=app;
|
||||
Encoding=UTF-8
|
||||
Exec=uengine launch --action=android.intent.action.MAIN --package={} --component={}
|
||||
GenericName={}
|
||||
Icon={}
|
||||
MimeType=
|
||||
Name={}
|
||||
StartupWMClass={}
|
||||
Terminal=false
|
||||
Type=Application
|
||||
'''.format(self.packageName(), self.activityName(), showName, iconPath, showName, showName)
|
||||
File(desktopPath).write(things)
|
||||
|
||||
class UEngine:
|
||||
def RemoveUengineCheck():
|
||||
os.remove("/usr/share/uengine/uengine-check-runnable.sh")
|
||||
def CPUCheck():
|
||||
return subprocess.getoutput("uengine check-features")
|
||||
class Services:
|
||||
|
@ -133,6 +156,34 @@ class UEngine:
|
|||
def ForceReload():
|
||||
os.system("pkexec uengine-bridge.sh force-reload")
|
||||
|
||||
class Adb:
|
||||
class Service:
|
||||
def Open():
|
||||
os.system("adb start-server")
|
||||
def Close():
|
||||
os.system("adb kill-server")
|
||||
def Kill():
|
||||
os.system("killall adb")
|
||||
|
||||
class File:
|
||||
def __init__(self, filePath):
|
||||
self.filePath = filePath
|
||||
|
||||
def read(self):
|
||||
f = open(self.filePath, "r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def write(self, things) -> "写入文本文档":
|
||||
TxtDir = os.path.dirname(self.filePath)
|
||||
print(TxtDir)
|
||||
if not os.path.exists(TxtDir):
|
||||
os.makedirs(TxtDir, exist_ok=True)
|
||||
file = open(self.filePath, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("本 API 不支持直接运行,请通过引入的方式使用此 API")
|
||||
apki = APK("/home/gfdgd_xi/下载/com.mihoyo.cloudgames.ys_1.0.0_liqucn.com.apk")
|
||||
|
|
Loading…
Reference in New Issue