Import Android SDK Platform P [4344336]
/google/data/ro/projects/android/fetch_artifact \
--bid 4344336 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4344336.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: If482fcd4cfaf6c5e544e5574926be25a293e9a6d
diff --git a/android/os/BatteryStats.java b/android/os/BatteryStats.java
index cea5715..66b6b47 100644
--- a/android/os/BatteryStats.java
+++ b/android/os/BatteryStats.java
@@ -53,6 +53,8 @@
private static final String TAG = "BatteryStats";
private static final boolean LOCAL_LOGV = false;
+ /** Fetching RPM stats is too slow to do each time screen changes, so disable it. */
+ protected static final boolean SCREEN_OFF_RPM_STATS_ENABLED = false;
/** @hide */
public static final String SERVICE_NAME = "batterystats";
@@ -213,8 +215,10 @@
* - Fixed bugs in background timers and BLE scan time
* New in version 25:
* - Package wakeup alarms are now on screen-off timebase
+ * New in version 26:
+ * - Resource power manager (rpm) states [but screenOffRpm is disabled from working properly]
*/
- static final String CHECKIN_VERSION = "25";
+ static final String CHECKIN_VERSION = "26";
/**
* Old version, we hit 9 and ran out of room, need to remove.
@@ -233,6 +237,10 @@
private static final String CPU_DATA = "cpu";
private static final String GLOBAL_CPU_FREQ_DATA = "gcf";
private static final String CPU_TIMES_AT_FREQ_DATA = "ctf";
+ // rpm line is:
+ // BATTERY_STATS_CHECKIN_VERSION, uid, which, "rpm", state/voter name, total time, total count,
+ // screen-off time, screen-off count
+ private static final String RESOURCE_POWER_MANAGER_DATA = "rpm";
private static final String SENSOR_DATA = "sr";
private static final String VIBRATOR_DATA = "vib";
private static final String FOREGROUND_ACTIVITY_DATA = "fg";
@@ -2648,6 +2656,16 @@
public abstract Map<String, ? extends Timer> getKernelWakelockStats();
+ /**
+ * Returns Timers tracking the total time of each Resource Power Manager state and voter.
+ */
+ public abstract Map<String, ? extends Timer> getRpmStats();
+ /**
+ * Returns Timers tracking the screen-off time of each Resource Power Manager state and voter.
+ */
+ public abstract Map<String, ? extends Timer> getScreenOffRpmStats();
+
+
public abstract LongSparseArray<? extends Timer> getKernelMemoryStats();
public abstract void writeToParcelWithoutUids(Parcel out, int flags);
@@ -3309,6 +3327,30 @@
}
}
+ final Map<String, ? extends Timer> rpmStats = getRpmStats();
+ final Map<String, ? extends Timer> screenOffRpmStats = getScreenOffRpmStats();
+ if (rpmStats.size() > 0) {
+ for (Map.Entry<String, ? extends Timer> ent : rpmStats.entrySet()) {
+ sb.setLength(0);
+ Timer totalTimer = ent.getValue();
+ long timeMs = (totalTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000;
+ int count = totalTimer.getCountLocked(which);
+ Timer screenOffTimer = screenOffRpmStats.get(ent.getKey());
+ long screenOffTimeMs = screenOffTimer != null
+ ? (screenOffTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : 0;
+ int screenOffCount = screenOffTimer != null
+ ? screenOffTimer.getCountLocked(which) : 0;
+ if (SCREEN_OFF_RPM_STATS_ENABLED) {
+ dumpLine(pw, 0 /* uid */, category, RESOURCE_POWER_MANAGER_DATA,
+ "\"" + ent.getKey() + "\"", timeMs, count, screenOffTimeMs,
+ screenOffCount);
+ } else {
+ dumpLine(pw, 0 /* uid */, category, RESOURCE_POWER_MANAGER_DATA,
+ "\"" + ent.getKey() + "\"", timeMs, count);
+ }
+ }
+ }
+
final BatteryStatsHelper helper = new BatteryStatsHelper(context, false, wifiOnly);
helper.create(this);
helper.refreshStats(which, UserHandle.USER_ALL);
@@ -4570,24 +4612,56 @@
}
final LongSparseArray<? extends Timer> mMemoryStats = getKernelMemoryStats();
- pw.println("Memory Stats");
- for (int i = 0; i < mMemoryStats.size(); i++) {
- sb.setLength(0);
- sb.append("Bandwidth ");
- sb.append(mMemoryStats.keyAt(i));
- sb.append(" Time ");
- sb.append(mMemoryStats.valueAt(i).getTotalTimeLocked(rawRealtime, which));
- pw.println(sb.toString());
+ if (mMemoryStats.size() > 0) {
+ pw.println(" Memory Stats");
+ for (int i = 0; i < mMemoryStats.size(); i++) {
+ sb.setLength(0);
+ sb.append(" Bandwidth ");
+ sb.append(mMemoryStats.keyAt(i));
+ sb.append(" Time ");
+ sb.append(mMemoryStats.valueAt(i).getTotalTimeLocked(rawRealtime, which));
+ pw.println(sb.toString());
+ }
+ pw.println();
+ }
+
+ final Map<String, ? extends Timer> rpmStats = getRpmStats();
+ if (rpmStats.size() > 0) {
+ pw.print(prefix); pw.println(" Resource Power Manager Stats");
+ if (rpmStats.size() > 0) {
+ for (Map.Entry<String, ? extends Timer> ent : rpmStats.entrySet()) {
+ final String timerName = ent.getKey();
+ final Timer timer = ent.getValue();
+ printTimer(pw, sb, timer, rawRealtime, which, prefix, timerName);
+ }
+ }
+ pw.println();
+ }
+ if (SCREEN_OFF_RPM_STATS_ENABLED) {
+ final Map<String, ? extends Timer> screenOffRpmStats = getScreenOffRpmStats();
+ if (screenOffRpmStats.size() > 0) {
+ pw.print(prefix);
+ pw.println(" Resource Power Manager Stats for when screen was off");
+ if (screenOffRpmStats.size() > 0) {
+ for (Map.Entry<String, ? extends Timer> ent : screenOffRpmStats.entrySet()) {
+ final String timerName = ent.getKey();
+ final Timer timer = ent.getValue();
+ printTimer(pw, sb, timer, rawRealtime, which, prefix, timerName);
+ }
+ }
+ pw.println();
+ }
}
final long[] cpuFreqs = getCpuFreqs();
if (cpuFreqs != null) {
sb.setLength(0);
- sb.append("CPU freqs:");
+ sb.append(" CPU freqs:");
for (int i = 0; i < cpuFreqs.length; ++i) {
sb.append(" " + cpuFreqs[i]);
}
pw.println(sb.toString());
+ pw.println();
}
for (int iu=0; iu<NU; iu++) {
diff --git a/android/os/Process.java b/android/os/Process.java
index 9351661..b5d62e5 100644
--- a/android/os/Process.java
+++ b/android/os/Process.java
@@ -19,8 +19,8 @@
import android.annotation.TestApi;
import android.system.Os;
import android.system.OsConstants;
-import android.util.Log;
import android.webkit.WebViewZygote;
+
import dalvik.system.VMRuntime;
/**
@@ -423,7 +423,7 @@
*
* When invokeWith is not null, the process will be started as a fresh app
* and not a zygote fork. Note that this is only allowed for uid 0 or when
- * debugFlags contains DEBUG_ENABLE_DEBUGGER.
+ * runtimeFlags contains DEBUG_ENABLE_DEBUGGER.
*
* @param processClass The class to use as the process's main entry
* point.
@@ -431,7 +431,7 @@
* @param uid The user-id under which the process will run.
* @param gid The group-id under which the process will run.
* @param gids Additional group-ids associated with the process.
- * @param debugFlags Additional flags.
+ * @param runtimeFlags Additional flags for the runtime.
* @param targetSdkVersion The target SDK version for the app.
* @param seInfo null-ok SELinux information for the new process.
* @param abi non-null the ABI this app should be started with.
@@ -448,7 +448,7 @@
public static final ProcessStartResult start(final String processClass,
final String niceName,
int uid, int gid, int[] gids,
- int debugFlags, int mountExternal,
+ int runtimeFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
String abi,
@@ -457,7 +457,7 @@
String invokeWith,
String[] zygoteArgs) {
return zygoteProcess.start(processClass, niceName, uid, gid, gids,
- debugFlags, mountExternal, targetSdkVersion, seInfo,
+ runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
}
@@ -465,7 +465,7 @@
public static final ProcessStartResult startWebView(final String processClass,
final String niceName,
int uid, int gid, int[] gids,
- int debugFlags, int mountExternal,
+ int runtimeFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
String abi,
@@ -474,7 +474,7 @@
String invokeWith,
String[] zygoteArgs) {
return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids,
- debugFlags, mountExternal, targetSdkVersion, seInfo,
+ runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
}
diff --git a/android/os/ServiceManager.java b/android/os/ServiceManager.java
index e11494d..34c7845 100644
--- a/android/os/ServiceManager.java
+++ b/android/os/ServiceManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,114 +16,44 @@
package android.os;
-import android.util.Log;
-
-import com.android.internal.os.BinderInternal;
-
-import java.util.HashMap;
import java.util.Map;
-/** @hide */
public final class ServiceManager {
- private static final String TAG = "ServiceManager";
-
- private static IServiceManager sServiceManager;
- private static HashMap<String, IBinder> sCache = new HashMap<String, IBinder>();
-
- private static IServiceManager getIServiceManager() {
- if (sServiceManager != null) {
- return sServiceManager;
- }
-
- // Find the service manager
- sServiceManager = ServiceManagerNative
- .asInterface(Binder.allowBlocking(BinderInternal.getContextObject()));
- return sServiceManager;
- }
/**
* Returns a reference to a service with the given name.
- *
+ *
* @param name the name of the service to get
* @return a reference to the service, or <code>null</code> if the service doesn't exist
*/
public static IBinder getService(String name) {
- try {
- IBinder service = sCache.get(name);
- if (service != null) {
- return service;
- } else {
- return Binder.allowBlocking(getIServiceManager().getService(name));
- }
- } catch (RemoteException e) {
- Log.e(TAG, "error in getService", e);
- }
return null;
}
/**
- * Returns a reference to a service with the given name, or throws
- * {@link NullPointerException} if none is found.
- *
- * @hide
+ * Is not supposed to return null, but that is fine for layoutlib.
*/
public static IBinder getServiceOrThrow(String name) throws ServiceNotFoundException {
- final IBinder binder = getService(name);
- if (binder != null) {
- return binder;
- } else {
- throw new ServiceNotFoundException(name);
- }
+ throw new ServiceNotFoundException(name);
}
/**
* Place a new @a service called @a name into the service
* manager.
- *
+ *
* @param name the name of the new service
* @param service the service object
*/
public static void addService(String name, IBinder service) {
- try {
- getIServiceManager().addService(name, service, false);
- } catch (RemoteException e) {
- Log.e(TAG, "error in addService", e);
- }
+ // pass
}
/**
- * Place a new @a service called @a name into the service
- * manager.
- *
- * @param name the name of the new service
- * @param service the service object
- * @param allowIsolated set to true to allow isolated sandboxed processes
- * to access this service
- */
- public static void addService(String name, IBinder service, boolean allowIsolated) {
- try {
- getIServiceManager().addService(name, service, allowIsolated);
- } catch (RemoteException e) {
- Log.e(TAG, "error in addService", e);
- }
- }
-
- /**
* Retrieve an existing service called @a name from the
* service manager. Non-blocking.
*/
public static IBinder checkService(String name) {
- try {
- IBinder service = sCache.get(name);
- if (service != null) {
- return service;
- } else {
- return Binder.allowBlocking(getIServiceManager().checkService(name));
- }
- } catch (RemoteException e) {
- Log.e(TAG, "error in checkService", e);
- return null;
- }
+ return null;
}
/**
@@ -132,27 +62,21 @@
* case of an exception
*/
public static String[] listServices() {
- try {
- return getIServiceManager().listServices();
- } catch (RemoteException e) {
- Log.e(TAG, "error in listServices", e);
- return null;
- }
+ // actual implementation returns null sometimes, so it's ok
+ // to return null instead of an empty list.
+ return null;
}
/**
* This is only intended to be called when the process is first being brought
* up and bound by the activity manager. There is only one thread in the process
* at that time, so no locking is done.
- *
+ *
* @param cache the cache of service references
* @hide
*/
public static void initServiceCache(Map<String, IBinder> cache) {
- if (sCache.size() != 0) {
- throw new IllegalStateException("setServiceCache may only be called once");
- }
- sCache.putAll(cache);
+ // pass
}
/**
@@ -163,6 +87,7 @@
* @hide
*/
public static class ServiceNotFoundException extends Exception {
+ // identical to the original implementation
public ServiceNotFoundException(String name) {
super("No service published for: " + name);
}
diff --git a/android/os/StrictMode.java b/android/os/StrictMode.java
index 615d3c4..f02631c 100644
--- a/android/os/StrictMode.java
+++ b/android/os/StrictMode.java
@@ -722,7 +722,7 @@
}
/**
- * Detect when an {@link java.io.Closeable} or other object with a explict termination
+ * Detect when an {@link java.io.Closeable} or other object with an explicit termination
* method is finalized without having been closed.
*
* <p>You always want to explicitly close such objects to avoid unnecessary resources
diff --git a/android/os/ZygoteProcess.java b/android/os/ZygoteProcess.java
index 7a13ee8..670f794 100644
--- a/android/os/ZygoteProcess.java
+++ b/android/os/ZygoteProcess.java
@@ -20,9 +20,11 @@
import android.net.LocalSocketAddress;
import android.util.Log;
import android.util.Slog;
+
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.Zygote;
import com.android.internal.util.Preconditions;
+
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.IOException;
@@ -173,7 +175,7 @@
*
* When invokeWith is not null, the process will be started as a fresh app
* and not a zygote fork. Note that this is only allowed for uid 0 or when
- * debugFlags contains DEBUG_ENABLE_DEBUGGER.
+ * runtimeFlags contains DEBUG_ENABLE_DEBUGGER.
*
* @param processClass The class to use as the process's main entry
* point.
@@ -181,7 +183,7 @@
* @param uid The user-id under which the process will run.
* @param gid The group-id under which the process will run.
* @param gids Additional group-ids associated with the process.
- * @param debugFlags Additional flags.
+ * @param runtimeFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
* @param seInfo null-ok SELinux information for the new process.
* @param abi non-null the ABI this app should be started with.
@@ -196,7 +198,7 @@
public final Process.ProcessStartResult start(final String processClass,
final String niceName,
int uid, int gid, int[] gids,
- int debugFlags, int mountExternal,
+ int runtimeFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
String abi,
@@ -206,7 +208,7 @@
String[] zygoteArgs) {
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
- debugFlags, mountExternal, targetSdkVersion, seInfo,
+ runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG,
@@ -317,7 +319,7 @@
* @param gid a POSIX gid that the new process shuold setgid() to
* @param gids null-ok; a list of supplementary group IDs that the
* new process should setgroup() to.
- * @param debugFlags Additional flags.
+ * @param runtimeFlags Additional flags for the runtime.
* @param targetSdkVersion The target SDK version for the app.
* @param seInfo null-ok SELinux information for the new process.
* @param abi the ABI the process should use.
@@ -331,7 +333,7 @@
final String niceName,
final int uid, final int gid,
final int[] gids,
- int debugFlags, int mountExternal,
+ int runtimeFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
String abi,
@@ -347,33 +349,7 @@
argsForZygote.add("--runtime-args");
argsForZygote.add("--setuid=" + uid);
argsForZygote.add("--setgid=" + gid);
- if ((debugFlags & Zygote.DEBUG_ENABLE_JNI_LOGGING) != 0) {
- argsForZygote.add("--enable-jni-logging");
- }
- if ((debugFlags & Zygote.DEBUG_ENABLE_SAFEMODE) != 0) {
- argsForZygote.add("--enable-safemode");
- }
- if ((debugFlags & Zygote.DEBUG_ENABLE_JDWP) != 0) {
- argsForZygote.add("--enable-jdwp");
- }
- if ((debugFlags & Zygote.DEBUG_ENABLE_CHECKJNI) != 0) {
- argsForZygote.add("--enable-checkjni");
- }
- if ((debugFlags & Zygote.DEBUG_GENERATE_DEBUG_INFO) != 0) {
- argsForZygote.add("--generate-debug-info");
- }
- if ((debugFlags & Zygote.DEBUG_ALWAYS_JIT) != 0) {
- argsForZygote.add("--always-jit");
- }
- if ((debugFlags & Zygote.DEBUG_NATIVE_DEBUGGABLE) != 0) {
- argsForZygote.add("--native-debuggable");
- }
- if ((debugFlags & Zygote.DEBUG_JAVA_DEBUGGABLE) != 0) {
- argsForZygote.add("--java-debuggable");
- }
- if ((debugFlags & Zygote.DEBUG_ENABLE_ASSERT) != 0) {
- argsForZygote.add("--enable-assert");
- }
+ argsForZygote.add("--runtime-flags=" + runtimeFlags);
if (mountExternal == Zygote.MOUNT_EXTERNAL_DEFAULT) {
argsForZygote.add("--mount-external-default");
} else if (mountExternal == Zygote.MOUNT_EXTERNAL_READ) {
diff --git a/android/os/storage/StorageManager.java b/android/os/storage/StorageManager.java
index 7036346..6594cd0 100644
--- a/android/os/storage/StorageManager.java
+++ b/android/os/storage/StorageManager.java
@@ -221,8 +221,6 @@
/** {@hide} */
public static final int FSTRIM_FLAG_DEEP = IVold.FSTRIM_FLAG_DEEP_TRIM;
- /** {@hide} */
- public static final int FSTRIM_FLAG_BENCHMARK = IVold.FSTRIM_FLAG_BENCHMARK_AFTER;
/** @hide The volume is not encrypted. */
public static final int ENCRYPTION_STATE_NONE =
diff --git a/android/os/storage/VolumeInfo.java b/android/os/storage/VolumeInfo.java
index b8353d7..76f79f1 100644
--- a/android/os/storage/VolumeInfo.java
+++ b/android/os/storage/VolumeInfo.java
@@ -76,21 +76,21 @@
/** Real volume representing internal emulated storage */
public static final String ID_EMULATED_INTERNAL = "emulated";
- public static final int TYPE_PUBLIC = IVold.TYPE_PUBLIC;
- public static final int TYPE_PRIVATE = IVold.TYPE_PRIVATE;
- public static final int TYPE_EMULATED = IVold.TYPE_EMULATED;
- public static final int TYPE_ASEC = IVold.TYPE_ASEC;
- public static final int TYPE_OBB = IVold.TYPE_OBB;
+ public static final int TYPE_PUBLIC = IVold.VOLUME_TYPE_PUBLIC;
+ public static final int TYPE_PRIVATE = IVold.VOLUME_TYPE_PRIVATE;
+ public static final int TYPE_EMULATED = IVold.VOLUME_TYPE_EMULATED;
+ public static final int TYPE_ASEC = IVold.VOLUME_TYPE_ASEC;
+ public static final int TYPE_OBB = IVold.VOLUME_TYPE_OBB;
- public static final int STATE_UNMOUNTED = IVold.STATE_UNMOUNTED;
- public static final int STATE_CHECKING = IVold.STATE_CHECKING;
- public static final int STATE_MOUNTED = IVold.STATE_MOUNTED;
- public static final int STATE_MOUNTED_READ_ONLY = IVold.STATE_MOUNTED_READ_ONLY;
- public static final int STATE_FORMATTING = IVold.STATE_FORMATTING;
- public static final int STATE_EJECTING = IVold.STATE_EJECTING;
- public static final int STATE_UNMOUNTABLE = IVold.STATE_UNMOUNTABLE;
- public static final int STATE_REMOVED = IVold.STATE_REMOVED;
- public static final int STATE_BAD_REMOVAL = IVold.STATE_BAD_REMOVAL;
+ public static final int STATE_UNMOUNTED = IVold.VOLUME_STATE_UNMOUNTED;
+ public static final int STATE_CHECKING = IVold.VOLUME_STATE_CHECKING;
+ public static final int STATE_MOUNTED = IVold.VOLUME_STATE_MOUNTED;
+ public static final int STATE_MOUNTED_READ_ONLY = IVold.VOLUME_STATE_MOUNTED_READ_ONLY;
+ public static final int STATE_FORMATTING = IVold.VOLUME_STATE_FORMATTING;
+ public static final int STATE_EJECTING = IVold.VOLUME_STATE_EJECTING;
+ public static final int STATE_UNMOUNTABLE = IVold.VOLUME_STATE_UNMOUNTABLE;
+ public static final int STATE_REMOVED = IVold.VOLUME_STATE_REMOVED;
+ public static final int STATE_BAD_REMOVAL = IVold.VOLUME_STATE_BAD_REMOVAL;
public static final int MOUNT_FLAG_PRIMARY = IVold.MOUNT_FLAG_PRIMARY;
public static final int MOUNT_FLAG_VISIBLE = IVold.MOUNT_FLAG_VISIBLE;