-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
386 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @ts-nocheck | ||
import { execSync } from "child_process"; | ||
|
||
const packageName = process.env.DISCORD_PACKAGE_NAME ?? "com.discord"; | ||
|
||
export function getPackageName() { | ||
return packageName; | ||
} | ||
|
||
export function isADBAvailableAndAppInstalled() { | ||
try { | ||
const out = execSync(`adb shell pm list packages ${packageName}`); | ||
return out.toString().trimEnd() === `package:${packageName}`; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
export async function restartAppFromADB(reversePort) { | ||
if (typeof reversePort === "number") { | ||
await execSync(`adb reverse tcp:${reversePort} tcp:${reversePort}`); | ||
} | ||
|
||
await forceStopAppFromADB(); | ||
await execSync(`adb shell am start ${packageName}/com.discord.main.MainActivity`); | ||
} | ||
|
||
export async function forceStopAppFromADB() { | ||
await execSync(`adb shell am force-stop ${packageName}`); | ||
} |
Oops, something went wrong.