首次添加 API 接口
This commit is contained in:
parent
65eaf17d85
commit
677ff4c16b
|
@ -2,5 +2,6 @@
|
|||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/Internet/random-questions/Question" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -5,6 +5,6 @@ Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-x
|
|||
Architecture: all
|
||||
Priority: optional
|
||||
Conflicts: com.gitee.uengine.runner.spark, spark-uengine-apk-builder
|
||||
Depends: python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib, fonts-noto-cjk, python3-numpy, python3-matplotlib, wget
|
||||
Depends: python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib, fonts-noto-cjk, python3-numpy, python3-matplotlib, wget, inotify-tools
|
||||
Description: UEngine Runner for deepin and UOS
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 35 KiB |
25
icon.svg
25
icon.svg
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 15 KiB |
|
@ -4,7 +4,7 @@
|
|||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.6.0",
|
||||
"Version": "1.6.1",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
"更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis",
|
||||
|
@ -22,6 +22,8 @@
|
|||
"5、如果想要使用adb连接UEngine或其他手机,请使用 1.2.0 以前的版本。(如需连接UEngine请安装adb补丁)"
|
||||
],
|
||||
"Update": [
|
||||
"V1.6.1:",
|
||||
"※1、修复了打包 deb 包在 APK 的包名有大写时无法启动的问题",
|
||||
"V1.6.0:",
|
||||
"※1、更换了新的图标",
|
||||
"※2、支持程序的评分和查看分数详情的功能(如果炸了我的服务器,这个就作废了)",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.6.0",
|
||||
"Version": "1.6.1",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
"更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis",
|
||||
|
@ -22,6 +22,8 @@
|
|||
"5、如果想要使用adb连接UEngine或其他手机,请使用 1.2.0 以前的版本。(如需连接UEngine请安装adb补丁)"
|
||||
],
|
||||
"Update": [
|
||||
"V1.6.1:",
|
||||
"※1、修复了打包 deb 包在 APK 的包名有大写时无法启动的问题",
|
||||
"V1.6.0:",
|
||||
"※1、更换了新的图标",
|
||||
"※2、支持程序的评分和查看分数详情的功能(如果炸了我的服务器,这个就作废了)",
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
import os
|
||||
import psutil
|
||||
import string
|
||||
import ttkthemes
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
|
||||
class Program:
|
||||
def GetRoot():
|
||||
return os.geteuid() == 0
|
||||
|
||||
def MountDisk():
|
||||
Disk.MountDisk(diskChoose.get(), "/data/uengine/安卓应用文件/media/" + name.get())
|
||||
|
||||
class Disk:
|
||||
def MountDisk(disk, path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
os.system("mount \"{}\" \"{}\"".format(disk, path))
|
||||
|
||||
class File:
|
||||
def DiskList():
|
||||
diskList = []
|
||||
partitions = psutil.disk_partitions()
|
||||
for p in partitions:
|
||||
if not "loop" in p.device and not "boot" in p.device and not p.device in diskList:
|
||||
#print(p.device)
|
||||
diskList.append(p.device)
|
||||
#print(p.mountpoint)
|
||||
return diskList
|
||||
|
||||
if __name__ == "__main__":
|
||||
window = tk.Tk()
|
||||
print(File.DiskList())
|
||||
if not Program.GetRoot():
|
||||
window.withdraw()
|
||||
messagebox.showerror(title="错误", message="此程序必须在 root 下运行!")
|
||||
quit()
|
||||
if not os.path.exists("/data/uengine/安卓应用文件/media"):
|
||||
os.makedirs("/data/uengine/安卓应用文件/media")
|
||||
#window.withdraw()
|
||||
#messagebox.showerror(title="错误", message="目录不存在,无法继续操作!")
|
||||
#quit()
|
||||
window.title("挂载磁盘")
|
||||
diskList = File.DiskList()
|
||||
diskChoose = tk.StringVar()
|
||||
diskChoose.set(diskList[0])
|
||||
weight = ttk.Frame(window)
|
||||
ttk.Label(weight, text="挂载磁盘:").grid(row=0, column=0)
|
||||
ttk.OptionMenu(weight, diskChoose, diskList[0], *diskList).grid(row=0, column=1)
|
||||
ttk.Label(weight, text="挂载名称:").grid(row=1, column=0)
|
||||
name = ttk.Entry(weight)
|
||||
ttk.Button(weight, text="挂载", command=Program.MountDisk).grid(row=2, column=1)
|
||||
name.grid(row=1, column=1)
|
||||
weight.pack()
|
||||
window.mainloop()
|
|
@ -3,7 +3,7 @@ Source: com.gitee.uengine.runner.spark
|
|||
Version: 1.6.0
|
||||
Architecture: all
|
||||
Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>
|
||||
Depends: deepin-elf-verify (>= 0.0.16.7-1), python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib, fonts-noto-cjk, python3-numpy, python3-matplotlib, wget
|
||||
Depends: deepin-elf-verify (>= 0.0.16.7-1), python3, python3-tk, python3-pip, aapt, uengine, python3-setuptools, deepin-terminal, curl, python3-pil, python3-pil.imagetk, python3-requests, adb, translate-shell, python3-xlib, fonts-noto-cjk, python3-numpy, python3-matplotlib, wget, inotify-tools
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Conflicts: spark-uengine-runner, spark-uengine-apk-builder
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi
|
||||
# 版本:1.5.3
|
||||
# 更新时间:2022年02月07日(要开学了)
|
||||
# 版本:1.6.1
|
||||
# 更新时间:2022年04月30日(五一了)
|
||||
# 感谢:anbox、deepin 和 统信
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
###########################################################################################
|
||||
|
@ -68,9 +68,9 @@ def BuildApkDeb(apkPath):
|
|||
RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
|
||||
apkPackageName = GetApkPackageName(apkPath, False)
|
||||
if qianZhui.get():
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, True)
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, True).lower()
|
||||
else:
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, False)
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, False).lower()
|
||||
apkPackageVersion = GetApkVersion(apkPath)
|
||||
if apkPackageVersion[0].upper() == "V":
|
||||
package = list(apkPackageVersion)
|
||||
|
@ -274,8 +274,8 @@ def GetApkPackageName(apkFilePath, setting):
|
|||
line = line.replace(" ", "")
|
||||
# 此较为特殊,因为需要判断用户是否要添加前缀
|
||||
if setting:
|
||||
return "uengine-dc-{}".format(line).lower()
|
||||
return line.lower()
|
||||
return "uengine-dc-{}".format(line)
|
||||
return line
|
||||
|
||||
def GetApkVersion(apkFilePath):
|
||||
info = GetApkInformation(apkFilePath)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import os
|
||||
import subprocess
|
||||
import getxmlimg
|
||||
# 判断程序以正确方式运行
|
||||
class ROOT:
|
||||
def GetRoot():
|
||||
return os.geteuid() == 0
|
||||
|
||||
class APK:
|
||||
def __init__(self, apkPath):
|
||||
self.apkPath = apkPath
|
||||
|
||||
def install(self):
|
||||
os.system("pkexec /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(self.apkPath))
|
||||
|
||||
def information(self):
|
||||
return subprocess.getoutput("aapt dump badging '{}'".format(self.apkPath))
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("本 API 不支持直接运行,请通过引入的方式使用此 API")
|
||||
quit()
|
||||
if not ROOT.GetRoot():
|
||||
print("请获取 ROOT 权限以便更好的使用该 API")
|
|
@ -0,0 +1,118 @@
|
|||
import PIL.Image as Image
|
||||
import PIL.ImageDraw as ImageDraw
|
||||
import zipfile
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
class getsavexml():
|
||||
|
||||
def savexml(self,apkFilePath,xmlpath,iconSavePath):
|
||||
cmddumpid = "aapt dump xmltree "+ apkFilePath + " " + xmlpath
|
||||
print(cmddumpid)
|
||||
xmltree = subprocess.getoutput(cmddumpid)
|
||||
xmls = xmltree.splitlines()
|
||||
# find strs ,print next line
|
||||
def FindStrs(lines,strs):
|
||||
i=0
|
||||
while i < len(lines):
|
||||
if re.search(strs,lines[i]):
|
||||
tmpstr = lines[i+1]
|
||||
i += 1
|
||||
Resultstr = tmpstr.split(":")[-1].split("=")[-1].split("0x")[-1]
|
||||
return Resultstr
|
||||
else:
|
||||
i += 1
|
||||
#从apk的信息中获取前后景图片的ID号
|
||||
backimgid = FindStrs(xmls,"background")
|
||||
foreimgid = FindStrs(xmls,"foreground")
|
||||
print(backimgid)
|
||||
print(foreimgid)
|
||||
|
||||
# 直接从apk resource文件获取前后两层图片路径及ID字符串
|
||||
resource = subprocess.getoutput("aapt dump --values resources " + apkFilePath + "| grep -iE -A1 " + "\"" + backimgid + "|" + foreimgid + "\"")
|
||||
resourcelines = resource.splitlines()
|
||||
print(resourcelines)
|
||||
|
||||
# 从过滤出的字符串中获取所有相同ID的图片路径
|
||||
def Findpicpath(lines,imgid):
|
||||
i=0
|
||||
Resultstr = []
|
||||
while i < len(lines):
|
||||
if re.search(imgid,lines[i]) and re.search("string8",lines[i+1]) :
|
||||
print(lines[i+1])
|
||||
tmpstr = lines[i+1].replace("\"","")
|
||||
i += 1
|
||||
Resultstr.append(tmpstr.split()[-1])
|
||||
else:
|
||||
i += 1
|
||||
return Resultstr
|
||||
|
||||
#获取所有带前后图片ID的图片路径(相同背景或者前景的图片ID但分辨率不一样)
|
||||
backimgs = Findpicpath(resourcelines,backimgid)
|
||||
foreimgs = Findpicpath(resourcelines,foreimgid)
|
||||
print(backimgs)
|
||||
print(foreimgs)
|
||||
#获取分辨率最高的图片路径
|
||||
def getmaxsize(imgs):
|
||||
j = 0
|
||||
size=(0,0)
|
||||
zipapk = zipfile.ZipFile(apkFilePath)
|
||||
imgpath = ""
|
||||
while j < len(imgs):
|
||||
print(imgs[j])
|
||||
img = Image.open(zipapk.open(imgs[j]))
|
||||
print(imgs[j])
|
||||
print(img.size)
|
||||
if size < img.size:
|
||||
size = img.size
|
||||
imgpath = imgs[j]
|
||||
j += 1
|
||||
return imgpath
|
||||
|
||||
# 获取到文件列表后,进行比较分辨率,选取分辨率最高的张图片
|
||||
iconbackpath = getmaxsize(backimgs)
|
||||
iconforepath = getmaxsize(foreimgs)
|
||||
print(iconbackpath + " " + iconforepath)
|
||||
|
||||
#从APK文件获取最终图片
|
||||
zipapk = zipfile.ZipFile(apkFilePath)
|
||||
iconback = zipapk.open(iconbackpath)
|
||||
iconfore = zipapk.open(iconforepath)
|
||||
|
||||
|
||||
# 叠加图片,mask 设置前景为蒙版
|
||||
iconbackimg = Image.open(iconback).convert("RGBA")
|
||||
iconforeimg = Image.open(iconfore).convert("RGBA")
|
||||
iconbackimg.paste(iconforeimg,mask=iconforeimg)
|
||||
|
||||
|
||||
# 圆角图片函数,网上拷贝的
|
||||
def circle_corner(img, radii): #把原图片变成圆角,这个函数是从网上找的,原址 https://www.pyget.cn/p/185266
|
||||
"""
|
||||
圆角处理
|
||||
:param img: 源图象。
|
||||
:param radii: 半径,如:30。
|
||||
:return: 返回一个圆角处理后的图象。
|
||||
"""
|
||||
# 画圆(用于分离4个角)
|
||||
circle = Image.new('L', (radii * 2, radii * 2), 0) # 创建一个黑色背景的画布
|
||||
draw = ImageDraw.Draw(circle)
|
||||
draw.ellipse((0, 0, radii * 2, radii * 2), fill=255) # 画白色圆形
|
||||
# 原图
|
||||
img = img.convert("RGBA")
|
||||
w, h = img.size
|
||||
# 画4个角(将整圆分离为4个部分)
|
||||
alpha = Image.new('L', img.size, 255)
|
||||
alpha.paste(circle.crop((0, 0, radii, radii)), (0, 0)) # 左上角
|
||||
alpha.paste(circle.crop((radii, 0, radii * 2, radii)), (w - radii, 0)) # 右上角
|
||||
alpha.paste(circle.crop((radii, radii, radii * 2, radii * 2)), (w - radii, h - radii)) # 右下角
|
||||
alpha.paste(circle.crop((0, radii, radii, radii * 2)), (0, h - radii)) # 左下角
|
||||
# alpha.show()
|
||||
img.putalpha(alpha) # 白色区域透明可见,黑色区域不可见
|
||||
return img
|
||||
|
||||
# 圆角半径1/8边长,保存icon图片
|
||||
w,h = iconbackimg.size
|
||||
iconimg = circle_corner(iconbackimg,int(w/8))
|
||||
iconimg.save(iconSavePath)
|
||||
|
Loading…
Reference in New Issue