Merge "Re-pin camera odex/vdex files only if they have changed" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9bb5e16657
@@ -36,6 +36,7 @@ import android.system.ErrnoException;
|
|||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
import android.system.StructStat;
|
import android.system.StructStat;
|
||||||
|
import android.util.ArraySet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.app.ResolverActivity;
|
import com.android.internal.app.ResolverActivity;
|
||||||
@@ -77,10 +78,10 @@ public final class PinnerService extends SystemService {
|
|||||||
// If this user's camera app has been updated, update pinned files accordingly.
|
// If this user's camera app has been updated, update pinned files accordingly.
|
||||||
if (intent.getAction() == Intent.ACTION_PACKAGE_REPLACED) {
|
if (intent.getAction() == Intent.ACTION_PACKAGE_REPLACED) {
|
||||||
Uri packageUri = intent.getData();
|
Uri packageUri = intent.getData();
|
||||||
ApplicationInfo cameraInfo = getCameraInfo(UserHandle.USER_SYSTEM);
|
String packageName = packageUri.getSchemeSpecificPart();
|
||||||
if (cameraInfo.packageName == packageUri.getSchemeSpecificPart()) {
|
ArraySet<String> updatedPackages = new ArraySet<>();
|
||||||
update();
|
updatedPackages.add(packageName);
|
||||||
}
|
update(updatedPackages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -129,10 +130,13 @@ public final class PinnerService extends SystemService {
|
|||||||
* Specifically, this only updates camera pinning.
|
* Specifically, this only updates camera pinning.
|
||||||
* The other files pinned in onStart will not need to be updated.
|
* The other files pinned in onStart will not need to be updated.
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update(ArraySet<String> updatedPackages) {
|
||||||
Slog.i(TAG, "Updating pinned files.");
|
ApplicationInfo cameraInfo = getCameraInfo(UserHandle.USER_SYSTEM);
|
||||||
mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, UserHandle.USER_SYSTEM, 0)
|
if (cameraInfo != null && updatedPackages.contains(cameraInfo.packageName)) {
|
||||||
.sendToTarget();
|
Slog.i(TAG, "Updating pinned files.");
|
||||||
|
mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, UserHandle.USER_SYSTEM, 0)
|
||||||
|
.sendToTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
|
|
||||||
mAbortPostBootUpdate.set(false);
|
mAbortPostBootUpdate.set(false);
|
||||||
|
|
||||||
|
ArraySet<String> updatedPackages = new ArraySet<>();
|
||||||
for (String pkg : pkgs) {
|
for (String pkg : pkgs) {
|
||||||
if (mAbortPostBootUpdate.get()) {
|
if (mAbortPostBootUpdate.get()) {
|
||||||
// JobScheduler requested an early abort.
|
// JobScheduler requested an early abort.
|
||||||
@@ -210,11 +211,15 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
// Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
|
// Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
|
||||||
// behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
|
// behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
|
||||||
// trade-off worth doing to save boot time work.
|
// trade-off worth doing to save boot time work.
|
||||||
pm.performDexOpt(pkg,
|
int result = pm.performDexOptWithStatus(pkg,
|
||||||
/* checkProfiles */ false,
|
/* checkProfiles */ false,
|
||||||
PackageManagerService.REASON_BOOT,
|
PackageManagerService.REASON_BOOT,
|
||||||
/* force */ false);
|
/* force */ false);
|
||||||
|
if (result == PackageDexOptimizer.DEX_OPT_PERFORMED) {
|
||||||
|
updatedPackages.add(pkg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
notifyPinService(updatedPackages);
|
||||||
// Ran to completion, so we abandon our timeslice and do not reschedule.
|
// Ran to completion, so we abandon our timeslice and do not reschedule.
|
||||||
jobFinished(jobParams, /* reschedule */ false);
|
jobFinished(jobParams, /* reschedule */ false);
|
||||||
}
|
}
|
||||||
@@ -267,6 +272,7 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
private int optimizePackages(PackageManagerService pm, ArraySet<String> pkgs,
|
private int optimizePackages(PackageManagerService pm, ArraySet<String> pkgs,
|
||||||
long lowStorageThreshold, boolean is_for_primary_dex,
|
long lowStorageThreshold, boolean is_for_primary_dex,
|
||||||
ArraySet<String> failedPackageNames) {
|
ArraySet<String> failedPackageNames) {
|
||||||
|
ArraySet<String> updatedPackages = new ArraySet<>();
|
||||||
for (String pkg : pkgs) {
|
for (String pkg : pkgs) {
|
||||||
int abort_code = abortIdleOptimizations(lowStorageThreshold);
|
int abort_code = abortIdleOptimizations(lowStorageThreshold);
|
||||||
if (abort_code != OPTIMIZE_CONTINUE) {
|
if (abort_code != OPTIMIZE_CONTINUE) {
|
||||||
@@ -286,14 +292,21 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
|
|
||||||
// Optimize package if needed. Note that there can be no race between
|
// Optimize package if needed. Note that there can be no race between
|
||||||
// concurrent jobs because PackageDexOptimizer.performDexOpt is synchronized.
|
// concurrent jobs because PackageDexOptimizer.performDexOpt is synchronized.
|
||||||
boolean success = is_for_primary_dex
|
boolean success;
|
||||||
? pm.performDexOpt(pkg,
|
if (is_for_primary_dex) {
|
||||||
/* checkProfiles */ true,
|
int result = pm.performDexOptWithStatus(pkg,
|
||||||
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
/* checkProfiles */ true,
|
||||||
/* force */ false)
|
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
||||||
: pm.performDexOptSecondary(pkg,
|
/* force */ false);
|
||||||
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
success = result != PackageDexOptimizer.DEX_OPT_FAILED;
|
||||||
/* force */ false);
|
if (result == PackageDexOptimizer.DEX_OPT_PERFORMED) {
|
||||||
|
updatedPackages.add(pkg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = pm.performDexOptSecondary(pkg,
|
||||||
|
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
||||||
|
/* force */ false);
|
||||||
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
// Dexopt succeeded, remove package from the list of failing ones.
|
// Dexopt succeeded, remove package from the list of failing ones.
|
||||||
synchronized (failedPackageNames) {
|
synchronized (failedPackageNames) {
|
||||||
@@ -301,6 +314,7 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyPinService(updatedPackages);
|
||||||
return OPTIMIZE_PROCESSED;
|
return OPTIMIZE_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,12 +389,6 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
result = runIdleOptimization(params, pm, pkgs);
|
result = runIdleOptimization(params, pm, pkgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
PinnerService pinnerService = (PinnerService) LocalServices.getService(PinnerService.class);
|
|
||||||
if (pinnerService != null) {
|
|
||||||
Log.i(TAG, "Pinning optimized code");
|
|
||||||
pinnerService.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,4 +405,12 @@ public class BackgroundDexOptService extends JobService {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyPinService(ArraySet<String> updatedPackages) {
|
||||||
|
PinnerService pinnerService = LocalServices.getService(PinnerService.class);
|
||||||
|
if (pinnerService != null) {
|
||||||
|
Log.i(TAG, "Pinning optimized code " + updatedPackages);
|
||||||
|
pinnerService.update(updatedPackages);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9132,9 +9132,20 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public boolean performDexOpt(String packageName,
|
public boolean performDexOpt(String packageName,
|
||||||
boolean checkProfiles, int compileReason, boolean force) {
|
boolean checkProfiles, int compileReason, boolean force) {
|
||||||
int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
|
return performDexOptWithStatus(packageName, checkProfiles, compileReason, force) !=
|
||||||
|
PackageDexOptimizer.DEX_OPT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform dexopt on the given package and return one of following result:
|
||||||
|
* {@link PackageDexOptimizer#DEX_OPT_SKIPPED}
|
||||||
|
* {@link PackageDexOptimizer#DEX_OPT_PERFORMED}
|
||||||
|
* {@link PackageDexOptimizer#DEX_OPT_FAILED}
|
||||||
|
*/
|
||||||
|
/* package */ int performDexOptWithStatus(String packageName,
|
||||||
|
boolean checkProfiles, int compileReason, boolean force) {
|
||||||
|
return performDexOptTraced(packageName, checkProfiles,
|
||||||
getCompilerFilterForReason(compileReason), force);
|
getCompilerFilterForReason(compileReason), force);
|
||||||
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user