summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/Context.java20
-rw-r--r--core/java/android/os/Environment.java23
-rw-r--r--core/java/android/os/Trace.java56
-rw-r--r--core/java/android/view/Surface.java8
-rw-r--r--core/java/android/view/ViewRootImpl.java12
-rw-r--r--core/java/android/webkit/AccessibilityInjector.java2
6 files changed, 105 insertions, 16 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 201b43f..7aa2507 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -33,6 +33,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.AttributeSet;
import android.view.CompatibilityInfoHolder;
import android.view.Display;
@@ -587,6 +588,10 @@ public abstract class Context {
* can read and write files placed here.
* </ul>
*
+ * <p>On devices with multiple users (as described by {@link UserManager}),
+ * each user has their own isolated external storage. Applications only
+ * have access to the external storage for the user they're running as.</p>
+ *
* <p>Here is an example of typical code to manipulate a file in
* an application's private storage:</p>
*
@@ -616,6 +621,9 @@ public abstract class Context {
* {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
* private_picture}
*
+ * <p>Writing to this path requires the
+ * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
+ *
* @param type The type of files directory to return. May be null for
* the root of the files directory or one of
* the following Environment constants for a subdirectory:
@@ -641,6 +649,11 @@ public abstract class Context {
* Return the directory where this application's OBB files (if there
* are any) can be found. Note if the application does not have any OBB
* files, this directory may not exist.
+ *
+ * <p>On devices with multiple users (as described by {@link UserManager}),
+ * multiple users may share the same OBB storage location. Applications
+ * should ensure that multiple instances running under different users
+ * don't interfere with each other.</p>
*/
public abstract File getObbDir();
@@ -689,6 +702,13 @@ public abstract class Context {
* can read and write files placed here.
* </ul>
*
+ * <p>On devices with multiple users (as described by {@link UserManager}),
+ * each user has their own isolated external storage. Applications only
+ * have access to the external storage for the user they're running as.</p>
+ *
+ * <p>Writing to this path requires the
+ * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
+ *
* @return Returns the path of the directory holding application cache files
* on external storage. Returns null if external storage is not currently
* mounted so it could not ensure the path exists; you will need to call
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 3315566..88529f8 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -274,6 +274,10 @@ public class Environment {
* built-in storage in a device that is distinct from the protected
* internal storage and can be mounted as a filesystem on a computer.</em></p>
*
+ * <p>On devices with multiple users (as described by {@link UserManager}),
+ * each user has their own isolated external storage. Applications only
+ * have access to the external storage for the user they're running as.</p>
+ *
* <p>In devices with multiple "external" storage directories (such as
* both secure app storage and mountable shared storage), this directory
* represents the "primary" external storage that the user will interact
@@ -286,7 +290,16 @@ public class Environment {
* Context.getExternalFilesDir}, which the system will take care of deleting
* if the application is uninstalled. Other shared files should be placed
* in one of the directories returned by
- * {@link #getExternalStoragePublicDirectory}.
+ * {@link #getExternalStoragePublicDirectory}.</p>
+ *
+ * <p>Writing to this path requires the
+ * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission. In
+ * a future platform release, access to this path will require the
+ * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
+ * which is automatically granted if you hold the write permission.</p>
+ *
+ * <p>This path may change between platform versions, so applications
+ * should only persist relative paths.</p>
*
* <p>Here is an example of typical code to monitor the state of
* external storage:</p>
@@ -423,6 +436,10 @@ public class Environment {
* to ensure you don't erase their files or get in the way of their own
* organization.
*
+ * <p>On devices with multiple users (as described by {@link UserManager}),
+ * each user has their own isolated external storage. Applications only
+ * have access to the external storage for the user they're running as.</p>
+ *
* <p>Here is an example of typical code to manipulate a picture on
* the public external storage:</p>
*
@@ -500,7 +517,7 @@ public class Environment {
}
/**
- * Gets the Android Download/Cache content directory.
+ * Gets the Android download/cache content directory.
*/
public static File getDownloadCacheDirectory() {
return DOWNLOAD_CACHE_DIRECTORY;
@@ -563,7 +580,7 @@ public class Environment {
/**
* Gets the current state of the primary "external" storage device.
*
- * <p>See {@link #getExternalStorageDirectory()} for more information.
+ * @see #getExternalStorageDirectory()
*/
public static String getExternalStorageState() {
try {
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java
index 59d0f7a..ed51818 100644
--- a/core/java/android/os/Trace.java
+++ b/core/java/android/os/Trace.java
@@ -16,6 +16,8 @@
package android.os;
+import android.util.Log;
+
/**
* Writes trace events to the kernel trace buffer. These trace events can be
* collected using the "atrace" program for offline analysis.
@@ -27,6 +29,8 @@ package android.os;
* @hide
*/
public final class Trace {
+ private static final String TAG = "Trace";
+
// These tags must be kept in sync with frameworks/native/include/utils/Trace.h.
public static final long TRACE_TAG_NEVER = 0;
public static final long TRACE_TAG_ALWAYS = 1L << 0;
@@ -49,7 +53,11 @@ public final class Trace {
public static final String PROPERTY_TRACE_TAG_ENABLEFLAGS = "debug.atrace.tags.enableflags";
- private static long sEnabledTags = nativeGetEnabledTags();
+ // This works as a "not ready" flag because TRACE_TAG_ALWAYS is always set.
+ private static final long TRACE_FLAGS_NOT_READY = 0;
+
+ // Must be volatile to avoid word tearing.
+ private static volatile long sEnabledTags = TRACE_FLAGS_NOT_READY;
private static native long nativeGetEnabledTags();
private static native void nativeTraceCounter(long tag, String name, int value);
@@ -57,9 +65,17 @@ public final class Trace {
private static native void nativeTraceEnd(long tag);
static {
+ // We configure two separate change callbacks, one in Trace.cpp and one here. The
+ // native callback reads the tags from the system property, and this callback
+ // reads the value that the native code retrieved. It's essential that the native
+ // callback executes first.
+ //
+ // The system provides ordering through a priority level. Callbacks made through
+ // SystemProperties.addChangeCallback currently have a negative priority, while
+ // our native code is using a priority of zero.
SystemProperties.addChangeCallback(new Runnable() {
@Override public void run() {
- sEnabledTags = nativeGetEnabledTags();
+ cacheEnabledTags();
}
});
}
@@ -68,13 +84,41 @@ public final class Trace {
}
/**
+ * Caches a copy of the enabled-tag bits. The "master" copy is held by the native code,
+ * and comes from the PROPERTY_TRACE_TAG_ENABLEFLAGS property.
+ * <p>
+ * If the native code hasn't yet read the property, we will cause it to do one-time
+ * initialization. We don't want to do this during class init, because this class is
+ * preloaded, so all apps would be stuck with whatever the zygote saw. (The zygote
+ * doesn't see the system-property update broadcasts.)
+ * <p>
+ * We want to defer initialization until the first use by an app, post-zygote.
+ * <p>
+ * We're okay if multiple threads call here simultaneously -- the native state is
+ * synchronized, and sEnabledTags is volatile (prevents word tearing).
+ */
+ private static long cacheEnabledTags() {
+ long tags = nativeGetEnabledTags();
+ if (tags == TRACE_FLAGS_NOT_READY) {
+ Log.w(TAG, "Unexpected value from nativeGetEnabledTags: " + tags);
+ // keep going
+ }
+ sEnabledTags = tags;
+ return tags;
+ }
+
+ /**
* Returns true if a trace tag is enabled.
*
* @param traceTag The trace tag to check.
* @return True if the trace tag is valid.
*/
public static boolean isTagEnabled(long traceTag) {
- return (sEnabledTags & traceTag) != 0;
+ long tags = sEnabledTags;
+ if (tags == TRACE_FLAGS_NOT_READY) {
+ tags = cacheEnabledTags();
+ }
+ return (tags & traceTag) != 0;
}
/**
@@ -85,7 +129,7 @@ public final class Trace {
* @param counterValue The counter value.
*/
public static void traceCounter(long traceTag, String counterName, int counterValue) {
- if ((sEnabledTags & traceTag) != 0) {
+ if (isTagEnabled(traceTag)) {
nativeTraceCounter(traceTag, counterName, counterValue);
}
}
@@ -98,7 +142,7 @@ public final class Trace {
* @param methodName The method name to appear in the trace.
*/
public static void traceBegin(long traceTag, String methodName) {
- if ((sEnabledTags & traceTag) != 0) {
+ if (isTagEnabled(traceTag)) {
nativeTraceBegin(traceTag, methodName);
}
}
@@ -110,7 +154,7 @@ public final class Trace {
* @param traceTag The trace tag.
*/
public static void traceEnd(long traceTag) {
- if ((sEnabledTags & traceTag) != 0) {
+ if (isTagEnabled(traceTag)) {
nativeTraceEnd(traceTag);
}
}
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 183b012..550a740 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -758,6 +758,7 @@ public class Surface implements Parcelable {
public float density;
public float xDpi;
public float yDpi;
+ public boolean secure;
public PhysicalDisplayInfo() {
}
@@ -778,7 +779,8 @@ public class Surface implements Parcelable {
&& refreshRate == other.refreshRate
&& density == other.density
&& xDpi == other.xDpi
- && yDpi == other.yDpi;
+ && yDpi == other.yDpi
+ && secure == other.secure;
}
@Override
@@ -793,13 +795,15 @@ public class Surface implements Parcelable {
density = other.density;
xDpi = other.xDpi;
yDpi = other.yDpi;
+ secure = other.secure;
}
// For debugging purposes
@Override
public String toString() {
return "PhysicalDisplayInfo{" + width + " x " + height + ", " + refreshRate + " fps, "
- + "density " + density + ", " + xDpi + " x " + yDpi + " dpi}";
+ + "density " + density + ", " + xDpi + " x " + yDpi + " dpi, secure " + secure
+ + "}";
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index b96a1c2..cd63f07 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -29,14 +29,12 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
-import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@@ -1424,8 +1422,6 @@ public final class ViewRootImpl implements ViewParent,
layerCanvas.setViewport(mWidth, mHeight);
layerCanvas.onPreDraw(null);
final int restoreCount = layerCanvas.save();
-
- layerCanvas.drawColor(0xff000000, PorterDuff.Mode.SRC);
int yoff;
final boolean scrolling = mScroller != null
@@ -1442,7 +1438,13 @@ public final class ViewRootImpl implements ViewParent,
mTranslator.translateCanvas(layerCanvas);
}
- mView.draw(layerCanvas);
+ DisplayList displayList = mView.mDisplayList;
+ if (displayList != null) {
+ layerCanvas.drawDisplayList(displayList, null,
+ DisplayList.FLAG_CLIP_CHILDREN);
+ } else {
+ mView.draw(layerCanvas);
+ }
drawAccessibilityFocusedDrawableIfNeeded(layerCanvas);
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java
index fe5cad4..95a0416 100644
--- a/core/java/android/webkit/AccessibilityInjector.java
+++ b/core/java/android/webkit/AccessibilityInjector.java
@@ -514,6 +514,8 @@ class AccessibilityInjector {
}
} catch (URISyntaxException e) {
// Do nothing.
+ } catch (IllegalArgumentException e) {
+ // Catch badly-formed URLs.
}
return ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED;