remove apks out of repo

This commit is contained in:
Rick Lan
2020-04-07 15:09:36 +10:00
parent baddb4fc4b
commit 0cc23f7269
9 changed files with 177 additions and 57 deletions
+6
View File
@@ -57,3 +57,9 @@ panda_jungle
htmlcov
pandaextra
apk/cn.dragonpilot.gpsservice.apk
apk/com.autonavi.amapauto.apk
apk/com.mixplorer.apk
apk/com.tomtom.speedcams.android.map.apk
apk/com.waze.apk
apk/tw.com.ainvest.outpack.apk
+1 -1
View File
@@ -6,7 +6,7 @@ import shutil
from common.basedir import BASEDIR
from selfdrive.swaglog import cloudlog
android_packages = ("ai.comma.plus.offroad", "tw.com.ainvest.outpack", "cn.dragonpilot.gpsservice", "com.autonavi.amapauto", "com.mixplorer", "com.tomtom.speedcams.android.map")
android_packages = ("ai.comma.plus.offroad",)
def get_installed_apks():
dat = subprocess.check_output(["pm", "list", "packages", "-f"], encoding='utf8').strip().split("\n")
+2
View File
@@ -180,6 +180,8 @@ keys = {
"DragonEnableTempMonitor": [TxType.PERSISTENT],
"DragonEnableCurvatureLearner": [TxType.PERSISTENT],
"DragonCurvatureLearnerOffset": [TxType.PERSISTENT],
"DragonAppAutoUpdate": [TxType.PERSISTENT],
"DragonUpdating": [TxType.CLEAR_ON_MANAGER_START],
}
+1
View File
@@ -3,4 +3,5 @@
export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
export HOME=/data/data/com.termux/files/home
export PATH=/usr/local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/sbin:/data/data/com.termux/files/usr/bin/applets:/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/data/com.termux/files/usr/bin/git
printf %s "1" > /data/params/d/DragonUpdating
cd /data/openpilot && git reset --hard @{u} && git clean -xdf && git pull && scons --clean && reboot
+136 -55
View File
@@ -10,6 +10,12 @@ from common.params import Params, put_nonblocking
params = Params()
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
from math import floor
import re
import os
is_gitee_src = "gitee" in subprocess.check_output(["git", "-C", "/data/openpilot", "config", "--get", "remote.origin.url"]).decode('utf8').rstrip()
is_offline = subprocess.call(["ping", "-W", "4", "-c", "1", "117.28.245.92"])
auto_update = params.get("DragonAppAutoUpdate", encoding='utf8') == "1"
class App():
@@ -56,19 +62,93 @@ class App():
# app options
self.opts = opts
self.is_enabled = False
self.is_installed = False
self.is_enabled = True if params.get(self.enable_param, encoding='utf8') == "1" else False
self.last_is_enabled = False
self.is_auto_runnable = False
self.is_running = False
self.manual_ctrl_status = self.MANUAL_IDLE
self.manually_ctrled = False
self.set_package_permissions()
self.system("pm disable %s" % self.app)
if self.is_enabled:
local_version = self.get_local_version()
if local_version is not None:
self.is_installed = True
if not is_offline:
remote_version = local_version
if local_version is not None and auto_update:
remote_version = self.get_remote_version()
if local_version is None or (remote_version is not None and local_version != remote_version):
self.update_app()
if self.is_installed:
self.set_package_permissions()
else:
self.uninstall_app()
if self.manual_ctrl_param is not None:
put_nonblocking(self.manual_ctrl_param, '0')
self.last_ts = sec_since_boot()
def get_remote_version(self):
apk = self.app + ".apk"
try:
if is_gitee_src:
url = "https://gitee.com/dragonpilot/apps/raw/%s/VERSION" % apk
else:
url = "https://raw.githubusercontent.com/dragonpilot-community/apps/%s/VERSION" % apk
return subprocess.check_output(["curl", "-H", "'Cache-Control: no-cache'", "-s", url], stderr=subprocess.STDOUT, shell=True).decode('utf8').rstrip()
except subprocess.CalledProcessError as e:
pass
return None
def uninstall_app(self):
try:
local_version = self.get_local_version()
if local_version is not None:
subprocess.check_output(["pm","uninstall", self.app])
self.is_installed = False
except subprocess.CalledProcessError as e:
pass
def update_app(self):
apk = self.app + ".apk"
apk_path = "/sdcard/" + apk
try:
os.remove(apk_path)
except (OSError, FileNotFoundError) as e:
pass
self.uninstall_app()
# if local_version is not None:
# try:
# subprocess.check_output(["pm","uninstall", self.app], stderr=subprocess.STDOUT, shell=True)
# except subprocess.CalledProcessError as e:
# pass
try:
put_nonblocking('DragonUpdating', '1')
url = "https://raw.githubusercontent.com/dragonpilot-community/apps/%s/%s" % (apk, apk)
subprocess.check_output(["curl","-o", apk_path,"-LJO", url])
subprocess.check_output(["pm","install","-r",apk_path])
self.is_installed = True
except subprocess.CalledProcessError as e:
self.is_installed = False
put_nonblocking('DragonUpdating', '0')
try:
os.remove(apk_path)
except (OSError, FileNotFoundError) as e:
pass
def get_local_version(self):
try:
result = subprocess.check_output(["dumpsys", "package", self.app, "|", "grep", "versionName"], encoding='utf8')
if len(result) > 12:
return re.findall(r"versionName=(.*)", result)[0]
except subprocess.CalledProcessError as e:
pass
return None
def read_params(self):
self.last_is_enabled = self.is_enabled
if self.enable_param is None:
@@ -76,29 +156,35 @@ class App():
else:
self.is_enabled = True if params.get(self.enable_param, encoding='utf8') == "1" else False
if self.is_enabled:
# a service app should run automatically and not manual controllable.
if self.app_type in [App.TYPE_SERVICE, App.TYPE_GPS_SERVICE]:
self.is_auto_runnable = True
self.manual_ctrl_status = self.MANUAL_IDLE
else:
if self.manual_ctrl_param is None:
if self.is_installed:
if self.is_enabled:
# a service app should run automatically and not manual controllable.
if self.app_type in [App.TYPE_SERVICE, App.TYPE_GPS_SERVICE]:
self.is_auto_runnable = True
self.manual_ctrl_status = self.MANUAL_IDLE
else:
self.manual_ctrl_status = params.get(self.manual_ctrl_param, encoding='utf8')
if self.manual_ctrl_status == self.MANUAL_IDLE:
if self.auto_run_param is None:
self.is_auto_runnable = False
if self.manual_ctrl_param is None:
self.manual_ctrl_status = self.MANUAL_IDLE
else:
self.is_auto_runnable = True if params.get(self.auto_run_param, encoding='utf8') == "1" else False
self.manual_ctrl_status = params.get(self.manual_ctrl_param, encoding='utf8')
if self.manual_ctrl_status == self.MANUAL_IDLE:
if self.auto_run_param is None:
self.is_auto_runnable = False
else:
self.is_auto_runnable = True if params.get(self.auto_run_param, encoding='utf8') == "1" else False
else:
if self.last_is_enabled:
self.uninstall_app()
self.is_auto_runnable = False
self.manual_ctrl_status = self.MANUAL_IDLE
self.manually_ctrled = False
else:
self.is_auto_runnable = False
self.manual_ctrl_status = self.MANUAL_IDLE
self.manually_ctrled = False
if not self.last_is_enabled and self.is_enabled:
self.update_app()
def run(self, force = False):
if force or self.is_enabled:
if self.is_installed and (force or self.is_enabled):
# app is manually ctrl, we record that
if self.manual_ctrl_param is not None and self.manual_ctrl_status == self.MANUAL_ON:
put_nonblocking(self.manual_ctrl_param, '0')
@@ -120,7 +206,7 @@ class App():
self.is_running = True
def kill(self, force = False):
if force or self.is_enabled:
if self.is_installed and (force or self.is_enabled):
# app is manually ctrl, we record that
if self.manual_ctrl_param is not None and self.manual_ctrl_status == self.MANUAL_OFF:
put_nonblocking(self.manual_ctrl_param, '0')
@@ -156,7 +242,19 @@ def init_apps(apps):
[],
))
apps.append(App(
# v1.16.2
"com.mixplorer",
"com.mixplorer.activities.BrowseActivity",
"DragonEnableMixplorer",
None,
"DragonRunMixplorer",
App.TYPE_UTIL,
[
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
],
[],
))
apps.append(App(
"com.tomtom.speedcams.android.map",
"com.tomtom.speedcams.android.activities.SpeedCamActivity",
"DragonEnableTomTom",
@@ -174,7 +272,22 @@ def init_apps(apps):
]
))
apps.append(App(
# v4.5.0.600053
"tw.com.ainvest.outpack",
"tw.com.ainvest.outpack.ui.MainActivity",
"DragonEnableAegis",
"DragonBootAegis",
"DragonRunAegis",
App.TYPE_GPS,
[
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
],
[
"SYSTEM_ALERT_WINDOW",
]
))
apps.append(App(
"com.autonavi.amapauto",
"com.autonavi.amapauto.MainMapActivity",
"DragonEnableAutonavi",
@@ -192,38 +305,6 @@ def init_apps(apps):
]
))
apps.append(App(
# v6.40.3
"com.mixplorer",
"com.mixplorer.activities.BrowseActivity",
"DragonEnableMixplorer",
None,
"DragonRunMixplorer",
App.TYPE_UTIL,
[
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
],
[],
))
apps.append(App(
# v2.9.5 build 74
"tw.com.ainvest.outpack",
"tw.com.ainvest.outpack.ui.MainActivity",
"DragonEnableAegis",
"DragonBootAegis",
"DragonRunAegis",
App.TYPE_GPS,
[
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
],
[
"SYSTEM_ALERT_WINDOW",
]
))
apps.append(App(
# v4.57.2.0
"com.waze",
"com.waze.MainActivity",
"DragonWazeMode",
@@ -78,6 +78,8 @@ default_conf = {
'DragonEnableTempMonitor': '1',
'DragonEnableCurvatureLearner': '0',
'DragonCurvatureLearnerOffset': '0.0',
'DragonAppAutoUpdate': '1',
'DragonUpdating': '0',
}
deprecated_conf = {
+20
View File
@@ -42,6 +42,26 @@ static void ui_draw_sidebar_home_button(UIState *s, bool hasSidebar) {
nvgRect(s->vg, home_btn_xr, home_btn_y, home_btn_w, home_btn_h);
nvgFillPaint(s->vg, imgPaint);
nvgFill(s->vg);
if (s->dragon_updating) {
nvgBeginPath(s->vg);
nvgCircle(s->vg, home_btn_xr + home_btn_w/2, home_btn_y + home_btn_h/2+2, 72);
// nvgRoundedRect(s->vg, home_btn_xr, home_btn_y + home_btn_h/2-5, home_btn_w, 20, 5);
nvgFillColor(s->vg, nvgRGBA(255, 255, 255, s->scene.alert_rate));
nvgFill(s->vg);
nvgFillColor(s->vg, nvgRGBA(0, 0, 0, s->scene.alert_rate));
nvgFontSize(s->vg, 30);
nvgFontFace(s->vg, "sans-bold");
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
nvgTextBox(s->vg, home_btn_xr, home_btn_y + home_btn_h/2+5, home_btn_w, "UPDATING", NULL);
s->scene.alert_rate += 5*s->scene.alert_type;
if (s->scene.alert_rate == 0 || s->scene.alert_rate == 255) {
s->scene.alert_type *= -1;
}
}
}
static void ui_draw_sidebar_network_strength(UIState *s, bool hasSidebar) {
+5 -1
View File
@@ -248,6 +248,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
// dragonpilot
read_param_float(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost");
read_param_bool(&s->dragon_waze_mode, "DragonWazeMode");
read_param_bool(&s->dragon_updating, "DragonUpdating");
if (s->dragon_waze_mode) {
s->dragon_ui_speed = false;
s->dragon_ui_event = false;
@@ -300,6 +301,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
s->dragon_ui_blinker_timeout = UI_FREQ * 6.3;
s->dragon_waze_mode_timeout = UI_FREQ * 6.4;
s->dragon_ui_dm_view_timeout = UI_FREQ * 6.5;
s->dragon_updating_timeout = UI_FREQ * 10;
}
static PathData read_path(cereal_ModelData_PathData_ptr pathp) {
@@ -960,7 +962,8 @@ int main(int argc, char* argv[]) {
int draws = 0;
s->scene.satelliteCount = -1;
s->scene.alert_rate = 0;
s->scene.alert_type = 1;
while (!do_exit) {
bool should_swap = false;
if (!s->vision_connected) {
@@ -1090,6 +1093,7 @@ int main(int argc, char* argv[]) {
// dragonpilot
read_param_float_timeout(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost", &s->dragon_ui_volume_boost_timeout);
read_param_bool_timeout(&s->dragon_waze_mode, "DragonWazeMode", &s->dragon_waze_mode_timeout);
read_param_bool_timeout(&s->dragon_updating, "DragonUpdating", &s->dragon_updating_timeout);
if (s->dragon_waze_mode) {
s->dragon_ui_speed = false;
+4
View File
@@ -162,6 +162,8 @@ typedef struct UIScene {
float angleSteersDes;
float angleSteers;
char ipAddr[20];
int alert_rate;
int alert_type;
// for blinker, from kegman
bool leftBlinker;
@@ -315,6 +317,7 @@ typedef struct UIState {
int dragon_ui_blinker_timeout;
int dragon_waze_mode_timeout;
int dragon_ui_dm_view_timeout;
int dragon_updating_timeout;
bool dragon_ui_speed;
bool dragon_ui_event;
@@ -331,6 +334,7 @@ typedef struct UIState {
bool dragon_ui_blinker;
bool dragon_waze_mode;
bool dragon_ui_dm_view;
bool dragon_updating;
} UIState;
// API