Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial browser application #189

Draft
wants to merge 68 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
08dd4b1
Begin adding application switcher
Eeems Feb 25, 2021
96f8d11
Get compiling
Eeems Feb 26, 2021
f67d830
Remove rmkit and begin working on custom gesture engine
Eeems Feb 26, 2021
16a0812
Add touch handling so that gesture handling can be built
Eeems Feb 26, 2021
2eda0e1
Add simple gestures
Eeems Feb 26, 2021
acf94b9
Get gestures more consistant
Eeems Feb 27, 2021
f8d1bc5
Clean up touch handling
Eeems Feb 28, 2021
ac463cb
Get task switcher displaying icons and more
Eeems Feb 28, 2021
83f40b5
Remove unneeded task manager item
Eeems Feb 28, 2021
a046c42
Merge remote-tracking branch 'origin/master' into feature/app_switcher
Eeems Feb 28, 2021
4174f3d
Add better logging for inhibited stuff
Eeems Feb 28, 2021
5a09b2f
Fix poweroff in decay
Eeems Feb 28, 2021
a8345a8
Fix compile
Eeems Feb 28, 2021
1f532b7
Move current application to the end of the list for previous applicat…
Eeems Feb 28, 2021
c33ff53
Add seperator on task switcher
Eeems Feb 28, 2021
627b582
Add dynamic text size to launcher
Eeems Feb 28, 2021
bebf1c4
Add more debug logging for the screen API
Eeems Feb 28, 2021
509e413
Add home icon
Eeems Mar 1, 2021
9860a4e
Get scrolling and sorting working
Eeems Mar 1, 2021
12d0355
Remove unused widget
Eeems Mar 1, 2021
385e458
Add long press to kill
Eeems Mar 1, 2021
63fccc1
Fix icon animation in launcher
Eeems Mar 1, 2021
071a0a7
Clean up logic/display when killing applications.
Eeems Mar 1, 2021
9ba4abc
Cleanup and better handle crashing apps
Eeems Mar 1, 2021
cd949d1
Cleanup svg icon display
Eeems Mar 2, 2021
a4ca22c
Get initial screenshot viewer working
Eeems Mar 2, 2021
7aaa2b2
Get menu options working
Eeems Mar 2, 2021
3f5ad0c
Fix #176
Eeems Mar 8, 2021
346cf47
Start adding scrolling to screenshot viewer and fix freeze with notif…
Eeems Mar 14, 2021
e434d43
Fix scrolling and indicate current size setting
Eeems Mar 14, 2021
d0404f4
Add screenshot viewing and removal
Eeems Mar 14, 2021
b01e7f3
Lazy load, fix up scrolling
Eeems Mar 14, 2021
bd6b061
Fix deleting screenshots
Eeems Mar 14, 2021
84012d1
Fix build for now
Eeems Mar 14, 2021
f669fa8
Try to get new toolchain to work
Eeems Mar 14, 2021
d1a3703
Try to get new toolchain to work
Eeems Mar 14, 2021
75f2592
Try to get new toolchain to work
Eeems Mar 14, 2021
ef504f0
Switch back to stable
Eeems Mar 14, 2021
fa35c3e
Force new name
Eeems Mar 14, 2021
cd4c969
Temporarily use non-stable
Eeems Mar 14, 2021
cc67c9b
Fix release build
Eeems Mar 14, 2021
7d30586
Fix #179
Eeems Mar 15, 2021
525a77c
Fix swipe directions on rM2
Eeems Mar 21, 2021
156c4b1
Merge branch 'feature/app_switcher' into feature/screenshot_application
Eeems Mar 21, 2021
5b46e7b
Merge branch 'feature/screenshot_application' into feature/splashscreens
Eeems Mar 21, 2021
9d8514e
Switch to using new button based scrolling
Eeems Mar 21, 2021
a62f708
Make row tappable
Eeems Mar 21, 2021
0b5fb75
Run xochitl if rm2fb not detected
Eeems Mar 21, 2021
3791244
backport build fix
Eeems Mar 21, 2021
47f8c77
Switch to better environment variable check
Eeems Mar 21, 2021
d865344
Get xochitl working in chroot
Eeems Mar 22, 2021
6711466
Get fifo for /sys/power/state working kind of
Eeems Mar 22, 2021
268daf1
Merge branch 'feature/app_switcher' into feature/screenshot_application
Eeems Mar 22, 2021
dbf282d
Merge branch 'master' into feature/screenshot_application
Eeems Mar 27, 2021
b5e0953
Merge branch 'feature/screenshot_application' into feature/splashscreens
Eeems Mar 27, 2021
f9731c8
Merge branch 'feature/splashscreens' into feature/erode_ui_refresh
Eeems Mar 27, 2021
950ef30
Merge branch 'feature/erode_ui_refresh' into feature/detect_no_rm2fb
Eeems Mar 27, 2021
8e8037d
Merge branch 'feature/detect_no_rm2fb' into feature/fifo
Eeems Mar 27, 2021
2adbb83
Merge remote-tracking branch 'origin/master' into feature/fifo
Eeems Mar 27, 2021
6573bb6
Fix up mount handling and implement fifo reader
Eeems Mar 27, 2021
596c270
Get power state control working
Eeems Mar 27, 2021
ea51ab9
Add ability to toggle swipes
Eeems Mar 28, 2021
29c9b26
Finish adding logic
Eeems Mar 28, 2021
83d0869
Add initial browser application
Eeems Mar 29, 2021
6516719
Merge branch 'master' into feature/browser
Eeems Feb 10, 2023
3da3981
Cleanup
Eeems Feb 10, 2023
b9c6063
Merge branch 'master' into feature/browser
Eeems Oct 3, 2024
0339324
Apply suggestions from code review
Eeems Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ release: clean
INSTALL_ROOT=../../release $(MAKE) -C .build/launcher install
INSTALL_ROOT=../../release $(MAKE) -C .build/lockscreen install
INSTALL_ROOT=../../release $(MAKE) -C .build/task-switcher install
INSTALL_ROOT=../../release $(MAKE) -C .build/web-browser install

build: tarnish erode rot oxide decay corrupt fret anxiety
build: tarnish erode rot oxide decay corrupt fret anxiety mold

erode:
mkdir -p .build/process-manager
Expand Down Expand Up @@ -105,3 +106,9 @@ anxiety: tarnish
cp -r applications/screenshot-viewer/* .build/screenshot-viewer
cd .build/screenshot-viewer && qmake anxiety.pro
$(MAKE) -C .build/screenshot-viewer all

mold: tarnish
mkdir -p .build/web-browser
cp -r applications/web-browser/* .build/web-browser
cd .build/web-browser && qmake mold.pro
$(MAKE) -C .build/web-browser all
6 changes: 3 additions & 3 deletions applications/screenshot-viewer/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

using namespace codes::eeems::oxide1;

#define CORRUPT_SETTINGS_VERSION 1
#define ANXIETY_SETTINGS_VERSION 1

enum State { Normal, PowerSaving };
enum BatteryState { BatteryUnknown, BatteryCharging, BatteryDischarging, BatteryNotPresent };
Expand Down Expand Up @@ -60,7 +60,7 @@ class Controller : public QObject {

settings.sync();
auto version = settings.value("version", 0).toInt();
if(version < CORRUPT_SETTINGS_VERSION){
if(version < ANXIETY_SETTINGS_VERSION){
migrate(&settings, version);
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ private slots:
throw "Unknown settings version";
}
// In the future migrate changes to settings between versions
settings->setValue("version", CORRUPT_SETTINGS_VERSION);
settings->setValue("version", ANXIETY_SETTINGS_VERSION);
settings->sync();
}
};
Expand Down
16 changes: 15 additions & 1 deletion applications/system-service/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "application.h"
#include "appsapi.h"
#include "systemapi.h"
#include "buttonhandler.h"
#include "digitizerhandler.h"
#include "devicesettings.h"
Expand All @@ -31,8 +32,8 @@ void Application::launchNoSecurityCheck(){
m_process->setProgram(bin());
}
updateEnvironment();
umountAll();
if(chroot()){
umountAll();
mountAll();
m_process->setChroot(chrootPath());
}else{
Expand Down Expand Up @@ -199,6 +200,7 @@ void Application::stopNoSecurityCheck(){
if(state == Inactive){
return;
}
qDebug() << "Stopping " << path();
if(!onStop().isEmpty()){
QProcess::execute(onStop());
}
Expand Down Expand Up @@ -366,3 +368,15 @@ void Application::showSplashScreen(){
EPFrameBuffer::waitForLastUpdate();
qDebug() << "Finished paining splash screen for" << name();
}
void Application::powerStateDataRecieved(FifoHandler* handler, const QString& data){
Q_UNUSED(handler);
if(!permissions().contains("power")){
qWarning() << "Denied powerState request";
return;
}
if((QStringList() << "mem" << "freeze" << "standby").contains(data)){
systemAPI->suspend();
}else{
qWarning() << "Unknown power state call: " << data;
}
}
171 changes: 129 additions & 42 deletions applications/system-service/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
#include <sys/mount.h>
#include <sys/prctl.h>
#include <stdexcept>
#include <sys/types.h>
#include <algorithm>

#include "dbussettings.h"
#include "mxcfb.h"
#include "screenapi.h"
#include "fifohandler.h"
#include "buttonhandler.h"

#define DEFAULT_PATH "/opt/bin:/opt/sbin:/opt/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

Expand Down Expand Up @@ -140,7 +144,7 @@ class Application : public QObject{
Q_PROPERTY(QStringList directories READ directories WRITE setDirectories NOTIFY directoriesChanged)
public:
Application(QDBusObjectPath path, QObject* parent) : Application(path.path(), parent) {}
Application(QString path, QObject* parent) : QObject(parent), m_path(path), m_backgrounded(false) {
Application(QString path, QObject* parent) : QObject(parent), m_path(path), m_backgrounded(false), fifos() {
m_process = new SandBoxProcess(this);
connect(m_process, &SandBoxProcess::started, this, &Application::started);
connect(m_process, QOverload<int>::of(&SandBoxProcess::finished), this, &Application::finished);
Expand Down Expand Up @@ -439,7 +443,7 @@ private slots:
}
}
void errorOccurred(QProcess::ProcessError error);

void powerStateDataRecieved(FifoHandler* handler, const QString& data);
private:
QVariantMap m_config;
QString m_path;
Expand All @@ -448,6 +452,7 @@ private slots:
QByteArray* screenCapture = nullptr;
size_t screenCaptureSize;
QElapsedTimer timer;
QMap<QString, FifoHandler*> fifos;

bool hasPermission(QString permission, const char* sender = __builtin_FUNCTION());
void showSplashScreen();
Expand Down Expand Up @@ -488,26 +493,44 @@ private slots:
}
void bind(const QString& source, const QString& target, bool readOnly = false){
umount(target);
mkdirs(target, 744);
if(QFileInfo(source).isDir()){
mkdirs(target, 744);
}else{
mkdirs(QFileInfo(target).dir().path(), 744);
}
auto ctarget = target.toStdString();
auto csource = source.toStdString();
mount(csource.c_str(), ctarget.c_str(), NULL, MS_BIND, NULL);
if(readOnly){
mount(csource.c_str(), ctarget.c_str(), NULL, MS_REMOUNT | MS_BIND | MS_RDONLY, NULL);
qDebug() << "mount ro" << source << target;
qDebug() << "mount" << source << target;
if(mount(csource.c_str(), ctarget.c_str(), NULL, MS_BIND, NULL)){
qWarning() << "Failed to create bindmount: " << ::strerror(errno);
return;
}
qDebug() << "mount rw" << source << target;
if(!readOnly){
return;
}
if(mount(csource.c_str(), ctarget.c_str(), NULL, MS_REMOUNT | MS_BIND | MS_RDONLY, NULL)){
qWarning() << "Failed to remount bindmount read only: " << ::strerror(errno);
}
qDebug() << "mount ro" << source << target;
}
void sysfs(const QString& path){
mkdirs(path, 744);
umount(path);
qDebug() << "sysfs" << path;
if(mount("none", path.toStdString().c_str(), "sysfs", 0, "")){
qWarning() << "Failed to mount sysfs: " << ::strerror(errno);
}
}
void ramdisk(const QString& path){
mkdirs(path, 744);
umount(path);
mount("tmpfs", path.toStdString().c_str(), "tmpfs", 0, "size=249m,rw,nosuid,nodev,mode=755");
qDebug() << "ramdisk" << path;
if(mount("tmpfs", path.toStdString().c_str(), "tmpfs", 0, "size=249m,mode=755")){
qWarning() << "Failed to create ramdisk: " << ::strerror(errno);
}
}
void umount(const QString& path){
QDir dir(path);
if(!dir.exists() || !isMounted(path)){
if(!isMounted(path)){
return;
}
auto cpath = path.toStdString();
Expand All @@ -516,19 +539,66 @@ private slots:
qDebug() << "umount failed" << path;
return;
}
rmdir(cpath.c_str());
QDir dir(path);
if(dir.exists()){
rmdir(cpath.c_str());
}
qDebug() << "umount" << path;
}
const QString chrootPath() { return "/tmp/tarnish-chroot/" + name(); }
FifoHandler* mkfifo(const QString& name, const QString& target){
if(isMounted(target)){
qWarning() << target << "Already mounted";
return fifos.contains(name) ? fifos[name] : nullptr;
}
auto source = resourcePath() + "/" + name;
if(!QFile::exists(source)){
if(::mkfifo(source.toStdString().c_str(), 0644)){
qWarning() << "Failed to create " << name << " fifo: " << ::strerror(errno);
}
}
if(!QFile::exists(source)){
qWarning() << "No fifo for " << name;
return fifos.contains(name) ? fifos[name] : nullptr;
}
bind(source, target);
if(!fifos.contains(name)){
qDebug() << "Creating fifo thread for" << source;
auto handler = new FifoHandler(name, source.toStdString().c_str(), this);
qDebug() << "Connecting fifo thread events for" << source;
connect(handler, &FifoHandler::finished, [this, name]{
if(fifos.contains(name)){
fifos.take(name);
}
});
fifos[name] = handler;
qDebug() << "Starting fifo thread for" << source;
handler->start();
qDebug() << "Fifo thread for " << source << "started";
}
return fifos[name];
}
void symlink(const QString& source, const QString& target){
if(QFile::exists(source)){
return;
}
qDebug() << "symlink" << source << target;
if(::symlink(target.toStdString().c_str(), source.toStdString().c_str())){
qWarning() << "Failed to create symlink: " << ::strerror(errno);
return;
}
}
const QString resourcePath() { return "/tmp/tarnish-chroot/" + name(); }
const QString chrootPath() { return resourcePath() + "/chroot"; }
void mountAll(){
auto path = chrootPath();
qDebug() << "Setting up chroot" << path;
// System tmpfs folders
bind("/dev", path + "/dev");
bind("/proc", path + "/proc");
bind("/sys", path + "/sys");
sysfs(path + "/sys");
// Folders required to run things
bind("/bin", path + "/bin", true);
bind("/sbin", path + "/sbin", true);
bind("/lib", path + "/lib", true);
bind("/usr/lib", path + "/usr/lib", true);
bind("/usr/bin", path + "/usr/bin", true);
Expand All @@ -537,60 +607,77 @@ private slots:
bind("/opt/lib", path + "/opt/lib", true);
bind("/opt/usr/bin", path + "/opt/usr/bin", true);
bind("/opt/usr/lib", path + "/opt/usr/lib", true);
// tmpfs folders
mkdirs(path + "/tmp", 744);
if(!QFile::exists(path + "/run")){
ramdisk(path + "/run");
}
if(!QFile::exists(path + "/var/volatile")){
ramdisk(path + "/var/volatile");
}
// Configured folders
for(auto directory : directories()){
bind(directory, path + directory);
}
// tmpfs folders
ramdisk(path + "/run");
ramdisk(path + "/var/volatile");
// Fake sys devices
auto fifo = mkfifo("powerState", path + "/sys/power/state");
connect(fifo, &FifoHandler::dataRecieved, this, &Application::powerStateDataRecieved);
// Missing symlinks
symlink(path + "/var/run", "../run");
symlink(path + "/var/lock", "../run/lock");
symlink(path + "/var/tmp", "volatile/tmp");
}
void umountAll(){
auto path = chrootPath();
for(auto name : fifos.keys()){
auto fifo = fifos.take(name);
fifo->quit();
fifo->deleteLater();
}
QDir dir(path);
if(!dir.exists()){
return;
}
qDebug() << "Tearing down chroot" << path;
QFile mounts("/proc/mounts");
if(!mounts.open(QIODevice::ReadOnly)){
qDebug() << "Unable to open /proc/mounts";
return;
for(auto file : dir.entryList(QDir::Files)){
QFile::remove(file);
}
QString line;
while(!(line = mounts.readLine()).isEmpty()){
auto mount = line.section(' ', 1, 1);
if(mount.startsWith(path + "/")){
umount(mount);
}

for(auto mount : getActiveApplicationMounts()){
umount(mount);
}
mounts.seek(0);
while(!(line = mounts.readLine()).isEmpty()){
auto mount = line.section(' ', 1, 1);
if(mount.startsWith(path + "/")){
qDebug() << "Some items are still mounted in chroot" << path;
return;
}
if(!getActiveApplicationMounts().isEmpty()){
qDebug() << "Some items are still mounted in chroot" << path;
return;
}
mounts.close();
dir.removeRecursively();
}
bool isMounted(const QString& path){
bool isMounted(const QString& path){ return getActiveMounts().contains(path); }
QStringList getActiveApplicationMounts(){
auto path = chrootPath() + "/";
QStringList activeMounts = getActiveMounts().filter(QRegularExpression("^" + QRegularExpression::escape(path) + ".*"));
activeMounts.sort(Qt::CaseSensitive);
std::reverse(std::begin(activeMounts), std::end(activeMounts));
return activeMounts;
}
QStringList getActiveMounts(){
QFile mounts("/proc/mounts");
if(!mounts.open(QIODevice::ReadOnly)){
qDebug() << "Unable to open /proc/mounts";
return false;
return QStringList();
}
QString line;
QStringList activeMounts;
while(!(line = mounts.readLine()).isEmpty()){
auto mount = line.section(' ', 1, 1);
if(mount == path){
mounts.close();
return true;
if(mount.startsWith("/")){
activeMounts.append(mount);
}

}
mounts.close();
return false;
activeMounts.sort(Qt::CaseSensitive);
std::reverse(std::begin(activeMounts), std::end(activeMounts));
return activeMounts;
}
};

Expand Down
2 changes: 1 addition & 1 deletion applications/system-service/appsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void AppsAPI::startup(){
qDebug() << "Auto starting" << app->name();
app->launchNoSecurityCheck();
if(app->type() == Backgroundable){
qDebug() << " Puasing auto started app" << app->name();
qDebug() << " Pausing auto started app" << app->name();
app->pauseNoSecurityCheck();
}
}
Expand Down
2 changes: 2 additions & 0 deletions applications/system-service/appsapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class AppsAPI : public APIBase {
settings.sync();
for(auto app : applications){
app->stopNoSecurityCheck();
}
for(auto app : applications){
app->waitForFinished();
delete app;
}
Expand Down
1 change: 1 addition & 0 deletions applications/system-service/buttonhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void ButtonHandler::run(){
while(stream.read((char*)&ie, sie)){
// TODO - Properly pass through non-button presses
// Read for non-zero event codes.
emit rawEvent(ie);
if(ie.code != 0){
emit activity();
// Toggle the button state.
Expand Down
1 change: 1 addition & 0 deletions applications/system-service/buttonhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private slots:
void powerHeld();
void powerPress();
void activity();
void rawEvent(const input_event&);

protected:
void run();
Expand Down
Loading