isEmpty checks all files like reset
Since reset deletes all files in a user directory, change isEmpty to
alse look at all files in the directory. This makes the two symmetric.
Bug: 16935053
Change-Id: Id30685203f4b5484d757022ee971f8d877c15263
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index 9e460d7..50e2ed4 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -1032,20 +1032,17 @@
bool isEmpty(uid_t uid) const {
const UserState* userState = getUserState(uid);
- if (userState == NULL) {
+ if (userState == NULL || userState->getState() == STATE_UNINITIALIZED) {
return true;
}
DIR* dir = opendir(userState->getUserDirName());
- struct dirent* file;
if (!dir) {
return true;
}
+
bool result = true;
-
- char filename[NAME_MAX];
- int n = snprintf(filename, sizeof(filename), "%u_", uid);
-
+ struct dirent* file;
while ((file = readdir(dir)) != NULL) {
// We only care about files.
if (file->d_type != DT_REG) {
@@ -1057,10 +1054,8 @@
continue;
}
- if (!strncmp(file->d_name, filename, n)) {
- result = false;
- break;
- }
+ result = false;
+ break;
}
closedir(dir);
return result;