Merge "Compute GradientDrawable's opacity correctly" into jb-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index 4abcaee..069fb4d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9346,6 +9346,7 @@
method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long);
method public void setAlpha(int);
method public void setColorFilter(android.graphics.ColorFilter);
+ method public void setLayoutDirection(int);
method public void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
field public static final int HORIZONTAL = 1; // 0x1
field public static final int VERTICAL = 2; // 0x2
@@ -9382,7 +9383,6 @@
method public android.graphics.drawable.Drawable getCurrent();
method public int getIntrinsicHeight();
method public int getIntrinsicWidth();
- method public int getLayoutDirection();
method public final int getLevel();
method public int getMinimumHeight();
method public int getMinimumWidth();
@@ -9410,7 +9410,6 @@
method public void setColorFilter(int, android.graphics.PorterDuff.Mode);
method public void setDither(boolean);
method public void setFilterBitmap(boolean);
- method public void setLayoutDirection(int);
method public final boolean setLevel(int);
method public boolean setState(int[]);
method public boolean setVisible(boolean, boolean);
@@ -9539,6 +9538,7 @@
method public boolean setDrawableByLayerId(int, android.graphics.drawable.Drawable);
method public void setId(int, int);
method public void setLayerInset(int, int, int, int, int);
+ method public void setLayoutDirection(int);
method public void setOpacity(int);
method public void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
}
@@ -9632,6 +9632,7 @@
public class StateListDrawable extends android.graphics.drawable.DrawableContainer {
ctor public StateListDrawable();
method public void addState(int[], android.graphics.drawable.Drawable);
+ method public void setLayoutDirection(int);
}
public class TransitionDrawable extends android.graphics.drawable.LayerDrawable implements android.graphics.drawable.Drawable.Callback {
@@ -13024,6 +13025,11 @@
field public static final int SSL_UNTRUSTED = 3; // 0x3
}
+ public class X509TrustManagerExtensions {
+ ctor public X509TrustManagerExtensions(javax.net.ssl.X509TrustManager) throws java.lang.IllegalArgumentException;
+ method public java.util.List<java.security.cert.X509Certificate> checkServerTrusted(java.security.cert.X509Certificate[], java.lang.String, java.lang.String) throws java.security.cert.CertificateException;
+ }
+
}
package android.net.nsd {
@@ -20002,6 +20008,8 @@
public class Script extends android.renderscript.BaseObj {
method public void bindAllocation(android.renderscript.Allocation, int);
+ method protected android.renderscript.Script.FieldID createFieldID(int, android.renderscript.Element);
+ method protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element);
method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker);
method protected void invoke(int);
method protected void invoke(int, android.renderscript.FieldPacker);
@@ -20031,17 +20039,39 @@
field protected android.renderscript.Element mElement;
}
+ public static final class Script.FieldID extends android.renderscript.BaseObj {
+ }
+
+ public static final class Script.KernelID extends android.renderscript.BaseObj {
+ }
+
public class ScriptC extends android.renderscript.Script {
ctor protected ScriptC(int, android.renderscript.RenderScript);
ctor protected ScriptC(android.renderscript.RenderScript, android.content.res.Resources, int);
}
+ public final class ScriptGroup extends android.renderscript.BaseObj {
+ method public void execute();
+ method public void setInput(android.renderscript.Script.KernelID, android.renderscript.Allocation);
+ method public void setOutput(android.renderscript.Script.KernelID, android.renderscript.Allocation);
+ }
+
+ public static final class ScriptGroup.Builder {
+ ctor public ScriptGroup.Builder(android.renderscript.RenderScript);
+ method public android.renderscript.ScriptGroup.Builder addConnection(android.renderscript.Type, android.renderscript.Script.KernelID, android.renderscript.Script.FieldID);
+ method public android.renderscript.ScriptGroup.Builder addConnection(android.renderscript.Type, android.renderscript.Script.KernelID, android.renderscript.Script.KernelID);
+ method public android.renderscript.ScriptGroup.Builder addKernel(android.renderscript.Script.KernelID);
+ method public android.renderscript.ScriptGroup create();
+ }
+
public abstract class ScriptIntrinsic extends android.renderscript.Script {
}
public final class ScriptIntrinsicBlur extends android.renderscript.ScriptIntrinsic {
method public static android.renderscript.ScriptIntrinsicBlur create(android.renderscript.RenderScript, android.renderscript.Element);
method public void forEach(android.renderscript.Allocation);
+ method public android.renderscript.Script.FieldID getFieldID_Input();
+ method public android.renderscript.Script.KernelID getKernelID();
method public void setInput(android.renderscript.Allocation);
method public void setRadius(float);
}
@@ -20049,6 +20079,7 @@
public final class ScriptIntrinsicColorMatrix extends android.renderscript.ScriptIntrinsic {
method public static android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript, android.renderscript.Element);
method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation);
+ method public android.renderscript.Script.KernelID getKernelID();
method public void setColorMatrix(android.renderscript.Matrix4f);
method public void setColorMatrix(android.renderscript.Matrix3f);
method public void setGreyscale();
@@ -20059,6 +20090,8 @@
public final class ScriptIntrinsicConvolve3x3 extends android.renderscript.ScriptIntrinsic {
method public static android.renderscript.ScriptIntrinsicConvolve3x3 create(android.renderscript.RenderScript, android.renderscript.Element);
method public void forEach(android.renderscript.Allocation);
+ method public android.renderscript.Script.FieldID getFieldID_Input();
+ method public android.renderscript.Script.KernelID getKernelID();
method public void setCoefficients(float[]);
method public void setInput(android.renderscript.Allocation);
}
@@ -20066,6 +20099,8 @@
public final class ScriptIntrinsicConvolve5x5 extends android.renderscript.ScriptIntrinsic {
method public static android.renderscript.ScriptIntrinsicConvolve5x5 create(android.renderscript.RenderScript, android.renderscript.Element);
method public void forEach(android.renderscript.Allocation);
+ method public android.renderscript.Script.FieldID getFieldID_Input();
+ method public android.renderscript.Script.KernelID getKernelID();
method public void setCoefficients(float[]);
method public void setInput(android.renderscript.Allocation);
}
@@ -20073,6 +20108,7 @@
public final class ScriptIntrinsicLUT extends android.renderscript.ScriptIntrinsic {
method public static android.renderscript.ScriptIntrinsicLUT create(android.renderscript.RenderScript, android.renderscript.Element);
method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation);
+ method public android.renderscript.Script.KernelID getKernelID();
method public void setAlpha(int, int);
method public void setBlue(int, int);
method public void setGreen(int, int);
@@ -22090,6 +22126,7 @@
method public static java.lang.CharSequence expandTemplate(java.lang.CharSequence, java.lang.CharSequence...);
method public static int getCapsMode(java.lang.CharSequence, int, int);
method public static void getChars(java.lang.CharSequence, int, int, char[], int);
+ method public static int getLayoutDirectionFromLocale(java.util.Locale);
method public static int getOffsetAfter(java.lang.CharSequence, int);
method public static int getOffsetBefore(java.lang.CharSequence, int);
method public static java.lang.CharSequence getReverse(java.lang.CharSequence, int, int);
@@ -23185,10 +23222,6 @@
method public android.util.JsonWriter value(java.lang.Number) throws java.io.IOException;
}
- public class LocaleUtil {
- method public static int getLayoutDirectionFromLocale(java.util.Locale);
- }
-
public final class Log {
method public static int d(java.lang.String, java.lang.String);
method public static int d(java.lang.String, java.lang.String, java.lang.Throwable);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 92104fa..56b745f 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -129,32 +129,33 @@
@Override
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter,
String broadcastPermission, Handler scheduler) {
- throw new ReceiverCallNotAllowedException(
- "IntentReceiver components are not allowed to register to receive intents");
- //ex.fillInStackTrace();
- //Log.e("IntentReceiver", ex.getMessage(), ex);
- //return mContext.registerReceiver(receiver, filter, broadcastPermission,
- // scheduler);
+ if (receiver == null) {
+ // Allow retrieving current sticky broadcast; this is safe since we
+ // aren't actually registering a receiver.
+ return super.registerReceiver(null, filter, broadcastPermission, scheduler);
+ } else {
+ throw new ReceiverCallNotAllowedException(
+ "BroadcastReceiver components are not allowed to register to receive intents");
+ }
}
@Override
public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user,
IntentFilter filter, String broadcastPermission, Handler scheduler) {
- throw new ReceiverCallNotAllowedException(
- "IntentReceiver components are not allowed to register to receive intents");
- //ex.fillInStackTrace();
- //Log.e("IntentReceiver", ex.getMessage(), ex);
- //return mContext.registerReceiver(receiver, filter, broadcastPermission,
- // scheduler);
+ if (receiver == null) {
+ // Allow retrieving current sticky broadcast; this is safe since we
+ // aren't actually registering a receiver.
+ return super.registerReceiverAsUser(null, user, filter, broadcastPermission, scheduler);
+ } else {
+ throw new ReceiverCallNotAllowedException(
+ "BroadcastReceiver components are not allowed to register to receive intents");
+ }
}
@Override
public boolean bindService(Intent service, ServiceConnection conn, int flags) {
throw new ReceiverCallNotAllowedException(
- "IntentReceiver components are not allowed to bind to services");
- //ex.fillInStackTrace();
- //Log.e("IntentReceiver", ex.getMessage(), ex);
- //return mContext.bindService(service, interfaceName, conn, flags);
+ "BroadcastReceiver components are not allowed to bind to services");
}
}
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 84a447f..185fb5a 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import android.app.ActivityThread;
import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
@@ -201,12 +202,15 @@
* @return a appWidgetId
* @hide
*/
- public static int allocateAppWidgetIdForHost(String packageName, int hostId) {
+ public static int allocateAppWidgetIdForSystem(int hostId) {
checkCallerIsSystem();
try {
if (sService == null) {
bindService();
}
+ Context systemContext =
+ (Context) ActivityThread.currentActivityThread().getSystemContext();
+ String packageName = systemContext.getPackageName();
return sService.allocateAppWidgetId(packageName, hostId);
} catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
@@ -240,7 +244,7 @@
* Stop listening to changes for this AppWidget.
* @hide
*/
- public static void deleteAppWidgetIdForHost(int appWidgetId) {
+ public static void deleteAppWidgetIdForSystem(int appWidgetId) {
checkCallerIsSystem();
try {
if (sService == null) {
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 7164713..51b8d25 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -19,7 +19,7 @@
import android.content.pm.ActivityInfo;
import android.os.Parcel;
import android.os.Parcelable;
-import android.util.LocaleUtil;
+import android.text.TextUtils;
import android.view.View;
import java.util.Locale;
@@ -1169,7 +1169,7 @@
public void setLayoutDirection(Locale locale) {
// There is a "1" difference between the configuration values for
// layout direction and View constants for layout direction, just add "1".
- final int layoutDirection = 1 + LocaleUtil.getLayoutDirectionFromLocale(locale);
+ final int layoutDirection = 1 + TextUtils.getLayoutDirectionFromLocale(locale);
screenLayout = (screenLayout&~SCREENLAYOUT_LAYOUTDIR_MASK)|
(layoutDirection << SCREENLAYOUT_LAYOUTDIR_SHIFT);
}
diff --git a/core/java/android/net/X509TrustManagerExtensions.java b/core/java/android/net/X509TrustManagerExtensions.java
new file mode 100644
index 0000000..115e972
--- /dev/null
+++ b/core/java/android/net/X509TrustManagerExtensions.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.http;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.KeyManagementException;
+import java.util.List;
+
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
+
+/**
+ * X509TrustManager wrapper exposing Android-added features.
+ *
+ * <p> The checkServerTrusted method allows callers to perform additional
+ * verification of certificate chains after they have been successfully
+ * verified by the platform.</p>
+ */
+public class X509TrustManagerExtensions {
+
+ TrustManagerImpl mDelegate;
+
+ /**
+ * Constructs a new X509TrustManagerExtensions wrapper.
+ *
+ * @param tm A {@link X509TrustManager} as returned by TrustManagerFactory.getInstance();
+ * @throws IllegalArgumentException If tm is an unsupported TrustManager type.
+ */
+ public X509TrustManagerExtensions(X509TrustManager tm) throws IllegalArgumentException {
+ if (tm instanceof TrustManagerImpl) {
+ mDelegate = (TrustManagerImpl) tm;
+ } else {
+ throw new IllegalArgumentException("tm is not a supported type of X509TrustManager");
+ }
+ }
+
+ /**
+ * Verifies the given certificate chain.
+ *
+ * <p>See {@link X509TrustManager#checkServerTrusted(X509Certificate[], String)} for a
+ * description of the chain and authType parameters. The final parameter, host, should be the
+ * hostname of the server.</p>
+ *
+ * @throws CertificateException if the chain does not verify correctly.
+ * @return the properly ordered chain used for verification as a list of X509Certificates.
+ */
+ public List<X509Certificate> checkServerTrusted(X509Certificate[] chain, String authType,
+ String host) throws CertificateException {
+ return mDelegate.checkServerTrusted(chain, authType, host);
+ }
+}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 392aff7..44b0b62 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.content.pm.UserInfo;
import android.graphics.Bitmap;
+import android.content.res.Resources;
import android.util.Log;
import java.util.List;
@@ -232,8 +233,9 @@
* @hide
* @return a value greater than or equal to 1
*/
- public int getMaxSupportedUsers() {
- return mContext.getResources().getInteger(R.integer.config_multiuserMaximumUsers);
+ public static int getMaxSupportedUsers() {
+ return SystemProperties.getInt("fw.max_users",
+ Resources.getSystem().getInteger(R.integer.config_multiuserMaximumUsers));
}
/**
diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java
index bbaa173..df8c4c6 100644
--- a/core/java/android/text/TextDirectionHeuristics.java
+++ b/core/java/android/text/TextDirectionHeuristics.java
@@ -17,7 +17,6 @@
package android.text;
-import android.util.LocaleUtil;
import android.view.View;
/**
@@ -242,7 +241,7 @@
@Override
protected boolean defaultIsRtl() {
- final int dir = LocaleUtil.getLayoutDirectionFromLocale(java.util.Locale.getDefault());
+ final int dir = TextUtils.getLayoutDirectionFromLocale(java.util.Locale.getDefault());
return (dir == View.LAYOUT_DIRECTION_RTL);
}
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 987062a..1508d10 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -46,11 +46,14 @@
import android.text.style.UnderlineSpan;
import android.util.Printer;
+import android.view.View;
import com.android.internal.R;
import com.android.internal.util.ArrayUtils;
+import libcore.icu.ICU;
import java.lang.reflect.Array;
import java.util.Iterator;
+import java.util.Locale;
import java.util.regex.Pattern;
public class TextUtils {
@@ -1706,10 +1709,64 @@
return (int) (range & 0x00000000FFFFFFFFL);
}
+ /**
+ * Return the layout direction for a given Locale
+ *
+ * @param locale the Locale for which we want the layout direction. Can be null.
+ * @return the layout direction. This may be one of:
+ * {@link android.view.View#LAYOUT_DIRECTION_LTR} or
+ * {@link android.view.View#LAYOUT_DIRECTION_RTL}.
+ *
+ * Be careful: this code will need to be updated when vertical scripts will be supported
+ */
+ public static int getLayoutDirectionFromLocale(Locale locale) {
+ if (locale != null && !locale.equals(Locale.ROOT)) {
+ final String scriptSubtag = ICU.getScript(ICU.addLikelySubtags(locale.toString()));
+ if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);
+
+ if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||
+ scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
+ return View.LAYOUT_DIRECTION_RTL;
+ }
+ }
+
+ return View.LAYOUT_DIRECTION_LTR;
+ }
+
+ /**
+ * Fallback algorithm to detect the locale direction. Rely on the fist char of the
+ * localized locale name. This will not work if the localized locale name is in English
+ * (this is the case for ICU 4.4 and "Urdu" script)
+ *
+ * @param locale
+ * @return the layout direction. This may be one of:
+ * {@link View#LAYOUT_DIRECTION_LTR} or
+ * {@link View#LAYOUT_DIRECTION_RTL}.
+ *
+ * Be careful: this code will need to be updated when vertical scripts will be supported
+ *
+ * @hide
+ */
+ private static int getLayoutDirectionFromFirstChar(Locale locale) {
+ switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ return View.LAYOUT_DIRECTION_RTL;
+
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ default:
+ return View.LAYOUT_DIRECTION_LTR;
+ }
+ }
+
private static Object sLock = new Object();
+
private static char[] sTemp = null;
private static String[] EMPTY_STRING_ARRAY = new String[]{};
private static final char ZWNBS_CHAR = '\uFEFF';
+
+ private static String ARAB_SCRIPT_SUBTAG = "Arab";
+ private static String HEBR_SCRIPT_SUBTAG = "Hebr";
}
diff --git a/core/java/android/util/LocaleUtil.java b/core/java/android/util/LocaleUtil.java
deleted file mode 100644
index 60526e1..0000000
--- a/core/java/android/util/LocaleUtil.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.util;
-
-import java.util.Locale;
-
-import android.view.View;
-import libcore.icu.ICU;
-
-/**
- * Various utilities for Locales
- *
- */
-public class LocaleUtil {
-
- private LocaleUtil() { /* cannot be instantiated */ }
-
- private static String ARAB_SCRIPT_SUBTAG = "Arab";
- private static String HEBR_SCRIPT_SUBTAG = "Hebr";
-
- /**
- * Return the layout direction for a given Locale
- *
- * @param locale the Locale for which we want the layout direction. Can be null.
- * @return the layout direction. This may be one of:
- * {@link View#LAYOUT_DIRECTION_LTR} or
- * {@link View#LAYOUT_DIRECTION_RTL}.
- *
- * Be careful: this code will need to be updated when vertical scripts will be supported
- */
- public static int getLayoutDirectionFromLocale(Locale locale) {
- if (locale != null && !locale.equals(Locale.ROOT)) {
- final String scriptSubtag = ICU.getScript(ICU.addLikelySubtags(locale.toString()));
- if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);
-
- if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||
- scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
- return View.LAYOUT_DIRECTION_RTL;
- }
- }
-
- return View.LAYOUT_DIRECTION_LTR;
- }
-
- /**
- * Fallback algorithm to detect the locale direction. Rely on the fist char of the
- * localized locale name. This will not work if the localized locale name is in English
- * (this is the case for ICU 4.4 and "Urdu" script)
- *
- * @param locale
- * @return the layout direction. This may be one of:
- * {@link View#LAYOUT_DIRECTION_LTR} or
- * {@link View#LAYOUT_DIRECTION_RTL}.
- *
- * Be careful: this code will need to be updated when vertical scripts will be supported
- *
- * @hide
- */
- private static int getLayoutDirectionFromFirstChar(Locale locale) {
- switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
- return View.LAYOUT_DIRECTION_RTL;
-
- case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
- default:
- return View.LAYOUT_DIRECTION_LTR;
- }
- }
-}
diff --git a/core/java/android/view/Gravity.java b/core/java/android/view/Gravity.java
index f031fe7..9a89fa5 100644
--- a/core/java/android/view/Gravity.java
+++ b/core/java/android/view/Gravity.java
@@ -153,8 +153,8 @@
* container.
* @param layoutDirection The layout direction.
*
- * @see {@link View#LAYOUT_DIRECTION_LTR}
- * @see {@link View#LAYOUT_DIRECTION_RTL}
+ * @see View#LAYOUT_DIRECTION_LTR
+ * @see View#LAYOUT_DIRECTION_RTL
*/
public static void apply(int gravity, int w, int h, Rect container,
Rect outRect, int layoutDirection) {
@@ -290,8 +290,8 @@
* container.
* @param layoutDirection The layout direction.
*
- * @see {@link View#LAYOUT_DIRECTION_LTR}
- * @see {@link View#LAYOUT_DIRECTION_RTL}
+ * @see View#LAYOUT_DIRECTION_LTR
+ * @see View#LAYOUT_DIRECTION_RTL
*/
public static void apply(int gravity, int w, int h, Rect container,
int xAdj, int yAdj, Rect outRect, int layoutDirection) {
@@ -370,8 +370,8 @@
* modified if needed to fit in the display.
* @param layoutDirection The layout direction.
*
- * @see {@link View#LAYOUT_DIRECTION_LTR}
- * @see {@link View#LAYOUT_DIRECTION_RTL}
+ * @see View#LAYOUT_DIRECTION_LTR
+ * @see View#LAYOUT_DIRECTION_RTL
*/
public static void applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection) {
int absGravity = getAbsoluteGravity(gravity, layoutDirection);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d93c1be1..fce478a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -48,9 +48,9 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.FloatProperty;
-import android.util.LocaleUtil;
import android.util.Log;
import android.util.Pool;
import android.util.Poolable;
@@ -11605,8 +11605,8 @@
*
* @param layoutDirection the direction of the layout
*
- * @see {@link #LAYOUT_DIRECTION_LTR}
- * @see {@link #LAYOUT_DIRECTION_RTL}
+ * @see #LAYOUT_DIRECTION_LTR
+ * @see #LAYOUT_DIRECTION_RTL
*/
public void onPaddingChanged(int layoutDirection) {
}
@@ -11655,7 +11655,7 @@
* @return true if the Locale uses an RTL script.
*/
protected static boolean isLayoutDirectionRtl(Locale locale) {
- return (LAYOUT_DIRECTION_RTL == LocaleUtil.getLayoutDirectionFromLocale(locale));
+ return (LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(locale));
}
/**
@@ -14053,8 +14053,8 @@
*
* @param layoutDirection The resolved layout direction.
*
- * @see {@link #LAYOUT_DIRECTION_LTR}
- * @see {@link #LAYOUT_DIRECTION_RTL}
+ * @see #LAYOUT_DIRECTION_LTR
+ * @see #LAYOUT_DIRECTION_RTL
*/
public void onResolveDrawables(int layoutDirection) {
}
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index 3baf5a9..1c81d11 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -21,8 +21,8 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
+import android.text.TextUtils;
import android.util.AttributeSet;
-import android.util.LocaleUtil;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -200,7 +200,7 @@
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
// Set the default layout direction to match the default locale one
final Locale locale = mContext.getResources().getConfiguration().locale;
- mLayoutDirection = LocaleUtil.getLayoutDirectionFromLocale(locale);
+ mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(locale);
}
/**
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index dc4ee3a..34ade74 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -400,6 +400,7 @@
int nonOverflowCount = 0;
int widthRemaining = right - left - getPaddingRight() - getPaddingLeft();
boolean hasOverflow = false;
+ final boolean isLayoutRtl = isLayoutRtl();
for (int i = 0; i < childCount; i++) {
final View v = getChildAt(i);
if (v.getVisibility() == GONE) {
@@ -414,8 +415,15 @@
}
int height = v.getMeasuredHeight();
- int r = getWidth() - getPaddingRight() - p.rightMargin;
- int l = r - overflowWidth;
+ int r;
+ int l;
+ if (isLayoutRtl) {
+ l = getPaddingLeft() + p.leftMargin;
+ r = l + overflowWidth;
+ } else {
+ r = getWidth() - getPaddingRight() - p.rightMargin;
+ l = r - overflowWidth;
+ }
int t = midVertical - (height / 2);
int b = t + height;
v.layout(l, t, r, b);
@@ -448,20 +456,38 @@
final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1);
final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0);
- int startLeft = getPaddingLeft();
- for (int i = 0; i < childCount; i++) {
- final View v = getChildAt(i);
- final LayoutParams lp = (LayoutParams) v.getLayoutParams();
- if (v.getVisibility() == GONE || lp.isOverflowButton) {
- continue;
- }
+ if (isLayoutRtl) {
+ int startRight = getWidth() - getPaddingRight();
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) v.getLayoutParams();
+ if (v.getVisibility() == GONE || lp.isOverflowButton) {
+ continue;
+ }
- startLeft += lp.leftMargin;
- int width = v.getMeasuredWidth();
- int height = v.getMeasuredHeight();
- int t = midVertical - height / 2;
- v.layout(startLeft, t, startLeft + width, t + height);
- startLeft += width + lp.rightMargin + spacerSize;
+ startRight -= lp.rightMargin;
+ int width = v.getMeasuredWidth();
+ int height = v.getMeasuredHeight();
+ int t = midVertical - height / 2;
+ v.layout(startRight - width, t, startRight, t + height);
+ startRight -= width + lp.leftMargin + spacerSize;
+ }
+ } else {
+ int startLeft = getPaddingLeft();
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) v.getLayoutParams();
+ if (v.getVisibility() == GONE || lp.isOverflowButton) {
+ continue;
+ }
+
+ startLeft += lp.leftMargin;
+ int width = v.getMeasuredWidth();
+ int height = v.getMeasuredHeight();
+ int t = midVertical - height / 2;
+ v.layout(startLeft, t, startLeft + width, t + height);
+ startLeft += width + lp.rightMargin + spacerSize;
+ }
}
}
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp
index bc58813..c48b974 100644
--- a/core/jni/android/graphics/SurfaceTexture.cpp
+++ b/core/jni/android/graphics/SurfaceTexture.cpp
@@ -223,10 +223,6 @@
} else if (err < 0) {
jniThrowRuntimeException(env, "Error during updateTexImage (see logcat for details)");
}
- err = surfaceTexture->doGLFenceWait();
- if (err != NO_ERROR) {
- jniThrowRuntimeException(env, "Error waiting for fence (see logcat for details)");
- }
}
static jint SurfaceTexture_detachFromGLContext(JNIEnv* env, jobject thiz)
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index b904c60..7e145fd 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2103,7 +2103,7 @@
<string name="lockscreen_low_battery">Connect your charger.</string>
<!-- Shown in the lock screen when there is no SIM card. -->
- <string name="lockscreen_missing_sim_message_short">No SIM card.</string>
+ <string name="lockscreen_missing_sim_message_short">No SIM card</string>
<!-- Shown in the lock screen when there is no SIM card. -->
<string name="lockscreen_missing_sim_message" product="tablet">No SIM card in tablet.</string>
<!-- Shown in the lock screen when there is no SIM card. -->
diff --git a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java
new file mode 100644
index 0000000..60c40db
--- /dev/null
+++ b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.http;
+
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
+
+public class X509TrustManagerExtensionsTest extends TestCase {
+
+ private class NotATrustManagerImpl implements X509TrustManager {
+
+ public void checkClientTrusted(X509Certificate[] chain, String authType) {}
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType) {}
+
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+ }
+
+ public void testBadCast() throws Exception {
+ NotATrustManagerImpl ntmi = new NotATrustManagerImpl();
+ try {
+ X509TrustManagerExtensions tme = new X509TrustManagerExtensions(ntmi);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testGoodCast() throws Exception {
+ String defaultType = KeyStore.getDefaultType();
+ TrustManagerImpl tmi = new TrustManagerImpl(KeyStore.getInstance(defaultType));
+ X509TrustManagerExtensions tme = new X509TrustManagerExtensions(tmi);
+ }
+
+ public void testNormalUseCase() throws Exception {
+ String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
+ String defaultKeystoreType = KeyStore.getDefaultType();
+ tmf.init(KeyStore.getInstance(defaultKeystoreType));
+ TrustManager[] tms = tmf.getTrustManagers();
+ for (TrustManager tm : tms) {
+ if (tm instanceof X509TrustManager) {
+ new X509TrustManagerExtensions((X509TrustManager)tm);
+ return;
+ }
+ }
+ fail();
+ }
+}
diff --git a/docs/html/design/style/iconography.jd b/docs/html/design/style/iconography.jd
index 31274c5..3ba3f71 100644
--- a/docs/html/design/style/iconography.jd
+++ b/docs/html/design/style/iconography.jd
@@ -109,9 +109,7 @@
</p>
<p>
-
-<a href="{@docRoot}downloads/design/Android_Design_Icons_20120229.zip">Download the Action Bar Icon Pack</a>
-
+<a href="{@docRoot}downloads/design/Android_Design_Icons_20120814.zip">Download the Action Bar Icon Pack</a>
</p>
<div class="layout-content-row">
diff --git a/docs/html/distribute/distribute_toc.cs b/docs/html/distribute/distribute_toc.cs
index f11e965..76073fb 100644
--- a/docs/html/distribute/distribute_toc.cs
+++ b/docs/html/distribute/distribute_toc.cs
@@ -72,10 +72,10 @@
<span class="en">Linking to Your Products</a></li>
<li><a href="<?cs var:toroot ?>distribute/googleplay/promote/badges.html">
<span class="en">Google Play Badges</a></li>
- <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/brand.html">
- <span class="en">Brand Assets and Guidelines</a></li>
<li><a href="<?cs var:toroot ?>distribute/promote/device-art.html">
<span class="en">Device Art Generator</a></li>
+ <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/brand.html">
+ <span class="en">Brand Assets and Guidelines</a></li>
</ul>
</li>
diff --git a/docs/html/distribute/googleplay/promote/badges.jd b/docs/html/distribute/googleplay/promote/badges.jd
index de12e2a..7b64be3 100644
--- a/docs/html/distribute/googleplay/promote/badges.jd
+++ b/docs/html/distribute/googleplay/promote/badges.jd
@@ -1,11 +1,20 @@
page.title=Google Play Badges
@jd:body
-<p>Google Play badges give you an officially branded way of promoting your app to Android users. Use the form below to quickly create badges to link users to your products from web pages, ads, reviews, and more. See <a href="linking.html">Linking to your products</a> for more ways to bring users to your apps.</p>
+<p>Google Play badges allow you to promote your app with official branding in your
+online ads, promotional materials, or anywhere else you want a link to your app.</p>
-<p>Input your app's package or your publisher name, choose the style, size, and language, and click "Build my badge". The form will generate code for an embbeded button that links to your app's product page or a list of your apps. </p>
+<p>In the form below,
+input your app's package name or publisher name, choose the badge style,
+click <em>Build my badge</em>, then paste the HTML into your web content.</p>
-<p>Note that you should not modify the Google Play badges after generating them, including colors, size, text, and logo. See <a href="http://www.android.com/branding.html">Android Brand Guidelines</a> for more information.</p>
+<p>If you're creating a promotional web page for your app, you should also use the
+<a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly
+wraps your screenshots in real device artwork.</p>
+
+<p>For guidelines when using the Google Play badge and other brand assets,
+see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand Assets and
+Guidelines</a>.</p>
<style type="text/css">
@@ -34,11 +43,13 @@
}
div.button-row input {
- vertical-align:120%;
+ vertical-align:middle;
+ margin:0 5px 0 0;
}
#jd-content div.button-row img {
margin: 0;
+ vertical-align:middle;
}
</style>
@@ -46,7 +57,7 @@
<script type="text/javascript">
// variables for creating 'try it out' demo button
-var imagePath = "http://www.android.com/images/brand/"
+var imagePath = "http://developer.android.com/images/brand/"
var linkStart = "<a href=\"http://play.google.com/store/";
var imageStart = "\">\n"
+ " <img alt=\"";
@@ -167,28 +178,29 @@
onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
<br/><br/>
-<div class="button-row">
- <input type="radio" name="buttonStyle" value="get_it_on_play_logo_small" id="ns" checked="checked" />
- <label for="ns"><img src="http://www.android.com/images/brand/get_it_on_play_logo_small.png"
-alt="Get it on Google Play (small)" /></label>
-
- <input type="radio" name="buttonStyle" value="get_it_on_play_logo_large" id="nm" />
- <label for="nm"><img src="http://www.android.com/images/brand/get_it_on_play_logo_large.png"
-alt="Get it on Google Play (large)" /></label>
-</div>
<div class="button-row">
- <input type="radio" name="buttonStyle" value="android_app_on_play_logo_small" id="ws" />
- <label for="ws"><img src="http://www.android.com/images/brand/android_app_on_play_logo_small.png"
+ <input type="radio" name="buttonStyle" value="en_app_rgb_wo_45" id="ws" checked="checked" />
+ <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
alt="Android app on Google Play (small)" /></label>
- <input type="radio" name="buttonStyle" value="android_app_on_play_logo_large" id="wm" />
- <label for="wm"><img src="http://www.android.com/images/brand/android_app_on_play_logo_large.png"
+ <input type="radio" name="buttonStyle" value="en_app_rgb_wo_60" id="wm" />
+ <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
alt="Android app on Google Play (large)" /></label>
</div>
+<div class="button-row">
+ <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_45" id="ns" />
+ <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
+alt="Get it on Google Play (small)" /></label>
+
+ <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_60" id="nm" />
+ <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
+alt="Get it on Google Play (large)" /></label>
+</div>
+
<input type="button" onclick="return buildButton(this.parentNode)" value="Build my badge"
-style="padding:5px" />
+style="padding:10px" />
<br/>
</form>
diff --git a/docs/html/distribute/googleplay/promote/brand.jd b/docs/html/distribute/googleplay/promote/brand.jd
index 76ed619..4051553 100644
--- a/docs/html/distribute/googleplay/promote/brand.jd
+++ b/docs/html/distribute/googleplay/promote/brand.jd
@@ -88,28 +88,28 @@
"Android is a trademark of Google Inc."</span>
</p>
+
<h2 id="brand-google_play">Google Play Brand</h2>
-<div style="clear:both">
- <div style="float:right;width:50%;padding:1.5em;">
- <p>
- <img alt="Google Play logo" src="http://www.android.com/images/brand/google_play_logo_450.png">
- </p>
- <p>
- <img alt="Get it on Google Play badge, large" src=
- "http://www.android.com/images/brand/get_it_on_play_logo_large.png"><br>
- Download: <a href="http://www.android.com/images/brand/get_it_on_play_logo_small.png">Small</a> | <a href=
- "http://www.android.com/images/brand/get_it_on_play_logo_large.png">Large</a>
- </p>
- <p>
- <img alt="Android App on Google Play badge, large" src=
- "http://www.android.com/images/brand/android_app_on_play_logo_large.png"><br>
- Download: <a href="http://www.android.com/images/brand/android_app_on_play_logo_small.png">Small</a> |
- <a href="http://www.android.com/images/brand/android_app_on_play_large.png">Large</a>
- </p>
- </div>
+ <img alt="" src="http://www.android.com/images/brand/google_play_logo_450.png"
+ style="float:right;">
+
+ <img alt="Android app on Google Play badge, large"
+ src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
+ style="float:right;clear:right;">
+
+ <img alt="Android app on Google Play badge, small"
+ src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
+ style="float:right;margin:0 30px 30px">
+
+ <img alt="Get it on Google Play badge, large"
+ src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
+ style="float:right;clear:right;">
+
+ <img alt="Get it on Google Play badge, small"
+ src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
+ style="float:right;margin:0 30px 30px;">
- <div style="width:45%;">
<h4>06/ <em>Get it on Google Play</em> Badge
</h4>
<p>
@@ -118,57 +118,34 @@
Play.
</p>
<p>
- The logos are available in two sizes:
- </p>
- <ul>
- <li>Large: 60(h) x 172(w)</li>
- </li>
- <li>Small 45(h) x 129(w)
- </li>
- </ul>
- <p>
Guidelines for usage:
</p>
<ul>
- <li>Never separate the phrase “Get it on Google Play” or "Android App on Google Play"
- from the Google Play logo, and do not change the color, proportions, spacing or any
- other aspect of the logo.
+ <li>Do not modify the color, proportions, spacing or any other aspect of the badge image.
</li>
- </ul>
- </div>
-
- <ul>
- <li>When used online, the badge logo should be used to direct users to:
+ <li>When used alongside logos for other application marketplaces, the Google Play logo
+ should be of equal or greater size.</li>
+ <li>When used online, the badge should link to either:
<ul>
- <li>The Google Play landing page: <br />
- <span style="margin-left:1em;">http://play.google.com</span>
- </li>
- <li>The Google Play Apps landing page: <br />
- <span style="margin-left:1em;">http://play.google.com/store/apps</span>
- </li>
- <li>A list of products that include your company name, for example, <br />
- <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>yourCompanyName</em></span>
- </li>
- <li>A list of products published by you, for example,<br />
+ <li>A list of products published by you, for example:<br />
<span style="margin-left:1em;">http://play.google.com/store/search?q=<em>publisherName</em></span>
</li>
- <li>A specific app product details page within Google Play, for example,<br />
+ <li>A specific app product details page within Google Play, for example:<br />
<span style="margin-left:1em;">http://play.google.com/store/apps/details?id=<em>packageName</em></span>
</li>
</ul>
</li>
- <li>When used alongside logos for other application marketplaces, the Google Play logo
- should be of equal or greater size</li>
</ul>
-
- <p>For details on all the ways that you can link to your product details page in Google Play,
- see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
- <p>For convenience, if you are using the logos online, you can use the
- <a href="{@docRoot}distribute/googleplay/promote/badges.html">badge generator</a>
- to create the appropriate markup and link to your apps.</p>
+ <p>For your convenience, you can use the
+ <a href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
+ to create badges that link to your apps on Google Play.</p>
+
+ <p>For details on all the ways that you can link to your product details page in Google Play,
+ see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
<h2>Other Brands</h2>
<p>Any other brands or icons depicted on this site are <em>not</em> are the property of their
respective owners and usage is reserved. You must seek the developer for appropriate permission to use them.</p>
+
diff --git a/docs/html/images/brand/en_app_rgb_wo_45.png b/docs/html/images/brand/en_app_rgb_wo_45.png
new file mode 100644
index 0000000..9891cbb
--- /dev/null
+++ b/docs/html/images/brand/en_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/en_app_rgb_wo_60.png b/docs/html/images/brand/en_app_rgb_wo_60.png
new file mode 100644
index 0000000..649e782
--- /dev/null
+++ b/docs/html/images/brand/en_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/en_generic_rgb_wo_45.png b/docs/html/images/brand/en_generic_rgb_wo_45.png
new file mode 100644
index 0000000..73dd393
--- /dev/null
+++ b/docs/html/images/brand/en_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/en_generic_rgb_wo_60.png b/docs/html/images/brand/en_generic_rgb_wo_60.png
new file mode 100644
index 0000000..9a50aff
--- /dev/null
+++ b/docs/html/images/brand/en_generic_rgb_wo_60.png
Binary files differ
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 41f6db9..f9392e4 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -377,6 +377,8 @@
*
* @return One of {@link android.view.View#LAYOUT_DIRECTION_LTR},
* {@link android.view.View#LAYOUT_DIRECTION_RTL}
+ *
+ * @hide
*/
public int getLayoutDirection() {
return mLayoutDirection;
@@ -387,8 +389,9 @@
* Drawable as no capacity to do the resolution on his own.
*
* @param layoutDirection One of {@link android.view.View#LAYOUT_DIRECTION_LTR},
- * {@link android.view.View#LAYOUT_DIRECTION_RTL},
+ * {@link android.view.View#LAYOUT_DIRECTION_RTL}
*
+ * @hide
*/
public void setLayoutDirection(int layoutDirection) {
if (getLayoutDirection() != layoutDirection) {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index af8b0c2..76edb0a 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -567,6 +567,42 @@
return rsnScriptIntrinsicCreate(mContext, id, eid);
}
+ native int rsnScriptKernelIDCreate(int con, int sid, int slot, int sig);
+ synchronized int nScriptKernelIDCreate(int sid, int slot, int sig) {
+ validate();
+ return rsnScriptKernelIDCreate(mContext, sid, slot, sig);
+ }
+
+ native int rsnScriptFieldIDCreate(int con, int sid, int slot);
+ synchronized int nScriptFieldIDCreate(int sid, int slot) {
+ validate();
+ return rsnScriptFieldIDCreate(mContext, sid, slot);
+ }
+
+ native int rsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types);
+ synchronized int nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types) {
+ validate();
+ return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types);
+ }
+
+ native void rsnScriptGroupSetInput(int con, int group, int kernel, int alloc);
+ synchronized void nScriptGroupSetInput(int group, int kernel, int alloc) {
+ validate();
+ rsnScriptGroupSetInput(mContext, group, kernel, alloc);
+ }
+
+ native void rsnScriptGroupSetOutput(int con, int group, int kernel, int alloc);
+ synchronized void nScriptGroupSetOutput(int group, int kernel, int alloc) {
+ validate();
+ rsnScriptGroupSetOutput(mContext, group, kernel, alloc);
+ }
+
+ native void rsnScriptGroupExecute(int con, int group);
+ synchronized void nScriptGroupExecute(int group) {
+ validate();
+ rsnScriptGroupExecute(mContext, group);
+ }
+
native int rsnSamplerCreate(int con, int magFilter, int minFilter,
int wrapS, int wrapT, int wrapR, float aniso);
synchronized int nSamplerCreate(int magFilter, int minFilter,
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index bbf5e7e..3fe3261 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -16,10 +16,105 @@
package android.renderscript;
+import android.util.SparseArray;
+
/**
*
**/
public class Script extends BaseObj {
+
+ /**
+ * KernelID is an identifier for a Script + root function pair. It is used
+ * as an identifier for ScriptGroup creation.
+ *
+ * This class should not be directly created. Instead use the method in the
+ * reflected or intrinsic code "getKernelID_funcname()".
+ *
+ */
+ public static final class KernelID extends BaseObj {
+ Script mScript;
+ int mSlot;
+ int mSig;
+ KernelID(int id, RenderScript rs, Script s, int slot, int sig) {
+ super(id, rs);
+ mScript = s;
+ mSlot = slot;
+ mSig = sig;
+ }
+ }
+
+ private final SparseArray<KernelID> mKIDs = new SparseArray<KernelID>();
+ /**
+ * Only to be used by generated reflected classes.
+ *
+ *
+ * @param slot
+ * @param sig
+ * @param ein
+ * @param eout
+ *
+ * @return KernelID
+ */
+ protected KernelID createKernelID(int slot, int sig, Element ein, Element eout) {
+ KernelID k = mKIDs.get(slot);
+ if (k != null) {
+ return k;
+ }
+
+ int id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig);
+ if (id == 0) {
+ throw new RSDriverException("Failed to create KernelID");
+ }
+
+ k = new KernelID(id, mRS, this, slot, sig);
+ mKIDs.put(slot, k);
+ return k;
+ }
+
+ /**
+ * FieldID is an identifier for a Script + exported field pair. It is used
+ * as an identifier for ScriptGroup creation.
+ *
+ * This class should not be directly created. Instead use the method in the
+ * reflected or intrinsic code "getFieldID_funcname()".
+ *
+ */
+ public static final class FieldID extends BaseObj {
+ Script mScript;
+ int mSlot;
+ FieldID(int id, RenderScript rs, Script s, int slot) {
+ super(id, rs);
+ mScript = s;
+ mSlot = slot;
+ }
+ }
+
+ private final SparseArray<FieldID> mFIDs = new SparseArray();
+ /**
+ * Only to be used by generated reflected classes.
+ *
+ * @param slot
+ * @param e
+ *
+ * @return FieldID
+ */
+ protected FieldID createFieldID(int slot, Element e) {
+ FieldID f = mFIDs.get(slot);
+ if (f != null) {
+ return f;
+ }
+
+ int id = mRS.nScriptFieldIDCreate(getID(mRS), slot);
+ if (id == 0) {
+ throw new RSDriverException("Failed to create FieldID");
+ }
+
+ f = new FieldID(id, mRS, this, slot);
+ mFIDs.put(slot, f);
+ return f;
+ }
+
+
/**
* Only intended for use by generated reflected code.
*
diff --git a/graphics/java/android/renderscript/ScriptGroup.java b/graphics/java/android/renderscript/ScriptGroup.java
index c4064b5..4efb45b 100644
--- a/graphics/java/android/renderscript/ScriptGroup.java
+++ b/graphics/java/android/renderscript/ScriptGroup.java
@@ -17,67 +17,60 @@
package android.renderscript;
import java.lang.reflect.Method;
+import java.util.ArrayList;
/**
- * @hide
+ * ScriptGroup creates a groups of scripts which are executed
+ * together based upon upon one execution call as if they were
+ * all part of a single script. The scripts may be connected
+ * internally or to an external allocation. For the internal
+ * connections the intermediate results are not observable after
+ * the execution of the script.
+ * <p>
+ * The external connections are grouped into inputs and outputs.
+ * All outputs are produced by a script kernel and placed into a
+ * user supplied allocation. Inputs are similar but supply the
+ * input of a kernal. Inputs bounds to a script are set directly
+ * upon the script.
+ *
**/
-public class ScriptGroup extends BaseObj {
- Node mNodes[];
- Connection mConnections[];
- Node mFirstNode;
+public final class ScriptGroup extends BaseObj {
IO mOutputs[];
IO mInputs[];
static class IO {
- Script mScript;
+ Script.KernelID mKID;
Allocation mAllocation;
- String mName;
- IO(Script s) {
- mScript = s;
- }
- IO(Script s, String n) {
- mScript = s;
- mName = n;
+ IO(Script.KernelID s) {
+ mKID = s;
}
}
- static class Connection {
- Node mTo[];
- String mToName[];
- Node mFrom;
- Type mAllocationType;
- Allocation mInternalAllocation;
-
- Connection(Node out, Type t) {
- mFrom = out;
+ static class ConnectLine {
+ ConnectLine(Type t, Script.KernelID from, Script.KernelID to) {
+ mFrom = from;
+ mToK = to;
mAllocationType = t;
}
- void addTo(Node n, String name) {
- if (mTo == null) {
- mTo = new Node[1];
- mToName = new String[1];
- } else {
- Node nt[] = new Node[mTo.length + 1];
- String ns[] = new String[mTo.length + 1];
- System.arraycopy(mTo, 0, nt, 0, mTo.length);
- System.arraycopy(mToName, 0, ns, 0, mTo.length);
- mTo = nt;
- mToName = ns;
- }
- mTo[mTo.length - 1] = n;
- mToName[mTo.length - 1] = name;
+ ConnectLine(Type t, Script.KernelID from, Script.FieldID to) {
+ mFrom = from;
+ mToF = to;
+ mAllocationType = t;
}
+
+ Script.FieldID mToF;
+ Script.KernelID mToK;
+ Script.KernelID mFrom;
+ Type mAllocationType;
}
static class Node {
Script mScript;
- Connection mInput[] = new Connection[8];
- Connection mOutput[] = new Connection[1];
- int mInputCount;
- int mOutputCount;
- int mDepth;
+ ArrayList<Script.KernelID> mKernels = new ArrayList<Script.KernelID>();
+ ArrayList<ConnectLine> mInputs = new ArrayList<ConnectLine>();
+ ArrayList<ConnectLine> mOutputs = new ArrayList<ConnectLine>();
boolean mSeen;
Node mNext;
@@ -85,24 +78,6 @@
Node(Script s) {
mScript = s;
}
-
- void addInput(Connection c) {
- if (mInput.length <= mInputCount) {
- Connection[] nc = new Connection[mInput.length + 8];
- System.arraycopy(mInput, 0, nc, 0, mInputCount);
- mInput = nc;
- }
- mInput[mInputCount++] = c;
- }
-
- void addOutput(Connection c) {
- if (mOutput.length <= mOutputCount) {
- Connection[] nc = new Connection[mOutput.length + 8];
- System.arraycopy(mOutput, 0, nc, 0, mOutputCount);
- mOutput = nc;
- }
- mOutput[mOutputCount++] = c;
- }
}
@@ -110,276 +85,326 @@
super(id, rs);
}
- void init(int nodeCount, int connectionCount) {
- mNodes = new Node[nodeCount];
- mConnections = new Connection[connectionCount];
-
- android.util.Log.v("RSR", "init" + nodeCount + ", " + connectionCount);
-
- // Count outputs and create array.
- Node n = mFirstNode;
- int outputCount = 0;
- int inputCount = 0;
- int connectionIndex = 0;
- int nodeNum = 0;
- while (n != null) {
- mNodes[nodeNum++] = n;
-
- // Look for unattached kernel inputs
- boolean hasInput = false;
- for (int ct=0; ct < n.mInput.length; ct++) {
- if (n.mInput[ct] != null) {
- if (n.mInput[ct].mToName == null) {
- hasInput = true;
- }
- }
- }
- if (!hasInput) {
- if (mInputs == null) {
- mInputs = new IO[1];
- }
- if (mInputs.length <= inputCount) {
- IO t[] = new IO[mInputs.length + 1];
- System.arraycopy(mInputs, 0, t, 0, mInputs.length);
- mInputs = t;
- }
- mInputs[inputCount++] = new IO(n.mScript);
- }
-
- // Look for unattached kernel outputs
- boolean hasOutput = false;
- for (int ct=0; ct < n.mOutput.length; ct++) {
- if (n.mOutput[ct] != null) {
- hasOutput = true;
- }
- }
- if (!hasOutput) {
- if (mOutputs == null) {
- mOutputs = new IO[1];
- }
- if (mOutputs.length <= outputCount) {
- IO t[] = new IO[mOutputs.length + 1];
- System.arraycopy(mOutputs, 0, t, 0, mOutputs.length);
- mOutputs = t;
- }
- mOutputs[outputCount++] = new IO(n.mScript);
- }
-
- // Make allocations for internal connections
- // Since script outputs are unique, use those to avoid duplicates.
- for (int ct=0; ct < n.mOutput.length; ct++) {
- android.util.Log.v("RSR", "init out2 " + n.mOutput[ct]);
- if (n.mOutput[ct] != null) {
- Connection t = n.mOutput[ct];
- mConnections[connectionIndex++] = t;
- t.mInternalAllocation = Allocation.createTyped(mRS, t.mAllocationType);
- }
- }
-
- n = n.mNext;
- }
- }
-
- public void setInput(Script s, Allocation a) {
+ /**
+ * Sets an input of the ScriptGroup. This specifies an
+ * Allocation to be used for the kernels which require a kernel
+ * input and that input is provided external to the group.
+ *
+ * @param s The ID of the kernel where the allocation should be
+ * connected.
+ * @param a The allocation to connect.
+ */
+ public void setInput(Script.KernelID s, Allocation a) {
for (int ct=0; ct < mInputs.length; ct++) {
- if (mInputs[ct].mScript == s) {
+ if (mInputs[ct].mKID == s) {
mInputs[ct].mAllocation = a;
+ mRS.nScriptGroupSetInput(getID(mRS), s.getID(mRS), mRS.safeID(a));
return;
}
}
throw new RSIllegalArgumentException("Script not found");
}
- public void setOutput(Script s, Allocation a) {
+ /**
+ * Sets an output of the ScriptGroup. This specifies an
+ * Allocation to be used for the kernels which require a kernel
+ * output and that output is provided external to the group.
+ *
+ * @param s The ID of the kernel where the allocation should be
+ * connected.
+ * @param a The allocation to connect.
+ */
+ public void setOutput(Script.KernelID s, Allocation a) {
for (int ct=0; ct < mOutputs.length; ct++) {
- if (mOutputs[ct].mScript == s) {
+ if (mOutputs[ct].mKID == s) {
mOutputs[ct].mAllocation = a;
+ mRS.nScriptGroupSetOutput(getID(mRS), s.getID(mRS), mRS.safeID(a));
return;
}
}
throw new RSIllegalArgumentException("Script not found");
}
+ /**
+ * Execute the ScriptGroup. This will run all the kernels in
+ * the script. The state of the connecting lines will not be
+ * observable after this operation.
+ */
public void execute() {
- android.util.Log.v("RSR", "execute");
- boolean more = true;
- int depth = 0;
- while (more) {
- more = false;
- for (int ct=0; ct < mNodes.length; ct++) {
- if (mNodes[ct].mDepth == depth) {
- more = true;
-
- Allocation kernelIn = null;
- for (int ct2=0; ct2 < mNodes[ct].mInputCount; ct2++) {
- android.util.Log.v("RSR", " kin " + ct2 + ", to " + mNodes[ct].mInput[ct2].mTo[0] + ", name " + mNodes[ct].mInput[ct2].mToName[0]);
- if (mNodes[ct].mInput[ct2].mToName[0] == null) {
- kernelIn = mNodes[ct].mInput[ct2].mInternalAllocation;
- break;
- }
- }
-
- Allocation kernelOut= null;
- for (int ct2=0; ct2 < mNodes[ct].mOutputCount; ct2++) {
- android.util.Log.v("RSR", " kout " + ct2 + ", from " + mNodes[ct].mOutput[ct2].mFrom);
- if (mNodes[ct].mOutput[ct2].mFrom != null) {
- kernelOut = mNodes[ct].mOutput[ct2].mInternalAllocation;
- break;
- }
- }
- if (kernelOut == null) {
- for (int ct2=0; ct2 < mOutputs.length; ct2++) {
- if (mOutputs[ct2].mScript == mNodes[ct].mScript) {
- kernelOut = mOutputs[ct2].mAllocation;
- break;
- }
- }
- }
-
- android.util.Log.v("RSR", "execute calling " + mNodes[ct] + ", with " + kernelIn);
- if (kernelIn != null) {
- try {
-
- Method m = mNodes[ct].mScript.getClass().getMethod("forEach_root",
- new Class[] { Allocation.class, Allocation.class });
- m.invoke(mNodes[ct].mScript, new Object[] {kernelIn, kernelOut} );
- } catch (Throwable t) {
- android.util.Log.e("RSR", "execute error " + t);
- }
- } else {
- try {
- Method m = mNodes[ct].mScript.getClass().getMethod("forEach_root",
- new Class[] { Allocation.class });
- m.invoke(mNodes[ct].mScript, new Object[] {kernelOut} );
- } catch (Throwable t) {
- android.util.Log.e("RSR", "execute error " + t);
- }
- }
-
- }
- }
- depth ++;
- }
-
+ mRS.nScriptGroupExecute(getID(mRS));
}
- public static class Builder {
- RenderScript mRS;
- Node mFirstNode;
- int mConnectionCount = 0;
- int mNodeCount = 0;
+ /**
+ * Create a ScriptGroup. There are two steps to creating a
+ * ScriptGoup.
+ * <p>
+ * First all the Kernels to be used by the group should be
+ * added. Once this is done the kernels should be connected.
+ * Kernels cannot be added once a connection has been made.
+ * <p>
+ * Second, add connections. There are two forms of connections.
+ * Kernel to Kernel and Kernel to Field. Kernel to Kernel is
+ * higher performance and should be used where possible. The
+ * line of connections cannot form a loop. If a loop is detected
+ * an exception is thrown.
+ * <p>
+ * Once all the connections are made a call to create will
+ * return the ScriptGroup object.
+ *
+ */
+ public static final class Builder {
+ private RenderScript mRS;
+ private ArrayList<Node> mNodes = new ArrayList<Node>();
+ private ArrayList<ConnectLine> mLines = new ArrayList<ConnectLine>();
+ private int mKernelCount;
+ /**
+ * Create a builder for generating a ScriptGroup.
+ *
+ *
+ * @param rs The Renderscript context.
+ */
public Builder(RenderScript rs) {
mRS = rs;
}
private void validateRecurse(Node n, int depth) {
n.mSeen = true;
- if (depth > n.mDepth) {
- n.mDepth = depth;
- }
- android.util.Log.v("RSR", " validateRecurse outputCount " + n.mOutputCount);
- for (int ct=0; ct < n.mOutputCount; ct++) {
- for (int ct2=0; ct2 < n.mOutput[ct].mTo.length; ct2++) {
- if (n.mOutput[ct].mTo[ct2].mSeen) {
+ //android.util.Log.v("RSR", " validateRecurse outputCount " + n.mOutputs.size());
+ for (int ct=0; ct < n.mOutputs.size(); ct++) {
+ final ConnectLine cl = n.mOutputs.get(ct);
+ if (cl.mToK != null) {
+ Node tn = findNode(cl.mToK.mScript);
+ if (tn.mSeen) {
throw new RSInvalidStateException("Loops in group not allowed.");
}
- validateRecurse(n.mOutput[ct].mTo[ct2], depth + 1);
+ validateRecurse(tn, depth + 1);
+ }
+ if (cl.mToF != null) {
+ Node tn = findNode(cl.mToF.mScript);
+ if (tn.mSeen) {
+ throw new RSInvalidStateException("Loops in group not allowed.");
+ }
+ validateRecurse(tn, depth + 1);
}
}
}
private void validate() {
- android.util.Log.v("RSR", "validate");
- Node n = mFirstNode;
- while (n != null) {
- n.mSeen = false;
- n.mDepth = 0;
- n = n.mNext;
- }
+ //android.util.Log.v("RSR", "validate");
- n = mFirstNode;
- while (n != null) {
- android.util.Log.v("RSR", "validate n= " + n);
- if ((n.mSeen == false) && (n.mInputCount == 0)) {
- android.util.Log.v("RSR", " recursing " + n);
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ for (int ct2=0; ct2 < mNodes.size(); ct2++) {
+ mNodes.get(ct2).mSeen = false;
+ }
+ Node n = mNodes.get(ct);
+ if (n.mInputs.size() == 0) {
validateRecurse(n, 0);
}
- n = n.mNext;
}
}
- private Node findScript(Script s) {
- Node n = mFirstNode;
- while (n != null) {
- if (n.mScript == s) {
- return n;
+ private Node findNode(Script s) {
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ if (s == mNodes.get(ct).mScript) {
+ return mNodes.get(ct);
}
- n = n.mNext;
}
return null;
}
- private void addNode(Node n) {
- n.mNext = mFirstNode;
- mFirstNode = n;
- }
-
- public Builder addConnection(Type t, Script output, Script input, String inputName) {
- android.util.Log.v("RSR", "addConnection " + t +", " + output + ", " + input);
-
- // Look for existing output
- Node nout = findScript(output);
- Connection c;
- if (nout == null) {
- // Make new node
- android.util.Log.v("RSR", "addConnection new output node");
- nout = new Node(output);
- mNodeCount++;
- c = new Connection(nout, t);
- mConnectionCount++;
- nout.addOutput(c);
- addNode(nout);
- } else {
- // Add to existing node
- android.util.Log.v("RSR", "addConnection reuse output node");
- if (nout.mOutput[0] != null) {
- if (nout.mOutput[0].mFrom.mScript != output) {
- throw new RSInvalidStateException("Changed output of existing node");
- }
- if (nout.mOutput[0].mAllocationType != t) {
- throw new RSInvalidStateException("Changed output type of existing node");
+ private Node findNode(Script.KernelID k) {
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ Node n = mNodes.get(ct);
+ for (int ct2=0; ct2 < n.mKernels.size(); ct2++) {
+ if (k == n.mKernels.get(ct2)) {
+ return n;
}
}
- c = nout.mOutput[0];
}
- // At this point we should have a connection attached to a script ouput.
+ return null;
+ }
- // Find input
- Node nin = findScript(input);
- if (nin == null) {
- android.util.Log.v("RSR", "addConnection new input node");
- nin = new Node(input);
- mNodeCount++;
- addNode(nin);
+ /**
+ * Adds a Kernel to the group.
+ *
+ *
+ * @param k The kernel to add.
+ *
+ * @return Builder Returns this.
+ */
+ public Builder addKernel(Script.KernelID k) {
+ if (mLines.size() != 0) {
+ throw new RSInvalidStateException(
+ "Kernels may not be added once connections exist.");
}
- c.addTo(nin, inputName);
- nin.addInput(c);
+
+ //android.util.Log.v("RSR", "addKernel 1 k=" + k);
+ if (findNode(k) != null) {
+ return this;
+ }
+ //android.util.Log.v("RSR", "addKernel 2 ");
+ mKernelCount++;
+ Node n = findNode(k.mScript);
+ if (n == null) {
+ //android.util.Log.v("RSR", "addKernel 3 ");
+ n = new Node(k.mScript);
+ mNodes.add(n);
+ }
+ n.mKernels.add(k);
+ return this;
+ }
+
+ /**
+ * Adds a connection to the group.
+ *
+ *
+ * @param t The type of the connection. This is used to
+ * determine the kernel launch sizes on the source side
+ * of this connection.
+ * @param from The source for the connection.
+ * @param to The destination of the connection.
+ *
+ * @return Builder Returns this
+ */
+ public Builder addConnection(Type t, Script.KernelID from, Script.FieldID to) {
+ //android.util.Log.v("RSR", "addConnection " + t +", " + from + ", " + to);
+
+ Node nf = findNode(from);
+ if (nf == null) {
+ throw new RSInvalidStateException("From kernel not found.");
+ }
+
+ Node nt = findNode(to.mScript);
+ if (nt == null) {
+ throw new RSInvalidStateException("To script not found.");
+ }
+
+ ConnectLine cl = new ConnectLine(t, from, to);
+ mLines.add(new ConnectLine(t, from, to));
+
+ nf.mOutputs.add(cl);
+ nt.mInputs.add(cl);
validate();
return this;
}
+ /**
+ * Adds a connection to the group.
+ *
+ *
+ * @param t The type of the connection. This is used to
+ * determine the kernel launch sizes for both sides of
+ * this connection.
+ * @param from The source for the connection.
+ * @param to The destination of the connection.
+ *
+ * @return Builder Returns this
+ */
+ public Builder addConnection(Type t, Script.KernelID from, Script.KernelID to) {
+ //android.util.Log.v("RSR", "addConnection " + t +", " + from + ", " + to);
+
+ Node nf = findNode(from);
+ if (nf == null) {
+ throw new RSInvalidStateException("From kernel not found.");
+ }
+
+ Node nt = findNode(to);
+ if (nt == null) {
+ throw new RSInvalidStateException("To script not found.");
+ }
+
+ ConnectLine cl = new ConnectLine(t, from, to);
+ mLines.add(new ConnectLine(t, from, to));
+
+ nf.mOutputs.add(cl);
+ nt.mInputs.add(cl);
+
+ validate();
+ return this;
+ }
+
+
+
+ /**
+ * Creates the Script group.
+ *
+ *
+ * @return ScriptGroup The new ScriptGroup
+ */
public ScriptGroup create() {
- ScriptGroup sg = new ScriptGroup(0, mRS);
- sg.mFirstNode = mFirstNode;
- mFirstNode = null;
+ ArrayList<IO> inputs = new ArrayList<IO>();
+ ArrayList<IO> outputs = new ArrayList<IO>();
- android.util.Log.v("RSR", "create nodes= " + mNodeCount + ", Connections= " + mConnectionCount);
+ int[] kernels = new int[mKernelCount];
+ int idx = 0;
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ Node n = mNodes.get(ct);
+ for (int ct2=0; ct2 < n.mKernels.size(); ct2++) {
+ final Script.KernelID kid = n.mKernels.get(ct2);
+ kernels[idx++] = kid.getID(mRS);
- sg.init(mNodeCount, mConnectionCount);
+ boolean hasInput = false;
+ boolean hasOutput = false;
+ for (int ct3=0; ct3 < n.mInputs.size(); ct3++) {
+ if (n.mInputs.get(ct3).mToK == kid) {
+ hasInput = true;
+ }
+ }
+ for (int ct3=0; ct3 < n.mOutputs.size(); ct3++) {
+ if (n.mOutputs.get(ct3).mFrom == kid) {
+ hasOutput = true;
+ }
+ }
+ if (!hasInput) {
+ inputs.add(new IO(kid));
+ }
+ if (!hasOutput) {
+ outputs.add(new IO(kid));
+ }
+
+ }
+ }
+ if (idx != mKernelCount) {
+ throw new RSRuntimeException("Count mismatch, should not happen.");
+ }
+
+ int[] src = new int[mLines.size()];
+ int[] dstk = new int[mLines.size()];
+ int[] dstf = new int[mLines.size()];
+ int[] types = new int[mLines.size()];
+
+ for (int ct=0; ct < mLines.size(); ct++) {
+ ConnectLine cl = mLines.get(ct);
+ src[ct] = cl.mFrom.getID(mRS);
+ if (cl.mToK != null) {
+ dstk[ct] = cl.mToK.getID(mRS);
+ }
+ if (cl.mToF != null) {
+ dstf[ct] = cl.mToF.getID(mRS);
+ }
+ types[ct] = cl.mAllocationType.getID(mRS);
+ }
+
+ int id = mRS.nScriptGroupCreate(kernels, src, dstk, dstf, types);
+ if (id == 0) {
+ throw new RSRuntimeException("Object creation error, should not happen.");
+ }
+
+ ScriptGroup sg = new ScriptGroup(id, mRS);
+ sg.mOutputs = new IO[outputs.size()];
+ for (int ct=0; ct < outputs.size(); ct++) {
+ sg.mOutputs[ct] = outputs.get(ct);
+ }
+
+ sg.mInputs = new IO[inputs.size()];
+ for (int ct=0; ct < inputs.size(); ct++) {
+ sg.mInputs[ct] = inputs.get(ct);
+ }
+
return sg;
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
index 8d093a7..61e5d4f 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
@@ -91,5 +91,22 @@
forEach(0, null, aout, null);
}
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 2, null, null);
+ }
+
+ /**
+ * Get a FieldID for the input field of this intrinsic.
+ *
+ * @return Script.FieldID The FieldID object.
+ */
+ public Script.FieldID getFieldID_Input() {
+ return createFieldID(1, null);
+ }
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
index 933a4dd..cb458ba 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
@@ -154,5 +154,14 @@
forEach(0, ain, aout, null);
}
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 3, null, null);
+ }
+
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
index fb2948d..d7e9f32 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
@@ -103,5 +103,23 @@
forEach(0, null, aout, null);
}
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 2, null, null);
+ }
+
+ /**
+ * Get a FieldID for the input field of this intrinsic.
+ *
+ * @return Script.FieldID The FieldID object.
+ */
+ public Script.FieldID getFieldID_Input() {
+ return createFieldID(1, null);
+ }
+
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
index 8599426..ff31270 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
@@ -98,5 +98,22 @@
forEach(0, null, aout, null);
}
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 2, null, null);
+ }
+
+ /**
+ * Get a FieldID for the input field of this intrinsic.
+ *
+ * @return Script.FieldID The FieldID object.
+ */
+ public Script.FieldID getFieldID_Input() {
+ return createFieldID(1, null);
+ }
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
index e45c0fd..188e04c 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
@@ -134,5 +134,13 @@
forEach(0, ain, aout, null);
}
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 3, null, null);
+ }
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 2109a01..3f642e8 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -1078,6 +1078,75 @@
return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid);
}
+static jint
+nScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig)
+{
+ LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig);
+ return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig);
+}
+
+static jint
+nScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot)
+{
+ LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot);
+ return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot);
+}
+
+static jint
+nScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src,
+ jintArray _dstk, jintArray _dstf, jintArray _types)
+{
+ LOG_API("nScriptGroupCreate, con(%p)", con);
+
+ jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int);
+ jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL);
+ jint srcLen = _env->GetArrayLength(_src) * sizeof(int);
+ jint *srcPtr = _env->GetIntArrayElements(_src, NULL);
+ jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int);
+ jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL);
+ jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int);
+ jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL);
+ jint typesLen = _env->GetArrayLength(_types) * sizeof(int);
+ jint *typesPtr = _env->GetIntArrayElements(_types, NULL);
+
+ int id = (int)rsScriptGroupCreate(con,
+ (RsScriptKernelID *)kernelsPtr, kernelsLen,
+ (RsScriptKernelID *)srcPtr, srcLen,
+ (RsScriptKernelID *)dstkPtr, dstkLen,
+ (RsScriptFieldID *)dstfPtr, dstfLen,
+ (RsType *)typesPtr, typesLen);
+
+ _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0);
+ _env->ReleaseIntArrayElements(_src, srcPtr, 0);
+ _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0);
+ _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0);
+ _env->ReleaseIntArrayElements(_types, typesPtr, 0);
+ return id;
+}
+
+static void
+nScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
+{
+ LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid);
+ rsScriptGroupExecute(con, (RsScriptGroup)gid);
+}
+
// ---------------------------------------------------------------------------
static jint
@@ -1420,6 +1489,12 @@
{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate },
{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate },
+{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate },
+{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate },
+{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate },
+{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput },
+{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput },
+{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute },
{"rsnProgramStoreCreate", "(IZZZZZZIII)I", (void*)nProgramStoreCreate },
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp
index 984461c..5b1b57d 100644
--- a/libs/hwui/Program.cpp
+++ b/libs/hwui/Program.cpp
@@ -178,7 +178,7 @@
void Program::use() {
glUseProgram(mProgramId);
if (texCoords >= 0 && !mHasSampler) {
- glUniform1i(getUniform("sampler"), 0);
+ glUniform1i(getUniform("baseSampler"), 0);
mHasSampler = true;
}
mUse = true;
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 2d13f60..6baf448 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -294,8 +294,8 @@
";\n",
";\n",
// Modulate
- " * fragColor.a;\n",
- " * fragColor.a;\n",
+ " * color.a;\n",
+ " * color.a;\n",
// Modulate with alpha 8 texture
" * texture2D(baseSampler, outTexCoords).a;\n",
" * pow(texture2D(baseSampler, outTexCoords).a, gamma);\n"
@@ -305,8 +305,8 @@
" fragColor = gradientColor;\n",
" fragColor = gradientColor;\n",
// Modulate
- " fragColor = gradientColor * fragColor.a;\n",
- " fragColor = gradientColor * fragColor.a;\n",
+ " fragColor = gradientColor * color.a;\n",
+ " fragColor = gradientColor * color.a;\n",
// Modulate with alpha 8 texture
" fragColor = gradientColor * texture2D(baseSampler, outTexCoords).a;\n",
" fragColor = gradientColor * pow(texture2D(baseSampler, outTexCoords).a, gamma);\n"
@@ -316,8 +316,8 @@
" fragColor = bitmapColor;\n",
" fragColor = bitmapColor;\n",
// Modulate
- " fragColor = bitmapColor * fragColor.a;\n",
- " fragColor = bitmapColor * fragColor.a;\n",
+ " fragColor = bitmapColor * color.a;\n",
+ " fragColor = bitmapColor * color.a;\n",
// Modulate with alpha 8 texture
" fragColor = bitmapColor * texture2D(baseSampler, outTexCoords).a;\n",
" fragColor = bitmapColor * pow(texture2D(baseSampler, outTexCoords).a, gamma);\n"
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index bd65b9e..487585e 100755
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -490,6 +490,7 @@
MtpConstants.FORMAT_MPEG,
MtpConstants.FORMAT_EXIF_JPEG,
MtpConstants.FORMAT_TIFF_EP,
+ MtpConstants.FORMAT_BMP,
MtpConstants.FORMAT_GIF,
MtpConstants.FORMAT_JFIF,
MtpConstants.FORMAT_PNG,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index a0ae9e3..9839c16 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -344,7 +344,12 @@
String notify = uri.getQueryParameter("notify");
if (notify == null || "true".equals(notify)) {
final int notifyTarget = isGlobal ? UserHandle.USER_ALL : userHandle;
- getContext().getContentResolver().notifyChange(uri, null, true, notifyTarget);
+ final long oldId = Binder.clearCallingIdentity();
+ try {
+ getContext().getContentResolver().notifyChange(uri, null, true, notifyTarget);
+ } finally {
+ Binder.restoreCallingIdentity(oldId);
+ }
if (LOCAL_LOGV) Log.v(TAG, "notifying for " + notifyTarget + ": " + uri);
} else {
if (LOCAL_LOGV) Log.v(TAG, "notification suppressed: " + uri);
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index 60896c3..409a00e 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -42,23 +42,6 @@
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
/>
- <com.android.systemui.statusbar.RotationToggle android:id="@+id/rotation_lock_button"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_margin="8dp"
- android:button="@drawable/ic_notify_rotation"
- android:contentDescription="@string/accessibility_rotation_lock_off"
- android:clickable="true"
- />
-
- <ImageView android:id="@+id/settings_button"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:scaleType="center"
- android:src="@drawable/ic_notify_quicksettings"
- android:contentDescription="@string/accessibility_settings_button"
- />
-
<Space
android:layout_width="0dp"
android:layout_height="0dp"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index ca1f82a..8f6a903 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -177,7 +177,6 @@
// top bar
View mClearButton;
View mSettingsButton;
- RotationToggle mRotationButton;
// carrier/wifi label
private TextView mCarrierLabel;
@@ -365,8 +364,9 @@
mClearButton.setEnabled(false);
mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date);
mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button);
- mSettingsButton.setOnClickListener(mSettingsButtonListener);
- mRotationButton = (RotationToggle) mStatusBarWindow.findViewById(R.id.rotation_lock_button);
+ if (mSettingsButton != null) {
+ mSettingsButton.setOnClickListener(mSettingsButtonListener);
+ }
mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll);
mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns
@@ -819,7 +819,9 @@
}
}
- mSettingsButton.setEnabled(isDeviceProvisioned());
+ if (mSettingsButton != null) {
+ mSettingsButton.setEnabled(isDeviceProvisioned());
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
index 0567371..fece57e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
@@ -96,16 +96,18 @@
}
private void updateBondedBluetoothDevices() {
- Set<BluetoothDevice> devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
- if (devices != null) {
- mBondedDevices.clear();
- for (BluetoothDevice device : devices) {
- if (device.getBondState() != BluetoothDevice.BOND_NONE) {
- mBondedDevices.add(device);
+ mBondedDevices.clear();
+
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ if (adapter != null) {
+ Set<BluetoothDevice> devices = adapter.getBondedDevices();
+ if (devices != null) {
+ for (BluetoothDevice device : devices) {
+ if (device.getBondState() != BluetoothDevice.BOND_NONE) {
+ mBondedDevices.add(device);
+ }
}
}
- } else {
- mBondedDevices.clear();
}
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 47ec243..991f90b 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -179,6 +179,7 @@
});
}
updateSecurityViews();
+ setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
}
private void updateSecurityViews() {
@@ -558,9 +559,13 @@
}
}
- // Discard current runnable if we're switching back to the selector view
+
if (securityMode == SecurityMode.None) {
+ // Discard current runnable if we're switching back to the selector view
setOnDismissRunnable(null);
+ setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
+ } else {
+ setSystemUiVisibility(getSystemUiVisibility() & (~View.STATUS_BAR_DISABLE_BACK));
}
mCurrentSecuritySelection = securityMode;
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index d9088e0..4032db0 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -90,11 +90,11 @@
maybeCreateKeyguardLocked(enableScreenRotation);
maybeEnableScreenRotation(enableScreenRotation);
- // Disable aspects of the system/status/navigation bars that are not appropriate or
- // useful for the lockscreen but can be re-shown by dialogs or SHOW_WHEN_LOCKED activities.
- // Other disabled bits are handled by the KeyguardViewMediator talking directly to the
- // status bar service.
- int visFlags = View.STATUS_BAR_DISABLE_BACK | View.STATUS_BAR_DISABLE_HOME;
+ // Disable common aspects of the system/status/navigation bars that are not appropriate or
+ // useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED
+ // activities. Other disabled bits are handled by the KeyguardViewMediator talking
+ // directly to the status bar service.
+ final int visFlags = View.STATUS_BAR_DISABLE_HOME;
if (DEBUG) Log.v(TAG, "KGVM: Set visibility on " + mKeyguardHost + " to " + visFlags);
mKeyguardHost.setSystemUiVisibility(visFlags);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 372b0fc..7f5a00e 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -1256,7 +1256,9 @@
// windows that appear on top, ever
int flags = StatusBarManager.DISABLE_NONE;
if (mShowing) {
- // disable navigation status bar components (home, recents) if lock screen is up
+ // Permanently disable components not available when keyguard is enabled
+ // (like recents). Temporary enable/disable (e.g. the "back" button) are
+ // done in KeyguardHostView.
flags |= StatusBarManager.DISABLE_RECENT;
if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) {
// showing secure lockscreen; disable expanding.
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 32ab154..ba758e5 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -549,34 +549,6 @@
}
}
- private final BroadcastReceiver mBootReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
- if (userId == -1) return;
- final UserHandle user = new UserHandle(userId);
-
- Slog.d(TAG, "BOOT_COMPLETED for " + user);
-
- // Broadcast mounted volumes to newly booted user. This kicks off
- // media scanner when a user becomes active.
- synchronized (mVolumesLock) {
- for (StorageVolume volume : mVolumes) {
- final UserHandle owner = volume.getOwner();
- final boolean ownerMatch = owner == null
- || owner.getIdentifier() == user.getIdentifier();
-
- final String state = mVolumeStates.get(volume.getPath());
-
- if (ownerMatch && (Environment.MEDIA_MOUNTED.equals(state)
- || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))) {
- sendStorageIntent(Intent.ACTION_MEDIA_MOUNTED, volume, user);
- }
- }
- }
- }
- };
-
private final BroadcastReceiver mUserReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -1309,10 +1281,6 @@
mHandlerThread.start();
mHandler = new MountServiceHandler(mHandlerThread.getLooper());
- // Watch for user boot completion
- mContext.registerReceiverAsUser(mBootReceiver, UserHandle.ALL,
- new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, mHandler);
-
// Watch for user changes
final IntentFilter userFilter = new IntentFilter();
userFilter.addAction(Intent.ACTION_USER_ADDED);
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ce5424b..55dcc65 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -14224,12 +14224,14 @@
@Override
public UserInfo getCurrentUser() {
- if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
- != PackageManager.PERMISSION_GRANTED) {
+ if ((checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
+ != PackageManager.PERMISSION_GRANTED) && (
+ checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
+ != PackageManager.PERMISSION_GRANTED)) {
String msg = "Permission Denial: getCurrentUser() from pid="
+ Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid()
- + " requires " + android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
+ + " requires " + android.Manifest.permission.INTERACT_ACROSS_USERS;
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
diff --git a/services/java/com/android/server/display/WifiDisplayController.java b/services/java/com/android/server/display/WifiDisplayController.java
index 87e11e6..328f687 100644
--- a/services/java/com/android/server/display/WifiDisplayController.java
+++ b/services/java/com/android/server/display/WifiDisplayController.java
@@ -485,6 +485,8 @@
mConnectingDevice = mDesiredDevice;
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = mConnectingDevice.deviceAddress;
+ // Helps with STA & P2P concurrency
+ config.groupOwnerIntent = WifiP2pConfig.MAX_GROUP_OWNER_INTENT;
final WifiDisplay display = createWifiDisplay(mConnectingDevice);
mHandler.post(new Runnable() {
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index be86628..2dc9a6a 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -39,6 +39,7 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.AtomicFile;
import android.util.Slog;
import android.util.SparseArray;
@@ -85,8 +86,6 @@
private SparseArray<UserInfo> mUsers = new SparseArray<UserInfo>();
- private final int mUserLimit;
-
private int[] mUserIds;
private boolean mGuestEnabled;
private int mNextSerialNumber;
@@ -129,8 +128,6 @@
mPm = pm;
mInstallLock = installLock;
mPackagesLock = packagesLock;
- mUserLimit = mContext.getResources().getInteger(
- com.android.internal.R.integer.config_multiuserMaximumUsers);
mUsersDir = new File(dataDir, USER_INFO_DIR);
mUsersDir.mkdirs();
// Make zeroth user directory, for services to migrate their files to that location
@@ -275,7 +272,7 @@
*/
private boolean isUserLimitReachedLocked() {
int nUsers = mUsers.size();
- return nUsers >= mUserLimit;
+ return nUsers >= UserManager.getMaxSupportedUsers();
}
/**
diff --git a/services/java/com/android/server/updatable/CertPinInstallReceiver.java b/services/java/com/android/server/updates/CertPinInstallReceiver.java
similarity index 100%
rename from services/java/com/android/server/updatable/CertPinInstallReceiver.java
rename to services/java/com/android/server/updates/CertPinInstallReceiver.java
diff --git a/services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java b/services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
similarity index 100%
rename from services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java
rename to services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java
index 3ef6d4c..392d5e7 100644
--- a/services/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/java/com/android/server/usb/UsbDeviceManager.java
@@ -91,6 +91,7 @@
private static final int MSG_SET_CURRENT_FUNCTIONS = 2;
private static final int MSG_SYSTEM_READY = 3;
private static final int MSG_BOOT_COMPLETED = 4;
+ private static final int MSG_USER_SWITCHED = 5;
private static final int AUDIO_MODE_NONE = 0;
private static final int AUDIO_MODE_SOURCE = 1;
@@ -295,14 +296,24 @@
private UsbAccessory mCurrentAccessory;
private int mUsbNotificationId;
private boolean mAdbNotificationShown;
+ private int mCurrentUser = UserHandle.USER_NULL;
private final BroadcastReceiver mBootCompletedReceiver = new BroadcastReceiver() {
+ @Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Slog.d(TAG, "boot completed");
mHandler.sendEmptyMessage(MSG_BOOT_COMPLETED);
}
};
+ private final BroadcastReceiver mUserSwitchedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
+ mHandler.obtainMessage(MSG_USER_SWITCHED, userId, 0).sendToTarget();
+ }
+ };
+
public UsbHandler(Looper looper) {
super(looper);
try {
@@ -347,8 +358,10 @@
mUEventObserver.startObserving(USB_STATE_MATCH);
mUEventObserver.startObserving(ACCESSORY_START_MATCH);
- mContext.registerReceiver(mBootCompletedReceiver,
- new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
+ mContext.registerReceiver(
+ mBootCompletedReceiver, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
+ mContext.registerReceiver(
+ mUserSwitchedReceiver, new IntentFilter(Intent.ACTION_USER_SWITCHED));
} catch (Exception e) {
Slog.e(TAG, "Error initializing UsbHandler", e);
}
@@ -611,6 +624,18 @@
mDebuggingManager.setAdbEnabled(mAdbEnabled);
}
break;
+ case MSG_USER_SWITCHED: {
+ final boolean mtpActive =
+ containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_MTP)
+ || containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP);
+ if (mtpActive && mCurrentUser != UserHandle.USER_NULL) {
+ Slog.v(TAG, "Current user switched; resetting USB host stack for MTP");
+ setUsbConfig("none");
+ setUsbConfig(mCurrentFunctions);
+ }
+ mCurrentUser = msg.arg1;
+ break;
+ }
}
}
diff --git a/services/tests/servicestests/src/com/android/server/updatable/CertPinInstallReceiverTest.java b/services/tests/servicestests/src/com/android/server/updates/CertPinInstallReceiverTest.java
similarity index 100%
rename from services/tests/servicestests/src/com/android/server/updatable/CertPinInstallReceiverTest.java
rename to services/tests/servicestests/src/com/android/server/updates/CertPinInstallReceiverTest.java
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java
index 732da4e..29c204c 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java
@@ -21,16 +21,16 @@
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
+import android.renderscript.ScriptIntrinsicConvolve3x3;
+import android.renderscript.ScriptIntrinsicColorMatrix;
import android.renderscript.Type;
import android.renderscript.Matrix4f;
import android.renderscript.ScriptGroup;
import android.util.Log;
public class GroupTest extends TestBase {
- private ScriptC_convolve3x3 mConvolve;
- private ScriptC_colormatrix mMatrix;
+ private ScriptIntrinsicConvolve3x3 mConvolve;
+ private ScriptIntrinsicColorMatrix mMatrix;
private Allocation mScratchPixelsAllocation1;
private ScriptGroup mGroup;
@@ -48,20 +48,20 @@
mWidth = mInPixelsAllocation.getType().getX();
mHeight = mInPixelsAllocation.getType().getY();
- mConvolve = new ScriptC_convolve3x3(mRS, res, R.raw.convolve3x3);
- mMatrix = new ScriptC_colormatrix(mRS, res, R.raw.colormatrix);
+ mConvolve = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
+ mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
float f[] = new float[9];
f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
- mConvolve.set_gCoeffs(f);
+ mConvolve.setCoefficients(f);
Matrix4f m = new Matrix4f();
m.set(1, 0, 0.2f);
m.set(1, 1, 0.9f);
m.set(1, 2, 0.2f);
- mMatrix.invoke_setMatrix(m);
+ mMatrix.setColorMatrix(m);
Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
tb.setX(mWidth);
@@ -70,24 +70,23 @@
if (mUseNative) {
ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
- b.addConnection(connect, mConvolve, mMatrix, null);
+ b.addKernel(mConvolve.getKernelID());
+ b.addKernel(mMatrix.getKernelID());
+ b.addConnection(connect, mConvolve.getKernelID(), mMatrix.getKernelID());
mGroup = b.create();
-
} else {
mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect);
}
}
public void runTest() {
- mConvolve.set_gIn(mInPixelsAllocation);
- mConvolve.set_gWidth(mWidth);
- mConvolve.set_gHeight(mHeight);
+ mConvolve.setInput(mInPixelsAllocation);
if (mUseNative) {
- mGroup.setOutput(mMatrix, mOutPixelsAllocation);
+ mGroup.setOutput(mMatrix.getKernelID(), mOutPixelsAllocation);
mGroup.execute();
} else {
- mConvolve.forEach_root(mScratchPixelsAllocation1);
- mMatrix.forEach_root(mScratchPixelsAllocation1, mOutPixelsAllocation);
+ mConvolve.forEach(mScratchPixelsAllocation1);
+ mMatrix.forEach(mScratchPixelsAllocation1, mOutPixelsAllocation);
}
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
index 100e062..f4440c8 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
@@ -37,6 +37,9 @@
*/
public WpsInfo wps;
+ /** @hide */
+ public static final int MAX_GROUP_OWNER_INTENT = 15;
+
/**
* This is an integer value between 0 and 15 where 0 indicates the least
* inclination to be a group owner and 15 indicates the highest inclination
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 35dd764..13abb79 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -135,7 +135,7 @@
private static final int DISCOVER_TIMEOUT_S = 120;
/* Idle time after a peer is gone when the group is torn down */
- private static final int GROUP_IDLE_TIME_S = 5;
+ private static final int GROUP_IDLE_TIME_S = 20;
private static final int BASE = Protocol.BASE_WIFI_P2P_SERVICE;
@@ -1212,13 +1212,10 @@
mGroup.getNetworkName()));
}
+ mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
if (mGroup.isGroupOwner()) {
startDhcpServer(mGroup.getInterface());
} else {
- // Set group idle only for a client on the group interface to speed up
- // disconnect when GO is gone. Setting group idle time for a group owner
- // causes connectivity issues for new clients
- mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(mContext,
P2pStateMachine.this, mGroup.getInterface());
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
@@ -1283,7 +1280,6 @@
//DHCP server has already been started if I am a group owner
if (mGroup.isGroupOwner()) {
setWifiP2pInfoOnGroupFormation(SERVER_ADDRESS);
- sendP2pConnectionChangedBroadcast();
}
}
@@ -1306,6 +1302,7 @@
} else {
loge("Connect on null device address, ignore");
}
+ sendP2pConnectionChangedBroadcast();
break;
case WifiMonitor.AP_STA_DISCONNECTED_EVENT:
device = (WifiP2pDevice) message.obj;
@@ -1317,6 +1314,11 @@
if (!mAutonomousGroup && mGroup.isClientListEmpty()) {
Slog.d(TAG, "Client list empty, remove non-persistent p2p group");
mWifiNative.p2pGroupRemove(mGroup.getInterface());
+ // We end up sending connection changed broadcast
+ // when this happens at exit()
+ } else {
+ // Notify when a client disconnects from group
+ sendP2pConnectionChangedBroadcast();
}
} else {
if (DBG) logd("Failed to remove client " + deviceAddress);