Skip to content
Open
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
2 changes: 1 addition & 1 deletion lua/android/sdk/discovery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function M.new(opts)
local config = opts and opts.config or nil
local root = opts and opts.root or nil
local cwd = opts and opts.cwd or nil
local os_name = opts and opts.os_name or nil
local os_name = opts and opts.os_name or vim.loop.os_uname().sysname
local home = opts and opts.home or nil
local discovery = {}

Expand Down
29 changes: 29 additions & 0 deletions lua/tests/android/sdk/discovery_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@ local function locates_sdk_tools_on_windows()
assert.eq(tools.adb, "C:/Sdk/platform-tools/adb.exe", "adb windows")
end

local function auto_detects_windows_tool_extensions()
local original_uname = vim.loop.os_uname
vim.loop.os_uname = function()
return { sysname = "Windows_NT" }
end

local store = require("android.state.store").new()
local discovery = require("android.sdk.discovery").new({
env = { ANDROID_SDK_ROOT = "C:/Sdk" },
exists = function(path)
local matches = {
["C:/Sdk"] = true,
["C:/Sdk/cmdline-tools/latest/bin/sdkmanager.bat"] = true,
["C:/Sdk/cmdline-tools/latest/bin/avdmanager.bat"] = true,
["C:/Sdk/emulator/emulator.exe"] = true,
["C:/Sdk/platform-tools/adb.exe"] = true,
}
return matches[path] or false
end,
store = store,
})

local tools = discovery.tools()
assert.eq(tools.adb, "C:/Sdk/platform-tools/adb.exe", "auto-detected adb windows")

vim.loop.os_uname = original_uname
end

local function falls_back_to_tools_bin()
local store = require("android.state.store").new()
local discovery = require("android.sdk.discovery").new({
Expand Down Expand Up @@ -236,6 +264,7 @@ function M.run()
uses_default_sdk_candidates()
locates_sdk_tools()
locates_sdk_tools_on_windows()
auto_detects_windows_tool_extensions()
falls_back_to_cmdline_tools_bin()
falls_back_to_tools_bin()
locates_aapt2_from_build_tools()
Expand Down