summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ContextImpl.java33
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java8
-rw-r--r--core/java/android/content/res/Configuration.java4
-rw-r--r--core/java/android/net/http/X509TrustManagerExtensions.java (renamed from core/java/android/net/X509TrustManagerExtensions.java)7
-rw-r--r--core/java/android/os/UserManager.java6
-rw-r--r--core/java/android/text/TextDirectionHeuristics.java3
-rw-r--r--core/java/android/text/TextUtils.java57
-rw-r--r--core/java/android/util/LocaleUtil.java84
-rw-r--r--core/java/android/view/FocusFinder.java2
-rw-r--r--core/java/android/view/Gravity.java12
-rw-r--r--core/java/android/view/View.java26
-rw-r--r--core/java/android/view/Window.java7
-rw-r--r--core/java/android/widget/ListPopupWindow.java4
13 files changed, 113 insertions, 140 deletions
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 @@ class ReceiverRestrictedContext extends ContextWrapper {
@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 @@ package android.appwidget;
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 @@ public class AppWidgetHost {
* @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 @@ public class AppWidgetHost {
* 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 @@ package android.content.res;
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 final class Configuration implements Parcelable, Comparable<Configuration
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/http/X509TrustManagerExtensions.java
index 4026a1d..64eacbc 100644
--- a/core/java/android/net/X509TrustManagerExtensions.java
+++ b/core/java/android/net/http/X509TrustManagerExtensions.java
@@ -16,15 +16,14 @@
package android.net.http;
+import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
+
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.
*
@@ -43,7 +42,7 @@ public class X509TrustManagerExtensions {
* @throws IllegalArgumentException If tm is an unsupported TrustManager type.
*/
public X509TrustManagerExtensions(X509TrustManager tm) throws IllegalArgumentException {
- if (mDelegate instanceof TrustManagerImpl) {
+ if (tm instanceof TrustManagerImpl) {
mDelegate = (TrustManagerImpl) tm;
} else {
throw new IllegalArgumentException("tm is not a supported type of X509TrustManager");
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 com.android.internal.R;
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 @@ public class UserManager {
* @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 @@ public class TextDirectionHeuristics {
@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.URLSpan;
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 @@ public class TextUtils {
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/FocusFinder.java b/core/java/android/view/FocusFinder.java
index 351c5c3..b2988ed 100644
--- a/core/java/android/view/FocusFinder.java
+++ b/core/java/android/view/FocusFinder.java
@@ -228,7 +228,7 @@ public class FocusFinder {
if (focusable == focused || focusable == root) continue;
// get focus bounds of other view in same coordinate system
- focusable.getFocusRect(mOtherRect);
+ focusable.getFocusedRect(mOtherRect);
root.offsetDescendantRectToMyCoords(focusable, mOtherRect);
if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
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 @@ public class Gravity
* 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 @@ public class Gravity
* 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 @@ public class Gravity
* 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 d93c1be..c374ca6 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -48,9 +48,9 @@ import android.os.Parcelable;
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;
@@ -8708,18 +8708,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
}
- /**
- * When searching for a view to focus this rectangle is used when considering if this view is
- * a good candidate for receiving focus.
- *
- * By default, the rectangle is the {@link #getDrawingRect}) of the view.
- *
- * @param r The rectangle to fill in, in this view's coordinates.
- */
- public void getFocusRect(Rect r) {
- getDrawingRect(r);
- }
-
/**
* Utility method to retrieve the inverse of the current mMatrix property.
* We cache the matrix to avoid recalculating it when transform properties
@@ -9698,7 +9686,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* When a view has focus and the user navigates away from it, the next view is searched for
* starting from the rectangle filled in by this method.
*
- * By default, the rectange is the {@link #getDrawingRect(android.graphics.Rect)})
+ * By default, the rectangle is the {@link #getDrawingRect(android.graphics.Rect)})
* of the view. However, if your view maintains some idea of internal selection,
* such as a cursor, or a selected row or column, you should override this method and
* fill in a more specific rectangle.
@@ -11605,8 +11593,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @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 +11643,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @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 +14041,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @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/view/Window.java b/core/java/android/view/Window.java
index a242895..06974d3 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -89,6 +89,13 @@ public abstract class Window {
* If overlay is enabled, the action mode UI will be allowed to cover existing window content.
*/
public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
+
+ /**
+ * Max value used as a feature ID
+ * @hide
+ */
+ public static final int FEATURE_MAX = FEATURE_ACTION_MODE_OVERLAY;
+
/** Flag for setting the progress bar's visibility to VISIBLE */
public static final int PROGRESS_VISIBILITY_ON = -1;
/** Flag for setting the progress bar's visibility to GONE */
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.database.DataSetObserver;
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 @@ public class ListPopupWindow {
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);
}
/**