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

Commit 6217e37d authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Framework: Prefer android.system.Os over libcore.io.Libcore.os

This is a pure refactoring with no a behavior change other than
that these calls now go through android.system.Os, which immediately
delegates to Libcore.os.

This is a first step towards separating framework (via
android.system.Os) vs. libcore (via Libcore.os) clients of these
low level APIs. Separating these is a prerequisite towards moving
the API parts of android.system into framework, and moving the
rest into a different package in libcore.

Test: Treehugger
Bug: 67901714

Change-Id: Ifd8349ec5416e5693f40dba48fdf2bef651b7d81
Merged-In: Ifd8349ec5416e5693f40dba48fdf2bef651b7d81
parent e994b4b5
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.util.apk;

import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.ArrayMap;
import android.util.Pair;
@@ -59,9 +60,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;

import libcore.io.Libcore;
import libcore.io.Os;

/**
 * APK Signature Scheme v2 verifier.
 *
@@ -994,8 +992,7 @@ public class ApkSignatureSchemeV2Verifier {
     * {@link DataSource#feedIntoMessageDigests(MessageDigest[], long, int) feedIntoMessageDigests}.
     */
    private static final class MemoryMappedFileDataSource implements DataSource {
        private static final Os OS = Libcore.os;
        private static final long MEMORY_PAGE_SIZE_BYTES = OS.sysconf(OsConstants._SC_PAGESIZE);
        private static final long MEMORY_PAGE_SIZE_BYTES = Os.sysconf(OsConstants._SC_PAGESIZE);

        private final FileDescriptor mFd;
        private final long mFilePosition;
@@ -1041,7 +1038,7 @@ public class ApkSignatureSchemeV2Verifier {
            long mmapRegionSize = size + dataStartOffsetInMmapRegion;
            long mmapPtr = 0;
            try {
                mmapPtr = OS.mmap(
                mmapPtr = Os.mmap(
                        0, // let the OS choose the start address of the region in memory
                        mmapRegionSize,
                        OsConstants.PROT_READ,
@@ -1066,7 +1063,7 @@ public class ApkSignatureSchemeV2Verifier {
            } finally {
                if (mmapPtr != 0) {
                    try {
                        OS.munmap(mmapPtr, mmapRegionSize);
                        Os.munmap(mmapPtr, mmapRegionSize);
                    } catch (ErrnoException ignored) {}
                }
            }
+2 −3
Original line number Diff line number Diff line
@@ -15,13 +15,12 @@
 */
package com.android.internal.os;

import android.system.Os;
import android.text.TextUtils;
import android.os.StrictMode;
import android.system.OsConstants;
import android.util.Slog;

import libcore.io.Libcore;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -53,7 +52,7 @@ public class KernelCpuSpeedReader {
                cpuNumber);
        mLastSpeedTimes = new long[numSpeedSteps];
        mDeltaSpeedTimes = new long[numSpeedSteps];
        long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
        long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
        mJiffyMillis = 1000/jiffyHz;
    }

+2 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.FileUtils;
import android.os.Process;
import android.os.StrictMode;
import android.os.SystemClock;
import android.system.Os;
import android.system.OsConstants;
import android.util.Slog;

@@ -294,7 +295,7 @@ public class ProcessCpuTracker {

    public ProcessCpuTracker(boolean includeThreads) {
        mIncludeThreads = includeThreads;
        long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
        long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
        mJiffyMillis = 1000/jiffyHz;
    }

+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import dalvik.system.CloseGuard;
import libcore.io.IoUtils;
@@ -72,8 +73,8 @@ public final class PdfEditor {

        final long size;
        try {
            Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
            size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
            Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
            size = Os.fstat(input.getFileDescriptor()).st_size;
        } catch (ErrnoException ee) {
            throw new IllegalArgumentException("file descriptor not seekable");
        }
+3 −3
Original line number Diff line number Diff line
@@ -26,10 +26,10 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import com.android.internal.util.Preconditions;
import dalvik.system.CloseGuard;
import libcore.io.Libcore;

import java.io.IOException;
import java.lang.annotation.Retention;
@@ -154,8 +154,8 @@ public final class PdfRenderer implements AutoCloseable {

        final long size;
        try {
            Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
            size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
            Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
            size = Os.fstat(input.getFileDescriptor()).st_size;
        } catch (ErrnoException ee) {
            throw new IllegalArgumentException("file descriptor not seekable");
        }
Loading