Merge "Fix issue #18607384: Run fstrim after every system update" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
281f36f548
@@ -4539,26 +4539,35 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
try {
|
try {
|
||||||
IMountService ms = PackageHelper.getMountService();
|
IMountService ms = PackageHelper.getMountService();
|
||||||
if (ms != null) {
|
if (ms != null) {
|
||||||
final long interval = android.provider.Settings.Global.getLong(
|
final boolean isUpgrade = isUpgrade();
|
||||||
mContext.getContentResolver(),
|
boolean doTrim = isUpgrade;
|
||||||
android.provider.Settings.Global.FSTRIM_MANDATORY_INTERVAL,
|
if (doTrim) {
|
||||||
DEFAULT_MANDATORY_FSTRIM_INTERVAL);
|
Slog.w(TAG, "Running disk maintenance immediately due to system update");
|
||||||
if (interval > 0) {
|
} else {
|
||||||
final long timeSinceLast = System.currentTimeMillis() - ms.lastMaintenance();
|
final long interval = android.provider.Settings.Global.getLong(
|
||||||
if (timeSinceLast > interval) {
|
mContext.getContentResolver(),
|
||||||
Slog.w(TAG, "No disk maintenance in " + timeSinceLast
|
android.provider.Settings.Global.FSTRIM_MANDATORY_INTERVAL,
|
||||||
+ "; running immediately");
|
DEFAULT_MANDATORY_FSTRIM_INTERVAL);
|
||||||
if (!isFirstBoot()) {
|
if (interval > 0) {
|
||||||
try {
|
final long timeSinceLast = System.currentTimeMillis() - ms.lastMaintenance();
|
||||||
ActivityManagerNative.getDefault().showBootMessage(
|
if (timeSinceLast > interval) {
|
||||||
mContext.getResources().getString(
|
doTrim = true;
|
||||||
R.string.android_upgrading_fstrim), true);
|
Slog.w(TAG, "No disk maintenance in " + timeSinceLast
|
||||||
} catch (RemoteException e) {
|
+ "; running immediately");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ms.runMaintenance();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (doTrim) {
|
||||||
|
if (!isFirstBoot()) {
|
||||||
|
try {
|
||||||
|
ActivityManagerNative.getDefault().showBootMessage(
|
||||||
|
mContext.getResources().getString(
|
||||||
|
R.string.android_upgrading_fstrim), true);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ms.runMaintenance();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Slog.e(TAG, "Mount service unavailable!");
|
Slog.e(TAG, "Mount service unavailable!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user