Skip to content

Commit 7d4a516

Browse files
committed
Merge branch 'release/0.2.7'
2 parents 7ea0cb2 + 2a73d11 commit 7d4a516

File tree

7 files changed

+43
-3
lines changed

7 files changed

+43
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "droidground",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"type": "module",
55
"author": "Angelo Delicato",
66
"scripts": {

src/client/api/rest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ class RESTManager {
7676
return res;
7777
}
7878

79+
async closeDialogs(): Promise<AxiosResponse<IGenericResultRes>> {
80+
const res = await http.post<IGenericResultRes>(E.DIALOGS);
81+
return res;
82+
}
83+
7984
async shutdown(): Promise<AxiosResponse<IGenericResultRes>> {
8085
const res = await http.post<IGenericResultRes>(E.SHUTDOWN);
8186
return res;

src/client/views/Overview.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ export const Overview: React.FC = () => {
4141
}
4242
};
4343

44+
const closeDialogs = async () => {
45+
try {
46+
await RESTManagerInstance.closeDialogs();
47+
toast.success("Request issued correctly");
48+
} catch (e) {
49+
console.error(e);
50+
toast.error("Error while closing system dialogs.");
51+
}
52+
};
53+
4454
const runBugreportz = async () => {
4555
try {
4656
await RESTManagerInstance.startBugreportz();
@@ -181,6 +191,17 @@ export const Overview: React.FC = () => {
181191
</div>
182192
</div>
183193

194+
<div className="flex w-full justify-between items-center">
195+
<p>
196+
Close <b>System Dialogs</b>
197+
</p>
198+
<div className="join">
199+
<button className="btn btn-accent join-item rounded-r-md" onClick={closeDialogs}>
200+
Close
201+
</button>
202+
</div>
203+
</div>
204+
184205
{featuresConfig.startActivityEnabled && (
185206
<div className="flex w-full justify-between items-center">
186207
<p>

src/server/api/controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ class APIController {
296296
}
297297
};
298298

299+
closeDialogs: RequestHandler = async (req: Request, res: Response<IGenericResultRes | IGenericErrRes>) => {
300+
Logger.info(`Received ${req.method} request on ${req.path}`);
301+
try {
302+
const adb = await ManagerSingleton.getInstance().getAdb();
303+
await adb.subprocess.noneProtocol.spawnWait(`am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS`);
304+
res.json({ result: "System dialogs closed" }).end();
305+
} catch (error: any) {
306+
Logger.error(`Error closing system dialogs: ${error}`);
307+
res.status(500).json({ error: "An error occurred while closing system dialogs." }).end();
308+
}
309+
};
310+
299311
shutdown: RequestHandler = async (req: Request, res: Response<IGenericResultRes | IGenericErrRes>) => {
300312
Logger.info(`Received ${req.method} request on ${req.path}`);
301313
try {

src/server/api/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default (app: Router) => {
7676
endpoint.get(E.FEATURES, APIController.features);
7777
endpoint.get(E.INFO, APIController.info);
7878
endpoint.post(E.RESTART, APIController.restartApp);
79+
endpoint.post(E.DIALOGS, APIController.closeDialogs);
7980
endpoint.post(E.SHUTDOWN, checkFeatureEnabled(features.shutdownEnabled), APIController.shutdown);
8081
endpoint.post(E.REBOOT, checkFeatureEnabled(features.rebootEnabled), APIController.reboot);
8182
endpoint.post(E.LOGCAT, checkFeatureEnabled(features.logcatEnabled), APIController.dumpLogcat);

src/shared/endpoints.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const REST_API_ENDPOINTS = {
66
ACTIVITY: "/activity",
77
BROADCAST: "/broadcast",
88
SERVICE: "/service",
9+
DIALOGS: "/closeDialogs",
910
SHUTDOWN: "/shutdown",
1011
REBOOT: "/reboot",
1112
LOGCAT: "/logcat",

0 commit comments

Comments
 (0)