fix: 修复设置开机自启动应用重启后失效问题

1. 设置自动启动时未将应用desktop文件写入到~/.config/autostart/目录下
2. 应用自动启动接口优化,确保调用时,接口返回正确。
(设置为自启动时,手动将Hidden字段写入到自启动目录的desktop文件中,并设置为false,只有这样,
安全中心才不会弹出自启动确认窗口, 这种操作是沿用V20阶段的约定规范,这块已经与安全中心研发对接过)

Log:
Influence: 设置自启动后重启应用也会保持生效
Bug: https://pms.uniontech.com/bug-view-172263.html
Bug: https://pms.uniontech.com/bug-view-172281.html
Task: https://pms.uniontech.com/task-view-215413.html
Change-Id: Idd03ac40850c95ef8cef2ac169cfe006405b809b
This commit is contained in:
songwentao
2022-11-23 14:36:04 +08:00
parent f6e6739532
commit 8be1b299e6
5 changed files with 85 additions and 114 deletions

View File

@ -38,10 +38,10 @@ class StartManager : public QObject
public:
explicit StartManager(QObject *parent = nullptr);
bool addAutostart(QString fileName);
bool removeAutostart(QString fileName);
bool addAutostart(const QString &desktop);
bool removeAutostart(const QString &desktop);
QStringList autostartList();
bool isAutostart(QString fileName);
bool isAutostart(const QString &desktop);
bool isMemSufficient();
void launchApp(const QString &desktopFile);
void launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
@ -51,13 +51,13 @@ public:
void runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
Q_SIGNALS:
void autostartChanged(QString status, QString fileName);
void autostartChanged(const QString &status, const QString &fileName);
public Q_SLOTS:
void onAutoStartupPathChange(const QString &dirPath);
private:
bool setAutostart(QString fileName, bool value);
bool setAutostart(const QString &fileName, const bool value);
bool doLaunchAppWithOptions(const QString &desktopFile);
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
@ -74,7 +74,7 @@ private:
uint64_t minMemAvail;
uint64_t maxSwapUsed;
StartManagerDBusHandler *dbusHandler;
QStringList autostartFiles;
QStringList m_autostartFiles;
QFileSystemWatcher *fileWatcher;
ApplicationManager *am;
};