Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7123bd69 authored by Brian Carlstrom's avatar Brian Carlstrom Committed by Android (Google) Code Review
Browse files

Merge "Use VMRuntime.isBootClassPathOnDisk" into lmp-dev

parents 1ed09f9b a39871ef
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1696,6 +1696,7 @@
  <java-symbol type="string" name="launch_warning_replace" />
  <java-symbol type="string" name="launch_warning_replace" />
  <java-symbol type="string" name="launch_warning_title" />
  <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" />
  <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="low_internal_storage_view_title" />
  <java-symbol type="string" name="notification_listener_binding_label" />
  <java-symbol type="string" name="notification_listener_binding_label" />
  <java-symbol type="string" name="condition_provider_service_binding_label" />
  <java-symbol type="string" name="condition_provider_service_binding_label" />
+12 −0
Original line number Original line Diff line number Diff line
@@ -4729,6 +4729,18 @@ public class PackageManagerService extends IPackageManager.Stub {
        return dexCodeInstructionSets.toArray(new String[dexCodeInstructionSets.size()]);
        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
    @Override
    public void forceDexOpt(String packageName) {
    public void forceDexOpt(String packageName) {
        enforceSystemOrRoot("forceDexOpt");
        enforceSystemOrRoot("forceDexOpt");
+36 −11
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.storage;


import com.android.server.EventLogTags;
import com.android.server.EventLogTags;
import com.android.server.SystemService;
import com.android.server.SystemService;
import com.android.server.pm.PackageManagerService;


import android.app.Notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.NotificationManager;
@@ -51,6 +52,8 @@ import java.io.File;
import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;


import dalvik.system.VMRuntime;

/**
/**
 * This class implements a service to monitor the amount of disk
 * This class implements a service to monitor the amount of disk
 * storage space on the device.  If the free storage on device is less
 * 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;
    private long mLastReportedFreeMemTime;
    boolean mLowMemFlag=false;
    boolean mLowMemFlag=false;
    private boolean mMemFullFlag=false;
    private boolean mMemFullFlag=false;
    private final boolean mIsBootImageOnDisk;
    private final ContentResolver mResolver;
    private final ContentResolver mResolver;
    private final long mTotalMemory;  // on /data
    private final long mTotalMemory;  // on /data
    private final StatFs mDataFileStats;
    private final StatFs mDataFileStats;
@@ -285,6 +289,10 @@ public class DeviceStorageMonitorService extends SystemService {
                    mLowMemFlag = false;
                    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 (mFreeMem < mMemFullThreshold) {
                if (!mMemFullFlag) {
                if (!mMemFullFlag) {
                    sendFullNotification();
                    sendFullNotification();
@@ -314,6 +322,7 @@ public class DeviceStorageMonitorService extends SystemService {
        super(context);
        super(context);
        mLastReportedFreeMemTime = 0;
        mLastReportedFreeMemTime = 0;
        mResolver = context.getContentResolver();
        mResolver = context.getContentResolver();
        mIsBootImageOnDisk = isBootImageOnDisk();
        //create StatFs object
        //create StatFs object
        mDataFileStats = new StatFs(DATA_PATH.getAbsolutePath());
        mDataFileStats = new StatFs(DATA_PATH.getAbsolutePath());
        mSystemFileStats = new StatFs(SYSTEM_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);
        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
    * Initializes the disk space threshold value and posts an empty message to
    * kickstart the process.
    * kickstart the process.
@@ -364,7 +382,7 @@ public class DeviceStorageMonitorService extends SystemService {


        @Override
        @Override
        public boolean isMemoryLow() {
        public boolean isMemoryLow() {
            return mLowMemFlag;
            return mLowMemFlag || !mIsBootImageOnDisk;
        }
        }


        @Override
        @Override
@@ -409,6 +427,7 @@ public class DeviceStorageMonitorService extends SystemService {


        pw.print("  mLowMemFlag="); pw.print(mLowMemFlag);
        pw.print("  mLowMemFlag="); pw.print(mLowMemFlag);
        pw.print(" mMemFullFlag="); pw.println(mMemFullFlag);
        pw.print(" mMemFullFlag="); pw.println(mMemFullFlag);
        pw.print(" mIsBootImageOnDisk="); pw.print(mIsBootImageOnDisk);


        pw.print("  mClearSucceeded="); pw.print(mClearSucceeded);
        pw.print("  mClearSucceeded="); pw.print(mClearSucceeded);
        pw.print(" mClearingCache="); pw.println(mClearingCache);
        pw.print(" mClearingCache="); pw.println(mClearingCache);
@@ -445,19 +464,25 @@ public class DeviceStorageMonitorService extends SystemService {
                        Context.NOTIFICATION_SERVICE);
                        Context.NOTIFICATION_SERVICE);
        CharSequence title = context.getText(
        CharSequence title = context.getText(
                com.android.internal.R.string.low_internal_storage_view_title);
                com.android.internal.R.string.low_internal_storage_view_title);
        CharSequence details = context.getText(
        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
                : com.android.internal.R.string.low_internal_storage_view_text_no_boot);
        PendingIntent intent = PendingIntent.getActivityAsUser(context, 0,  lowMemIntent, 0,
        PendingIntent intent = PendingIntent.getActivityAsUser(context, 0,  lowMemIntent, 0,
                null, UserHandle.CURRENT);
                null, UserHandle.CURRENT);
        Notification notification = new Notification();
        Notification notification = new Notification.Builder(context)
        notification.icon = com.android.internal.R.drawable.stat_notify_disk_full;
                .setSmallIcon(com.android.internal.R.drawable.stat_notify_disk_full)
        notification.tickerText = title;
                .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.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,
        mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
                UserHandle.ALL);
                UserHandle.ALL);
        context.sendStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
        context.sendStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
+4 −0
Original line number Original line Diff line number Diff line
@@ -382,6 +382,10 @@ class UsageStatsDatabase {
        File[] files = dir.listFiles();
        File[] files = dir.listFiles();
        if (files != null) {
        if (files != null) {
            for (File f : files) {
            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());
                long beginTime = Long.parseLong(f.getName());
                if (beginTime < expiryTime) {
                if (beginTime < expiryTime) {
                    new AtomicFile(f).delete();
                    new AtomicFile(f).delete();