am ae214fac: am 7123bd69: Merge "Use VMRuntime.isBootClassPathOnDisk" into lmp-dev

* commit 'ae214fac0fa3887c41b1b16a0016a4e6f5b127b1':
  Use VMRuntime.isBootClassPathOnDisk
This commit is contained in:
Brian Carlstrom
2014-10-01 15:16:27 +00:00
committed by Android Git Automerger
4 changed files with 53 additions and 11 deletions

View File

@@ -1697,6 +1697,7 @@
<java-symbol type="string" name="launch_warning_replace" />
<java-symbol type="string" name="launch_warning_title" />
<java-symbol type="string" name="low_internal_storage_view_text" />
<java-symbol type="string" name="low_internal_storage_view_text_no_boot" />
<java-symbol type="string" name="low_internal_storage_view_title" />
<java-symbol type="string" name="notification_listener_binding_label" />
<java-symbol type="string" name="condition_provider_service_binding_label" />

View File

@@ -4729,6 +4729,18 @@ public class PackageManagerService extends IPackageManager.Stub {
return dexCodeInstructionSets.toArray(new String[dexCodeInstructionSets.size()]);
}
/**
* Returns deduplicated list of supported instructions for dex code.
*/
public static String[] getAllDexCodeInstructionSets() {
String[] supportedInstructionSets = new String[Build.SUPPORTED_ABIS.length];
for (int i = 0; i < supportedInstructionSets.length; i++) {
String abi = Build.SUPPORTED_ABIS[i];
supportedInstructionSets[i] = VMRuntime.getInstructionSet(abi);
}
return getDexCodeInstructionSets(supportedInstructionSets);
}
@Override
public void forceDexOpt(String packageName) {
enforceSystemOrRoot("forceDexOpt");

View File

@@ -18,6 +18,7 @@ package com.android.server.storage;
import com.android.server.EventLogTags;
import com.android.server.SystemService;
import com.android.server.pm.PackageManagerService;
import android.app.Notification;
import android.app.NotificationManager;
@@ -51,6 +52,8 @@ import java.io.File;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import dalvik.system.VMRuntime;
/**
* This class implements a service to monitor the amount of disk
* storage space on the device. If the free storage on device is less
@@ -89,6 +92,7 @@ public class DeviceStorageMonitorService extends SystemService {
private long mLastReportedFreeMemTime;
boolean mLowMemFlag=false;
private boolean mMemFullFlag=false;
private final boolean mIsBootImageOnDisk;
private final ContentResolver mResolver;
private final long mTotalMemory; // on /data
private final StatFs mDataFileStats;
@@ -285,6 +289,10 @@ public class DeviceStorageMonitorService extends SystemService {
mLowMemFlag = false;
}
}
if (!mLowMemFlag && !mIsBootImageOnDisk) {
Slog.i(TAG, "No boot image on disk due to lack of space. Sending notification");
sendNotification();
}
if (mFreeMem < mMemFullThreshold) {
if (!mMemFullFlag) {
sendFullNotification();
@@ -314,6 +322,7 @@ public class DeviceStorageMonitorService extends SystemService {
super(context);
mLastReportedFreeMemTime = 0;
mResolver = context.getContentResolver();
mIsBootImageOnDisk = isBootImageOnDisk();
//create StatFs object
mDataFileStats = new StatFs(DATA_PATH.getAbsolutePath());
mSystemFileStats = new StatFs(SYSTEM_PATH.getAbsolutePath());
@@ -331,6 +340,15 @@ public class DeviceStorageMonitorService extends SystemService {
mStorageNotFullIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
}
private static boolean isBootImageOnDisk() {
for (String instructionSet : PackageManagerService.getAllDexCodeInstructionSets()) {
if (!VMRuntime.isBootClassPathOnDisk(instructionSet)) {
return false;
}
}
return true;
}
/**
* Initializes the disk space threshold value and posts an empty message to
* kickstart the process.
@@ -364,7 +382,7 @@ public class DeviceStorageMonitorService extends SystemService {
@Override
public boolean isMemoryLow() {
return mLowMemFlag;
return mLowMemFlag || !mIsBootImageOnDisk;
}
@Override
@@ -409,6 +427,7 @@ public class DeviceStorageMonitorService extends SystemService {
pw.print(" mLowMemFlag="); pw.print(mLowMemFlag);
pw.print(" mMemFullFlag="); pw.println(mMemFullFlag);
pw.print(" mIsBootImageOnDisk="); pw.print(mIsBootImageOnDisk);
pw.print(" mClearSucceeded="); pw.print(mClearSucceeded);
pw.print(" mClearingCache="); pw.println(mClearingCache);
@@ -445,19 +464,25 @@ public class DeviceStorageMonitorService extends SystemService {
Context.NOTIFICATION_SERVICE);
CharSequence title = context.getText(
com.android.internal.R.string.low_internal_storage_view_title);
CharSequence details = context.getText(
com.android.internal.R.string.low_internal_storage_view_text);
CharSequence details = context.getText(mIsBootImageOnDisk
? com.android.internal.R.string.low_internal_storage_view_text
: com.android.internal.R.string.low_internal_storage_view_text_no_boot);
PendingIntent intent = PendingIntent.getActivityAsUser(context, 0, lowMemIntent, 0,
null, UserHandle.CURRENT);
Notification notification = new Notification();
notification.icon = com.android.internal.R.drawable.stat_notify_disk_full;
notification.tickerText = title;
Notification notification = new Notification.Builder(context)
.setSmallIcon(com.android.internal.R.drawable.stat_notify_disk_full)
.setTicker(title)
.setColor(context.getResources().getColor(
com.android.internal.R.color.system_notification_accent_color))
.setContentTitle(title)
.setContentText(details)
.setContentIntent(intent)
.setStyle(new Notification.BigTextStyle()
.bigText(details))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setCategory(Notification.CATEGORY_SYSTEM)
.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.color = context.getResources().getColor(
com.android.internal.R.color.system_notification_accent_color);
notification.setLatestEventInfo(context, title, details, intent);
notification.visibility = Notification.VISIBILITY_PUBLIC;
notification.category = Notification.CATEGORY_SYSTEM;
mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
UserHandle.ALL);
context.sendStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);

View File

@@ -382,6 +382,10 @@ class UsageStatsDatabase {
File[] files = dir.listFiles();
if (files != null) {
for (File f : files) {
String path = f.getPath();
if (path.endsWith(".bak")) {
f = new File(path.substring(0, path.length() - 4));
}
long beginTime = Long.parseLong(f.getName());
if (beginTime < expiryTime) {
new AtomicFile(f).delete();