Skip to content

Commit

Permalink
[utilities] Add operation to reset aliendalvik. JB#24058
Browse files Browse the repository at this point in the history
Stop alien, remove the /home/.android directory (saving any packaged
apks to be reinstalled afterwards), then restart it. Re-install any
store packaged apks.

If alien has been uninstalled but /home/.android is still present, then
this option can be used to remove all that residual data.

Also removed obsolete tracker reset service workaround that hasn't been used for a
long time.
  • Loading branch information
abranson committed Feb 14, 2023
1 parent a7374ac commit 42c8114
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 15 deletions.
10 changes: 10 additions & 0 deletions plugin/utiltools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ void UtilTools::restartLipstick(QJSValue successCallback, QJSValue errorCallback
execute(SystemTool, QStringList("restart_lipstick"), successCallback, errorCallback);
}

void UtilTools::resetAliendalvik(QJSValue successCallback, QJSValue errorCallback)
{
execute(SystemTool, QStringList("reset_aliendalvik"), successCallback, errorCallback);
}

bool UtilTools::dirExists(const QString &path)
{
return QDir(path).exists();
}

void UtilTools::handleProcessExit(int exitCode, QProcess::ExitStatus status)
{
QProcess *process = qobject_cast<QProcess*>(sender());
Expand Down
5 changes: 5 additions & 0 deletions plugin/utiltools.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class UtilTools: public QObject
Q_INVOKABLE void restartLipstick(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

Q_INVOKABLE void resetAliendalvik(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

Q_INVOKABLE bool dirExists(const QString &path);

private slots:
void handleProcessExit(int exitCode, QProcess::ExitStatus status);

Expand Down
3 changes: 2 additions & 1 deletion qml/ActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Column {
plugins.append(info)
}
var names = [ "RestartNetwork", "RestartUI",
"CleanPackageCache", "CleanTracker" ]
"CleanPackageCache", "CleanTracker",
"ResetAlien" ]
for (var i = 0; i < names.length; ++i)
justLoad(names[i])
}
Expand Down
26 changes: 26 additions & 0 deletions qml/plugins/ResetAlien.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Utilities 1.0

ActionItem {
visible: UtilTools.dirExists("/home/.android")
//% "Android™ App Support"
title: qsTrId("sailfish-tools-he-android_app_support")
//% "Reset"
actionName: qsTrId("sailfish-tools-bt-reset")
//% "Completely reset Android App support, removing "
//% "all settings, apps and app data. Android data in "
//% "your home directory will not be removed, and any "
//% "Android apps installed from the Jolla store will "
//% "be reinstalled. You can also use this utility to clean "
//% "your Android data from your device after uninstalling "
//% "Android App Support.
description: qsTrId("sailfish-utilities-me-clean_aas_desc")
//% "Resetting Android™ App Support"
remorseText: qsTrId("sailfish-utilities-me-clean_aas_remorse")
deviceLockRequired: false

function action(on_reply, on_error) {
UtilTools.resetAliendalvik(on_reply, on_error)
}
}
1 change: 0 additions & 1 deletion rpm/sailfish-utilities.spec
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ rm -rf %{buildroot}
%{_datadir}/translations/settings-sailfish_utilities_eng_en.qm
%dir %{_libdir}/qt5/qml/Sailfish/Utilities
%{_libdir}/qt5/qml/Sailfish/Utilities/*
%{_userunitdir}/tracker-reindex.service

%files ts-devel
%defattr(-,root,root,-)
Expand Down
8 changes: 1 addition & 7 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ set(CMAKE_CXX_FLAGS
configure_file(config.hpp.in config.hpp @ONLY)
add_executable(sailfish_tools_system_action sailfish_tools_system_action.cpp)

configure_file(tracker-reindex.service.in tracker-reindex.service @ONLY)

install(FILES
tracker-reindex.service
DESTINATION lib/systemd/user
)

install(TARGETS
sailfish_tools_system_action
DESTINATION bin
Expand All @@ -22,5 +15,6 @@ install(PROGRAMS
restart_network.sh
restart_lipstick.sh
tracker_reindex.sh
reset_aliendalvik.sh
DESTINATION share/sailfish-utilities
)
54 changes: 54 additions & 0 deletions tools/reset_aliendalvik.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

# Stop aliendalvik if running
if systemctl is-active --quiet aliendalvik
systemctl stop aliendalvik || :
fi
if systemctl is-active --quiet apkd
systemctl stop apkd || :
fi

# Remove all launchers
rm -f /home/*/.local/share/applications/apkd_launcher_*.desktop || :
rm -f /home/*/.local/share/applications/apkd_handler_*.desktop || :
update-desktop-database

if [ -f /opt/alien/system.img ]; then
# If alien installed, wipe /data, but keep any apps from the store
if [ -d /home/.android/data/aas-staging/app/packaged ]; then
# alien8
mv /home/.android/data/aas-staging/app/packaged /home/.android
rm -rf /home/.android/data
mkdir -p /home/.android/data/aas-staging/app/
mv /home/.android/packaged /home/.android/data/aas-staging/app/
elif [ -d /home/.android/data/app/packaged ]; then
# alien4
systemctl stop alien-settings
mv /home/.android/data/app/packaged /home/.android
rm -rf /home/.android/data
mkdir -p /home/.android/data/app/
mv /home/.android/packaged /home/.android/data/app/
/usr/bin/add-oneshot --now alien-create-build-prop
systemctl-user start alien-pre-start.service
else
# neither packaged dir is available, cleanup anyway
rm -rf /home/.android/data
fi

# Start aliendalvik
systemctl start apkd
systemctl start aliendalvik

sleep 5
for apk in /home/.android/data/app/packaged/*.apk; do
/usr/bin/apkd-harbour-rpm-post $apk
done
for apk in /home/.android/data/aas-staging/app/packaged/*.apk; do
/usr/bin/apkd-harbour-rpm-post $apk
done
else
# Just cleanup all data
rm -rf /home/.android
fi


5 changes: 4 additions & 1 deletion tools/sailfish_tools_system_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ std::map<std::string, action_type> actions = {
}},
{ "tracker_reindex", [](action_ctx const *) {
return execute_own_utility("tracker_reindex.sh");
}},
{ "reset_aliendalvik", [](action_ctx const *) {
return execute_own_utility("reset_aliendalvik.sh");
}}
};

std::set<std::string> root_actions = {
"repair_rpm_db", "restart_network"
"repair_rpm_db", "restart_network", "reset_aliendalvik"
};

class BecomeRoot
Expand Down
5 changes: 0 additions & 5 deletions tools/tracker-reindex.service.in

This file was deleted.

0 comments on commit 42c8114

Please sign in to comment.