Re-pin camera odex/vdex files only if they have changed
Test: Camera is re-pinned after
adb shell cmd package compile -f -m extract
com.google.android.GoogleCamera
adb shell cmd package bg-dexopt-job
Bug: 33168521
Change-Id: I5c5e76d1e40b6d433c9a0beba463c86f79ad437e
diff --git a/services/core/java/com/android/server/PinnerService.java b/services/core/java/com/android/server/PinnerService.java
index f8baf17..45f9025 100644
--- a/services/core/java/com/android/server/PinnerService.java
+++ b/services/core/java/com/android/server/PinnerService.java
@@ -36,6 +36,7 @@
import android.system.Os;
import android.system.OsConstants;
import android.system.StructStat;
+import android.util.ArraySet;
import android.util.Slog;
import com.android.internal.app.ResolverActivity;
@@ -77,10 +78,10 @@
// If this user's camera app has been updated, update pinned files accordingly.
if (intent.getAction() == Intent.ACTION_PACKAGE_REPLACED) {
Uri packageUri = intent.getData();
- ApplicationInfo cameraInfo = getCameraInfo(UserHandle.USER_SYSTEM);
- if (cameraInfo.packageName == packageUri.getSchemeSpecificPart()) {
- update();
- }
+ String packageName = packageUri.getSchemeSpecificPart();
+ ArraySet<String> updatedPackages = new ArraySet<>();
+ updatedPackages.add(packageName);
+ update(updatedPackages);
}
}
};
@@ -129,10 +130,13 @@
* Specifically, this only updates camera pinning.
* The other files pinned in onStart will not need to be updated.
*/
- public void update() {
- Slog.i(TAG, "Updating pinned files.");
- mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, UserHandle.USER_SYSTEM, 0)
- .sendToTarget();
+ public void update(ArraySet<String> updatedPackages) {
+ ApplicationInfo cameraInfo = getCameraInfo(UserHandle.USER_SYSTEM);
+ if (cameraInfo != null && updatedPackages.contains(cameraInfo.packageName)) {
+ Slog.i(TAG, "Updating pinned files.");
+ mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, UserHandle.USER_SYSTEM, 0)
+ .sendToTarget();
+ }
}
/**