Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 68 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignAfterOpenBracket: BlockIndent
AlignTrailingComments: false
AlwaysBreakTemplateDeclarations: Yes
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeComma
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
PackConstructorInitializers: CurrentLine
ContinuationIndentWidth: 4
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowAllArgumentsOnNextLine: false
BinPackArguments: false
BinPackParameters: false
PenaltyBreakAssignment: 1000000
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeBlocks: Preserve
IncludeIsMainRegex: '([-_](test|unittest))?$'
SortIncludes: false
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
InsertNewlineAtEOF: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
FixNamespaceComments: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
TabWidth: 4
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ add_subdirectory(extern/glfw)
set(REFLECTCPP_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(REFLECTCPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(extern/reflect-cpp)
if (MINGW)
target_compile_options(reflectcpp PRIVATE
-Wa,-mbig-obj
$<$<CONFIG:Debug>:-O1>
$<$<CONFIG:Debug>:-g0>
)
endif ()

set(TINYFD_DIR ${CMAKE_SOURCE_DIR}/extern/tinyfiledialogs)
add_library(tinyfiledialogs STATIC ${TINYFD_DIR}/tinyfiledialogs.c)
Expand Down Expand Up @@ -164,6 +171,7 @@ add_executable(${PROJECT_NAME}
src/gui/windows/avd_options.cpp
src/gui/windows/delete_avd.cpp
src/gui/windows/create_avd.cpp
src/gui/windows/device_profile.cpp
src/gui/windows/install_image.cpp
src/gui/windows/main_menu_bar.cpp
src/gui/windows/onboarding.cpp
Expand Down Expand Up @@ -230,7 +238,11 @@ endif ()

if (WIN32)
configure_file(${CMAKE_SOURCE_DIR}/resources.rc.in ${CMAKE_BINARY_DIR}/resources.rc @ONLY)
target_link_options(${PROJECT_NAME} PRIVATE "/SUBSYSTEM:WINDOWS" "/ENTRY:mainCRTStartup")
if (MSVC)
target_link_options(${PROJECT_NAME} PRIVATE "/SUBSYSTEM:WINDOWS" "/ENTRY:mainCRTStartup")
elseif (MINGW)
target_link_options(${PROJECT_NAME} PRIVATE "-mwindows")
endif ()
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/resources.rc)
elseif (APPLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE GL_SILENCE_DEPRECATION)
Expand Down
2 changes: 1 addition & 1 deletion src/core/app_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ namespace CoreDeck {
void SaveAppSettings(const AppSettings &settings);
}

#endif //COREDECK_APP_SETTINGS_H
#endif // COREDECK_APP_SETTINGS_H
2 changes: 1 addition & 1 deletion src/core/app_settings_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ namespace CoreDeck {
};
}

#endif //COREDECK_APP_SETTINGS_TYPES_H
#endif // COREDECK_APP_SETTINGS_TYPES_H
111 changes: 98 additions & 13 deletions src/core/avd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// Created by AbdulMuaz Aqeel on 05/04/2026.
//

#include <fstream>
#include <unordered_map>
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <unordered_map>

#include "avd.h"
#include "paths.h"
#include "process.h"
#include "utilities.h"

namespace CoreDeck {
static std::unordered_map<std::string, std::string> ParseConfigFile(const std::string &path) {
Expand Down Expand Up @@ -39,6 +41,92 @@ namespace CoreDeck {
return config;
}

static std::vector<std::string> SplitConfigList(const std::string &value) {
std::vector<std::string> items;
std::stringstream stream(value);
std::string item;
while (std::getline(stream, item, ',')) {
while (!item.empty() && (item.back() == ' ' || item.back() == '\t')) item.pop_back();
while (!item.empty() && (item.front() == ' ' || item.front() == '\t')) item.erase(item.begin());
if (!item.empty()) items.push_back(item);
}
return items;
}

static bool HasTag(const std::vector<std::string> &tags, const std::string &needle) {
return std::ranges::any_of(tags, [&](const std::string &tag) {
return LowerCopy(tag) == needle;
});
}

static void ExtractSystemImageInfo(AvdInfo &avd, const std::unordered_map<std::string, std::string> &config) {
if (const auto it = config.find("image.sysdir.1"); it != config.end()) {
avd.SystemImagePath = it->second;

std::string sysdir = it->second;
std::ranges::replace(sysdir, '\\', '/');

if (auto start = sysdir.find("android-"); start != std::string::npos) {
start += 8;
if (const auto end = sysdir.find('/', start); end != std::string::npos) {
avd.ApiLevel = sysdir.substr(start, end - start);

const auto variantStart = end + 1;
if (const auto variantEnd = sysdir.find('/', variantStart); variantEnd != std::string::npos) {
avd.SystemImageVariant = sysdir.substr(variantStart, variantEnd - variantStart);

const auto abiStart = variantEnd + 1;
if (const auto abiEnd = sysdir.find('/', abiStart); abiEnd != std::string::npos && avd.Abi.empty()) {
avd.Abi = sysdir.substr(abiStart, abiEnd - abiStart);
}
}
}
}
}

if (const auto it = config.find("tag.id"); it != config.end()) {
avd.SystemImageTagId = it->second;
}
if (const auto it = config.find("tag.display"); it != config.end()) {
avd.SystemImageTagDisplay = it->second;
}
if (const auto it = config.find("tag.ids"); it != config.end()) {
avd.SystemImageTagIds = SplitConfigList(it->second);
} else if (!avd.SystemImageTagId.empty()) {
avd.SystemImageTagIds = {avd.SystemImageTagId};
}
if (const auto it = config.find("tag.displaynames"); it != config.end()) {
avd.SystemImageTagDisplayNames = SplitConfigList(it->second);
} else if (!avd.SystemImageTagDisplay.empty()) {
avd.SystemImageTagDisplayNames = {avd.SystemImageTagDisplay};
}

const std::string variant = LowerCopy(avd.SystemImageVariant);
const std::string tagId = LowerCopy(avd.SystemImageTagId);
const std::string tagDisplay = LowerCopy(avd.SystemImageTagDisplay);
const std::string tagDisplayNames = LowerCopy(StrConcat(
avd.SystemImageTagDisplay,
" ",
config.contains("tag.displaynames") ? config.at("tag.displaynames") : ""
));

avd.IsGooglePlayImage = variant.find("google_apis_playstore") != std::string::npos ||
tagId == "google_apis_playstore" ||
HasTag(avd.SystemImageTagIds, "google_apis_playstore") ||
tagDisplay.find("play") != std::string::npos;

avd.IsGoogleApisImage = avd.IsGooglePlayImage ||
variant.find("google_apis") != std::string::npos ||
tagId == "google_apis" ||
HasTag(avd.SystemImageTagIds, "google_apis") ||
tagDisplay.find("google apis") != std::string::npos;

avd.Supports16KbPageSize = variant.find("ps16k") != std::string::npos ||
HasTag(avd.SystemImageTagIds, "page_size_16kb") ||
tagDisplayNames.find("16kb") != std::string::npos ||
tagDisplayNames.find("16 kb") != std::string::npos;
}

static AvdInfo ExtractAvdInfo(const std::string &avdName) {
AvdInfo avd;

Expand All @@ -65,20 +153,12 @@ namespace CoreDeck {
avd.DisplayName = it->second;
}

if (auto it = config.find("image.sysdir.1"); it != config.end()) {
auto &sysdir = it->second;
if (auto start = sysdir.find("android-"); start != std::string::npos) {
start += 8;
if (const auto end = sysdir.find('/', start); end != std::string::npos) {
avd.ApiLevel = sysdir.substr(start, end - start);
}
}
}

if (auto it = config.find("abi.type"); it != config.end()) {
avd.Abi = it->second;
}

ExtractSystemImageInfo(avd, config);

if (auto it = config.find("sdcard.size"); it != config.end()) {
avd.SdCard = it->second;
}
Expand Down Expand Up @@ -143,7 +223,12 @@ namespace CoreDeck {
if (data.Name.empty() || data.SystemImagePackagePath.empty()) return false;

std::vector<std::string> args = {
"create", "avd", "-n", data.Name, "-k", data.SystemImagePackagePath
"create",
"avd",
"-n",
data.Name,
"-k",
data.SystemImagePackagePath
};
if (!data.DeviceId.empty()) {
args.emplace_back("-d");
Expand Down
11 changes: 10 additions & 1 deletion src/core/avd.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ namespace CoreDeck {
std::string Device;
std::string ApiLevel;
std::string Abi;
std::string SystemImagePath;
std::string SystemImageVariant;
std::string SystemImageTagId;
std::string SystemImageTagDisplay;
std::vector<std::string> SystemImageTagIds;
std::vector<std::string> SystemImageTagDisplayNames;
bool IsGoogleApisImage = false;
bool IsGooglePlayImage = false;
bool Supports16KbPageSize = false;
std::string SdCard;
std::string RamSize;
std::string ScreenResolution;
Expand Down Expand Up @@ -44,4 +53,4 @@ namespace CoreDeck {
bool DeleteAvd(const SdkInfo &sdk, const std::string &avdName);
}

#endif //EMU_LAUNCHER_AVD_INFO_H
#endif // EMU_LAUNCHER_AVD_INFO_H
40 changes: 25 additions & 15 deletions src/core/crash_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
namespace CoreDeck::CrashReporter {
static sentry_level_t ToSentryLevel(const Level level) {
switch (level) {
case Level::Debug: return SENTRY_LEVEL_DEBUG;
case Level::Info: return SENTRY_LEVEL_INFO;
case Level::Warning: return SENTRY_LEVEL_WARNING;
case Level::Error: return SENTRY_LEVEL_ERROR;
case Level::Fatal: return SENTRY_LEVEL_FATAL;
case Level::Debug:
return SENTRY_LEVEL_DEBUG;
case Level::Info:
return SENTRY_LEVEL_INFO;
case Level::Warning:
return SENTRY_LEVEL_WARNING;
case Level::Error:
return SENTRY_LEVEL_ERROR;
case Level::Fatal:
return SENTRY_LEVEL_FATAL;
}
return SENTRY_LEVEL_INFO;
}
Expand All @@ -36,9 +41,9 @@ namespace CoreDeck::CrashReporter {

const char *handlerName =
#ifdef _WIN32
"crashpad_handler.exe";
"crashpad_handler.exe";
#else
"crashpad_handler";
"crashpad_handler";
#endif
const std::string handlerPath = Paths::JoinPaths(
{Paths::GetExecutableDirectory(), handlerName}
Expand All @@ -52,15 +57,16 @@ namespace CoreDeck::CrashReporter {
sentry_close();
}

bool IsEnabled() { return true; }
bool IsEnabled() {
return true;
}

void CaptureMessage(const Level level, const std::string_view message) {
sentry_capture_event(sentry_value_new_message_event(
ToSentryLevel(level),
nullptr,
ToString(message).c_str()
)
);
ToSentryLevel(level),
nullptr,
ToString(message).c_str()
));
}

void CaptureException(const std::string_view type, const std::string_view message) {
Expand All @@ -87,12 +93,16 @@ namespace CoreDeck::CrashReporter {
#else

namespace CoreDeck::CrashReporter {
bool Init() { return false; }
bool Init() {
return false;
}

void Shutdown() {
}

bool IsEnabled() { return false; }
bool IsEnabled() {
return false;
}

void CaptureMessage(Level, std::string_view) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/crash_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ namespace CoreDeck::CrashReporter {
void AddBreadcrumb(std::string_view category, std::string_view message);
}

#endif //COREDECK_CRASH_REPORTER_H
#endif // COREDECK_CRASH_REPORTER_H
Loading
Loading