初步的未知来源安装开启功能完成

This commit is contained in:
gfdgd xi 2022-06-19 14:03:40 +08:00
parent 8747f69065
commit c030ab2c16
5 changed files with 63 additions and 6 deletions

View File

@ -27,6 +27,18 @@
"ApkFileError": "该应用安装包异常,无法查询相关数据!",
"InputDataError": "你输入的数值不正确!"
},
"Information": {
"Title": "提示",
"CompleteInformation": "完成"
},
"Answer": {
"Title": "提示",
"AllowOrDisallowUpdateAndroidAppAnswer": [
"你确定要启用 UEngine 可以安装以及使用默认的更新程序升级应用?(即允许未知来源)",
"你确定要禁用 UEngine 可以安装以及使用默认的更新程序升级应用?(即禁止未知来源)"
],
"UseAdbPackageAnswer": "你没有安装 adb 补丁,必须安装才能继续。是否安装?"
},
"Menu": [
{
"Name": "程序",
@ -120,7 +132,8 @@
"安装默认的 UEngine 镜像"
]
},
"在 Ubuntu 上安装 UEngine"
"在 Ubuntu 上安装 UEngine",
"允许安装未知来源应用即支持UEngine安装的安卓程序程序更新"
]
},
{
@ -179,6 +192,18 @@
"ApkFileError": "This apk file is error and can't find any data about the apk file!",
"InputDataError": "Your input error data!"
},
"Information": {
"Title": "Tips",
"CompleteInformation": "Complete!"
},
"Answer": {
"Title": "Tips",
"AllowOrDisallowUpdateAndroidAppAnswer": [
"Are you sure to allow UEngine to install or update other android program? (Allow )(即允许未知来源)",
"Are you sure to disallow UEngine to install or update other android program? (Allow )(即允许未知来源)"
],
"UseAdbPackageAnswer": "You don't install adb package with UEngine, you must install, and after install you can connect to set.\nDo you want to install?"
},
"Menu": [
{
"Name": "Program",
@ -272,7 +297,8 @@
"Install Defult UEngine Image"
]
},
"Install UEngine On Ubuntu"
"Install UEngine On Ubuntu",
"Allow/Disallow UEngine To Install Or Update Other Android Program"
]
},
{

View File

@ -319,6 +319,12 @@ class UEngine:
os.system("pkexec uengine-bridge.sh force-reload")
class Adb:
def __init__(self, ip=""):
self.ip = ip
def connect(self):
os.system(f"adb connect {self.ip}")
class Service:
def Open():
os.system("adb start-server")
@ -327,6 +333,12 @@ class Adb:
def Kill():
os.system("killall adb")
def boolAndroidInstallOtherAppSetting(self):
return subprocess.getoutput(f"adb -s {self.ip} shell settings get secure install_non_market_apps").replace(" ", "") == "1"
def setAndroidInstallOtherAppSetting(self, op: bool):
os.system(f"adb -s {self.ip} shell settings put secure install_non_market_apps {int(op)}")
class File:
def __init__(self, filePath):
self.filePath = filePath
@ -350,6 +362,9 @@ class UengineRunner:
if __name__ == "__main__":
print("本 API 不支持直接运行,请通过引入的方式使用此 API")
adb = Adb("192.168.250.2:5555")
print(adb.boolAndroidInstallOtherAppSetting())
quit()
if not ROOT.GetRoot():

Binary file not shown.

View File

@ -4,7 +4,7 @@
"https://gitee.com/gfdgd-xi/uengine-runner",
"https://github.com/gfdgd-xi/uengine-runner"
],
"Version": "1.6.2",
"Version": "1.6.2 Alpha",
"System": "Linuxdeepin/UOS",
"Tips": [
"更多可见https://gitee.com/gfdgd-xi/uengine-runner/wikis",

22
main.py
View File

@ -2,8 +2,8 @@
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi<3025613752@qq.com>
# 版本1.6.1
# 更新时间2022年5月21日要开学了)
# 版本1.6.2 Alpha
# 更新时间2022年6月19日要期末考试了)
# 感谢anbox、deepin 和 UOS
# 基于 Python3 的 tkinter 构建
# 更新gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢
@ -12,6 +12,7 @@
# 引入所需的库
#################
import os
import api
import sys
import time
import json
@ -663,6 +664,21 @@ def VersionCheck(version1, version2):
def ShowHelp():
webbrowser.open_new_tab(programPath + "/Help/index.html")
def AllowOrDisallowUpdateAndroidApp():
if not os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
if not messagebox.askyesno(title=langFile[lang]["Main"]["MainWindow"]["Answer"]["Title"], message=langFile[lang]["Main"]["MainWindow"]["Answer"]["UseAdbPackageAnswer"]):
return
os.system("pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-useadb 0 '{}'".format(programPath,
"{}/.android/adbkey.pub".format(
get_home()))) # 写入配置
adb = api.Adb("192.168.250.2:5555")
adb.Service.Close()
adb.connect()
if messagebox.askyesno(title=langFile[lang]["Main"]["MainWindow"]["Answer"]["Title"], message=langFile[lang]["Main"]["MainWindow"]["Answer"]["AllowOrDisallowUpdateAndroidAppAnswer"][int(adb.boolAndroidInstallOtherAppSetting())]):
adb.setAndroidInstallOtherAppSetting(not adb.boolAndroidInstallOtherAppSetting())
messagebox.showinfo(title=langFile[lang]["Main"]["MainWindow"]["Information"]["Title"], message=langFile[lang]["Main"]["MainWindow"]["Answer"]["CompleteInformation"])
class SettingWindow():
saveApkOption = tk.IntVar()
def ShowWindow():
@ -848,7 +864,6 @@ Activity{}
matplotlib.pylab.title("" + chinese + "”的用户评分(数据只供参考)", fontproperties=fonts)
matplotlib.pylab.show()
class AdbChangeUengineDisplaySize():
def ShowWindows():
global displayX
@ -1400,6 +1415,7 @@ adbServer.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Men
adbServer.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][1], command=AdbStopServer)
adbServer.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][2], command=AdbKillAdbProgress)
uengine.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][13], command=AllowOrDisallowUpdateAndroidApp)
uengine.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][1], command=OpenUengineDebBuilder)
uengine.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][7], command=KeyboardToMouse)
uengine.add_command(label=langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][8], command=UengineCheckCpu)