summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndres Morales <anmorales@google.com>2015-01-07 14:24:57 -0800
committerAndres Morales <anmorales@google.com>2015-01-07 14:46:19 -0800
commit1ce7d179bf00a9ebebef8aff0006d71469870c26 (patch)
tree8653c0b499b95a314ec89e4bf468b90f331ff9eb
parent4667d247bbff30d7fe47a4022b91eb03da17be4d (diff)
downloadframeworks_base-1ce7d179bf00a9ebebef8aff0006d71469870c26.zip
frameworks_base-1ce7d179bf00a9ebebef8aff0006d71469870c26.tar.gz
frameworks_base-1ce7d179bf00a9ebebef8aff0006d71469870c26.tar.bz2
Wipe FRP partition if OEM unlock enabled
Not all devices invoke recovery on every userdata wipe, so we can't rely on code in the recovery OS to do this. This results in fastboot -w not properly wiping the FRP partition. This patch fixes the issue by having the framework level service check the OEM unlock enabled bit, and wiping the partition if it is set. Bug: 18644051 Change-Id: Id97a29916fe39561700912a920c5741109842bdb
-rw-r--r--services/core/java/com/android/server/PersistentDataBlockService.java52
1 files changed, 33 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/PersistentDataBlockService.java b/services/core/java/com/android/server/PersistentDataBlockService.java
index 9d4cd99..e5ace1b 100644
--- a/services/core/java/com/android/server/PersistentDataBlockService.java
+++ b/services/core/java/com/android/server/PersistentDataBlockService.java
@@ -103,9 +103,19 @@ public class PersistentDataBlockService extends SystemService {
@Override
public void onStart() {
enforceChecksumValidity();
+ formatIfOemUnlockEnabled();
publishBinderService(Context.PERSISTENT_DATA_BLOCK_SERVICE, mService);
}
+ private void formatIfOemUnlockEnabled() {
+ if (doGetOemUnlockEnabled()) {
+ synchronized (mLock) {
+ formatPartitionLocked();
+ doSetOemUnlockEnabledLocked(true);
+ }
+ }
+ }
+
private void enforceOemUnlockPermission() {
mContext.enforceCallingOrSelfPermission(
Manifest.permission.OEM_UNLOCK_STATE,
@@ -285,6 +295,28 @@ public class PersistentDataBlockService extends SystemService {
}
}
+ private boolean doGetOemUnlockEnabled() {
+ DataInputStream inputStream;
+ try {
+ inputStream = new DataInputStream(new FileInputStream(new File(mDataBlockFile)));
+ } catch (FileNotFoundException e) {
+ Slog.e(TAG, "partition not available");
+ return false;
+ }
+
+ try {
+ synchronized (mLock) {
+ inputStream.skip(getBlockDeviceSize() - 1);
+ return inputStream.readByte() != 0;
+ }
+ } catch (IOException e) {
+ Slog.e(TAG, "unable to access persistent partition", e);
+ return false;
+ } finally {
+ IoUtils.closeQuietly(inputStream);
+ }
+ }
+
private native long nativeGetBlockDeviceSize(String path);
private native int nativeWipe(String path);
@@ -410,25 +442,7 @@ public class PersistentDataBlockService extends SystemService {
@Override
public boolean getOemUnlockEnabled() {
enforceOemUnlockPermission();
- DataInputStream inputStream;
- try {
- inputStream = new DataInputStream(new FileInputStream(new File(mDataBlockFile)));
- } catch (FileNotFoundException e) {
- Slog.e(TAG, "partition not available");
- return false;
- }
-
- try {
- synchronized (mLock) {
- inputStream.skip(getBlockDeviceSize() - 1);
- return inputStream.readByte() != 0;
- }
- } catch (IOException e) {
- Slog.e(TAG, "unable to access persistent partition", e);
- return false;
- } finally {
- IoUtils.closeQuietly(inputStream);
- }
+ return doGetOemUnlockEnabled();
}
@Override