Merge "Fix multithreaded backtraces for seccomp processes."
diff --git a/adb/client/adb_install.cpp b/adb/client/adb_install.cpp
index c0d09fd..c00d955 100644
--- a/adb/client/adb_install.cpp
+++ b/adb/client/adb_install.cpp
@@ -177,7 +177,9 @@
}
cleanup_streamed_apk:
- delete_device_patch_file(file);
+ if (use_fastdeploy == true) {
+ delete_device_patch_file(file);
+ }
return result;
} else {
struct stat sb;
@@ -258,10 +260,10 @@
std::string apk_dest =
android::base::StringPrintf(where, android::base::Basename(argv[last_apk]).c_str());
- TemporaryFile metadataTmpFile;
- TemporaryFile patchTmpFile;
-
if (use_fastdeploy == true) {
+ TemporaryFile metadataTmpFile;
+ TemporaryFile patchTmpFile;
+
FILE* metadataFile = fopen(metadataTmpFile.path, "wb");
int metadata_len = extract_metadata(apk_file[0], metadataFile);
fclose(metadataFile);
@@ -294,7 +296,9 @@
result = pm_command(argc, argv);
cleanup_apk:
- delete_device_patch_file(apk_file[0]);
+ if (use_fastdeploy == true) {
+ delete_device_patch_file(apk_file[0]);
+ }
delete_device_file(apk_dest);
return result;
}
@@ -328,9 +332,6 @@
} else if (!strcmp(argv[i], "--no-fastdeploy")) {
processedArgIndicies.push_back(i);
use_fastdeploy = false;
- } else if (!strcmp(argv[i], "-f")) {
- processedArgIndicies.push_back(i);
- use_fastdeploy = true;
} else if (!strcmp(argv[i], "--force-agent")) {
processedArgIndicies.push_back(i);
agent_update_strategy = FastDeploy_AgentUpdateAlways;
@@ -383,12 +384,7 @@
if (use_fastdeploy == true) {
fastdeploy_set_local_agent(use_localagent);
-
- bool agent_up_to_date = update_agent(agent_update_strategy);
- if (agent_up_to_date == false) {
- printf("Failed to update agent, exiting\n");
- return 1;
- }
+ update_agent(agent_update_strategy);
}
switch (installMode) {
@@ -533,19 +529,3 @@
std::string cmd = "rm -f " + escape_arg(filename);
return send_shell_command(cmd);
}
-
-int delete_host_file(const std::string& filename) {
-#ifdef _WIN32
- BOOL delete_return = DeleteFileA(filename.c_str());
- if (delete_return != 0) {
- return 0;
- } else {
- DWORD last_error = GetLastError();
- printf("Error [%ld] deleting: %s\n", last_error, filename.c_str());
- return delete_return;
- }
-#else
- std::string cmd = "rm -f " + escape_arg(filename);
- return system(cmd.c_str());
-#endif
-}
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index a5cfd7f..6e143c1 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -158,7 +158,7 @@
" --instant: cause the app to be installed as an ephemeral install app\n"
" --no-streaming: always push APK to device and invoke Package Manager as separate steps\n"
" --streaming: force streaming APK directly into Package Manager\n"
- " -f/--fastdeploy: use fast deploy (only valid with -r)\n"
+ " --fastdeploy: use fast deploy (only valid with -r)\n"
" --no-fastdeploy: prevent use of fast deploy (only valid with -r)\n"
" --force-agent: force update of deployment agent when using fast deploy\n"
" --date-check-agent: update deployment agent when local version is newer and using fast deploy\n"
diff --git a/adb/client/fastdeploy.cpp b/adb/client/fastdeploy.cpp
index 2914836..d3f35c8 100644
--- a/adb/client/fastdeploy.cpp
+++ b/adb/client/fastdeploy.cpp
@@ -30,7 +30,7 @@
static constexpr const char* kDeviceAgentPath = "/data/local/tmp/";
-static bool use_localagent = false;
+static bool g_use_localagent = false;
long get_agent_version() {
std::vector<char> versionOutputBuffer;
@@ -61,48 +61,36 @@
return api_level;
}
-void fastdeploy_set_local_agent(bool set_use_localagent) {
- use_localagent = set_use_localagent;
+void fastdeploy_set_local_agent(bool use_localagent) {
+ g_use_localagent = use_localagent;
}
// local_path - must start with a '/' and be relative to $ANDROID_PRODUCT_OUT
-static bool get_agent_component_host_path(const char* local_path, const char* sdk_path,
- std::string* output_path) {
+static std::string get_agent_component_host_path(const char* local_path, const char* sdk_path) {
std::string adb_dir = android::base::GetExecutableDirectory();
if (adb_dir.empty()) {
- return false;
+ fatal("Could not determine location of adb!");
}
- if (use_localagent) {
+ if (g_use_localagent) {
const char* product_out = getenv("ANDROID_PRODUCT_OUT");
if (product_out == nullptr) {
- return false;
+ fatal("Could not locate %s because $ANDROID_PRODUCT_OUT is not defined", local_path);
}
- *output_path = android::base::StringPrintf("%s%s", product_out, local_path);
- return true;
+ return android::base::StringPrintf("%s%s", product_out, local_path);
} else {
- *output_path = adb_dir + sdk_path;
- return true;
+ return adb_dir + sdk_path;
}
- return false;
}
static bool deploy_agent(bool checkTimeStamps) {
std::vector<const char*> srcs;
- std::string agent_jar_path;
- if (get_agent_component_host_path("/system/framework/deployagent.jar", "/deployagent.jar",
- &agent_jar_path)) {
- srcs.push_back(agent_jar_path.c_str());
- } else {
- return false;
- }
-
- std::string agent_sh_path;
- if (get_agent_component_host_path("/system/bin/deployagent", "/deployagent", &agent_sh_path)) {
- srcs.push_back(agent_sh_path.c_str());
- } else {
- return false;
- }
+ std::string jar_path =
+ get_agent_component_host_path("/system/framework/deployagent.jar", "/deployagent.jar");
+ std::string script_path =
+ get_agent_component_host_path("/system/bin/deployagent", "/deployagent");
+ srcs.push_back(jar_path.c_str());
+ srcs.push_back(script_path.c_str());
if (do_sync_push(srcs, kDeviceAgentPath, checkTimeStamps)) {
// on windows the shell script might have lost execute permission
@@ -111,24 +99,24 @@
std::string chmodCommand =
android::base::StringPrintf(kChmodCommandPattern, kDeviceAgentPath);
int ret = send_shell_command(chmodCommand);
- return (ret == 0);
+ if (ret != 0) {
+ fatal("Error executing %s returncode: %d", chmodCommand.c_str(), ret);
+ }
} else {
- return false;
+ fatal("Error pushing agent files to device");
}
+
+ return true;
}
-bool update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy) {
+void update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy) {
long agent_version = get_agent_version();
switch (agentUpdateStrategy) {
case FastDeploy_AgentUpdateAlways:
- if (deploy_agent(false) == false) {
- return false;
- }
+ deploy_agent(false);
break;
case FastDeploy_AgentUpdateNewerTimeStamp:
- if (deploy_agent(true) == false) {
- return false;
- }
+ deploy_agent(true);
break;
case FastDeploy_AgentUpdateDifferentVersion:
if (agent_version != kRequiredAgentVersion) {
@@ -138,19 +126,20 @@
printf("Device agent version is (%ld), (%ld) is required, re-deploying\n",
agent_version, kRequiredAgentVersion);
}
- if (deploy_agent(false) == false) {
- return false;
- }
+ deploy_agent(false);
}
break;
}
agent_version = get_agent_version();
- return (agent_version == kRequiredAgentVersion);
+ if (agent_version != kRequiredAgentVersion) {
+ fatal("After update agent version remains incorrect! Expected %ld but version is %ld",
+ kRequiredAgentVersion, agent_version);
+ }
}
static std::string get_aapt2_path() {
- if (use_localagent) {
+ if (g_use_localagent) {
// This should never happen on a Windows machine
const char* host_out = getenv("ANDROID_HOST_OUT");
if (host_out == nullptr) {
@@ -186,26 +175,24 @@
}
// output is required to point to a valid output string (non-null)
-static bool get_packagename_from_apk(const char* apkPath, std::string* output) {
+static std::string get_packagename_from_apk(const char* apkPath) {
const char* kAapt2DumpNameCommandPattern = R"(%s dump packagename "%s")";
std::string aapt2_path_string = get_aapt2_path();
std::string getPackagenameCommand = android::base::StringPrintf(
kAapt2DumpNameCommandPattern, aapt2_path_string.c_str(), apkPath);
- if (system_capture(getPackagenameCommand.c_str(), *output) == 0) {
- // strip any line end characters from the output
- *output = android::base::Trim(*output);
- return true;
+ std::string package_name;
+ int exit_code = system_capture(getPackagenameCommand.c_str(), package_name);
+ if (exit_code != 0) {
+ fatal("Error executing '%s' exitcode: %d", getPackagenameCommand.c_str(), exit_code);
}
- return false;
+
+ // strip any line end characters from the output
+ return android::base::Trim(package_name);
}
int extract_metadata(const char* apkPath, FILE* outputFp) {
- std::string packageName;
- if (get_packagename_from_apk(apkPath, &packageName) == false) {
- return -1;
- }
-
+ std::string packageName = get_packagename_from_apk(apkPath);
const char* kAgentExtractCommandPattern = "/data/local/tmp/deployagent extract %s";
std::string extractCommand =
android::base::StringPrintf(kAgentExtractCommandPattern, packageName.c_str());
@@ -223,7 +210,7 @@
}
static std::string get_patch_generator_command() {
- if (use_localagent) {
+ if (g_use_localagent) {
// This should never happen on a Windows machine
const char* host_out = getenv("ANDROID_HOST_OUT");
if (host_out == nullptr) {
@@ -250,11 +237,7 @@
}
std::string get_patch_path(const char* apkPath) {
- std::string packageName;
- if (get_packagename_from_apk(apkPath, &packageName) == false) {
- return "";
- }
-
+ std::string packageName = get_packagename_from_apk(apkPath);
std::string patchDevicePath =
android::base::StringPrintf("%s%s.patch", kDeviceAgentPath, packageName.c_str());
return patchDevicePath;
@@ -262,12 +245,7 @@
int apply_patch_on_device(const char* apkPath, const char* patchPath, const char* outputPath) {
const std::string kAgentApplyCommandPattern = "/data/local/tmp/deployagent apply %s %s -o %s";
-
- std::string packageName;
- if (get_packagename_from_apk(apkPath, &packageName) == false) {
- return -1;
- }
-
+ std::string packageName = get_packagename_from_apk(apkPath);
std::string patchDevicePath = get_patch_path(apkPath);
std::vector<const char*> srcs = {patchPath};
@@ -286,12 +264,7 @@
int install_patch(const char* apkPath, const char* patchPath, int argc, const char** argv) {
const std::string kAgentApplyCommandPattern = "/data/local/tmp/deployagent apply %s %s -pm %s";
-
- std::string packageName;
- if (get_packagename_from_apk(apkPath, &packageName) == false) {
- return -1;
- }
-
+ std::string packageName = get_packagename_from_apk(apkPath);
std::vector<const char*> srcs;
std::string patchDevicePath =
android::base::StringPrintf("%s%s.patch", kDeviceAgentPath, packageName.c_str());
diff --git a/adb/client/fastdeploy.h b/adb/client/fastdeploy.h
index 80f3875..e5e7663 100644
--- a/adb/client/fastdeploy.h
+++ b/adb/client/fastdeploy.h
@@ -26,7 +26,7 @@
void fastdeploy_set_local_agent(bool use_localagent);
int get_device_api_level();
-bool update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy);
+void update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy);
int extract_metadata(const char* apkPath, FILE* outputFp);
int create_patch(const char* apkPath, const char* metadataPath, const char* patchPath);
int apply_patch_on_device(const char* apkPath, const char* patchPath, const char* outputPath);
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index bc18994..be0bdd0 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -72,12 +72,7 @@
return c == '\\' || c == '/';
}
-static __inline__ int adb_thread_setname(const std::string& name) {
- // TODO: See https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx for how to set
- // the thread name in Windows. Unfortunately, it only works during debugging, but
- // our build process doesn't generate PDB files needed for debugging.
- return 0;
-}
+extern int adb_thread_setname(const std::string& name);
static __inline__ void close_on_exec(int fd)
{
diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp
index c94d13f..026dd1c 100644
--- a/adb/sysdeps_win32.cpp
+++ b/adb/sysdeps_win32.cpp
@@ -2742,3 +2742,26 @@
return buf;
}
+
+// The SetThreadDescription API was brought in version 1607 of Windows 10.
+typedef HRESULT(WINAPI* SetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription);
+
+// Based on PlatformThread::SetName() from
+// https://cs.chromium.org/chromium/src/base/threading/platform_thread_win.cc
+int adb_thread_setname(const std::string& name) {
+ // The SetThreadDescription API works even if no debugger is attached.
+ auto set_thread_description_func = reinterpret_cast<SetThreadDescription>(
+ ::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "SetThreadDescription"));
+ if (set_thread_description_func) {
+ std::wstring name_wide;
+ if (!android::base::UTF8ToWide(name.c_str(), &name_wide)) {
+ return errno;
+ }
+ set_thread_description_func(::GetCurrentThread(), name_wide.c_str());
+ }
+
+ // Don't use the thread naming SEH exception because we're compiled with -fno-exceptions.
+ // https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2017
+
+ return 0;
+}
diff --git a/adb/test_device.py b/adb/test_device.py
index 20f224a..9f45115 100644
--- a/adb/test_device.py
+++ b/adb/test_device.py
@@ -1334,6 +1334,206 @@
self.device.forward_remove("tcp:{}".format(local_port))
+if sys.platform == "win32":
+ # From https://stackoverflow.com/a/38749458
+ import os
+ import contextlib
+ import msvcrt
+ import ctypes
+ from ctypes import wintypes
+
+ kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
+
+ GENERIC_READ = 0x80000000
+ GENERIC_WRITE = 0x40000000
+ FILE_SHARE_READ = 1
+ FILE_SHARE_WRITE = 2
+ CONSOLE_TEXTMODE_BUFFER = 1
+ INVALID_HANDLE_VALUE = wintypes.HANDLE(-1).value
+ STD_OUTPUT_HANDLE = wintypes.DWORD(-11)
+ STD_ERROR_HANDLE = wintypes.DWORD(-12)
+
+ def _check_zero(result, func, args):
+ if not result:
+ raise ctypes.WinError(ctypes.get_last_error())
+ return args
+
+ def _check_invalid(result, func, args):
+ if result == INVALID_HANDLE_VALUE:
+ raise ctypes.WinError(ctypes.get_last_error())
+ return args
+
+ if not hasattr(wintypes, 'LPDWORD'): # Python 2
+ wintypes.LPDWORD = ctypes.POINTER(wintypes.DWORD)
+ wintypes.PSMALL_RECT = ctypes.POINTER(wintypes.SMALL_RECT)
+
+ class COORD(ctypes.Structure):
+ _fields_ = (('X', wintypes.SHORT),
+ ('Y', wintypes.SHORT))
+
+ class CONSOLE_SCREEN_BUFFER_INFOEX(ctypes.Structure):
+ _fields_ = (('cbSize', wintypes.ULONG),
+ ('dwSize', COORD),
+ ('dwCursorPosition', COORD),
+ ('wAttributes', wintypes.WORD),
+ ('srWindow', wintypes.SMALL_RECT),
+ ('dwMaximumWindowSize', COORD),
+ ('wPopupAttributes', wintypes.WORD),
+ ('bFullscreenSupported', wintypes.BOOL),
+ ('ColorTable', wintypes.DWORD * 16))
+ def __init__(self, *args, **kwds):
+ super(CONSOLE_SCREEN_BUFFER_INFOEX, self).__init__(
+ *args, **kwds)
+ self.cbSize = ctypes.sizeof(self)
+
+ PCONSOLE_SCREEN_BUFFER_INFOEX = ctypes.POINTER(
+ CONSOLE_SCREEN_BUFFER_INFOEX)
+ LPSECURITY_ATTRIBUTES = wintypes.LPVOID
+
+ kernel32.GetStdHandle.errcheck = _check_invalid
+ kernel32.GetStdHandle.restype = wintypes.HANDLE
+ kernel32.GetStdHandle.argtypes = (
+ wintypes.DWORD,) # _In_ nStdHandle
+
+ kernel32.CreateConsoleScreenBuffer.errcheck = _check_invalid
+ kernel32.CreateConsoleScreenBuffer.restype = wintypes.HANDLE
+ kernel32.CreateConsoleScreenBuffer.argtypes = (
+ wintypes.DWORD, # _In_ dwDesiredAccess
+ wintypes.DWORD, # _In_ dwShareMode
+ LPSECURITY_ATTRIBUTES, # _In_opt_ lpSecurityAttributes
+ wintypes.DWORD, # _In_ dwFlags
+ wintypes.LPVOID) # _Reserved_ lpScreenBufferData
+
+ kernel32.GetConsoleScreenBufferInfoEx.errcheck = _check_zero
+ kernel32.GetConsoleScreenBufferInfoEx.argtypes = (
+ wintypes.HANDLE, # _In_ hConsoleOutput
+ PCONSOLE_SCREEN_BUFFER_INFOEX) # _Out_ lpConsoleScreenBufferInfo
+
+ kernel32.SetConsoleScreenBufferInfoEx.errcheck = _check_zero
+ kernel32.SetConsoleScreenBufferInfoEx.argtypes = (
+ wintypes.HANDLE, # _In_ hConsoleOutput
+ PCONSOLE_SCREEN_BUFFER_INFOEX) # _In_ lpConsoleScreenBufferInfo
+
+ kernel32.SetConsoleWindowInfo.errcheck = _check_zero
+ kernel32.SetConsoleWindowInfo.argtypes = (
+ wintypes.HANDLE, # _In_ hConsoleOutput
+ wintypes.BOOL, # _In_ bAbsolute
+ wintypes.PSMALL_RECT) # _In_ lpConsoleWindow
+
+ kernel32.FillConsoleOutputCharacterW.errcheck = _check_zero
+ kernel32.FillConsoleOutputCharacterW.argtypes = (
+ wintypes.HANDLE, # _In_ hConsoleOutput
+ wintypes.WCHAR, # _In_ cCharacter
+ wintypes.DWORD, # _In_ nLength
+ COORD, # _In_ dwWriteCoord
+ wintypes.LPDWORD) # _Out_ lpNumberOfCharsWritten
+
+ kernel32.ReadConsoleOutputCharacterW.errcheck = _check_zero
+ kernel32.ReadConsoleOutputCharacterW.argtypes = (
+ wintypes.HANDLE, # _In_ hConsoleOutput
+ wintypes.LPWSTR, # _Out_ lpCharacter
+ wintypes.DWORD, # _In_ nLength
+ COORD, # _In_ dwReadCoord
+ wintypes.LPDWORD) # _Out_ lpNumberOfCharsRead
+
+ @contextlib.contextmanager
+ def allocate_console():
+ allocated = kernel32.AllocConsole()
+ try:
+ yield allocated
+ finally:
+ if allocated:
+ kernel32.FreeConsole()
+
+ @contextlib.contextmanager
+ def console_screen(ncols=None, nrows=None):
+ info = CONSOLE_SCREEN_BUFFER_INFOEX()
+ new_info = CONSOLE_SCREEN_BUFFER_INFOEX()
+ nwritten = (wintypes.DWORD * 1)()
+ hStdOut = kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
+ kernel32.GetConsoleScreenBufferInfoEx(
+ hStdOut, ctypes.byref(info))
+ if ncols is None:
+ ncols = info.dwSize.X
+ if nrows is None:
+ nrows = info.dwSize.Y
+ elif nrows > 9999:
+ raise ValueError('nrows must be 9999 or less')
+ fd_screen = None
+ hScreen = kernel32.CreateConsoleScreenBuffer(
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ None, CONSOLE_TEXTMODE_BUFFER, None)
+ try:
+ fd_screen = msvcrt.open_osfhandle(
+ hScreen, os.O_RDWR | os.O_BINARY)
+ kernel32.GetConsoleScreenBufferInfoEx(
+ hScreen, ctypes.byref(new_info))
+ new_info.dwSize = COORD(ncols, nrows)
+ new_info.srWindow = wintypes.SMALL_RECT(
+ Left=0, Top=0, Right=(ncols - 1),
+ Bottom=(info.srWindow.Bottom - info.srWindow.Top))
+ kernel32.SetConsoleScreenBufferInfoEx(
+ hScreen, ctypes.byref(new_info))
+ kernel32.SetConsoleWindowInfo(hScreen, True,
+ ctypes.byref(new_info.srWindow))
+ kernel32.FillConsoleOutputCharacterW(
+ hScreen, u'\0', ncols * nrows, COORD(0,0), nwritten)
+ kernel32.SetConsoleActiveScreenBuffer(hScreen)
+ try:
+ yield fd_screen
+ finally:
+ kernel32.SetConsoleScreenBufferInfoEx(
+ hStdOut, ctypes.byref(info))
+ kernel32.SetConsoleWindowInfo(hStdOut, True,
+ ctypes.byref(info.srWindow))
+ kernel32.SetConsoleActiveScreenBuffer(hStdOut)
+ finally:
+ if fd_screen is not None:
+ os.close(fd_screen)
+ else:
+ kernel32.CloseHandle(hScreen)
+
+ def read_screen(fd):
+ hScreen = msvcrt.get_osfhandle(fd)
+ csbi = CONSOLE_SCREEN_BUFFER_INFOEX()
+ kernel32.GetConsoleScreenBufferInfoEx(
+ hScreen, ctypes.byref(csbi))
+ ncols = csbi.dwSize.X
+ pos = csbi.dwCursorPosition
+ length = ncols * pos.Y + pos.X + 1
+ buf = (ctypes.c_wchar * length)()
+ n = (wintypes.DWORD * 1)()
+ kernel32.ReadConsoleOutputCharacterW(
+ hScreen, buf, length, COORD(0,0), n)
+ lines = [buf[i:i+ncols].rstrip(u'\0')
+ for i in range(0, n[0], ncols)]
+ return u'\n'.join(lines)
+
+@unittest.skipUnless(sys.platform == "win32", "requires Windows")
+class WindowsConsoleTest(DeviceTest):
+ def test_unicode_output(self):
+ """Test Unicode command line parameters and Unicode console window output.
+
+ Bug: https://issuetracker.google.com/issues/111972753
+ """
+ # If we don't have a console window, allocate one. This isn't necessary if we're already
+ # being run from a console window, which is typical.
+ with allocate_console() as allocated_console:
+ # Create a temporary console buffer and switch to it. We could also pass a parameter of
+ # ncols=len(unicode_string), but it causes the window to flash as it is resized and
+ # likely unnecessary given the typical console window size.
+ with console_screen(nrows=1000) as screen:
+ unicode_string = u'로보카 폴리'
+ # Run adb and allow it to detect that stdout is a console, not a pipe, by using
+ # device.shell_popen() which does not use a pipe, unlike device.shell().
+ process = self.device.shell_popen(['echo', '"' + unicode_string + '"'])
+ process.wait()
+ # Read what was written by adb to the temporary console buffer.
+ console_output = read_screen(screen)
+ self.assertEqual(unicode_string, console_output)
+
+
def main():
random.seed(0)
if len(adb.get_devices()) > 0:
diff --git a/fastboot/Android.bp b/fastboot/Android.bp
index 3b91ddd..6b175af 100644
--- a/fastboot/Android.bp
+++ b/fastboot/Android.bp
@@ -121,6 +121,7 @@
shared_libs: [
"android.hardware.boot@1.0",
+ "android.hardware.fastboot@1.0",
"libadbd",
"libasyncio",
"libbase",
diff --git a/fastboot/constants.h b/fastboot/constants.h
index 8a425ae..57e25fc 100644
--- a/fastboot/constants.h
+++ b/fastboot/constants.h
@@ -53,6 +53,7 @@
#define FB_VAR_HAS_SLOT "has-slot"
#define FB_VAR_SLOT_COUNT "slot-count"
#define FB_VAR_PARTITION_SIZE "partition-size"
+#define FB_VAR_PARTITION_TYPE "partition-type"
#define FB_VAR_SLOT_SUCCESSFUL "slot-successful"
#define FB_VAR_SLOT_UNBOOTABLE "slot-unbootable"
#define FB_VAR_IS_LOGICAL "is-logical"
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 771c288..0ec0994 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -88,6 +88,7 @@
{FB_VAR_SLOT_SUCCESSFUL, {GetSlotSuccessful, nullptr}},
{FB_VAR_SLOT_UNBOOTABLE, {GetSlotUnbootable, nullptr}},
{FB_VAR_PARTITION_SIZE, {GetPartitionSize, GetAllPartitionArgsWithSlot}},
+ {FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}},
{FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}};
diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp
index 55aca9c..ae2e7a6 100644
--- a/fastboot/device/fastboot_device.cpp
+++ b/fastboot/device/fastboot_device.cpp
@@ -19,7 +19,7 @@
#include <android-base/logging.h>
#include <android-base/strings.h>
#include <android/hardware/boot/1.0/IBootControl.h>
-
+#include <android/hardware/fastboot/1.0/IFastboot.h>
#include <algorithm>
#include "constants.h"
@@ -29,6 +29,7 @@
using ::android::hardware::hidl_string;
using ::android::hardware::boot::V1_0::IBootControl;
using ::android::hardware::boot::V1_0::Slot;
+using ::android::hardware::fastboot::V1_0::IFastboot;
namespace sph = std::placeholders;
FastbootDevice::FastbootDevice()
@@ -49,7 +50,8 @@
{FB_CMD_UPDATE_SUPER, UpdateSuperHandler},
}),
transport_(std::make_unique<ClientUsbTransport>()),
- boot_control_hal_(IBootControl::getService()) {}
+ boot_control_hal_(IBootControl::getService()),
+ fastboot_hal_(IFastboot::getService()) {}
FastbootDevice::~FastbootDevice() {
CloseDevice();
diff --git a/fastboot/device/fastboot_device.h b/fastboot/device/fastboot_device.h
index 171e7ae..189cf80 100644
--- a/fastboot/device/fastboot_device.h
+++ b/fastboot/device/fastboot_device.h
@@ -23,6 +23,7 @@
#include <vector>
#include <android/hardware/boot/1.0/IBootControl.h>
+#include <android/hardware/fastboot/1.0/IFastboot.h>
#include "commands.h"
#include "transport.h"
@@ -49,11 +50,15 @@
android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal() {
return boot_control_hal_;
}
+ android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal() {
+ return fastboot_hal_;
+ }
private:
const std::unordered_map<std::string, CommandHandler> kCommandMap;
std::unique_ptr<Transport> transport_;
android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal_;
+ android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal_;
std::vector<char> download_data_;
};
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp
index a960189..7535248 100644
--- a/fastboot/device/variables.cpp
+++ b/fastboot/device/variables.cpp
@@ -31,6 +31,9 @@
using ::android::hardware::boot::V1_0::BoolResult;
using ::android::hardware::boot::V1_0::Slot;
+using ::android::hardware::fastboot::V1_0::FileSystemType;
+using ::android::hardware::fastboot::V1_0::Result;
+using ::android::hardware::fastboot::V1_0::Status;
constexpr int kMaxDownloadSizeDefault = 0x20000000;
constexpr char kFastbootProtocolVersion[] = "0.4";
@@ -195,6 +198,47 @@
return true;
}
+bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
+ std::string* message) {
+ if (args.size() < 1) {
+ *message = "Missing argument";
+ return false;
+ }
+ std::string partition_name = args[0];
+ auto fastboot_hal = device->fastboot_hal();
+ if (!fastboot_hal) {
+ *message = "Fastboot HAL not found";
+ return false;
+ }
+
+ FileSystemType type;
+ Result ret;
+ auto ret_val =
+ fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) {
+ type = fs_type;
+ ret = result;
+ });
+ if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
+ *message = "Unable to retrieve partition type";
+ } else {
+ switch (type) {
+ case FileSystemType::RAW:
+ *message = "raw";
+ return true;
+ case FileSystemType::EXT4:
+ *message = "ext4";
+ return true;
+ case FileSystemType::F2FS:
+ *message = "f2fs";
+ return true;
+ default:
+ *message = "Unknown file system type";
+ }
+ }
+
+ return false;
+}
+
bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
std::string* message) {
if (args.size() < 1) {
diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h
index a44e729..63f2670 100644
--- a/fastboot/device/variables.h
+++ b/fastboot/device/variables.h
@@ -44,6 +44,8 @@
bool GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args, std::string* message);
bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& args,
std::string* message);
+bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
+ std::string* message);
bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
std::string* message);
bool GetIsUserspace(FastbootDevice* device, const std::vector<std::string>& args,
diff --git a/init/Android.bp b/init/Android.bp
index a2c49d0..c793971 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -68,6 +68,7 @@
],
shared_libs: [
"libbase",
+ "libbinder",
"libbootloader_message",
"libcutils",
"libdl",
@@ -78,6 +79,7 @@
"liblog",
"liblogwrap",
"libselinux",
+ "libutils",
],
}
@@ -127,6 +129,13 @@
type: "lite",
export_proto_headers: true,
},
+
+ target: {
+ recovery: {
+ cflags: ["-DRECOVERY"],
+ exclude_shared_libs: ["libbinder", "libutils"],
+ },
+ },
}
cc_binary {
@@ -143,6 +152,12 @@
],
srcs: ["main.cpp"],
symlinks: ["ueventd"],
+ target: {
+ recovery: {
+ cflags: ["-DRECOVERY"],
+ exclude_shared_libs: ["libbinder", "libutils"],
+ },
+ },
}
// Tests
diff --git a/init/init.cpp b/init/init.cpp
index 16564f4..3ab0a52 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -41,6 +41,10 @@
#include <keyutils.h>
#include <libavb/libavb.h>
+#ifndef RECOVERY
+#include <binder/ProcessState.h>
+#endif
+
#include "action_parser.h"
#include "epoll.h"
#include "first_stage_mount.h"
@@ -413,6 +417,22 @@
return Success();
}
+static Result<Success> InitBinder(const BuiltinArguments& args) {
+ // init's use of binder is very limited. init cannot:
+ // - have any binder threads
+ // - receive incoming binder calls
+ // - pass local binder services to remote processes
+ // - use death recipients
+ // The main supported usecases are:
+ // - notifying other daemons (oneway calls only)
+ // - retrieving data that is necessary to boot
+ // Also, binder can't be used by recovery.
+#ifndef RECOVERY
+ android::ProcessState::self()->setThreadPoolMaxThreadCount(0);
+#endif
+ return Success();
+}
+
// Set the UDC controller for the ConfigFS USB Gadgets.
// Read the UDC controller in use from "/sys/class/udc".
// In case of multiple UDC controllers select the first one.
@@ -673,6 +693,9 @@
// wasn't ready immediately after wait_for_coldboot_done
am.QueueBuiltinAction(MixHwrngIntoLinuxRngAction, "MixHwrngIntoLinuxRng");
+ // Initialize binder before bringing up other system services
+ am.QueueBuiltinAction(InitBinder, "InitBinder");
+
// Don't mount filesystems or start core system services in charger mode.
std::string bootmode = GetProperty("ro.bootmode", "");
if (bootmode == "charger") {
diff --git a/libnativebridge/include/nativebridge/native_bridge.h b/libnativebridge/include/nativebridge/native_bridge.h
index 9bfc935..28f1927 100644
--- a/libnativebridge/include/nativebridge/native_bridge.h
+++ b/libnativebridge/include/nativebridge/native_bridge.h
@@ -99,7 +99,7 @@
bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);
// Decrements the reference count on the dynamic library handler. If the reference count drops
-// to zero then the dynamic library is unloaded.
+// to zero then the dynamic library is unloaded. Returns 0 on success and non-zero on error.
int NativeBridgeUnloadLibrary(void* handle);
// Get last error message of native bridge when fail to load library or search symbol.
diff --git a/libnativeloader/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h
index 19a1783..c1d9d2a 100644
--- a/libnativeloader/include/nativeloader/native_loader.h
+++ b/libnativeloader/include/nativeloader/native_loader.h
@@ -47,8 +47,9 @@
bool* needs_native_bridge,
std::string* error_msg);
-__attribute__((visibility("default")))
-bool CloseNativeLibrary(void* handle, const bool needs_native_bridge);
+__attribute__((visibility("default"))) bool CloseNativeLibrary(void* handle,
+ const bool needs_native_bridge,
+ std::string* error_msg);
#if defined(__ANDROID__)
// Look up linker namespace by class_loader. Returns nullptr if
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 67c1c10..b3e2b97 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -710,9 +710,21 @@
#endif
}
-bool CloseNativeLibrary(void* handle, const bool needs_native_bridge) {
- return needs_native_bridge ? NativeBridgeUnloadLibrary(handle) :
- dlclose(handle);
+bool CloseNativeLibrary(void* handle, const bool needs_native_bridge, std::string* error_msg) {
+ bool success;
+ if (needs_native_bridge) {
+ success = (NativeBridgeUnloadLibrary(handle) == 0);
+ if (!success) {
+ *error_msg = NativeBridgeGetError();
+ }
+ } else {
+ success = (dlclose(handle) == 0);
+ if (!success) {
+ *error_msg = dlerror();
+ }
+ }
+
+ return success;
}
#if defined(__ANDROID__)
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 07f0797..b68dc34 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -206,6 +206,7 @@
LOCAL_MODULE_STEM := $(call append_vndk_version,$(LOCAL_MODULE))
include $(BUILD_SYSTEM)/base_rules.mk
ld_config_template := $(LOCAL_PATH)/etc/ld.config.txt
+check_backward_compatibility := true
vndk_version := $(PLATFORM_VNDK_VERSION)
include $(LOCAL_PATH)/update_and_install_ld_config.mk
@@ -243,6 +244,7 @@
LOCAL_MODULE_STEM := $$(LOCAL_MODULE)
include $(BUILD_SYSTEM)/base_rules.mk
ld_config_template := $(LOCAL_PATH)/etc/ld.config.txt
+check_backward_compatibility := true
vndk_version := $(1)
lib_list_from_prebuilts := true
include $(LOCAL_PATH)/update_and_install_ld_config.mk
diff --git a/rootdir/ld_config_backward_compatibility_check.py b/rootdir/ld_config_backward_compatibility_check.py
new file mode 100755
index 0000000..1a27578
--- /dev/null
+++ b/rootdir/ld_config_backward_compatibility_check.py
@@ -0,0 +1,177 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import glob
+import os.path
+import re
+import sys
+
+PREBUILTS_VNDK_DIR = "prebuilts/vndk"
+VENDOR_DIRECTORIES = ('/vendor', '/odm')
+
+def find_latest_vndk_snapshot_version():
+ """Returns latest vndk snapshot version in current source tree.
+ It will skip the test if the snapshot directories are not found.
+
+ Returns:
+ latest_version: string
+ """
+ vndk_dir_list = glob.glob(PREBUILTS_VNDK_DIR + "/v*")
+ if not vndk_dir_list:
+ """Exit without error because we may have source trees that do not include
+ VNDK snapshot directories in it.
+ """
+ sys.exit(0)
+ vndk_ver_list = [re.match(r".*/v(\d+)", vndk_dir).group(1)
+ for vndk_dir in vndk_dir_list]
+ latest_version = max(vndk_ver_list)
+ if latest_version == '27':
+ """Exit without error because VNDK v27 is not using ld.config.txt template
+ """
+ sys.exit(0)
+ return latest_version
+
+def get_vendor_configuration(ld_config_file):
+ """Reads the ld.config.txt file to parse the namespace configurations.
+ It finds the configurations that include vendor directories.
+
+ Args:
+ ld_config_file: string, path (relative to build top) of the ld.config.txt
+ file.
+ Returns:
+ configs: dict{string:[string]}, dictionary of namespace configurations.
+ it has 'section + property' names as keys and the directory list
+ as values.
+ """
+ try:
+ conf_file = open(ld_config_file)
+ except IOError:
+ print("error: could not read %s" % ld_config_file)
+ sys.exit(1)
+
+ configs = dict()
+ current_section = None
+
+ with conf_file:
+ for line in conf_file:
+ # ignore comments
+ found = line.find('#')
+ if found != -1:
+ line = line[:found]
+ line = line.strip()
+ if not line:
+ continue
+
+ if line[0] == '[' and line[-1] == ']':
+ # new section started
+ current_section = line[1:-1]
+ continue
+
+ if current_section == None:
+ continue
+
+ found = line.find('+=')
+ opr_len = 2
+ if found == -1:
+ found = line.find('=')
+ opr_len = 1
+ if found == -1:
+ continue
+
+ namespace = line[:found].strip()
+ if not namespace.endswith(".paths"):
+ # check ".paths" only
+ continue
+ namespace = '[' + current_section + ']' + namespace
+ values = line[found + opr_len:].strip()
+ directories = values.split(':')
+
+ for directory in directories:
+ if any(vendor_dir in directory for vendor_dir in VENDOR_DIRECTORIES):
+ if namespace in configs:
+ configs[namespace].append(directory)
+ else:
+ configs[namespace] = [directory]
+
+ return configs
+
+def get_snapshot_config(version):
+ """Finds the ld.config.{version}.txt file from the VNDK snapshot directory.
+ In the vndk prebuilt directory (prebuilts/vndk/v{version}), it searches
+ {arch}/configs/ld.config.{version}.txt file, where {arch} is one of ('arm64',
+ 'arm', 'x86_64', 'x86').
+
+ Args:
+ version: string, the VNDK snapshot version to search.
+ Returns:
+ ld_config_file: string, relative path to ld.config.{version}.txt
+ """
+ arch_list = ('arm64', 'arm', 'x86_64', 'x86')
+ for arch in arch_list:
+ ld_config_file = (PREBUILTS_VNDK_DIR
+ + "/v{0}/{1}/configs/ld.config.{0}.txt".format(version, arch))
+ if os.path.isfile(ld_config_file):
+ return ld_config_file
+ print("error: cannot find ld.config.{0}.txt file in snapshot v{0}"
+ .format(version))
+ sys.exit(1)
+
+def check_backward_compatibility(ld_config, vndk_snapshot_version):
+ """Checks backward compatibility for current ld.config.txt file with the
+ old ld.config.txt file. If any of the vendor directories in the old namespace
+ configurations are missing, the test will fail. It is allowed to have new
+ vendor directories in current ld.config.txt file.
+
+ Args:
+ ld_config: string, relative path to current ld.config.txt file.
+ vndk_snapshot_version: string, the VNDK snapshot version that has an old
+ ld.config.txt file to compare.
+ Returns:
+ result: bool, True if the current configuration is backward compatible.
+ """
+ current_config = get_vendor_configuration(ld_config)
+ old_config = get_vendor_configuration(
+ get_snapshot_config(vndk_snapshot_version))
+ for namespace in old_config:
+ if namespace not in current_config:
+ print("error: cannot find %s which was provided in ld.config.%s.txt"
+ % (namespace, vndk_snapshot_version))
+ return False
+ for path in old_config[namespace]:
+ if not path in current_config[namespace]:
+ print("error: %s for %s in ld.config.%s.txt are missing in %s"
+ % (path, namespace, vndk_snapshot_version, ld_config))
+ return False
+ return True
+
+def main():
+ if len(sys.argv) != 2:
+ print ("Usage: %s target_ld_config_txt_file_name" % sys.argv[0])
+ sys.exit(1)
+
+ latest_vndk_snapshot_version = find_latest_vndk_snapshot_version()
+ if not check_backward_compatibility(sys.argv[1],
+ latest_vndk_snapshot_version):
+ print("error: %s has backward incompatible changes to old "
+ "vendor partition." % sys.argv[1])
+ sys.exit(1)
+
+ # Current ld.config.txt file is backward compatible
+ sys.exit(0)
+
+if __name__ == '__main__':
+ main()
diff --git a/rootdir/update_and_install_ld_config.mk b/rootdir/update_and_install_ld_config.mk
index 4d6df77..56a30b2 100644
--- a/rootdir/update_and_install_ld_config.mk
+++ b/rootdir/update_and_install_ld_config.mk
@@ -18,10 +18,13 @@
# Read inputs
ld_config_template := $(strip $(ld_config_template))
+check_backward_compatibility := $(strip $(check_backward_compatibility))
vndk_version := $(strip $(vndk_version))
lib_list_from_prebuilts := $(strip $(lib_list_from_prebuilts))
libz_is_llndk := $(strip $(libz_is_llndk))
+compatibility_check_script := \
+ $(LOCAL_PATH)/ld_config_backward_compatibility_check.py
intermediates_dir := $(call intermediates-dir-for,ETC,$(LOCAL_MODULE))
library_lists_dir := $(intermediates_dir)
ifeq ($(lib_list_from_prebuilts),true)
@@ -82,11 +85,19 @@
$(LOCAL_BUILT_MODULE): PRIVATE_SANITIZER_RUNTIME_LIBRARIES := $(sanitizer_runtime_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_VERSION_SUFFIX := $(vndk_version_suffix)
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DIR := $(intermediates_dir)
+$(LOCAL_BUILT_MODULE): PRIVATE_COMP_CHECK_SCRIPT := $(compatibility_check_script)
deps := $(llndk_libraries_file) $(vndksp_libraries_file) $(vndkcore_libraries_file) \
$(vndkprivate_libraries_file)
+ifeq ($(check_backward_compatibility),true)
+deps += $(compatibility_check_script)
+endif
$(LOCAL_BUILT_MODULE): $(ld_config_template) $(deps)
@echo "Generate: $< -> $@"
+ifeq ($(check_backward_compatibility),true)
+ @echo "Checking backward compatibility..."
+ $(hide) $(PRIVATE_COMP_CHECK_SCRIPT) $<
+endif
@mkdir -p $(dir $@)
$(call private-filter-out-private-libs,$(PRIVATE_LLNDK_LIBRARIES_FILE),$(PRIVATE_INTERMEDIATES_DIR)/llndk_filtered)
$(hide) sed -e "s?%LLNDK_LIBRARIES%?$$(cat $(PRIVATE_INTERMEDIATES_DIR)/llndk_filtered)?g" $< >$@
@@ -108,9 +119,11 @@
$(hide) rm -f $@.bak
ld_config_template :=
+check_backward_compatibility :=
vndk_version :=
lib_list_from_prebuilts :=
libz_is_llndk :=
+compatibility_check_script :=
intermediates_dir :=
library_lists_dir :=
llndk_libraries_file :=
diff --git a/trusty/keymaster/3.0/android.hardware.keymaster@3.0-service.trusty.rc b/trusty/keymaster/3.0/android.hardware.keymaster@3.0-service.trusty.rc
index e9d3054..503f3de 100644
--- a/trusty/keymaster/3.0/android.hardware.keymaster@3.0-service.trusty.rc
+++ b/trusty/keymaster/3.0/android.hardware.keymaster@3.0-service.trusty.rc
@@ -1,4 +1,4 @@
service vendor.keymaster-3-0 /vendor/bin/hw/android.hardware.keymaster@3.0-service.trusty
class early_hal
user nobody
- group system drmrpc
+ group drmrpc
diff --git a/trusty/keymaster/include/trusty_keymaster/legacy/trusty_keymaster_device.h b/trusty/keymaster/include/trusty_keymaster/legacy/trusty_keymaster_device.h
index 5a80795..a483c0d 100644
--- a/trusty/keymaster/include/trusty_keymaster/legacy/trusty_keymaster_device.h
+++ b/trusty/keymaster/include/trusty_keymaster/legacy/trusty_keymaster_device.h
@@ -80,6 +80,8 @@
const keymaster_blob_t* input, const keymaster_blob_t* signature,
keymaster_key_param_set_t* out_params, keymaster_blob_t* output);
keymaster_error_t abort(keymaster_operation_handle_t operation_handle);
+ keymaster_error_t delete_key(const keymaster_key_blob_t* key);
+ keymaster_error_t delete_all_keys();
private:
keymaster_error_t Send(uint32_t command, const Serializable& request,
diff --git a/trusty/keymaster/legacy/trusty_keymaster_device.cpp b/trusty/keymaster/legacy/trusty_keymaster_device.cpp
index afdf43b..88c3e7b 100644
--- a/trusty/keymaster/legacy/trusty_keymaster_device.cpp
+++ b/trusty/keymaster/legacy/trusty_keymaster_device.cpp
@@ -70,8 +70,8 @@
device_.export_key = export_key;
device_.attest_key = attest_key;
device_.upgrade_key = upgrade_key;
- device_.delete_key = nullptr;
- device_.delete_all_keys = nullptr;
+ device_.delete_key = delete_key;
+ device_.delete_all_keys = delete_all_keys;
device_.begin = begin;
device_.update = update;
device_.finish = finish;
@@ -606,6 +606,34 @@
return trusty_keymaster_send(KM_ABORT_OPERATION, request, &response);
}
+keymaster_error_t TrustyKeymasterDevice::delete_key(const keymaster_key_blob_t* key) {
+ ALOGD("Device received delete_key");
+
+ if (error_ != KM_ERROR_OK) {
+ return error_;
+ }
+
+ if (!key || !key->key_material)
+ return KM_ERROR_UNEXPECTED_NULL_POINTER;
+
+ DeleteKeyRequest request(message_version_);
+ request.SetKeyMaterial(*key);
+ DeleteKeyResponse response(message_version_);
+ return trusty_keymaster_send(KM_DELETE_KEY, request, &response);
+}
+
+keymaster_error_t TrustyKeymasterDevice::delete_all_keys() {
+ ALOGD("Device received delete_all_key");
+
+ if (error_ != KM_ERROR_OK) {
+ return error_;
+ }
+
+ DeleteAllKeysRequest request(message_version_);
+ DeleteAllKeysResponse response(message_version_);
+ return trusty_keymaster_send(KM_DELETE_ALL_KEYS, request, &response);
+}
+
hw_device_t* TrustyKeymasterDevice::hw_device() {
return &device_.common;
}
@@ -719,4 +747,15 @@
return convert_device(dev)->abort(operation_handle);
}
+/* static */
+keymaster_error_t TrustyKeymasterDevice::delete_key(const keymaster2_device_t* dev,
+ const keymaster_key_blob_t* key) {
+ return convert_device(dev)->delete_key(key);
+}
+
+/* static */
+keymaster_error_t TrustyKeymasterDevice::delete_all_keys(const keymaster2_device_t* dev) {
+ return convert_device(dev)->delete_all_keys();
+}
+
} // namespace keymaster