summaryrefslogtreecommitdiff
path: root/gatekeeperd
diff options
context:
space:
mode:
authorAndres Morales <anmorales@google.com>2015-06-24 18:52:51 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-06-24 18:52:51 +0000
commitdb100ff0767317d052e9e76a8d877eaaf70133ca (patch)
treec05dd3fbfe382131ce71869e368352ac1d9479d1 /gatekeeperd
parentc25f0dc38bf4b7d1d91742657e50add72f41898d (diff)
parent7f270fa8a18c86b8d5451dfcd8936c79115440ef (diff)
am 7f270fa8: am 3c2086da: [gatekeeperd] clear state and mark on cold boot
* commit '7f270fa8a18c86b8d5451dfcd8936c79115440ef': [gatekeeperd] clear state and mark on cold boot
Diffstat (limited to 'gatekeeperd')
-rw-r--r--gatekeeperd/gatekeeperd.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp
index adfec1ecc..f4f2cbfc3 100644
--- a/gatekeeperd/gatekeeperd.cpp
+++ b/gatekeeperd/gatekeeperd.cpp
@@ -58,6 +58,13 @@ public:
if (ret < 0)
LOG_ALWAYS_FATAL_IF(ret < 0, "Unable to open GateKeeper HAL");
}
+
+ if (mark_cold_boot()) {
+ ALOGI("cold boot: clearing state");
+ if (device != NULL && device->delete_all_users != NULL) {
+ device->delete_all_users(device);
+ }
+ }
}
virtual ~GateKeeperProxy() {
@@ -76,6 +83,20 @@ public:
close(fd);
}
+ bool mark_cold_boot() {
+ const char *filename = ".coldboot";
+ if (access(filename, F_OK) == -1) {
+ int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ ALOGE("could not open file: %s : %s", filename, strerror(errno));
+ return false;
+ }
+ close(fd);
+ return true;
+ }
+ return false;
+ }
+
void maybe_store_sid(uint32_t uid, uint64_t sid) {
char filename[21];
sprintf(filename, "%u", uid);
@@ -249,6 +270,10 @@ public:
return;
}
clear_sid(uid);
+
+ if (device != NULL && device->delete_user != NULL) {
+ device->delete_user(device, uid);
+ }
}
virtual status_t dump(int fd, const Vector<String16> &) {