From a6d3cd1bb95af821d7911561422873c58579460d Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Mon, 13 May 2019 16:40:39 -0700 Subject: [PATCH] PinnerService: add pinner.pin_camera to toggle camera pinning Also adds pinner.use_pinlist and pinner.whole_odex Bug: 137395899 Bug: 132649131 Change-Id: I93625c62671540c8b5cdca79002e15b7de6b3d06 --- .../com/android/server/PinnerService.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/PinnerService.java b/services/core/java/com/android/server/PinnerService.java index 097a7d614ab64..16c84c63959b9 100644 --- a/services/core/java/com/android/server/PinnerService.java +++ b/services/core/java/com/android/server/PinnerService.java @@ -97,6 +97,16 @@ public final class PinnerService extends SystemService { private static final int KEY_CAMERA = 0; private static final int KEY_HOME = 1; + // Pin the camera application. + private static boolean PROP_PIN_CAMERA = SystemProperties.getBoolean( + "pinner.pin_camera", true); + // Pin using pinlist.meta when pinning apps. + private static boolean PROP_PIN_PINLIST = SystemProperties.getBoolean( + "pinner.use_pinlist", true); + // Pin the whole odex/vdex/etc file when pinning apps. + private static boolean PROP_PIN_ODEX = SystemProperties.getBoolean( + "pinner.whole_odex", true); + private static final int MAX_CAMERA_PIN_SIZE = 80 * (1 << 20); // 80MB max for camera app. private static final int MAX_HOME_PIN_SIZE = 6 * (1 << 20); // 6MB max for home app. @@ -160,7 +170,11 @@ public final class PinnerService extends SystemService { boolean shouldPinHome = context.getResources().getBoolean( com.android.internal.R.bool.config_pinnerHomeApp); if (shouldPinCamera) { - mPinKeys.add(KEY_CAMERA); + if (PROP_PIN_CAMERA) { + mPinKeys.add(KEY_CAMERA); + } else if (DEBUG) { + Slog.i(TAG, "Pinner - skip pinning camera app"); + } } if (shouldPinHome) { mPinKeys.add(KEY_HOME); @@ -599,10 +613,16 @@ public final class PinnerService extends SystemService { pf = pinFile(file, pinSizeLimit, /*attemptPinIntrospection=*/false); if (pf != null) { synchronized (this) { - pinnedApp.mFiles.add(pf); + if (PROP_PIN_ODEX) { + pinnedApp.mFiles.add(pf); + } } if (DEBUG) { - Slog.i(TAG, "Pinned " + pf.fileName); + if (PROP_PIN_ODEX) { + Slog.i(TAG, "Pinned " + pf.fileName); + } else { + Slog.i(TAG, "Pinned [skip] " + pf.fileName); + } } } } @@ -696,6 +716,13 @@ public final class PinnerService extends SystemService { * @return Open input stream or null on any error */ private static InputStream maybeOpenPinMetaInZip(ZipFile zipFile, String fileName) { + if (!PROP_PIN_PINLIST) { + if (DEBUG) { + Slog.i(TAG, "Pin - skip pinlist.meta in " + fileName); + } + return null; + } + ZipEntry pinMetaEntry = zipFile.getEntry(PIN_META_FILENAME); InputStream pinMetaStream = null; if (pinMetaEntry != null) {