修复 deepin 23 安装的 APK 无法正常在启动器显示图标的问题

This commit is contained in:
gfdgd_xi 2024-01-29 19:17:20 +08:00
parent d385fdd64c
commit f82d767a19
15 changed files with 68 additions and 27 deletions

View File

@ -4,7 +4,7 @@
"https://gitee.com/gfdgd-xi/uengine-runner",
"https://github.com/gfdgd-xi/uengine-runner"
],
"Version": "2.1.2",
"Version": "2.2.0",
"System": "Linuxdeepin/UOS/Ubuntu/Debian",
"Tips": [
"更多可见https://gitee.com/gfdgd-xi/uengine-runner/wikis 或程序的更多帮助",
@ -22,6 +22,12 @@
"5、如果想要使用adb连接UEngine或其他手机请使用 1.2.0 以前的版本。如需连接UEngine请安装adb补丁"
],
"Update": [
"<b>V2.2.0</b>",
"※1、支持 deepin 23不需要强制依赖 aapt",
"※2、修复 deepin 23 安装的 APK 无法正常在启动器显示图标的问题",
"3、优化安装量统计机制",
"4、关于窗口新增赞助页",
"",
"<b>V2.1.2</b>",
"※1、修复 https://gitee.com/gfdgd-xi/uengine-runner/issues/I6ZRZX",
"※2、修复添加应用图标时activity名称错误的问题",

View File

@ -89,8 +89,8 @@ class UninstallProgram(QtCore.QThread):
self.error.emit("疑似卸载失败,请检查 UEngine 是否正常安装、运行以及 APK 文件或包名是否正确、完整")
DisabledAndEnbled(False)
return
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), package)):
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), package))
if os.path.exists("{}/{}.desktop".format(desktopFilePath, package)):
os.remove("{}/{}.desktop".format(desktopFilePath, package))
if os.path.exists("{}/{}.desktop".format(get_desktop_path(), package)):
os.remove("{}/{}.desktop".format(get_desktop_path(), package))
findApkHistory.append(ComboInstallPath.currentText())
@ -174,9 +174,9 @@ class InstallApk(QtCore.QThread):
try:
if not os.path.exists("/tmp/uengine-runner"):
os.makedirs("/tmp/uengine-runner")
if not os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
if not os.path.exists(desktopFilePath):
print("Mkdir")
os.makedirs("{}/.local/share/applications/uengine/".format(get_home()))
os.makedirs(desktopFilePath)
# 读取设置
setting = json.loads(readtxt(get_home() + "/.config/uengine-runner/setting.json"))
# 安装应用
@ -246,7 +246,7 @@ logicalHeight {verticalHeighe}
"{}/{}.desktop".format(get_desktop_path(), GetApkPackageName(path)))
print("start install apk3")
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), GetApkPackageName(path)))
"{}/{}.desktop".format(desktopFilePath, GetApkPackageName(path)))
print("\nprint install complete")
if quit:
return
@ -266,7 +266,7 @@ def InstallBuildDesktop(iconSavePath):
"{}/{}.desktop".format(get_desktop_path(), GetApkPackageName(path)), choose)
print("start install apk3")
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), GetApkPackageName(path)), choose)
"{}/{}.desktop".format(desktopFilePath, GetApkPackageName(path)), choose)
print("\nprint install complete")
def UpdateCombobox(tmp):
@ -587,8 +587,8 @@ def BackUengineClean()->"清空 uengine 数据":
if QtWidgets.QMessageBox.warning(widget, "警告", "清空后数据将会完全丢失,确定要继续吗?", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Ok:
DisabledAndEnbled(True)
try:
if os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
shutil.rmtree("{}/.local/share/applications/uengine/".format(get_home()))
if os.path.exists(desktopFilePath):
shutil.rmtree(desktopFilePath)
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
@ -1462,7 +1462,7 @@ class AddNewUengineDesktopLink():
# 添加快捷方式
def SaveDesktopLink():
try:
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.text())):
if os.path.exists("{}/{}.desktop".format(desktopFilePath, packageName.text())):
if QtWidgets.QMessageBox.question(widget, "提示", "文件已存在,是否要覆盖?") == QtWidgets.QMessageBox.No:
return
if not os.path.exists("{}/.local/share/icons/hicolor/256x256/apps/".format(get_home())):
@ -1471,7 +1471,7 @@ class AddNewUengineDesktopLink():
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.text())
shutil.copy(programPath + "/defult.png", iconSavePath)
BuildUengineDesktop(packageName.text(), activityName.text(), packageName.text(), iconSavePath,
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.text()))
"{}/{}.desktop".format(desktopFilePath, packageName.text()))
BuildUengineDesktop(packageName.text(), activityName.text(), packageName.text(), iconSavePath,
"{}/{}.desktop".format(get_desktop_path(), packageName.text()))
AddNewUengineDesktopLink.SaveHistory()
@ -1485,13 +1485,13 @@ class AddNewUengineDesktopLink():
def DelDesktopLink():
try:
global packageName
if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.text())):
QtWidgets.QMessageBox.critical(widget, "错误", "此包名对应的 UEngine 桌面快捷方式不存在!")
if not os.path.exists("{}/{}.desktop".format(desktopFilePath, packageName.text())):
QtWidgets.QMessageBox.critical(widget, "错误", "此包名对应的 UEngine 快捷方式不存在!")
return
if QtWidgets.QMessageBox.warning(widget, "警告", "你确定要删除吗?删除后将无法恢复!", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Cancel:
return
try:
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.text()))
os.remove("{}/{}.desktop".format(desktopFilePath, packageName.text()))
AddNewUengineDesktopLink.SaveHistory()
QtWidgets.QMessageBox.information(widget, "提示", "已删除")
except:
@ -1611,13 +1611,25 @@ desktop = programPath + "/UengineAndroidProgramList.desktop"
desktopName = "UengineAndroidProgramList.desktop"
useProgram = ""
threading.Thread(target=UseProgram).start()
isDeepin23=False
# 判断是不是 Deepin23
if os.path.exists("/etc/deepin_version"):
try:
with open(f"/etc/deepin_version") as file:
isDeepin23 = "23" in file.read()
except:
traceback.print_exc()
desktopFilePath = f"{get_home()}/.local/share/applications/uengine/"
if isDeepin23:
desktopFilePath = f"{get_home()}/.local/share/applications/"
###########################
# 加载配置
###########################
app = QtWidgets.QApplication(sys.argv)
if not os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
os.makedirs("{}/.local/share/applications/uengine/".format(get_home()))
if not os.path.exists(desktopFilePath):
os.makedirs(desktopFilePath)
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
os.makedirs(get_home() + "/.config/uengine-runner") # 创建配置文件夹
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkHistory.json"): # 如果没有配置文件

View File

@ -0,0 +1 @@
libaapt.so.0

View File

@ -0,0 +1,14 @@
#!/bin/bash
# 判断是不是 Deepin23
cat /etc/deepin_version | grep 23
if [[ $? != 0 ]]; then
# 如果不是
aapt "$@"
exit $?
fi
# 如果是
programPath=$(cd $(dirname $0); pwd)
echo $programPath
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$programPath"
$programPath/aapt "$@"
exit $?

View File

@ -6,6 +6,12 @@ import traceback
import subprocess
from getxmlimg import getsavexml
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
class ProgramInformation:
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
version = "1.6.0Alpha2"
@ -49,7 +55,7 @@ class APK:
def uninstall(self):
return os.system("uengine uninstall --pkg='{}'".format(self.packageName()))
def information(self):
return subprocess.getoutput("aapt dump badging '{}'".format(self.apkPath))
return subprocess.getoutput("'{}/aapt/run-aapt.sh' dump badging '{}'".format(programPath, self.apkPath))
def activityName(self):
info = self.information()
for line in info.split('\n'):

View File

@ -10,10 +10,12 @@ import zipfile
import subprocess
import re
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
class getsavexml():
def savexml(self,apkFilePath,xmlpath,iconSavePath):
cmddumpid = "aapt dump xmltree "+ apkFilePath + " " + xmlpath
cmddumpid = f"'{programPath}/aapt/run-aapt.sh' dump xmltree "+ apkFilePath + " " + xmlpath
print(cmddumpid)
xmltree = subprocess.getoutput(cmddumpid)
xmls = xmltree.splitlines()
@ -35,7 +37,7 @@ class getsavexml():
print(foreimgid)
# 直接从apk resource文件获取前后两层图片路径及ID字符串
resource = subprocess.getoutput("aapt dump --values resources " + apkFilePath + "| grep -iE -A1 " + "\"" + backimgid + "|" + foreimgid + "\"")
resource = subprocess.getoutput(f"'{programPath}/aapt/run-aapt.sh' dump --values resources " + apkFilePath + "| grep -iE -A1 " + "\"" + backimgid + "|" + foreimgid + "\"")
resourcelines = resource.splitlines()
print(resourcelines)

View File

@ -263,7 +263,7 @@
"11、deepin 终端",
"……"
],
"Time": "2024-01-29 18:34:06 Linux-6.1.32-amd64-desktop-hwe-x86_64-with-glibc2.35",
"Time": "2024-01-29 19:04:32 Linux-6.1.32-amd64-desktop-hwe-x86_64-with-glibc2.35",
"Contribute": [
"<b>感谢以下用户提供的问题、建议、图标、代码等,如果有遗漏,请及时与开发者联系添加,以及如果侵犯到您的合法权益,也及时与开发者联系:</p>",
"<hr>",

View File

@ -289,7 +289,7 @@ def write_txt(path, things):
file.close() # 关闭文本对象
def GetApkInformation(apkFilePath):
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
return GetCommandReturn("'{}/aapt/run-aapt.sh' dump badging '{}'".format(programPath, apkFilePath))
def GetApkActivityName(apkFilePath):
info = GetApkInformation(apkFilePath)

View File

@ -313,7 +313,7 @@ def write_txt(path, things):
file.close() # 关闭文本对象
def GetApkInformation(apkFilePath):
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
return GetCommandReturn("'{}/aapt/run-aapt.sh' dump badging '{}'".format(programPath, apkFilePath))
def GetApkActivityName(apkFilePath):
info = GetApkInformation(apkFilePath)

View File

@ -418,7 +418,7 @@ def write_txt(path: "路径", things: "内容")->"写入文本文档":
# 获取 aapt 的所有信息
def GetApkInformation(apkFilePath: "apk 所在路径")->"获取 aapt 的所有信息":
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
return GetCommandReturn("'{}/aapt/run-aapt.sh' dump badging '{}'".format(programPath, apkFilePath))
# 获取 apk Activity
def GetApkActivityName(apkFilePath: "apk 所在路径")->"获取 apk Activity":
@ -1559,7 +1559,7 @@ def UseProgram():
<p>10、deepin 终端:{}</p>'''.format(subprocess.getoutput("uengine version"),
subprocess.getoutput("python3 --version"),
QtCore.qVersion,
subprocess.getoutput("aapt version"),
subprocess.getoutput(f"'{programPath}/aapt/run-aapt.sh' version"),
subprocess.getoutput("dpkg --version"),
subprocess.getoutput("mkdir --version"),
subprocess.getoutput("chmod --version"),
@ -1582,7 +1582,7 @@ if not lang in langFile.keys():
programUrl = information["Url"][0]
version = information["Version"]
goodRunSystem = information["System"]
aaptVersion = GetCommandReturn("aapt version")
aaptVersion = GetCommandReturn(f"'{programPath}/aapt/run-aapt.sh' version")
SystemVersion = GetSystemVersion()
iconPath = "{}/runner.svg".format(os.path.split(os.path.realpath(__file__))[0])
about = f'''<p align="center"><img width=256 src="{iconPath}"/></p>

View File

@ -35,7 +35,7 @@ information = json.loads(readtxt(programPath + "/information.json"))
programUrl = information["Url"][0]
version = information["Version"]
goodRunSystem = information["System"]
aaptVersion = subprocess.getoutput("aapt version")
aaptVersion = subprocess.getoutput(f"'{programPath}/aapt/run-aapt.sh' version")
about = '''介绍 :一个基于 Python3 的 tkinter 制作的 UEngine 运行器在新版本Deepin/UOS发布后可以在应用商店安装部分官方已适配的安卓应用对爱好者来说不能自己安装APK软件包始终差点意思本程序可以为Deepin/UOS上的UEngine安卓运行环境安装自定义APK软件包并能发送安装的APK包启动菜单到桌面或系统菜单。
版本 {}
@ -75,7 +75,7 @@ def UseProgram():
10、deepin 终端:{}'''.format(subprocess.getoutput("uengine version"),
subprocess.getoutput("python3 --version"),
tk.TkVersion,
subprocess.getoutput("aapt version"),
subprocess.getoutput(f"'{programPath}/aapt/run-aapt.sh' version"),
subprocess.getoutput("dpkg --version"),
subprocess.getoutput("mkdir --version"),
subprocess.getoutput("chmod --version"),