Merge "Make TextView Marquee RTL-aware"
diff --git a/api/current.txt b/api/current.txt
index 6b6b127..2716d5b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -660,8 +660,10 @@
field public static final int listPreferredItemHeight = 16842829; // 0x101004d
field public static final int listPreferredItemHeightLarge = 16843654; // 0x1010386
field public static final int listPreferredItemHeightSmall = 16843655; // 0x1010387
+ field public static final int listPreferredItemPaddingEnd = 16843710; // 0x10103be
field public static final int listPreferredItemPaddingLeft = 16843683; // 0x10103a3
field public static final int listPreferredItemPaddingRight = 16843684; // 0x10103a4
+ field public static final int listPreferredItemPaddingStart = 16843709; // 0x10103bd
field public static final int listSelector = 16843003; // 0x10100fb
field public static final int listSeparatorTextViewStyle = 16843272; // 0x1010208
field public static final int listViewStyle = 16842868; // 0x1010074
@@ -11401,6 +11403,7 @@
field public static final int MEDIA_INFO_METADATA_UPDATE = 802; // 0x322
field public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321
field public static final int MEDIA_INFO_UNKNOWN = 1; // 0x1
+ field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3
field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc
field public static final java.lang.String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip";
field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; // 0x1
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 9364a57..f3f9b64 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -477,7 +477,7 @@
public Object createService(ContextImpl ctx) {
IBinder b = ServiceManager.getService(WIFI_SERVICE);
IWifiManager service = IWifiManager.Stub.asInterface(b);
- return new WifiManager(service, ctx.mMainThread.getHandler());
+ return new WifiManager(ctx.getOuterContext(), service);
}});
registerService(WIFI_P2P_SERVICE, new ServiceFetcher() {
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index 1ef0916..a28585c 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -1442,9 +1442,9 @@
attendeeValues.put(Attendees.ATTENDEE_STATUS,
subCursor.getInt(COLUMN_ATTENDEE_STATUS));
attendeeValues.put(Attendees.ATTENDEE_IDENTITY,
- subCursor.getInt(COLUMN_ATTENDEE_IDENTITY));
+ subCursor.getString(COLUMN_ATTENDEE_IDENTITY));
attendeeValues.put(Attendees.ATTENDEE_ID_NAMESPACE,
- subCursor.getInt(COLUMN_ATTENDEE_ID_NAMESPACE));
+ subCursor.getString(COLUMN_ATTENDEE_ID_NAMESPACE));
entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);
}
} finally {
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index ce49268..6136d8f 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -416,14 +416,8 @@
outMetrics.ydpi = outMetrics.noncompatYdpi = mDpiY;
}
- static IWindowManager getWindowManager() {
- synchronized (sStaticInit) {
- if (sWindowManager == null) {
- sWindowManager = IWindowManager.Stub.asInterface(
- ServiceManager.getService("window"));
- }
- return sWindowManager;
- }
+ private static IWindowManager getWindowManager() {
+ return WindowManagerImpl.getWindowManagerService();
}
/*
@@ -449,6 +443,5 @@
private static final Object sStaticInit = new Object();
private static boolean sInitialized = false;
- private static IWindowManager sWindowManager;
}
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index dab48b1..8236cd7 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -197,18 +197,18 @@
/**
* Initializes the hardware renderer for the specified surface.
*
- * @param holder The holder for the surface to hardware accelerate.
+ * @param surface The surface to hardware accelerate
*
* @return True if the initialization was successful, false otherwise.
*/
- abstract boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException;
+ abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException;
/**
* Updates the hardware renderer for the specified surface.
- *
- * @param holder The holder for the surface to hardware accelerate
+ *
+ * @param surface The surface to hardware accelerate
*/
- abstract void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException;
+ abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException;
/**
* Destroys the layers used by the specified view hierarchy.
@@ -228,10 +228,10 @@
/**
* This method should be invoked whenever the current hardware renderer
* context should be reset.
- *
- * @param holder The holder for the surface to hardware accelerate
+ *
+ * @param surface The surface to hardware accelerate
*/
- abstract void invalidate(SurfaceHolder holder);
+ abstract void invalidate(Surface surface);
/**
* This method should be invoked to ensure the hardware renderer is in
@@ -474,14 +474,14 @@
*
* @param width The width of the drawing surface.
* @param height The height of the drawing surface.
- * @param holder The target surface
+ * @param surface The surface to hardware accelerate
*/
- void initializeIfNeeded(int width, int height, SurfaceHolder holder)
+ void initializeIfNeeded(int width, int height, Surface surface)
throws Surface.OutOfResourcesException {
if (isRequested()) {
// We lost the gl context, so recreate it.
if (!isEnabled()) {
- if (initialize(holder)) {
+ if (initialize(surface)) {
setup(width, height);
}
}
@@ -742,10 +742,10 @@
}
@Override
- boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException {
+ boolean initialize(Surface surface) throws Surface.OutOfResourcesException {
if (isRequested() && !isEnabled()) {
initializeEgl();
- mGl = createEglSurface(holder);
+ mGl = createEglSurface(surface);
mDestroyed = false;
if (mGl != null) {
@@ -771,9 +771,9 @@
}
@Override
- void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException {
+ void updateSurface(Surface surface) throws Surface.OutOfResourcesException {
if (isRequested() && isEnabled()) {
- createEglSurface(holder);
+ createEglSurface(surface);
}
}
@@ -888,7 +888,7 @@
Log.d(LOG_TAG, " SURFACE_TYPE = 0x" + Integer.toHexString(value[0]));
}
- GL createEglSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException {
+ GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException {
// Check preconditions.
if (sEgl == null) {
throw new RuntimeException("egl not initialized");
@@ -908,7 +908,7 @@
destroySurface();
// Create an EGL surface we can render into.
- if (!createSurface(holder)) {
+ if (!createSurface(surface)) {
return null;
}
@@ -982,7 +982,7 @@
}
@Override
- void invalidate(SurfaceHolder holder) {
+ void invalidate(Surface surface) {
// Cancels any existing buffer to ensure we'll get a buffer
// of the right size before we call eglSwapBuffers
sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
@@ -993,8 +993,8 @@
setEnabled(false);
}
- if (holder.getSurface().isValid()) {
- if (!createSurface(holder)) {
+ if (surface.isValid()) {
+ if (!createSurface(surface)) {
return;
}
@@ -1006,8 +1006,8 @@
}
}
- private boolean createSurface(SurfaceHolder holder) {
- mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null);
+ private boolean createSurface(Surface surface) {
+ mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, surface, null);
if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) {
int error = sEgl.eglGetError();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 697f38e..a89c970 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -12877,7 +12877,8 @@
// to call invalidate() successfully when doing animations
mPrivateFlags |= DRAWN;
- if (!concatMatrix && canvas.quickReject(mLeft, mTop, mRight, mBottom, Canvas.EdgeType.BW) &&
+ if (!concatMatrix && (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) == 0 &&
+ canvas.quickReject(mLeft, mTop, mRight, mBottom, Canvas.EdgeType.BW) &&
(mPrivateFlags & DRAW_ANIMATION) == 0) {
mPrivateFlags2 |= VIEW_QUICK_REJECTED;
return more;
@@ -17296,6 +17297,16 @@
final RectF mTmpTransformRect = new RectF();
/**
+ * Temporary for use in transforming invalidation rect
+ */
+ final Matrix mTmpMatrix = new Matrix();
+
+ /**
+ * Temporary for use in transforming invalidation rect
+ */
+ final Transformation mTmpTransformation = new Transformation();
+
+ /**
* Temporary list for use in collecting focusable descendents of a view.
*/
final ArrayList<View> mTempArrayList = new ArrayList<View>(24);
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index 107f1cc..3082976 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Point;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.DisplayMetrics;
@@ -277,15 +278,17 @@
mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
- final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
// Size of the screen in bytes, in ARGB_8888 format
- mMaximumDrawingCacheSize = 4 * display.getRawWidth() * display.getRawHeight();
+ final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
+ final Point size = new Point();
+ display.getRealSize(size);
+ mMaximumDrawingCacheSize = 4 * size.x * size.y;
mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
if (!sHasPermanentMenuKeySet) {
- IWindowManager wm = Display.getWindowManager();
+ IWindowManager wm = WindowManagerImpl.getWindowManagerService();
try {
sHasPermanentMenuKey = !wm.hasSystemNavBar() && !wm.hasNavigationBar();
sHasPermanentMenuKeySet = true;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 147669f..5ae9a5f 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2988,7 +2988,7 @@
*
* @param enabled True to enable static transformations on children, false otherwise.
*
- * @see #FLAG_SUPPORT_STATIC_TRANSFORMATIONS
+ * @see #getChildStaticTransformation(View, android.view.animation.Transformation)
*/
protected void setStaticTransformationsEnabled(boolean enabled) {
setBooleanFlag(FLAG_SUPPORT_STATIC_TRANSFORMATIONS, enabled);
@@ -2998,7 +2998,8 @@
* Sets <code>t</code> to be the static transformation of the child, if set, returning a
* boolean to indicate whether a static transform was set. The default implementation
* simply returns <code>false</code>; subclasses may override this method for different
- * behavior.
+ * behavior. {@link #setStaticTransformationsEnabled(boolean)} must be set to true
+ * for this method to be called.
*
* @param child The child view whose static transform is being requested
* @param t The Transformation which will hold the result
@@ -3962,11 +3963,27 @@
final int[] location = attachInfo.mInvalidateChildLocation;
location[CHILD_LEFT_INDEX] = child.mLeft;
location[CHILD_TOP_INDEX] = child.mTop;
- if (!childMatrix.isIdentity()) {
+ if (!childMatrix.isIdentity() ||
+ (mGroupFlags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
RectF boundingRect = attachInfo.mTmpTransformRect;
boundingRect.set(dirty);
- //boundingRect.inset(-0.5f, -0.5f);
- childMatrix.mapRect(boundingRect);
+ Matrix transformMatrix;
+ if ((mGroupFlags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
+ Transformation t = attachInfo.mTmpTransformation;
+ boolean transformed = getChildStaticTransformation(child, t);
+ if (transformed) {
+ transformMatrix = attachInfo.mTmpMatrix;
+ transformMatrix.set(t.getMatrix());
+ if (!childMatrix.isIdentity()) {
+ transformMatrix.preConcat(childMatrix);
+ }
+ } else {
+ transformMatrix = childMatrix;
+ }
+ } else {
+ transformMatrix = childMatrix;
+ }
+ transformMatrix.mapRect(boundingRect);
dirty.set((int) (boundingRect.left - 0.5f),
(int) (boundingRect.top - 0.5f),
(int) (boundingRect.right + 0.5f),
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index d5d1b74..e8bd618 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -331,7 +331,7 @@
if (!mInitialized) {
try {
InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
- IWindowManager windowManager = Display.getWindowManager();
+ IWindowManager windowManager = WindowManagerImpl.getWindowManagerService();
sWindowSession = windowManager.openSession(
imm.getClient(), imm.getInputContext());
float animatorScale = windowManager.getAnimationScale(2);
@@ -1500,7 +1500,8 @@
if (mAttachInfo.mHardwareRenderer != null) {
try {
- hwInitialized = mAttachInfo.mHardwareRenderer.initialize(mHolder);
+ hwInitialized = mAttachInfo.mHardwareRenderer.initialize(
+ mHolder.getSurface());
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException initializing HW surface", e);
try {
@@ -1533,7 +1534,7 @@
mSurfaceHolder == null && mAttachInfo.mHardwareRenderer != null) {
mFullRedrawNeeded = true;
try {
- mAttachInfo.mHardwareRenderer.updateSurface(mHolder);
+ mAttachInfo.mHardwareRenderer.updateSurface(mHolder.getSurface());
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException updating HW surface", e);
try {
@@ -1624,7 +1625,7 @@
mHeight != mAttachInfo.mHardwareRenderer.getHeight()) {
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
if (!hwInitialized) {
- mAttachInfo.mHardwareRenderer.invalidate(mHolder);
+ mAttachInfo.mHardwareRenderer.invalidate(mHolder.getSurface());
}
}
}
@@ -2887,7 +2888,7 @@
mFullRedrawNeeded = true;
try {
mAttachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight,
- mHolder);
+ mHolder.getSurface());
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException locking surface", e);
try {
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index dedee97..bd95cdb 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -21,6 +21,7 @@
import android.content.res.Configuration;
import android.opengl.ManagedEGLContext;
import android.os.IBinder;
+import android.os.ServiceManager;
import android.os.SystemProperties;
import android.util.AndroidRuntimeException;
import android.util.Log;
@@ -111,6 +112,7 @@
public static final int ADD_PERMISSION_DENIED = -8;
private static WindowManagerImpl sDefaultWindowManager;
+ private static IWindowManager sWindowManagerService;
private final WindowManagerState mState;
private final Window mParentWindow;
@@ -135,6 +137,16 @@
}
}
+ public static IWindowManager getWindowManagerService() {
+ synchronized (WindowManagerImpl.class) {
+ if (sWindowManagerService == null) {
+ sWindowManagerService = IWindowManager.Stub.asInterface(
+ ServiceManager.getService("window"));
+ }
+ return sWindowManagerService;
+ }
+ }
+
public WindowManagerImpl makeLocal(Window parentWindow) {
return new WindowManagerImpl(mState, parentWindow, parentWindow.getCompatibilityInfo());
}
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 7a67a14..193e98d 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -94,30 +94,33 @@
}
/**
- * Default cache usage pattern. Use with {@link #setCacheMode}.
+ * Default cache usage mode. If the navigation type doesn't impose any
+ * specific behavior, use cached resources when they are available
+ * and not expired, otherwise load resources from the network.
+ * Use with {@link #setCacheMode}.
*/
public static final int LOAD_DEFAULT = -1;
/**
- * Normal cache usage pattern. Use with {@link #setCacheMode}.
+ * Normal cache usage mode. Use with {@link #setCacheMode}.
*/
public static final int LOAD_NORMAL = 0;
/**
- * Use cache if content is there, even if expired (eg, history nav).
- * If it is not in the cache, load from network.
+ * Use cached resources when they are available, even if they have expired.
+ * Otherwise load resources from the network.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_CACHE_ELSE_NETWORK = 1;
/**
- * Don't use the cache, load from network.
+ * Don't use the cache, load from the network.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_NO_CACHE = 2;
/**
- * Don't use the network, load from cache only.
+ * Don't use the network, load from the cache.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_CACHE_ONLY = 3;
diff --git a/core/res/res/layout/activity_list_item.xml b/core/res/res/layout/activity_list_item.xml
index 90babd2..d639aa0 100644
--- a/core/res/res/layout/activity_list_item.xml
+++ b/core/res/res/layout/activity_list_item.xml
@@ -33,6 +33,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft" />
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart" />
</LinearLayout>
diff --git a/core/res/res/layout/list_menu_item_layout.xml b/core/res/res/layout/list_menu_item_layout.xml
index 5c1639c..0f37c71 100644
--- a/core/res/res/layout/list_menu_item_layout.xml
+++ b/core/res/res/layout/list_menu_item_layout.xml
@@ -26,8 +26,8 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:layout_marginStart="?android:attr/listPreferredItemPaddingLeft"
- android:layout_marginEnd="?android:attr/listPreferredItemPaddingRight"
+ android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
+ android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd"
android:duplicateParentState="true">
<TextView
diff --git a/core/res/res/layout/media_route_list_item.xml b/core/res/res/layout/media_route_list_item.xml
index 3f750e0..53d813e 100644
--- a/core/res/res/layout/media_route_list_item.xml
+++ b/core/res/res/layout/media_route_list_item.xml
@@ -31,8 +31,8 @@
android:layout_weight="1"
android:orientation="vertical"
android:gravity="start|center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight">
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/media_route_list_item_checkable.xml b/core/res/res/layout/media_route_list_item_checkable.xml
index 088317f..5fb82f7 100644
--- a/core/res/res/layout/media_route_list_item_checkable.xml
+++ b/core/res/res/layout/media_route_list_item_checkable.xml
@@ -31,8 +31,8 @@
android:layout_weight="1"
android:orientation="vertical"
android:gravity="start|center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight">
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/media_route_list_item_collapse_group.xml b/core/res/res/layout/media_route_list_item_collapse_group.xml
index 9e6a969..323e24d 100644
--- a/core/res/res/layout/media_route_list_item_collapse_group.xml
+++ b/core/res/res/layout/media_route_list_item_collapse_group.xml
@@ -22,8 +22,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:background="#19ffffff"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:gravity="center_vertical">
<TextView android:layout_width="0dp"
diff --git a/core/res/res/layout/media_route_list_item_section_header.xml b/core/res/res/layout/media_route_list_item_section_header.xml
index f0b081a..949635f 100644
--- a/core/res/res/layout/media_route_list_item_section_header.xml
+++ b/core/res/res/layout/media_route_list_item_section_header.xml
@@ -27,8 +27,8 @@
android:textStyle="bold"
android:textAllCaps="true"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="24dp"
/>
</FrameLayout>
diff --git a/core/res/res/layout/media_route_list_item_top_header.xml b/core/res/res/layout/media_route_list_item_top_header.xml
index cdc5393..0c49b24 100644
--- a/core/res/res/layout/media_route_list_item_top_header.xml
+++ b/core/res/res/layout/media_route_list_item_top_header.xml
@@ -23,7 +23,7 @@
android:textStyle="bold"
android:textAllCaps="true"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="24dp"
/>
diff --git a/core/res/res/layout/preference_holo.xml b/core/res/res/layout/preference_holo.xml
index af7130b..7a0a494 100644
--- a/core/res/res/layout/preference_holo.xml
+++ b/core/res/res/layout/preference_holo.xml
@@ -33,11 +33,11 @@
android:orientation="horizontal">
<ImageView
android:id="@+android:id/icon"
- android:layout_width="48dp"
- android:layout_height="48dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="center"
- android:scaleType="centerCrop"
- android:layout_marginEnd="@dimen/preference_item_padding_inner"
+ android:minWidth="48dp"
+ android:paddingRight="@dimen/preference_item_padding_inner"
/>
</LinearLayout>
diff --git a/core/res/res/layout/simple_list_item_1.xml b/core/res/res/layout/simple_list_item_1.xml
index b1da979..4249d10 100644
--- a/core/res/res/layout/simple_list_item_1.xml
+++ b/core/res/res/layout/simple_list_item_1.xml
@@ -20,7 +20,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>
diff --git a/core/res/res/layout/simple_list_item_2.xml b/core/res/res/layout/simple_list_item_2.xml
index d67ecaf..8c6c9d3 100644
--- a/core/res/res/layout/simple_list_item_2.xml
+++ b/core/res/res/layout/simple_list_item_2.xml
@@ -24,7 +24,7 @@
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?android:attr/listPreferredItemPaddingLeft"
+ android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="8dip"
android:textAppearance="?android:attr/textAppearanceListItem"
/>
diff --git a/core/res/res/layout/simple_list_item_activated_1.xml b/core/res/res/layout/simple_list_item_activated_1.xml
index 20a5514..41155e4 100644
--- a/core/res/res/layout/simple_list_item_activated_1.xml
+++ b/core/res/res/layout/simple_list_item_activated_1.xml
@@ -20,8 +20,8 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>
diff --git a/core/res/res/layout/simple_list_item_activated_2.xml b/core/res/res/layout/simple_list_item_activated_2.xml
index a531943..725697d 100644
--- a/core/res/res/layout/simple_list_item_activated_2.xml
+++ b/core/res/res/layout/simple_list_item_activated_2.xml
@@ -27,7 +27,7 @@
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?android:attr/listPreferredItemPaddingLeft"
+ android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceListItem"
/>
diff --git a/core/res/res/layout/simple_list_item_checked.xml b/core/res/res/layout/simple_list_item_checked.xml
index 6d36490..0c497d6 100644
--- a/core/res/res/layout/simple_list_item_checked.xml
+++ b/core/res/res/layout/simple_list_item_checked.xml
@@ -21,6 +21,6 @@
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/textCheckMark"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
/>
diff --git a/core/res/res/layout/simple_list_item_multiple_choice.xml b/core/res/res/layout/simple_list_item_multiple_choice.xml
index 0d142d2..076d8c6 100644
--- a/core/res/res/layout/simple_list_item_multiple_choice.xml
+++ b/core/res/res/layout/simple_list_item_multiple_choice.xml
@@ -21,6 +21,6 @@
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
/>
diff --git a/core/res/res/layout/simple_list_item_single_choice.xml b/core/res/res/layout/simple_list_item_single_choice.xml
index f27c5fb..4c1af09 100644
--- a/core/res/res/layout/simple_list_item_single_choice.xml
+++ b/core/res/res/layout/simple_list_item_single_choice.xml
@@ -21,6 +21,6 @@
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
- android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
- android:paddingEnd="?android:attr/listPreferredItemPaddingRight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
/>
diff --git a/core/res/res/values-af/strings.xml b/core/res/res/values-af/strings.xml
index 7fb0e8f..476f7b0 100644
--- a/core/res/res/values-af/strings.xml
+++ b/core/res/res/values-af/strings.xml
@@ -245,7 +245,7 @@
<string name="permdesc_retrieve_window_content" msgid="3193269069469700265">"Laat die program toe om die inhoud van die aktiewe venster op te haal. Kwaadwillige programme kan die hele venster se inhoud ophaal, en al die teks ondersoek, behalwe wagwoorde."</string>
<string name="permlab_retrieve_window_info" msgid="8532295199112519378">"haal vensterinligting op"</string>
<string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"Laat \'n program toe om inligting oor vensters vanaf die vensterbestuurder op te haal. Kwaadwillige programme kan moontlik inligting ophaal wat vir interne stelselgebruik bedoel is."</string>
- <string name="permlab_filter_events" msgid="8675535648807427389">"filtergebeure"</string>
+ <string name="permlab_filter_events" msgid="8675535648807427389">"filter gebeure"</string>
<string name="permdesc_filter_events" msgid="8006236315888347680">"Laat \'n program toe om \'n invoerfilter te registreer wat die stroom van alle gebruikergebeure filter voordat dit versend word. Kwaadwillige programme kan moontlik die stelsel-UI beheer sonder gebruikers se tussentrede."</string>
<string name="permlab_shutdown" msgid="7185747824038909016">"gedeeltelike afskakeling"</string>
<string name="permdesc_shutdown" msgid="7046500838746291775">"Plaas die aktiwiteitbestuurder in \'n afsluitingstatus. Doen nie \'n volledige afsluiting nie."</string>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
index 446e20ba..b1cf6bd 100644
--- a/core/res/res/values-es-rUS/strings.xml
+++ b/core/res/res/values-es-rUS/strings.xml
@@ -243,10 +243,10 @@
<string name="permdesc_dump" msgid="1778299088692290329">"Permite que la aplicación recupere el estado interno del sistema. Las aplicaciones maliciosas pueden recuperar una amplia variedad de información privada y segura que normalmente no necesitarían."</string>
<string name="permlab_retrieve_window_content" msgid="8022588608994589938">"recuperar contenido de la pantalla"</string>
<string name="permdesc_retrieve_window_content" msgid="3193269069469700265">"Permite que la aplicación recupere el contenido de la ventana activa. Las aplicaciones maliciosas pueden recuperar el contenido completo de la ventana y examinar todo el texto, excepto las contraseñas."</string>
- <string name="permlab_retrieve_window_info" msgid="8532295199112519378">"Recuperar información de ventanas"</string>
- <string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"Permite a una aplicación recuperar la información del administrador de ventanas relacionada con estas. Las aplicaciones maliciosas pueden recuperar información destinada al uso interno del sistema."</string>
- <string name="permlab_filter_events" msgid="8675535648807427389">"Filtrar eventos"</string>
- <string name="permdesc_filter_events" msgid="8006236315888347680">"Permite a una aplicación registrar un filtro de entrada que filtre la transmisión de todos los eventos del usuario antes de ser enviados. Las aplicaciones maliciosas pueden controlar la IU del sistema sin la intervención del usuario."</string>
+ <string name="permlab_retrieve_window_info" msgid="8532295199112519378">"recuperar información de ventanas"</string>
+ <string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"Permite que una aplicación recupere la información del administrador de ventanas relacionada con estas. Las aplicaciones maliciosas pueden recuperar información destinada al uso interno del sistema."</string>
+ <string name="permlab_filter_events" msgid="8675535648807427389">"filtrar eventos"</string>
+ <string name="permdesc_filter_events" msgid="8006236315888347680">"Permite que una aplicación registre un filtro de entrada que filtre la transmisión de todos los eventos del usuario antes de ser enviados. Las aplicaciones maliciosas pueden controlar la IU del sistema sin la intervención del usuario."</string>
<string name="permlab_shutdown" msgid="7185747824038909016">"cierre parcial"</string>
<string name="permdesc_shutdown" msgid="7046500838746291775">"Pone al administrador de la actividad en estado de cierre. No realiza un cierre completo."</string>
<string name="permlab_stopAppSwitches" msgid="4138608610717425573">"impedir conmutadores de aplicación"</string>
diff --git a/core/res/res/values-fa/strings.xml b/core/res/res/values-fa/strings.xml
index fa98e56..e497489 100644
--- a/core/res/res/values-fa/strings.xml
+++ b/core/res/res/values-fa/strings.xml
@@ -244,9 +244,9 @@
<string name="permlab_retrieve_window_content" msgid="8022588608994589938">"بازیابی محتوای صفحه"</string>
<string name="permdesc_retrieve_window_content" msgid="3193269069469700265">"به برنامه اجازه میدهد تا محتوای پنجره فعال را بازیابی کند. برنامههای مخرب میتوانند کل محتوای پنجره را بازیابی کنند و همه متن آنرا به غیر از گذرواژهها امتحان کنند."</string>
<string name="permlab_retrieve_window_info" msgid="8532295199112519378">"بازیابی اطلاعات پنجره"</string>
- <string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"به یک برنامهٔ کاربردی اجازه میدهد که اطلاعات مربوط به پنجرهها را از مدیریت پنجره بازیابی کند. برنامههای کاربردی مخرب ممکن است اطلاعاتی که برای استفاده سیستم داخلی درنظر گرفته شدهاند را بازیابی کنند."</string>
+ <string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"به یک برنامه کاربردی اجازه میدهد که اطلاعات مربوط به پنجرهها را از مدیریت پنجره بازیابی کند. برنامههای کاربردی مخرب ممکن است اطلاعاتی که برای استفاده سیستم داخلی درنظر گرفته شدهاند را بازیابی کنند."</string>
<string name="permlab_filter_events" msgid="8675535648807427389">"فیلتر کردن رویدادها"</string>
- <string name="permdesc_filter_events" msgid="8006236315888347680">"به یک برنامهٔ کاربردی اجازه میدهد یک فیلتر ورودی را که جریان تمام رویدادهای کاربران را قبل از ارسال شدن فیلتر میکند، ثبت نماید. برنامه کاربردی مخرب ممکن است رابط کاربری سیستم را بدون مداخله کاربر، کنترل کند."</string>
+ <string name="permdesc_filter_events" msgid="8006236315888347680">"به یک برنامه کاربردی اجازه میدهد یک فیلتر ورودی را که جریان تمام رویدادهای کاربران را قبل از ارسال شدن فیلتر میکند، ثبت نماید. برنامه کاربردی مخرب ممکن است رابط کاربری سیستم را بدون مداخله کاربر، کنترل کند."</string>
<string name="permlab_shutdown" msgid="7185747824038909016">"خاموش شدن جزئی"</string>
<string name="permdesc_shutdown" msgid="7046500838746291775">"مدیر فعالیت را در حالت خاموشی قرار میدهد. خاموشی را به صورت کامل انجام نمیدهد."</string>
<string name="permlab_stopAppSwitches" msgid="4138608610717425573">"ممانعت از جابجایی برنامه"</string>
diff --git a/core/res/res/values-nl/strings.xml b/core/res/res/values-nl/strings.xml
index c6c4d5f..04765cf 100644
--- a/core/res/res/values-nl/strings.xml
+++ b/core/res/res/values-nl/strings.xml
@@ -824,7 +824,7 @@
<string name="searchview_description_query" msgid="5911778593125355124">"Zoekopdracht"</string>
<string name="searchview_description_clear" msgid="1330281990951833033">"Zoekopdracht wissen"</string>
<string name="searchview_description_submit" msgid="2688450133297983542">"Zoekopdracht verzenden"</string>
- <string name="searchview_description_voice" msgid="2453203695674994440">"Spraakgestuurd zoeken"</string>
+ <string name="searchview_description_voice" msgid="2453203695674994440">"Gesproken zoekopdrachten"</string>
<string name="enable_explore_by_touch_warning_title" msgid="7460694070309730149">"\'Verkennen via aanraking\' aan?"</string>
<string name="enable_explore_by_touch_warning_message" product="tablet" msgid="8655887539089910577">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> wil \'Verkennen via aanraking\' inschakelen. Wanneer \'Verkennen via aanraking\' is ingeschakeld, kunt u beschrijvingen beluisteren of bekijken van wat er onder uw vinger staat of aanraakbewerkingen uitvoeren op de tablet."</string>
<string name="enable_explore_by_touch_warning_message" product="default" msgid="2708199672852373195">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> wil \'Verkennen via aanraking\' inschakelen. Wanneer \'Verkennen via aanraking\' is ingeschakeld, kunt u beschrijvingen beluisteren of bekijken van wat er onder uw vinger staat of aanraakbewerkingen uitvoeren op de telefoon."</string>
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index 12f80da..2657d92 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -245,8 +245,8 @@
<string name="permdesc_retrieve_window_content" msgid="3193269069469700265">"允许应用检索活动窗口的内容。恶意应用可能会检索整个窗口的内容,并检查其中除密码以外的所有文字。"</string>
<string name="permlab_retrieve_window_info" msgid="8532295199112519378">"检索窗口信息"</string>
<string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"允许应用通过窗口管理器检索窗口信息。恶意应用可能会检索供内部系统使用的信息。"</string>
- <string name="permlab_filter_events" msgid="8675535648807427389">"过滤活动"</string>
- <string name="permdesc_filter_events" msgid="8006236315888347680">"允许应用注册输入过滤器,这类过滤器会在所有用户活动分派之前对这些用户活动的信息流进行过滤。恶意应用可能会在没有用户干预的情况下控制系统用户界面。"</string>
+ <string name="permlab_filter_events" msgid="8675535648807427389">"过滤事件"</string>
+ <string name="permdesc_filter_events" msgid="8006236315888347680">"允许应用注册输入过滤器,这类过滤器会在所有用户事件分派之前对用户事件流进行过滤。恶意应用可能会在没有用户干预的情况下控制系统用户界面。"</string>
<string name="permlab_shutdown" msgid="7185747824038909016">"部分关机"</string>
<string name="permdesc_shutdown" msgid="7046500838746291775">"使活动管理器进入关闭状态。不执行彻底关机。"</string>
<string name="permlab_stopAppSwitches" msgid="4138608610717425573">"禁止切换应用"</string>
diff --git a/core/res/res/values-zu/strings.xml b/core/res/res/values-zu/strings.xml
index 59cdab1..7c9a500 100644
--- a/core/res/res/values-zu/strings.xml
+++ b/core/res/res/values-zu/strings.xml
@@ -245,7 +245,7 @@
<string name="permdesc_retrieve_window_content" msgid="3193269069469700265">"Ivumela insiza ukuthi ithole okuqukethe kwi-Window. Izinsiza ezinobungozi zingathola kabush iwindi eliphelele bese ibheka konke okuqukethwe ngaphandle kwaaaphasiwedi."</string>
<string name="permlab_retrieve_window_info" msgid="8532295199112519378">"buyisa ulwazi lewindi"</string>
<string name="permdesc_retrieve_window_info" msgid="4998836370424186849">"Ivumela uhlelo lokusebenza ukubuyisa ulwazi mayelana namawindi avela kumphathi wewindi. Izinhlelo zokusebenza zingabuyisa ulwazi olubhekiswe ukusetshenziselwa kohlelo lwangaphakathi."</string>
- <string name="permlab_filter_events" msgid="8675535648807427389">"hlunga izehlakalo"</string>
+ <string name="permlab_filter_events" msgid="8675535648807427389">"hlunga imicimbi"</string>
<string name="permdesc_filter_events" msgid="8006236315888347680">"Ivumela uhlelo lokusebenza ukubhalisa isihlungi sokufaka ukusakaza kwazo zonke izehlakalo zomsebenzisi ngaphambi kokuthunyelwa. Izinhlelo zokusebenza zingalawula i-UI yohlelo ngaphandle kokungena komsebenzisi."</string>
<string name="permlab_shutdown" msgid="7185747824038909016">"ukuvala shaqa kwengxenye"</string>
<string name="permdesc_shutdown" msgid="7046500838746291775">"Ibeka imeneja yomsebenzi kwisimo sokuvala shaqa. Ayenzi ukuvala shaqa okuphelele."</string>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 258914b..6386bcb 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -275,6 +275,11 @@
<!-- The preferred item height for dropdown lists. -->
<attr name="dropdownListPreferredItemHeight" format="dimension" />
+ <!-- The preferred padding along the start edge of list items. -->
+ <attr name="listPreferredItemPaddingStart" format="dimension" />
+ <!-- The preferred padding along the end edge of list items. -->
+ <attr name="listPreferredItemPaddingEnd" format="dimension" />
+
<!-- ============= -->
<!-- Window styles -->
<!-- ============= -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 9bc3c89..b9b8a1b 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3662,9 +3662,10 @@
<!-- ===============================================================
Resources added in version 17 of the platform (Jelly Bean MRx?)
=============================================================== -->
+ <eat-comment />
<public type="attr" name="supportsRtl" />
- <public type="attr" name="textDirection"/>
- <public type="attr" name="textAlignment"/>
+ <public type="attr" name="textDirection" />
+ <public type="attr" name="textAlignment" />
<public type="attr" name="layoutDirection" />
<public type="attr" name="paddingStart"/>
<public type="attr" name="paddingEnd"/>
@@ -3676,5 +3677,7 @@
<public type="attr" name="layout_alignEnd" />
<public type="attr" name="layout_alignParentStart" />
<public type="attr" name="layout_alignParentEnd" />
+ <public type="attr" name="listPreferredItemPaddingStart" />
+ <public type="attr" name="listPreferredItemPaddingEnd" />
</resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 2f18944..9c12263 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -128,6 +128,8 @@
<item name="textAppearanceListItemSmall">?android:attr/textAppearanceLarge</item>
<item name="listPreferredItemPaddingLeft">6dip</item>
<item name="listPreferredItemPaddingRight">6dip</item>
+ <item name="listPreferredItemPaddingStart">6dip</item>
+ <item name="listPreferredItemPaddingEnd">6dip</item>
<!-- @hide -->
<item name="searchResultListItemHeight">58dip</item>
@@ -637,6 +639,8 @@
<item name="listPreferredItemPaddingLeft">10dip</item>
<item name="listPreferredItemPaddingRight">10dip</item>
+ <item name="listPreferredItemPaddingStart">10dip</item>
+ <item name="listPreferredItemPaddingEnd">10dip</item>
</style>
<!-- Variant of {@link Theme_Dialog} that does not include a frame (or background).
@@ -962,6 +966,8 @@
<item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
<item name="listPreferredItemPaddingLeft">8dip</item>
<item name="listPreferredItemPaddingRight">8dip</item>
+ <item name="listPreferredItemPaddingStart">8dip</item>
+ <item name="listPreferredItemPaddingEnd">8dip</item>
<!-- @hide -->
<item name="searchResultListItemHeight">58dip</item>
@@ -1267,6 +1273,8 @@
<item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
<item name="listPreferredItemPaddingLeft">8dip</item>
<item name="listPreferredItemPaddingRight">8dip</item>
+ <item name="listPreferredItemPaddingStart">8dip</item>
+ <item name="listPreferredItemPaddingEnd">8dip</item>
<!-- @hide -->
<item name="searchResultListItemHeight">58dip</item>
@@ -1573,6 +1581,8 @@
<item name="listPreferredItemPaddingLeft">16dip</item>
<item name="listPreferredItemPaddingRight">16dip</item>
+ <item name="listPreferredItemPaddingStart">16dip</item>
+ <item name="listPreferredItemPaddingEnd">16dip</item>
</style>
<!-- Variant of Theme.Holo.Dialog that has a nice minimum width for
@@ -1681,6 +1691,8 @@
<item name="listPreferredItemPaddingLeft">16dip</item>
<item name="listPreferredItemPaddingRight">16dip</item>
+ <item name="listPreferredItemPaddingStart">16dip</item>
+ <item name="listPreferredItemPaddingEnd">16dip</item>
</style>
<!-- Variant of Theme.Holo.Light.Dialog that has a nice minimum width for
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index f01562c..6630601 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -94,7 +94,6 @@
* Control Wifi States
*/
public WifiManager mWifiManager;
- public WifiManager.Channel mChannel;
/*
* Verify connectivity state
@@ -242,7 +241,6 @@
// Get an instance of WifiManager
mWifiManager =(WifiManager)getSystemService(Context.WIFI_SERVICE);
mContext = this;
- mChannel = mWifiManager.initialize(mContext, mContext.getMainLooper(), null);
if (mWifiManager.isWifiApEnabled()) {
// if soft AP is enabled, disable it
@@ -599,7 +597,7 @@
log("found " + ssid + " in the scan result list");
log("retry: " + retry);
foundApInScanResults = true;
- mWifiManager.connect(mChannel, config,
+ mWifiManager.connect(config,
new WifiManager.ActionListener() {
public void onSuccess() {
}
@@ -658,7 +656,7 @@
for (WifiConfiguration wifiConfig: wifiConfigList) {
log("remove wifi configuration: " + wifiConfig.networkId);
int netId = wifiConfig.networkId;
- mWifiManager.forget(mChannel, netId, new WifiManager.ActionListener() {
+ mWifiManager.forget(netId, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
index 8d73bc0..81075ef 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
@@ -63,7 +63,6 @@
private ConnectivityManagerTestActivity mAct;
private ConnectivityManagerTestRunner mRunner;
private WifiManager mWifiManager = null;
- private WifiManager.Channel mChannel;
private Set<WifiConfiguration> enabledNetworks = null;
public WifiConnectionTest() {
@@ -77,7 +76,6 @@
mWifiManager = (WifiManager) mRunner.getContext().getSystemService(Context.WIFI_SERVICE);
mAct = getActivity();
- mChannel = mWifiManager.initialize(mAct, mAct.getMainLooper(), null);
networks = mAct.loadNetworkConfigurations();
if (DEBUG) {
@@ -93,24 +91,6 @@
assertTrue("wpa_supplicant is not started ", mAct.mWifiManager.pingSupplicant());
}
- private class WifiServiceHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
- if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
- //AsyncChannel in msg.obj
- } else {
- log("Failed to establish AsyncChannel connection");
- }
- break;
- default:
- //Ignore
- break;
- }
- }
- }
-
private void printNetworkConfigurations() {
log("==== print network configurations parsed from XML file ====");
log("number of access points: " + networks.size());
diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
index c3cc7c5..d5fcc1c 100644
--- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
+++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
@@ -74,7 +74,6 @@
private int mWifiState;
private NetworkInfo mWifiNetworkInfo;
private WifiManager mWifiManager;
- private WifiManager.Channel mChannel;
private Context mContext;
// Verify connectivity state
private static final int NUM_NETWORK_TYPES = ConnectivityManager.MAX_NETWORK_TYPE + 1;
@@ -115,7 +114,6 @@
// Get an instance of WifiManager
mWifiManager =(WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
- mChannel = mWifiManager.initialize(mContext, mContext.getMainLooper(), null);
mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
@@ -574,7 +572,7 @@
Log.v(LOG_TAG, "Found " + ssid + " in the scan result list.");
Log.v(LOG_TAG, "Retry: " + retry);
foundApInScanResults = true;
- mWifiManager.connect(mChannel, config, new WifiManager.ActionListener() {
+ mWifiManager.connect(config, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
@@ -628,7 +626,7 @@
for (WifiConfiguration wifiConfig: wifiConfigList) {
Log.v(LOG_TAG, "Remove wifi configuration: " + wifiConfig.networkId);
int netId = wifiConfig.networkId;
- mWifiManager.forget(mChannel, netId, new WifiManager.ActionListener() {
+ mWifiManager.forget(netId, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 38a75b6..1b69daf 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -167,6 +167,12 @@
<assign-permission name="android.permission.FORCE_STOP_PACKAGES" uid="shell" />
<assign-permission name="android.permission.STOP_APP_SWITCHES" uid="shell" />
<assign-permission name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY" uid="shell" />
+ <assign-permission name="android.permission.GRANT_REVOKE_PERMISSIONS" uid="shell" />
+ <assign-permission name="android.permission.SET_KEYBOARD_LAYOUT" uid="shell" />
+ <assign-permission name="android.permission.GET_DETAILED_TASKS" uid="shell" />
+ <assign-permission name="android.permission.SET_SCREEN_COMPATIBILITY" uid="shell" />
+ <assign-permission name="android.permission.READ_EXTERNAL_STORAGE" uid="shell" />
+ <assign-permission name="android.permission.WRITE_EXTERNAL_STORAGE" uid="shell" />
<assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" />
<assign-permission name="android.permission.ACCESS_DRM" uid="media" />
diff --git a/docs/html/images/tools/lint.png b/docs/html/images/tools/lint.png
new file mode 100644
index 0000000..889e325
--- /dev/null
+++ b/docs/html/images/tools/lint.png
Binary files differ
diff --git a/docs/html/images/tools/lint_output.png b/docs/html/images/tools/lint_output.png
new file mode 100644
index 0000000..554aee7
--- /dev/null
+++ b/docs/html/images/tools/lint_output.png
Binary files differ
diff --git a/docs/html/sdk/installing/installing-adt.jd b/docs/html/sdk/installing/installing-adt.jd
index 60f67a2..414b97b 100644
--- a/docs/html/sdk/installing/installing-adt.jd
+++ b/docs/html/sdk/installing/installing-adt.jd
@@ -1,9 +1,9 @@
page.title=Installing the Eclipse Plugin
walkthru=1
-adt.zip.version=20.0.1
-adt.zip.download=ADT-20.0.1.zip
-adt.zip.bytes=12387574
-adt.zip.checksum=6ebd7f8566bfd2cd031b07d56d49542d
+adt.zip.version=20.0.2
+adt.zip.download=ADT-20.0.2.zip
+adt.zip.bytes=12388464
+adt.zip.checksum=8e727bcdc9789c900784a82e6330ec22
@jd:body
diff --git a/docs/html/tools/debugging/debugging-ui.jd b/docs/html/tools/debugging/debugging-ui.jd
index c1976b8..a5991ec 100644
--- a/docs/html/tools/debugging/debugging-ui.jd
+++ b/docs/html/tools/debugging/debugging-ui.jd
@@ -29,7 +29,7 @@
<li><a href="#overlays">Working with Pixel Perfect overlays</a></li>
</ol>
</li>
- <li><a href="#layoutopt">Using layoutopt</a></li>
+ <li><a href="#lint">Using lint to optimize your UI</a></li>
</ol>
<h2>Related videos</h2>
<ol>
@@ -55,15 +55,15 @@
<p>
Sometimes your application's layout can slow down your application.
To help debug issues in your layout, the Android SDK provides the Hierarchy Viewer and
- <code>layoutopt</code> tools.
+ <code>lint</code> tools.
</p>
<p>The Hierarchy Viewer application allows you to debug and optimize your user interface. It
provides a visual representation of the layout's View hierarchy (the View Hierarchy window)
and a magnified view of the display (the Pixel Perfect window).</p>
- <p><code>layoutopt</code> is a command-line tool that helps you optimize the layouts and layout
- hierarchies of your applications. You can run it against your layout files or resource
+ <p>Android <code>lint</code> is a static code scanning tool that helps you optimize the layouts and layout
+ hierarchies of your applications, as well as detect other common coding problems. You can run it against your layout files or resource
directories to quickly check for inefficiencies or other types of problems that could be
affecting the performance of your application.</p>
@@ -491,57 +491,7 @@
alt=""
height="600"/>
<p class="img-caption"><strong>Figure 4.</strong> The Pixel Perfect window</p>
-<h2 id="layoutopt">Using layoutopt</h2>
-<p>
- The <code>layoutopt</code> tool lets you analyze the XML files that define your
- application's UI to find inefficiencies in the view hierarchy.</p>
-
-<p>
- To run the tool, open a terminal and launch <code>layoutopt <xmlfiles></code>
- from your SDK <code>tools/</code> directory. The <xmlfiles> argument is a space-
- delimited list of resources you want to analyze, either uncompiled resource xml files or
- directories of such files.
-</p>
-<p>
- The tool loads the specified XML files and analyzes their definitions and
- hierarchies according to a set of predefined rules. For every issue it detects, it
- displays the following information:
-</p>
-<ul>
- <li>
- The filename in which the issue was detected.
- </li>
- <li>
- The line number for the issue.
- </li>
- <li>
- A description of the issue, and for some types of issues it also suggests a resolution.
- </li>
-</ul>
-<p>The following is a sample of the output from the tool:</p>
-<pre>
-$ layoutopt samples/
-samples/compound.xml
- 7:23 The root-level <FrameLayout/> can be replaced with <merge/>
- 11:21 This LinearLayout layout or its FrameLayout parent is useless
-samples/simple.xml
- 7:7 The root-level <FrameLayout/> can be replaced with <merge/>
-samples/too_deep.xml
- -1:-1 This layout has too many nested layouts: 13 levels, it should have <= 10!
- 20:81 This LinearLayout layout or its LinearLayout parent is useless
- 24:79 This LinearLayout layout or its LinearLayout parent is useless
- 28:77 This LinearLayout layout or its LinearLayout parent is useless
- 32:75 This LinearLayout layout or its LinearLayout parent is useless
- 36:73 This LinearLayout layout or its LinearLayout parent is useless
- 40:71 This LinearLayout layout or its LinearLayout parent is useless
- 44:69 This LinearLayout layout or its LinearLayout parent is useless
- 48:67 This LinearLayout layout or its LinearLayout parent is useless
- 52:65 This LinearLayout layout or its LinearLayout parent is useless
- 56:63 This LinearLayout layout or its LinearLayout parent is useless
-samples/too_many.xml
- 7:413 The root-level <FrameLayout/> can be replaced with <merge/>
- -1:-1 This layout has too many views: 81 views, it should have <= 80!
-samples/useless.xml
- 7:19 The root-level <FrameLayout/> can be replaced with <merge/>
- 11:17 This LinearLayout layout or its FrameLayout parent is useless
-</pre>
+<h2 id="lint">Using lint to Optimize Your UI</h2>
+<p>The Android {@code lint} tool lets you analyze the XML files that define your application's UI to find inefficiencies in the view hierarchy.</p>
+<p class="note"><strong>Note: </strong>The Android <code>layoutopt</code> tool has been replaced by the {@code lint} tool beginning in ADT and SDK Tools revision 16. The {@code lint} tool reports UI layout performance issues in a similar way as <code>layoutopt</code>, and detects additional problems.</p>
+<p>For more information about using {@code lint}, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a> and the <a href="{@docRoot}tools/help/lint.html">lint reference documentation</a>.</p>
diff --git a/docs/html/tools/debugging/improving-w-lint.jd b/docs/html/tools/debugging/improving-w-lint.jd
new file mode 100644
index 0000000..7e238fa
--- /dev/null
+++ b/docs/html/tools/debugging/improving-w-lint.jd
@@ -0,0 +1,219 @@
+page.title=Improving Your Code with lint
+parent.title=Debugging
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In This Document</h2>
+
+ <ol>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href=#eclipse">Running lint from Eclipse</a></li>
+ <li><a href=#commandline">Running lint from the command-line</a></li>
+ <li><a href=#config">Configuring lint</a>
+ <ol>
+ <LI><a href="#eclipse_config">Configuring lint in Eclipse</a></LI>
+ <LI><a href="#pref">Configuring the lint file</a></LI>
+ <LI><a href="#src">Configuring lint checking in Java and XML source files</a></LI>
+ </ol>
+ </li>
+ </ol>
+ <h2>See Also</h2>
+ <ol>
+ <li><a href="{@docRoot}tools/help/lint.html">lint (reference)</a></li>
+ </ol>
+ </div>
+</div>
+
+
+<p>
+In addition to testing that your Android application meets its functional requirements, it's important to ensure that your code has no structural problems. Poorly structured code can impact the reliability and efficiency of your Android apps and make your code harder to maintain. For example, if your XML resource files contain unused namespaces, this takes up space and incurs unnecessary processing. Other structural issues, such as use of deprecated elements or API calls that are not supported by the target API versions, might lead to code failing to run correctly.</p>
+
+<h2 id="overview">Overview</h2>
+<p>The Android SDK provides a code scanning tool called {@code lint} that can help you to easily identify and correct problems with the structural quality of your code, without having to execute the app or write any test cases. Each problem detected by the tool is reported with a description message and a severity level, so that you can quickly prioritize the critical improvements that need to be made. You can also configure a problem's severity level to ignore issues that are not relevant for your project, or raise the severity level. The tool has a command-line interface, so you can easily integrate it into your automated testing process.</p>
+<p>The {@code lint} tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. You can run {@code lint} from the command-line or from the Eclipse environment.</p>
+<p>Figure 1 shows how the {@code lint} tool processes the application source files.</p>
+<img id="Fig1" src="{@docRoot}images/tools/lint.png" alt="">
+<p class="img-caption"><strong>Figure 1.</strong> Code scanning workflow with the {@code lint} tool</p>
+<dl>
+<dt><b>Application source files</b></dt>
+<dd>The source files consist of files that make up your Android project, including Java and XML files, icons, and ProGuard configuration files. </dd>
+<dt><b>The <code>lint.xml</code> file</b></dt>
+<dd>A configuration file that you can use to specify any {@code lint} checks that you want to exclude and to customize problem severity levels.</dd>
+<dt><b>The {@code lint} tool</b></dt>
+<dd>A static code scanning tool that you can run on your Android project from the command-line or from Eclipse. The {@code lint} tool checks for structural code problems that could affect the quality and performance of your Android application. It is strongly recommended that you correct any errors that {@code lint} detects before publishing your application.</dd>
+<dt><b>Results of {@code lint} checking</b></dt>
+<dd>You can view the results from {@code lint} in the console or in the <strong>Lint Warnings</strong> view in Eclipse. Each issue is identified by the location in the source files where it occurred and a description of the issue.</dd>
+</dl>
+<p>The {@code lint} tool is automatically installed as part of the Android SDK Tools revision 16 or higher. If you want to use {@code lint} in the Eclipse environment, you must also install the Android Development Tools (ADT) Plugin for Eclipse revision 16 or higher. For more information about installing the SDK or the ADT Plugin for Eclipse, see <a href="http://developer.android.com/sdk/installing.html">Installing the SDK.</a></p>
+
+<h2 id="eclipse">Running lint from Eclipse</h2>
+<p>If the ADT Plugin is installed in your Eclipse environment, the {@code lint} tool runs automatically when you perform one of these actions:</p>
+<ul>
+<LI>Export an APK</LI>
+<LI>Edit and save an XML source file in your Android project (such as a manifest or layout file)</LI>
+<LI>Use the layout editor in Eclipse to make changes</LI>
+</ul>
+<p>Note that when you export an APK, {@code lint} only runs an automatic check for fatal errors and aborts the export if fatal errors are found. You can turn off this automatic checking from the <strong>Lint Error Checking</strong> page in Eclipse Preferences. </p>
+<p>The output is displayed in the <strong>Lint Warnings</strong> view. If the <strong>Lint Warnings</strong> view is not showing in the workbench, you can bring it up from the Eclipse menu by clicking <strong>Window > Show View > Other > Android > Lint Warnings</strong>.</p>
+<p>Figure 2 shows an example of the output in the Lint Warnings view.</p>
+<img id="Fig2" src="{@docRoot}images/tools/lint_output.png" alt="">
+<p class="img-caption"><strong>Figure 2.</strong> Sample output in the <strong>Lint Warnings</strong> view</p>
+<p>You can also run a {@code lint} scan manually on your Android project in Eclipse by right-clicking on the project folder in the Package Explorer > <strong>Android Tools > Run Lint: Check for Common Errors</strong>.</p>
+
+
+<h2 id="commandline">Running lint from the Command-Line</h2>
+<p>
+To run {@code lint} against a list of files in a project directory:
+<pre>lint [flags] <project directory></pre>
+<p>For example, you can issue the following command to scan the files under the {@code myproject} directory and its subdirectories. The issue ID <code>MissingPrefix</code> tells {@code lint} to only scan for XML attributes that are missing the Android namespace prefix.</p>
+<pre>lint --check MissingPrefix myproject </pre>
+<p>To see the full list of flags and command-line arguments supported by the tool:</p>
+<pre>lint --help</pre>
+</p>
+
+<h3>Example lint output</h3>
+<p>The following example shows the console output when the {@code lint} command is run against a project called Earthquake. </p>
+<pre>
+$ lint Earthquake
+
+Scanning Earthquake: ...............................................................................................................................
+Scanning Earthquake (Phase 2): .......
+AndroidManifest.xml:23: Warning: <uses-sdk> tag appears after <application> tag [ManifestOrder]
+ <uses-sdk android:minSdkVersion="7" />
+ ^
+AndroidManifest.xml:23: Warning: <uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?" [UsesMinSdkAttributes]
+ <uses-sdk android:minSdkVersion="7" />
+ ^
+res/layout/preferences.xml: Warning: The resource R.layout.preferences appears to be unused [UnusedResources]
+res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]
+0 errors, 4 warnings
+</pre>
+<p>The output above lists four warnings and no errors in this project. Three warnings ({@code ManifestOrder}, {@code UsesMinSdkAttributes}, and {@code UsesMinSdkAttributes}) were found in the project's <code>AndroidManifest.xml</code> file. The remaining warning ({@code IconMissingDensityFolder}) was found in the <code>Preferences.xml</code> layout file.</p>
+
+<h2 id="config">Configuring lint</h2>
+<p>By default, when you run a {@code lint} scan, the tool checks for all issues that are supported by {@code lint}. You can also restrict the issues for {@code lint} to check and assign the severity level for those issues. For example, you can disable {@code lint} checking for specific issues that are not relevant to your project and configure {@code lint} to report non-critical issues at a lower severity level.</p>
+<p>You can configure {@code lint} checking at different levels:</p>
+<ul>
+<LI>Globally, for all projects</LI>
+<li>Per project</li>
+<li>Per file</li>
+<li>Per Java class or method (by using the <code>@SuppressLint</code> annotation), or per XML element (by using the <code>tools:ignore</code> attribute.</li>
+</ul>
+
+<h3 id="eclipse_config">Configuring lint in Eclipse</h3>
+<p>You can configure global, project-specific, and file-specific settings for {@code lint} from the Eclipse user interface.</p>
+
+<h4>Global preferences</h4>
+<ol>
+<LI>Open <strong>Window > Preferences > Android > Lint Error Checking</strong>.</LI>
+<li>Specify your preferences and click <b>OK</b>.</li>
+</ol>
+<p>These settings are applied by default when you run {@code lint} on your Android projects in Eclipse.</p>
+
+<h4>Project and file-specific preferences</h4>
+<ol>
+<LI>Run the {@code lint} tool on your project by right-clicking on your project folder in the Package Explorer and selecting <strong>Android Tools > Run Lint: Check for Common Errors</strong>. This action brings up the <strong>Lint Warnings</strong> view which displays a list of issues that {@code lint} detected in your project.</LI>
+<li>From the <strong>Lint Warnings</strong> view, use the toolbar options to configure {@code lint} preferences for individual projects and files in Eclipse. The options you can select include:
+<ul>
+<LI><b>Suppress this error with an annotation/attribute</b> - If the issue appears in a Java class, the {@code lint} tool adds a <code>@SuppressLint</code> annotation to the method where the issue was detected. If the issue appears in an {@code .xml} file, {@code lint} inserts a <code>tools:ignore</code> attribute to disable checking for the {@code lint} issue in this file.</LI>
+<LI><b>Ignore in this file</b> - Disables checking for this {@code lint} issue in this file.</LI>
+<li><b>Ignore in this project</b> - Disables checking for this {@code lint} issue in this project.</li>
+<li><b>Always ignore</b> - Disables checking for this {@code lint} issue globally for all projects.</li>
+</ul>
+</li>
+</ol>
+<p>If you select the second or third option, the {@code lint} tool automatically generates a <code>lint.xml</code> file with these configuration settings in your Android application project folder. </p>
+
+<h3 id="pref">Configuring the lint file</h3>
+<p>You can specify your {@code lint} checking preferences in the <code>lint.xml</code> file. If you are creating this file manually, place it in the root directory of your Android project. If you are configuring {@code lint} preferences in Eclipse, the <code>lint.xml</code> file is automatically created and added to your Android project for you.</p>
+<p>The <code>lint.xml</code> file consists of an enclosing <code><lint></code> parent tag that contains one or more children <code><issue></code> elements. Each <code><issue></code> is identified by a unique <code>id</code> attribute value, which is defined by {@code lint}.</p>
+<pre>
+<?xml version="1.0" encoding="UTF-8"?>
+ <lint>
+ <!-- list of issues to configure -->
+</lint>
+</pre>
+<p>By setting the severity attribute value in the <code><issue></code> tag, you can disable {@code lint} checking for an issue or change the severity level for an issue. </p>
+<p class="note"><strong>Tip: </strong>To see the full list of issues supported by the {@code lint} tool and their corresponding issue IDs, run the <code>lint --list</code> command.</p>
+
+<h4>Sample lint.xml file</h4>
+<p>The following example shows the contents of a <code>lint.xml</code> file.</p>
+<pre>
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+ <!-- Disable the given check in this project -->
+ <issue id="IconMissingDensityFolder" severity="ignore" />
+
+ <!-- Ignore the ObsoleteLayoutParam issue in the specified files -->
+ <issue id="ObsoleteLayoutParam">
+ <ignore path="res/layout/activation.xml" />
+ <ignore path="res/layout-xlarge/activation.xml" />
+ </issue>
+
+ <!-- Ignore the UselessLeaf issue in the specified file -->
+ <issue id="UselessLeaf">
+ <ignore path="res/layout/main.xml" />
+ </issue>
+
+ <!-- Change the severity of hardcoded strings to "error" -->
+ <issue id="HardcodedText" severity="error" />
+</lint>
+</pre>
+
+<h3 id="src">Configuring lint checking in Java and XML source files</h3>
+<p>You can disable {@code lint} checking from your Java and XML source files.</p>
+
+<p class="note"><strong>Tip: </strong>If you are using Eclipse, you can use the <strong>Quick Fix</strong> feature to automatically add the annotation or attribute to disable {@code lint} checking to your Java or XML source files:
+<ol>
+<LI>Open the Java or XML file that has a {@code lint} warning or error in an Eclipse editor.</LI>
+<LI>Move your cursor to the location in the file where is {@code lint} issue is found, then press <code>Ctrl+1</code> to bring up the <strong>Quick Fix</strong> pop-up.</LI>
+<li>From the <strong>Quick Fix</strong> pop-up, select the action to add an annotation or attribute to ignore the {@code lint} issue.</li>
+</ol>
+</p>
+
+<h4>Configuring lint checking in Java</h4>
+<p>To disable {@code lint} checking specifically for a Java class or method in your Android project, add the <code>@SuppressLint</code> annotation to that Java code. </p>
+<p>The following example shows how you can turn off {@code lint} checking for the {@code NewApi} issue in the <code>onCreate</code> method. The {@code lint} tool continues to check for the {@code NewApi} issue in other methods of this class.</p>
+<pre>
+@SuppressLint("NewApi")
+@Override
+public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+</pre>
+<p>The following example shows how to turn off {@code lint} checking for the {@code ParserError} issue in the <code>FeedProvider</code> class:</p>
+<pre>
+@SuppressLint("ParserError")
+public class FeedProvider extends ContentProvider {
+</pre>
+<p>To suppress checking for all {@code lint} issues in the Java file, use the {@code all} keyword, like this:</p>
+<pre>
+@SuppressLint("all")
+</pre>
+
+<h4>Configuring lint checking in XML</h4>
+<p>You can use the <code>tools:ignore</code> attribute to disable {@code lint} checking for specific sections of your XML files. In order for this attribute to be recognized by the {@code lint} tool, the following namespace value must be included in your XML file:</p>
+<pre>
+namespace xmlns:tools="http://schemas.android.com/tools"
+</pre>
+<p>The following example shows how you can turn off {@code lint} checking for the {@code UnusedResources} issue for the <code><LinearLayout></code> element of an XML layout file. The <code>ignore</code> attribute is inherited by the children elements of the parent element in which the attribute is declared. In this example, the {@code lint} check is also disabled for the child <code><TextView></code> element. </p>
+<pre>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:ignore="UnusedResources" >
+
+ <TextView
+ android:text="@string/auto_update_prompt" />
+</LinearLayout>
+</pre>
+<p>To disable more than one issue, list the issues to disable in a comma-separated string. For example:</p>
+<pre>
+tools:ignore="NewApi,StringFormatInvalid"
+</pre>
+<p>To suppress checking for all {@code lint} issues in the XML element, use the {@code all} keyword, like this:</p>
+<pre>
+tools:ignore="all"
+</pre>
diff --git a/docs/html/tools/help/bmgr.jd b/docs/html/tools/help/bmgr.jd
index 2248fa6..8823f33 100644
--- a/docs/html/tools/help/bmgr.jd
+++ b/docs/html/tools/help/bmgr.jd
@@ -7,9 +7,6 @@
<div id="qv-wrapper">
<div id="qv">
- <h2>bmgr quickview</h2>
-<p><code>bmgr</code> lets you control the backup/restore system on an Android device.
-
<h2>In this document</h2>
<ol>
<li><a href="#backup">Forcing a Backup Operation</a></li>
diff --git a/docs/html/tools/help/lint.jd b/docs/html/tools/help/lint.jd
new file mode 100644
index 0000000..ba31f6d
--- /dev/null
+++ b/docs/html/tools/help/lint.jd
@@ -0,0 +1,178 @@
+page.title=lint
+parent.title=Tools
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#syntax">Syntax</a></li>
+ <li><a href="#options">Options</a></li>
+ <li><a href="#config_keywords">Configuring Java and XML Source Files</a></li>
+ </ol>
+ </div>
+</div>
+
+<p>The Android {@code lint} tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. </p>
+<p>For more information on running {@code lint}, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>
+
+<h2 id="syntax">Syntax</h2>
+<p>
+<pre>lint [flags] <project directory></pre>
+
+For example, you can issue the following command to scan the Java and XML files under the {@code myproject} directory and its subdirectories. The result is displayed on the console.
+<pre>lint myproject</pre>
+
+You can also use {@code lint} to check for a specific issue. For example, you can run the following command to scan the files under the {@code myproject} directory and its subdirectories to check for XML attributes missing the Android namespace prefix. The issue ID {@code MissingPrefix} tells lint to only scan for this issue.
+<pre>lint --check MissingPrefix myproject</pre>
+
+You can create an HTML report for the issues that {@code lint} detects. For example, you can run the following command to scan the {@code myproject} directory and its subdirectories for accessibility issues, then generate an HTML report in the {@code accessibility_report.html} file.
+<pre>lint --check Accessibility --HTML accessibility_report.html myproject</pre>
+</p>
+
+<h2 id="options">Options</h2>
+<p>Table 1 describes the command-line options for {@code lint}.</p>
+<p class="table-caption" id="table1">
+ <strong>Table 1.</strong> Command-line options for lint</p>
+<table>
+<tr>
+ <th>Category</th>
+ <th>Option</th>
+ <th>Description</th>
+ <th>Comments</th>
+</tr>
+
+<tr>
+<td rowspan="7">Checking</td>
+<td><nobr><code>--disable <list></code></nobr></td>
+<td>Disable checking for a specific list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--enable <list></code></nobr></td>
+<td>Check for all the default issues supported by {@code lint} as well as the specifically enabled list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--check <list></code></nobr></td>
+<td>Check for a specific list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>-w</code> or <code>--nowarn</code></nobr></td>
+<td>Only check for errors and ignore warnings</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>-Wall</code></nobr></td>
+<td>Check for all warnings, including those that are disabled by default</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>-Werror</code></nobr></td>
+<td>Report all warnings as errors</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--config <filename></code></nobr></td>
+<td>Use the specified configuration file to determine if issues are enabled or disabled for {@code lint} checking</td>
+<td>If the project contains a {@code lint.xml} file, the {@code lint.xml} file will be used as the configuration file by default.</td>
+</tr>
+
+<tr>
+<td rowspan="9">Reporting</td>
+<td><nobr><code>--html <filename></code></nobr></td>
+<td>Generate an HTML report.</td>
+<td>The report is saved in the output file specified in the argument. The HTML output includes code snippets of the source code where {@code lint} detected an issue, a verbose description of the issue found, and links to the source file.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--url <filepath>=<url></code></nobr></td>
+<td>In the HTML output, replace a local path prefix <code><filepath></code> with a url prefix <code><url></code>.</td>
+<td>The {@code --url} option only applies when you are generating an HTML report with the {@code --html} option. You can specify multiple <filepath>=<url> mappings in the argument by separating each mapping with a comma.<p>To turn off linking to files, use {@code --url none}</p></td>
+</tr>
+
+<tr>
+<td><nobr><code>--simplehtml <filename></code></nobr></td>
+<td>Generate a simple HTML report</td>
+<td>The report is saved in the output file specified in the argument.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--xml <filename></code></nobr></td>
+<td>Generate an XML report</td>
+<td>The report is saved in the output file specified in the argument.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--fullpath</code></nobr></td>
+<td>Show the full file paths in the {@code lint} checking results.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--showall</code></nobr></td>
+<td>Don't truncate long messages or lists of alternate locations.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--nolines</code></nobr></td>
+<td>Don't include code snippets from the source files in the output.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--exitcode</code></nobr></td>
+<td>Set the exit code to 1 if errors are found.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--quiet</code></nobr></td>
+<td>Don't show the progress indicator.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td rowspan="4">Help</td>
+<td><nobr><code>--help</code></nobr></td>
+<td>List the command-line arguments supported by the {@code lint} tool.</td>
+<td>Use {@code --help <topic>} to see help information for a specific topic, such as "suppress".</td>
+</tr>
+
+<tr>
+<td><nobr><code>--list</code></nobr></td>
+<td>List the ID and short description for issues that can be checked by {@code lint}</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--show</code></nobr></td>
+<td>List the ID and verbose description for issues that can be checked by {@code lint}</td>
+<td>Use {@code --show <ids>} to see descriptions for a specific list of {@code lint} issue IDs.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--version</code></nobr></td>
+<td>Show the {@code lint} version</td>
+<td> </td>
+</tr>
+
+</table>
+
+
+<h2 id="config_keywords">Configuring Java and XML Source Files</h2>
+<p>To configure lint checking, you can apply the following annotation or attribute to the source files in your Android project. </p>
+<ul>
+<LI>To disable lint checking for a specific Java class or method, use the <code>@SuppressLint</code> annotation. </LI>
+<li>To disable lint checking for specific sections of your XML file, use the <code>tools:ignore</code> attribute. </li>
+</ul>
+<p>You can also specify your lint checking preferences for a specific Android project in the lint.xml file. For more information on configuring lint, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>
diff --git a/docs/html/tools/help/monitor.jd b/docs/html/tools/help/monitor.jd
index 8e2ea36..18fb49a 100644
--- a/docs/html/tools/help/monitor.jd
+++ b/docs/html/tools/help/monitor.jd
@@ -1,7 +1,7 @@
-page.title=Debug Monitor
+page.title=Device Monitor
@jd:body
-<p>Android Debug Monitor is a stand-alone tool that provides a graphical user interface for
+<p>Android Device Monitor is a stand-alone tool that provides a graphical user interface for
several Android application debugging and analysis tools. The Monitor tool does not
require installation of a integrated development environment, such as Eclipse, and encapsulates the
following tools:</p>
@@ -16,9 +16,9 @@
<h2 id="usage">Usage</h2>
-<p>To start Debug Monitor, enter the following command from the SDK <code>tools/</code>
+<p>To start Device Monitor, enter the following command from the SDK <code>tools/</code>
directory:</p>
<pre>monitor</pre>
-<p>Start an Android emulator or connect an Android device via USB cable, and connect the Debug
+<p>Start an Android emulator or connect an Android device via USB cable, and connect Device
Monitor to the device by selecting it in the <strong>Devices</strong> window.</p>
diff --git a/docs/html/tools/sdk/eclipse-adt.jd b/docs/html/tools/sdk/eclipse-adt.jd
index 947e463..bdb4a9e 100644
--- a/docs/html/tools/sdk/eclipse-adt.jd
+++ b/docs/html/tools/sdk/eclipse-adt.jd
@@ -96,8 +96,41 @@
<div class="toggleable opened">
<a href="#" onclick="return toggleDiv(this)">
<img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px"
- width="9px" />
-ADT 20.0.1</a> <em>(June 2012)</em>
+ width="9px"/>
+ADT 20.0.2</a> <em>(July 2012)</em>
+ <div class="toggleme">
+<dl>
+ <dt>Dependencies:</dt>
+
+ <dd>
+ <ul>
+ <li>Java 1.6 or higher is required for ADT 20.0.2.</li>
+ <li>Eclipse Helios (Version 3.6.2) or higher is required for ADT 20.0.2.</li>
+ <li>ADT 20.0.2 is designed for use with <a href="{@docRoot}tools/sdk/tools-notes.html">SDK
+ Tools r20.0.1</a>. If you haven't already installed SDK Tools r20.0.1 into your SDK, use the
+ Android SDK Manager to do so.</li>
+ </ul>
+ </dd>
+
+ <dt>Bug fixes:</dt>
+ <dd>
+ <ul>
+ <li>Fixed keybindings in various XML editors for Eclipse 4.x.</li>
+ <li>Fixed bug when creating layout configurations that already exist.</li>
+ </ul>
+ </dd>
+
+</dl>
+
+</div>
+</div>
+
+
+<div class="toggleable closed">
+ <a href="#" onclick="return toggleDiv(this)">
+ <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-img" height="9px"
+ width="9px"/>
+ADT 20.0.1</a> <em>(July 2012)</em>
<div class="toggleme">
<dl>
<dt>Dependencies:</dt>
diff --git a/docs/html/tools/sdk/ndk/index.jd b/docs/html/tools/sdk/ndk/index.jd
index 216a304..064b2c3 100644
--- a/docs/html/tools/sdk/ndk/index.jd
+++ b/docs/html/tools/sdk/ndk/index.jd
@@ -161,10 +161,10 @@
co-exist with the original GCC 4.4.3 toolchain ({@code binutils} 2.19 and GDB 6.6).</p>
<ul>
<li>GCC 4.6 is now the default toolchain. You may set {@code
-NDK_TOOLCHAIN_VERSION=4.4.3} in {@code Android.mk} to select the original one.</li>
+NDK_TOOLCHAIN_VERSION=4.4.3} in {@code Application.mk} to select the original one.</li>
<li>Support for the {@code gold} linker is only available for ARM and x86
architectures on Linux and Mac OS hosts. This support is disabled by default. Add {@code
-LOCAL_C_FLAGS += -fuse-ld=gold} in {@code Android.mk} to enable it.</li>
+LOCAL_LDLIBS += -fuse-ld=gold} in {@code Android.mk} to enable it.</li>
<li>Programs compiled with {@code -fPIE} require the new {@code GDB} for debugging,
including binaries in Android 4.1 (API Level 16) system images.</li>
<li>The {@code binutils} 2.21 {@code ld} tool contains back-ported fixes from
diff --git a/docs/html/tools/tools_toc.cs b/docs/html/tools/tools_toc.cs
index c7cdded..850e0ec 100644
--- a/docs/html/tools/tools_toc.cs
+++ b/docs/html/tools/tools_toc.cs
@@ -107,6 +107,7 @@
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-projects-cmdline.html"><span class="en">From Other IDEs</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/ddms.html"><span class="en">Using DDMS</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-log.html"><span class="en">Reading and Writing Logs</span></a></li>
+ <li><a href="<?cs var:toroot ?>tools/debugging/improving-w-lint.html"><span class="en">Improving Your Code with lint</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-ui.html"><span class="en">Optimizing your UI</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-tracing.html"><span class="en">Profiling with Traceview and dmtracedump</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-devtools.html"><span class="en">Using the Dev Tools App</span></a></li>
@@ -137,7 +138,7 @@
<li><a href="<?cs var:toroot ?>tools/help/etc1tool.html">etc1tool</a></li>
<li><a href="<?cs var:toroot ?>tools/help/hierarchy-viewer.html">Hierarchy Viewer</a></li>
<li><a href="<?cs var:toroot ?>tools/help/hprof-conv.html">hprof-conv</a></li>
- <li><a href="<?cs var:toroot ?>tools/help/layoutopt.html">layoutopt</a></li>
+ <li><a href="<?cs var:toroot ?>tools/help/lint.html">lint</span></a></li>
<li><a href="<?cs var:toroot ?>tools/help/logcat.html">logcat</a></li>
<li><a href="<?cs var:toroot ?>tools/help/mksdcard.html">mksdcard</a></li>
<li><a href="<?cs var:toroot ?>tools/help/monkey.html">monkey</a></li>
diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd
index 97f2a5d..2ea8b2f 100644
--- a/docs/html/training/basics/firstapp/creating-project.jd
+++ b/docs/html/training/basics/firstapp/creating-project.jd
@@ -41,10 +41,10 @@
SDK tools from a command line.</p>
<p class="note"><strong>Note:</strong> You should already have the Android SDK installed, and if
-you're using Eclipse, you should also have the <a
-href="{@docRoot}tools/sdk/eclipse-adt.html">ADT plugin</a> installed. If you don't have
-these, follow the guide to <a href="{@docRoot}sdk/installing/index.html">Installing the Android SDK</a>
-before you start this lesson.</p>
+you're using Eclipse, you should also have the <a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT
+plugin</a> installed (version 20.0.0 or higher). If you don't have these, follow the guide to <a
+href="{@docRoot}sdk/installing/index.html">Installing the Android SDK</a> before you start this
+lesson.</p>
<h2 id="Eclipse">Create a Project with Eclipse</h2>
diff --git a/docs/html/training/basics/firstapp/index.jd b/docs/html/training/basics/firstapp/index.jd
index e2b9cff..4c1a0dc3 100644
--- a/docs/html/training/basics/firstapp/index.jd
+++ b/docs/html/training/basics/firstapp/index.jd
@@ -14,8 +14,9 @@
<h2>Dependencies and prerequisites</h2>
<ul>
- <li>Android 1.6 or higher</li>
<li><a href="http://developer.android.com/sdk/index.html">Android SDK</a></li>
+ <li><a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT Plugin</a> 20.0.0 or higher
+ (if you're using Eclipse)</li>
</ul>
</div>
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 552d5fa..0c428e7 100644
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -133,8 +133,9 @@
<ol>
<li>Launch the Android Virtual Device Manager:
<ol type="a">
- <li>In Eclipse, AVD Manager <img src="{@docRoot}images/tools/avd_manager.png"
-style="vertical-align:baseline;margin:0" /> in the toolbar.</li>
+ <li>In Eclipse, click Android Virtual Device Manager
+ <img src="{@docRoot}images/tools/avd_manager.png"
+style="vertical-align:baseline;margin:0" /> from the toolbar.</li>
<li>From the command line, change
directories to <code><sdk>/tools/</code> and execute:
<pre class="no-pretty-print">android avd</pre></li>
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 870a4a9..a25d934 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -2319,6 +2319,11 @@
*/
public static final int MEDIA_INFO_STARTED_AS_NEXT = 2;
+ /** The player just pushed the very first video frame for rendering.
+ * @see android.media.MediaPlayer.OnInfoListener
+ */
+ public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3;
+
/** The video is too complex for the decoder: it can't decode frames fast
* enough. Possibly only the audio plays fine at this stage.
* @see android.media.MediaPlayer.OnInfoListener
@@ -2374,6 +2379,7 @@
* <ul>
* <li>{@link #MEDIA_INFO_UNKNOWN}
* <li>{@link #MEDIA_INFO_VIDEO_TRACK_LAGGING}
+ * <li>{@link #MEDIA_INFO_VIDEO_RENDERING_START}
* <li>{@link #MEDIA_INFO_BUFFERING_START}
* <li>{@link #MEDIA_INFO_BUFFERING_END}
* <li>{@link #MEDIA_INFO_BAD_INTERLEAVING}
diff --git a/opengl/java/com/google/android/gles_jni/EGLImpl.java b/opengl/java/com/google/android/gles_jni/EGLImpl.java
index 6992019..64a54c2 100644
--- a/opengl/java/com/google/android/gles_jni/EGLImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLImpl.java
@@ -83,6 +83,8 @@
} else if (native_window instanceof SurfaceHolder) {
SurfaceHolder holder = (SurfaceHolder)native_window;
sur = holder.getSurface();
+ } else if (native_window instanceof Surface) {
+ sur = (Surface) native_window;
}
int eglSurfaceId;
@@ -94,8 +96,7 @@
} else {
throw new java.lang.UnsupportedOperationException(
"eglCreateWindowSurface() can only be called with an instance of " +
- "SurfaceView, SurfaceHolder or SurfaceTexture at the moment, " +
- "this will be fixed later.");
+ "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.");
}
if (eglSurfaceId == 0) {
diff --git a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml b/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
deleted file mode 100644
index b5f1f90..0000000
--- a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* apps/common/assets/default/default/skins/StatusBar.xml
-**
-** Copyright 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.
-*/
--->
-
-<com.android.systemui.SearchPanelView
- xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/search_panel_container"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <com.android.internal.widget.multiwaveview.GlowPadView
- android:id="@+id/glow_pad_view"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/navbar_search_panel_height"
- android:layout_gravity="left|bottom"
- android:gravity="top|right"
- android:layout_marginLeft="-150dip"
-
- prvandroid:targetDrawables="@array/navbar_search_targets"
- prvandroid:targetDescriptions="@array/navbar_search_target_descriptions"
- prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
- prvandroid:outerRingDrawable="@drawable/navbar_search_outerring"
- prvandroid:outerRadius="@dimen/navbar_search_outerring_radius"
- prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius"
- prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
- prvandroid:feedbackCount="0"
- prvandroid:vibrationDuration="@integer/config_vibration_duration"
- prvandroid:alwaysTrackFinger="true"
- prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius"
- prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot"/>
-
-</com.android.systemui.SearchPanelView>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java b/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java
index b4b29da..81a16ae 100755
--- a/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java
@@ -234,7 +234,7 @@
w.close();
mGestures.clear();
// If we have a pending gesture, push it back
- if (!mCurrentGesture.isComplete()) {
+ if (mCurrentGesture != null && !mCurrentGesture.isComplete()) {
mGestures.add(mCurrentGesture);
}
if (DEBUG) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 00d6d6f..63c9b79 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -22,6 +22,7 @@
import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
@@ -431,13 +432,14 @@
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("NavigationBarView {");
final Rect r = new Rect();
+ final Point size = new Point();
+ mDisplay.getRealSize(size);
pw.println(String.format(" this: " + PhoneStatusBar.viewInfo(this)
+ " " + visibilityToString(getVisibility())));
getWindowVisibleDisplayFrame(r);
- final boolean offscreen = r.right > mDisplay.getRawWidth()
- || r.bottom > mDisplay.getRawHeight();
+ final boolean offscreen = r.right > size.x || r.bottom > size.y;
pw.println(" window: "
+ r.toShortString()
+ " " + visibilityToString(getWindowVisibility())
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 4d22f33..4fc6940 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -935,10 +935,12 @@
if (mDataConnected) {
mobileLabel = mNetworkName;
- } else if (mConnected) {
- if (hasService()) {
+ } else if (mConnected || mServiceState.isEmergencyOnly()) {
+ if (hasService() || mServiceState.isEmergencyOnly()) {
+ // The isEmergencyOnly test covers the case of a phone with no SIM
mobileLabel = mNetworkName;
} else {
+ // Tablets, basically
mobileLabel = "";
}
} else {
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index c1fd515..bb07a1d 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -21,8 +21,7 @@
import com.android.internal.widget.DigitalClock;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.TransportControlView;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.SimStateCallback;
+import com.android.internal.policy.impl.KeyguardUpdateMonitor.BatteryStatus;
import java.util.ArrayList;
import java.util.Date;
@@ -107,6 +106,8 @@
private CharSequence mSpn;
protected int mPhoneState;
private DigitalClock mDigitalClock;
+ protected boolean mBatteryCharged;
+ protected boolean mBatteryIsLow;
private class TransientTextManager {
private TextView mTextView;
@@ -198,8 +199,8 @@
mTransientTextManager = new TransientTextManager(mCarrierView);
- mUpdateMonitor.registerInfoCallback(mInfoCallback);
- mUpdateMonitor.registerSimStateCallback(mSimStateCallback);
+ // Registering this callback immediately updates the battery state, among other things.
+ mUpdateMonitor.registerCallback(mInfoCallback);
resetStatusInfo();
refreshDate();
@@ -287,7 +288,6 @@
public void onPause() {
if (DEBUG) Log.v(TAG, "onPause()");
mUpdateMonitor.removeCallback(mInfoCallback);
- mUpdateMonitor.removeCallback(mSimStateCallback);
}
/** {@inheritDoc} */
@@ -299,8 +299,7 @@
mDigitalClock.updateTime();
}
- mUpdateMonitor.registerInfoCallback(mInfoCallback);
- mUpdateMonitor.registerSimStateCallback(mSimStateCallback);
+ mUpdateMonitor.registerCallback(mInfoCallback);
resetStatusInfo();
// Issue the biometric unlock failure message in a centralized place
// TODO: we either need to make the Face Unlock multiple failures string a more general
@@ -312,9 +311,6 @@
void resetStatusInfo() {
mInstructionText = null;
- mShowingBatteryInfo = mUpdateMonitor.shouldShowBatteryInfo();
- mPluggedIn = mUpdateMonitor.isDevicePluggedIn();
- mBatteryLevel = mUpdateMonitor.getBatteryLevel();
updateStatusLines(true);
}
@@ -379,14 +375,11 @@
if (mShowingBatteryInfo) {
// Battery status
if (mPluggedIn) {
- // Charging or charged
- if (mUpdateMonitor.isDeviceCharged()) {
- string = getContext().getString(R.string.lockscreen_charged);
- } else {
- string = getContext().getString(R.string.lockscreen_plugged_in, mBatteryLevel);
- }
+ // Charging, charged or waiting to charge.
+ string = getContext().getString(mBatteryCharged ? R.string.lockscreen_charged
+ :R.string.lockscreen_plugged_in, mBatteryLevel);
icon.value = CHARGING_ICON;
- } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) {
+ } else if (mBatteryIsLow) {
// Battery is low
string = getContext().getString(R.string.lockscreen_low_battery);
icon.value = BATTERY_LOW_ICON;
@@ -406,14 +399,11 @@
} else if (mShowingBatteryInfo) {
// Battery status
if (mPluggedIn) {
- // Charging or charged
- if (mUpdateMonitor.isDeviceCharged()) {
- string = getContext().getString(R.string.lockscreen_charged);
- } else {
- string = getContext().getString(R.string.lockscreen_plugged_in, mBatteryLevel);
- }
+ // Charging, charged or waiting to charge.
+ string = getContext().getString(mBatteryCharged ? R.string.lockscreen_charged
+ :R.string.lockscreen_plugged_in, mBatteryLevel);
icon.value = CHARGING_ICON;
- } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) {
+ } else if (mBatteryIsLow) {
// Battery is low
string = getContext().getString(R.string.lockscreen_low_battery);
icon.value = BATTERY_LOW_ICON;
@@ -629,14 +619,15 @@
}
}
- private InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
+ private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
- public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn,
- int batteryLevel) {
- mShowingBatteryInfo = showBatteryInfo;
- mPluggedIn = pluggedIn;
- mBatteryLevel = batteryLevel;
+ public void onRefreshBatteryInfo(BatteryStatus status) {
+ mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
+ mPluggedIn = status.isPluggedIn();
+ mBatteryLevel = status.level;
+ mBatteryCharged = status.isCharged();
+ mBatteryIsLow = status.isBatteryLow();
final MutableInt tmpIcon = new MutableInt(0);
update(BATTERY_INFO, getAltTextMessage(tmpIcon));
}
@@ -659,10 +650,7 @@
updateEmergencyCallButtonState(phoneState);
}
- };
-
- private SimStateCallback mSimStateCallback = new SimStateCallback() {
-
+ @Override
public void onSimStateChanged(IccCardConstants.State simState) {
updateCarrierStateWithSimStatus(simState);
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index 5cd0349..a939222 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -57,37 +57,13 @@
*/
public class KeyguardUpdateMonitor {
- static private final String TAG = "KeyguardUpdateMonitor";
- static private final boolean DEBUG = false;
-
- /* package */ static final int LOW_BATTERY_THRESHOLD = 20;
-
- private final Context mContext;
-
- private IccCardConstants.State mSimState = IccCardConstants.State.READY;
-
- private boolean mDeviceProvisioned;
-
- private BatteryStatus mBatteryStatus;
-
- private CharSequence mTelephonyPlmn;
- private CharSequence mTelephonySpn;
-
- private int mFailedAttempts = 0;
- private int mFailedBiometricUnlockAttempts = 0;
+ private static final String TAG = "KeyguardUpdateMonitor";
+ private static final boolean DEBUG = false;
+ private static final boolean DEBUG_SIM_STATES = DEBUG || false;
private static final int FAILED_BIOMETRIC_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 3;
+ private static final int LOW_BATTERY_THRESHOLD = 20;
- private boolean mClockVisible;
-
- private Handler mHandler;
-
- private ArrayList<InfoCallback> mInfoCallbacks = Lists.newArrayList();
- private ArrayList<SimStateCallback> mSimStateCallbacks = Lists.newArrayList();
- private ContentObserver mContentObserver;
- private int mRingMode;
- private int mPhoneState;
-
- // messages for the handler
+ // Callback messages
private static final int MSG_TIME_UPDATE = 301;
private static final int MSG_BATTERY_UPDATE = 302;
private static final int MSG_CARRIER_INFO_UPDATE = 303;
@@ -97,9 +73,118 @@
private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;
private static final int MSG_DEVICE_PROVISIONED = 308;
protected static final int MSG_DPM_STATE_CHANGED = 309;
- protected static final int MSG_USER_CHANGED = 310;
+ protected static final int MSG_USER_SWITCHED = 310;
+ protected static final int MSG_USER_REMOVED = 311;
- protected static final boolean DEBUG_SIM_STATES = DEBUG || false;
+ private final Context mContext;
+
+ // Telephony state
+ private IccCardConstants.State mSimState = IccCardConstants.State.READY;
+ private CharSequence mTelephonyPlmn;
+ private CharSequence mTelephonySpn;
+ private int mRingMode;
+ private int mPhoneState;
+
+ private boolean mDeviceProvisioned;
+
+ private BatteryStatus mBatteryStatus;
+
+ private int mFailedAttempts = 0;
+ private int mFailedBiometricUnlockAttempts = 0;
+
+ private boolean mClockVisible;
+
+ private ArrayList<KeyguardUpdateMonitorCallback> mCallbacks = Lists.newArrayList();
+ private ContentObserver mContentObserver;
+
+ private final Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_TIME_UPDATE:
+ handleTimeUpdate();
+ break;
+ case MSG_BATTERY_UPDATE:
+ handleBatteryUpdate((BatteryStatus) msg.obj);
+ break;
+ case MSG_CARRIER_INFO_UPDATE:
+ handleCarrierInfoUpdate();
+ break;
+ case MSG_SIM_STATE_CHANGE:
+ handleSimStateChange((SimArgs) msg.obj);
+ break;
+ case MSG_RINGER_MODE_CHANGED:
+ handleRingerModeChange(msg.arg1);
+ break;
+ case MSG_PHONE_STATE_CHANGED:
+ handlePhoneStateChanged((String)msg.obj);
+ break;
+ case MSG_CLOCK_VISIBILITY_CHANGED:
+ handleClockVisibilityChanged();
+ break;
+ case MSG_DEVICE_PROVISIONED:
+ handleDeviceProvisioned();
+ break;
+ case MSG_DPM_STATE_CHANGED:
+ handleDevicePolicyManagerStateChanged();
+ break;
+ case MSG_USER_SWITCHED:
+ handleUserSwitched(msg.arg1);
+ break;
+ case MSG_USER_REMOVED:
+ handleUserRemoved(msg.arg1);
+ break;
+ }
+ }
+ };
+
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+ if (DEBUG) Log.d(TAG, "received broadcast " + action);
+
+ if (Intent.ACTION_TIME_TICK.equals(action)
+ || Intent.ACTION_TIME_CHANGED.equals(action)
+ || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_TIME_UPDATE));
+ } else if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
+ mTelephonyPlmn = getTelephonyPlmnFrom(intent);
+ mTelephonySpn = getTelephonySpnFrom(intent);
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_CARRIER_INFO_UPDATE));
+ } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
+ final int status = intent.getIntExtra(EXTRA_STATUS, BATTERY_STATUS_UNKNOWN);
+ final int plugged = intent.getIntExtra(EXTRA_PLUGGED, 0);
+ final int level = intent.getIntExtra(EXTRA_LEVEL, 0);
+ final int health = intent.getIntExtra(EXTRA_HEALTH, BATTERY_HEALTH_UNKNOWN);
+ final Message msg = mHandler.obtainMessage(
+ MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health));
+ mHandler.sendMessage(msg);
+ } else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
+ if (DEBUG_SIM_STATES) {
+ Log.v(TAG, "action " + action + " state" +
+ intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE));
+ }
+ mHandler.sendMessage(mHandler.obtainMessage(
+ MSG_SIM_STATE_CHANGE, SimArgs.fromIntent(intent)));
+ } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED,
+ intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0));
+ } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
+ String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
+ } else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED
+ .equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_DPM_STATE_CHANGED));
+ } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED,
+ intent.getIntExtra(Intent.EXTRA_USERID, 0), 0));
+ } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_REMOVED,
+ intent.getIntExtra(Intent.EXTRA_USERID, 0), 0));
+ }
+ }
+ };
/**
* When we receive a
@@ -156,7 +241,7 @@
}
}
- private static class BatteryStatus {
+ /* package */ static class BatteryStatus {
public final int status;
public final int level;
public final int plugged;
@@ -168,91 +253,53 @@
this.health = health;
}
+ /**
+ * Determine whether the device is plugged in (USB or power).
+ * @return true if the device is plugged in.
+ */
+ boolean isPluggedIn() {
+ return plugged == BatteryManager.BATTERY_PLUGGED_AC
+ || plugged == BatteryManager.BATTERY_PLUGGED_USB;
+ }
+
+ /**
+ * Whether or not the device is charged. Note that some devices never return 100% for
+ * battery level, so this allows either battery level or status to determine if the
+ * battery is charged.
+ * @return true if the device is charged
+ */
+ public boolean isCharged() {
+ return status == BATTERY_STATUS_FULL || level >= 100;
+ }
+
+ /**
+ * Whether battery is low and needs to be charged.
+ * @return true if battery is low
+ */
+ public boolean isBatteryLow() {
+ return level < LOW_BATTERY_THRESHOLD;
+ }
+
}
public KeyguardUpdateMonitor(Context context) {
mContext = context;
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_TIME_UPDATE:
- handleTimeUpdate();
- break;
- case MSG_BATTERY_UPDATE:
- handleBatteryUpdate((BatteryStatus) msg.obj);
- break;
- case MSG_CARRIER_INFO_UPDATE:
- handleCarrierInfoUpdate();
- break;
- case MSG_SIM_STATE_CHANGE:
- handleSimStateChange((SimArgs) msg.obj);
- break;
- case MSG_RINGER_MODE_CHANGED:
- handleRingerModeChange(msg.arg1);
- break;
- case MSG_PHONE_STATE_CHANGED:
- handlePhoneStateChanged((String)msg.obj);
- break;
- case MSG_CLOCK_VISIBILITY_CHANGED:
- handleClockVisibilityChanged();
- break;
- case MSG_DEVICE_PROVISIONED:
- handleDeviceProvisioned();
- break;
- case MSG_DPM_STATE_CHANGED:
- handleDevicePolicyManagerStateChanged();
- break;
- case MSG_USER_CHANGED:
- handleUserChanged(msg.arg1);
- break;
- }
- }
- };
-
mDeviceProvisioned = Settings.Secure.getInt(
mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
// Since device can't be un-provisioned, we only need to register a content observer
// to update mDeviceProvisioned when we are...
if (!mDeviceProvisioned) {
- mContentObserver = new ContentObserver(mHandler) {
- @Override
- public void onChange(boolean selfChange) {
- super.onChange(selfChange);
- mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
- if (mDeviceProvisioned) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
- }
- if (DEBUG) Log.d(TAG, "DEVICE_PROVISIONED state = " + mDeviceProvisioned);
- }
- };
-
- mContext.getContentResolver().registerContentObserver(
- Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED),
- false, mContentObserver);
-
- // prevent a race condition between where we check the flag and where we register the
- // observer by grabbing the value once again...
- boolean provisioned = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
- if (provisioned != mDeviceProvisioned) {
- mDeviceProvisioned = provisioned;
- if (mDeviceProvisioned) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
- }
- }
+ watchForDeviceProvisioning();
}
- // take a guess to start
- mSimState = IccCardConstants.State.READY;
+ // Take a guess at initial SIM state, battery status and PLMN until we get an update
+ mSimState = IccCardConstants.State.NOT_READY;
mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0);
-
mTelephonyPlmn = getDefaultPlmn();
- // setup receiver
+ // Watch for interesting updates
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
@@ -265,67 +312,72 @@
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_USER_REMOVED);
- context.registerReceiver(new BroadcastReceiver() {
+ context.registerReceiver(mBroadcastReceiver, filter);
+ }
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (DEBUG) Log.d(TAG, "received broadcast " + action);
-
- if (Intent.ACTION_TIME_TICK.equals(action)
- || Intent.ACTION_TIME_CHANGED.equals(action)
- || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_TIME_UPDATE));
- } else if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
- mTelephonyPlmn = getTelephonyPlmnFrom(intent);
- mTelephonySpn = getTelephonySpnFrom(intent);
- mHandler.sendMessage(mHandler.obtainMessage(MSG_CARRIER_INFO_UPDATE));
- } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
- final int status = intent.getIntExtra(EXTRA_STATUS, BATTERY_STATUS_UNKNOWN);
- final int plugged = intent.getIntExtra(EXTRA_PLUGGED, 0);
- final int level = intent.getIntExtra(EXTRA_LEVEL, 0);
- final int health = intent.getIntExtra(EXTRA_HEALTH, BATTERY_HEALTH_UNKNOWN);
- final Message msg = mHandler.obtainMessage(
- MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health));
- mHandler.sendMessage(msg);
- } else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
- if (DEBUG_SIM_STATES) {
- Log.v(TAG, "action " + action + " state" +
- intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE));
- }
- mHandler.sendMessage(mHandler.obtainMessage(
- MSG_SIM_STATE_CHANGE, SimArgs.fromIntent(intent)));
- } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED,
- intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0));
- } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
- String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
- mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
- } else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED
- .equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_DPM_STATE_CHANGED));
- } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_CHANGED,
- intent.getIntExtra(Intent.EXTRA_USERID, 0), 0));
+ private void watchForDeviceProvisioning() {
+ mContentObserver = new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ super.onChange(selfChange);
+ mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+ if (mDeviceProvisioned) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
}
+ if (DEBUG) Log.d(TAG, "DEVICE_PROVISIONED state = " + mDeviceProvisioned);
}
- }, filter);
+ };
+
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED),
+ false, mContentObserver);
+
+ // prevent a race condition between where we check the flag and where we register the
+ // observer by grabbing the value once again...
+ boolean provisioned = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+ if (provisioned != mDeviceProvisioned) {
+ mDeviceProvisioned = provisioned;
+ if (mDeviceProvisioned) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
+ }
+ }
}
+ /**
+ * Handle {@link #MSG_DPM_STATE_CHANGED}
+ */
protected void handleDevicePolicyManagerStateChanged() {
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onDevicePolicyManagerStateChanged();
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onDevicePolicyManagerStateChanged();
}
}
- protected void handleUserChanged(int userId) {
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onUserChanged(userId);
+ /**
+ * Handle {@link #MSG_USER_SWITCHED}
+ */
+ protected void handleUserSwitched(int userId) {
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onUserSwitched(userId);
}
}
+ /**
+ * Handle {@link #MSG_USER_SWITCHED}
+ */
+ protected void handleUserRemoved(int userId) {
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onUserRemoved(userId);
+ }
+ }
+
+ /**
+ * Handle {@link #MSG_DEVICE_PROVISIONED}
+ */
protected void handleDeviceProvisioned() {
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onDeviceProvisioned();
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onDeviceProvisioned();
}
if (mContentObserver != null) {
// We don't need the observer anymore...
@@ -334,6 +386,9 @@
}
}
+ /**
+ * Handle {@link #MSG_PHONE_STATE_CHANGED}
+ */
protected void handlePhoneStateChanged(String newState) {
if (DEBUG) Log.d(TAG, "handlePhoneStateChanged(" + newState + ")");
if (TelephonyManager.EXTRA_STATE_IDLE.equals(newState)) {
@@ -343,16 +398,19 @@
} else if (TelephonyManager.EXTRA_STATE_RINGING.equals(newState)) {
mPhoneState = TelephonyManager.CALL_STATE_RINGING;
}
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onPhoneStateChanged(mPhoneState);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onPhoneStateChanged(mPhoneState);
}
}
+ /**
+ * Handle {@link #MSG_RINGER_MODE_CHANGED}
+ */
protected void handleRingerModeChange(int mode) {
if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")");
mRingMode = mode;
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onRingerModeChanged(mode);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onRingerModeChanged(mode);
}
}
@@ -361,24 +419,21 @@
*/
private void handleTimeUpdate() {
if (DEBUG) Log.d(TAG, "handleTimeUpdate");
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onTimeChanged();
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onTimeChanged();
}
}
/**
* Handle {@link #MSG_BATTERY_UPDATE}
*/
- private void handleBatteryUpdate(BatteryStatus batteryStatus) {
+ private void handleBatteryUpdate(BatteryStatus status) {
if (DEBUG) Log.d(TAG, "handleBatteryUpdate");
- final boolean batteryUpdateInteresting =
- isBatteryUpdateInteresting(mBatteryStatus, batteryStatus);
- mBatteryStatus = batteryStatus;
+ final boolean batteryUpdateInteresting = isBatteryUpdateInteresting(mBatteryStatus, status);
+ mBatteryStatus = status;
if (batteryUpdateInteresting) {
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- // TODO: pass BatteryStatus object to onRefreshBatteryInfo() instead...
- mInfoCallbacks.get(i).onRefreshBatteryInfo(
- shouldShowBatteryInfo(),isPluggedIn(batteryStatus), batteryStatus.level);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onRefreshBatteryInfo(status);
}
}
}
@@ -390,8 +445,8 @@
if (DEBUG) Log.d(TAG, "handleCarrierInfoUpdate: plmn = " + mTelephonyPlmn
+ ", spn = " + mTelephonySpn);
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
}
}
@@ -408,31 +463,25 @@
if (state != IccCardConstants.State.UNKNOWN && state != mSimState) {
mSimState = state;
- for (int i = 0; i < mSimStateCallbacks.size(); i++) {
- mSimStateCallbacks.get(i).onSimStateChanged(state);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onSimStateChanged(state);
}
}
}
+ /**
+ * Handle {@link #MSG_CLOCK_VISIBILITY_CHANGED}
+ */
private void handleClockVisibilityChanged() {
if (DEBUG) Log.d(TAG, "handleClockVisibilityChanged()");
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onClockVisibilityChanged();
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onClockVisibilityChanged();
}
}
- /**
- * @param pluggedIn state from {@link android.os.BatteryManager#EXTRA_PLUGGED}
- * @return Whether the device is considered "plugged in."
- */
- private static boolean isPluggedIn(BatteryStatus status) {
- return status.plugged == BatteryManager.BATTERY_PLUGGED_AC
- || status.plugged == BatteryManager.BATTERY_PLUGGED_USB;
- }
-
private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current) {
- final boolean nowPluggedIn = isPluggedIn(current);
- final boolean wasPluggedIn = isPluggedIn(old);
+ final boolean nowPluggedIn = current.isPluggedIn();
+ final boolean wasPluggedIn = old.isPluggedIn();
final boolean stateChangedWhilePluggedIn =
wasPluggedIn == true && nowPluggedIn == true
&& (old.status != current.status);
@@ -448,16 +497,12 @@
}
// change where battery needs charging
- if (!nowPluggedIn && isBatteryLow(current) && current.level != old.level) {
+ if (!nowPluggedIn && current.isBatteryLow() && current.level != old.level) {
return true;
}
return false;
}
- private static boolean isBatteryLow(BatteryStatus status) {
- return status.level < LOW_BATTERY_THRESHOLD;
- }
-
/**
* @param intent The intent with action {@link TelephonyIntents#SPN_STRINGS_UPDATED_ACTION}
* @return The string to use for the plmn, or null if it should not be shown.
@@ -465,11 +510,7 @@
private CharSequence getTelephonyPlmnFrom(Intent intent) {
if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
final String plmn = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
- if (plmn != null) {
- return plmn;
- } else {
- return getDefaultPlmn();
- }
+ return (plmn != null) ? plmn : getDefaultPlmn();
}
return null;
}
@@ -478,8 +519,7 @@
* @return The default plmn (no service)
*/
private CharSequence getDefaultPlmn() {
- return mContext.getResources().getText(
- R.string.lockscreen_carrier_default);
+ return mContext.getResources().getText(R.string.lockscreen_carrier_default);
}
/**
@@ -497,104 +537,12 @@
}
/**
- * Remove the given observer from being registered from any of the kinds
- * of callbacks.
- * @param observer The observer to remove (an instance of {@link ConfigurationChangeCallback},
- * {@link InfoCallback} or {@link SimStateCallback}
+ * Remove the given observer's callback.
+ *
+ * @param observer The observer to remove
*/
public void removeCallback(Object observer) {
- mInfoCallbacks.remove(observer);
- mSimStateCallbacks.remove(observer);
- }
-
- /**
- * Callback for general information relevant to lock screen.
- */
- interface InfoCallback {
- void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel);
- void onTimeChanged();
-
- /**
- * @param plmn The operator name of the registered network. May be null if it shouldn't
- * be displayed.
- * @param spn The service provider name. May be null if it shouldn't be displayed.
- */
- void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn);
-
- /**
- * Called when the ringer mode changes.
- * @param state the current ringer state, as defined in
- * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
- */
- void onRingerModeChanged(int state);
-
- /**
- * Called when the phone state changes. String will be one of:
- * {@link TelephonyManager#EXTRA_STATE_IDLE}
- * {@link TelephonyManager@EXTRA_STATE_RINGING}
- * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
- */
- void onPhoneStateChanged(int phoneState);
-
- /**
- * Called when visibility of lockscreen clock changes, such as when
- * obscured by a widget.
- */
- void onClockVisibilityChanged();
-
- /**
- * Called when the device becomes provisioned
- */
- void onDeviceProvisioned();
-
- /**
- * Called when the device policy changes.
- * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
- */
- void onDevicePolicyManagerStateChanged();
-
- /**
- * Called when the user changes.
- */
- void onUserChanged(int userId);
- }
-
- // Simple class that allows methods to easily be overwritten
- public static class InfoCallbackImpl implements InfoCallback {
- public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn,
- int batteryLevel) {
- }
-
- public void onTimeChanged() {
- }
-
- public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
- }
-
- public void onRingerModeChanged(int state) {
- }
-
- public void onPhoneStateChanged(int phoneState) {
- }
-
- public void onClockVisibilityChanged() {
- }
-
- public void onDeviceProvisioned() {
- }
-
- public void onDevicePolicyManagerStateChanged() {
- }
-
- public void onUserChanged(int userId) {
- }
- }
-
- /**
- * Callback to notify of sim state change.
- */
- interface SimStateCallback {
- void onSimStateChanged(IccCardConstants.State simState);
+ mCallbacks.remove(observer);
}
/**
@@ -602,35 +550,20 @@
* (see {@link InfoCallback}.
* @param callback The callback.
*/
- public void registerInfoCallback(InfoCallback callback) {
- if (!mInfoCallbacks.contains(callback)) {
- mInfoCallbacks.add(callback);
+ public void registerCallback(KeyguardUpdateMonitorCallback callback) {
+ if (!mCallbacks.contains(callback)) {
+ mCallbacks.add(callback);
// Notify listener of the current state
- callback.onRefreshBatteryInfo(shouldShowBatteryInfo(),isPluggedIn(mBatteryStatus),
- mBatteryStatus.level);
+ callback.onRefreshBatteryInfo(mBatteryStatus);
callback.onTimeChanged();
callback.onRingerModeChanged(mRingMode);
callback.onPhoneStateChanged(mPhoneState);
callback.onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
callback.onClockVisibilityChanged();
- } else {
- if (DEBUG) Log.e(TAG, "Object tried to add another INFO callback",
- new Exception("Whoops"));
- }
- }
-
- /**
- * Register to be notified of sim state changes.
- * @param callback The callback.
- */
- public void registerSimStateCallback(SimStateCallback callback) {
- if (!mSimStateCallbacks.contains(callback)) {
- mSimStateCallbacks.add(callback);
- // Notify listener of the current state
callback.onSimStateChanged(mSimState);
} else {
- if (DEBUG) Log.e(TAG, "Object tried to add another SIM callback",
- new Exception("Whoops"));
+ if (DEBUG) Log.e(TAG, "Object tried to add another callback",
+ new Exception("Called by"));
}
}
@@ -655,23 +588,6 @@
handleSimStateChange(new SimArgs(IccCardConstants.State.READY));
}
- public boolean isDevicePluggedIn() {
- return isPluggedIn(mBatteryStatus);
- }
-
- public boolean isDeviceCharged() {
- return mBatteryStatus.status == BATTERY_STATUS_FULL
- || mBatteryStatus.level >= 100; // in case particular device doesn't flag it
- }
-
- public int getBatteryLevel() {
- return mBatteryStatus.level;
- }
-
- public boolean shouldShowBatteryInfo() {
- return isPluggedIn(mBatteryStatus) || isBatteryLow(mBatteryStatus);
- }
-
public CharSequence getTelephonyPlmn() {
return mTelephonyPlmn;
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitorCallback.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitorCallback.java
new file mode 100644
index 0000000..d791419
--- /dev/null
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitorCallback.java
@@ -0,0 +1,97 @@
+/*
+ * 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 com.android.internal.policy.impl;
+
+import android.app.admin.DevicePolicyManager;
+import android.media.AudioManager;
+
+import com.android.internal.policy.impl.KeyguardUpdateMonitor.BatteryStatus;
+import com.android.internal.telephony.IccCardConstants;
+
+/**
+ * Callback for general information relevant to lock screen.
+ */
+class KeyguardUpdateMonitorCallback {
+ /**
+ * Called when the battery status changes, e.g. when plugged in or unplugged, charge
+ * level, etc. changes.
+ *
+ * @param status current battery status
+ */
+ void onRefreshBatteryInfo(BatteryStatus status) { }
+
+ /**
+ * Called once per minute or when the time changes.
+ */
+ void onTimeChanged() { }
+
+ /**
+ * Called when the carrier PLMN or SPN changes.
+ *
+ * @param plmn The operator name of the registered network. May be null if it shouldn't
+ * be displayed.
+ * @param spn The service provider name. May be null if it shouldn't be displayed.
+ */
+ void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { }
+
+ /**
+ * Called when the ringer mode changes.
+ * @param state the current ringer state, as defined in
+ * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
+ */
+ void onRingerModeChanged(int state) { }
+
+ /**
+ * Called when the phone state changes. String will be one of:
+ * {@link TelephonyManager#EXTRA_STATE_IDLE}
+ * {@link TelephonyManager@EXTRA_STATE_RINGING}
+ * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
+ */
+ void onPhoneStateChanged(int phoneState) { }
+
+ /**
+ * Called when visibility of lockscreen clock changes, such as when
+ * obscured by a widget.
+ */
+ void onClockVisibilityChanged() { }
+
+ /**
+ * Called when the device becomes provisioned
+ */
+ void onDeviceProvisioned() { }
+
+ /**
+ * Called when the device policy changes.
+ * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
+ */
+ void onDevicePolicyManagerStateChanged() { }
+
+ /**
+ * Called when the user changes.
+ */
+ void onUserSwitched(int userId) { }
+
+ /**
+ * Called when the SIM state changes.
+ * @param simState
+ */
+ void onSimStateChanged(IccCardConstants.State simState) { }
+
+ /**
+ * Called when a user is removed.
+ */
+ void onUserRemoved(int userId) { }
+}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index 504bb63..fb6ff24 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -147,7 +147,7 @@
if (enableScreenRotation) {
if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen On!");
- mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
+ mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
} else {
if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen Off!");
mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 73edbd3..1fb63db 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -18,7 +18,6 @@
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
@@ -90,8 +89,7 @@
* directly to the keyguard UI is posted to a {@link Handler} to ensure it is taken on the UI
* thread of the keyguard.
*/
-public class KeyguardViewMediator implements KeyguardViewCallback,
- KeyguardUpdateMonitor.SimStateCallback {
+public class KeyguardViewMediator implements KeyguardViewCallback {
private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
private final static boolean DEBUG = false;
private final static boolean DBG_WAKE = false;
@@ -257,7 +255,38 @@
*/
private final float mLockSoundVolume;
- InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
+ KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
+
+ @Override
+ public void onUserSwitched(int userId) {
+ mLockPatternUtils.setCurrentUser(userId);
+ synchronized (KeyguardViewMediator.this) {
+ resetStateLocked();
+ }
+ }
+
+ @Override
+ public void onUserRemoved(int userId) {
+ mLockPatternUtils.removeUser(userId);
+ }
+
+ @Override
+ void onPhoneStateChanged(int phoneState) {
+ synchronized (KeyguardViewMediator.this) {
+ if (TelephonyManager.CALL_STATE_IDLE == phoneState // call ending
+ && !mScreenOn // screen off
+ && mExternallyEnabled) { // not disabled by any app
+
+ // note: this is a way to gracefully reenable the keyguard when the call
+ // ends and the screen is off without always reenabling the keyguard
+ // each time the screen turns off while in call (and having an occasional ugly
+ // flicker while turning back on the screen and disabling the keyguard again).
+ if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the "
+ + "keyguard is showing");
+ doKeyguardLocked();
+ }
+ }
+ };
@Override
public void onClockVisibilityChanged() {
@@ -269,40 +298,86 @@
mContext.sendBroadcast(mUserPresentIntent);
}
+ @Override
+ public void onSimStateChanged(IccCardConstants.State simState) {
+ if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);
+
+ switch (simState) {
+ case NOT_READY:
+ case ABSENT:
+ // only force lock screen in case of missing sim if user hasn't
+ // gone through setup wizard
+ synchronized (this) {
+ if (!mUpdateMonitor.isDeviceProvisioned()) {
+ if (!isShowing()) {
+ if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing,"
+ + " we need to show the keyguard since the "
+ + "device isn't provisioned yet.");
+ doKeyguardLocked();
+ } else {
+ resetStateLocked();
+ }
+ }
+ }
+ break;
+ case PIN_REQUIRED:
+ case PUK_REQUIRED:
+ synchronized (this) {
+ if (!isShowing()) {
+ if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't "
+ + "showing; need to show keyguard so user can enter sim pin");
+ doKeyguardLocked();
+ } else {
+ resetStateLocked();
+ }
+ }
+ break;
+ case PERM_DISABLED:
+ synchronized (this) {
+ if (!isShowing()) {
+ if (DEBUG) Log.d(TAG, "PERM_DISABLED and "
+ + "keygaurd isn't showing.");
+ doKeyguardLocked();
+ } else {
+ if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
+ + "show permanently disabled message in lockscreen.");
+ resetStateLocked();
+ }
+ }
+ break;
+ case READY:
+ synchronized (this) {
+ if (isShowing()) {
+ resetStateLocked();
+ }
+ }
+ break;
+ }
+ }
+
};
public KeyguardViewMediator(Context context, PhoneWindowManager callback,
LocalPowerManager powerManager) {
mContext = context;
-
+ mCallback = callback;
mRealPowerManager = powerManager;
mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWakeLock = mPM.newWakeLock(
- PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
- "keyguard");
+ PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
mWakeLock.setReferenceCounted(false);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
- mWakeAndHandOff = mPM.newWakeLock(
- PowerManager.PARTIAL_WAKE_LOCK,
- "keyguardWakeAndHandOff");
+ mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
mWakeAndHandOff.setReferenceCounted(false);
- IntentFilter filter = new IntentFilter();
- filter.addAction(DELAYED_KEYGUARD_ACTION);
- filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- context.registerReceiver(mBroadCastReceiver, filter);
- mAlarmManager = (AlarmManager) context
- .getSystemService(Context.ALARM_SERVICE);
- mCallback = callback;
+ mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION));
+
+ mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mUpdateMonitor = new KeyguardUpdateMonitor(context);
- mUpdateMonitor.registerInfoCallback(mInfoCallback);
-
- mUpdateMonitor.registerSimStateCallback(this);
-
mLockPatternUtils = new LockPatternUtils(mContext);
mKeyguardViewProperties
= new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);
@@ -336,10 +411,6 @@
int lockSoundDefaultAttenuation = context.getResources().getInteger(
com.android.internal.R.integer.config_lockSoundVolumeDb);
mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20);
- IntentFilter userFilter = new IntentFilter();
- userFilter.addAction(Intent.ACTION_USER_SWITCHED);
- userFilter.addAction(Intent.ACTION_USER_REMOVED);
- mContext.registerReceiver(mUserChangeReceiver, userFilter);
}
/**
@@ -349,6 +420,7 @@
synchronized (this) {
if (DEBUG) Log.d(TAG, "onSystemReady");
mSystemReady = true;
+ mUpdateMonitor.registerCallback(mUpdateCallback);
doKeyguardLocked();
}
}
@@ -726,123 +798,21 @@
mHandler.sendMessage(msg);
}
- /** {@inheritDoc} */
- public void onSimStateChanged(IccCardConstants.State simState) {
- if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);
-
- switch (simState) {
- case ABSENT:
- // only force lock screen in case of missing sim if user hasn't
- // gone through setup wizard
- synchronized (this) {
- if (!mUpdateMonitor.isDeviceProvisioned()) {
- if (!isShowing()) {
- if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing,"
- + " we need to show the keyguard since the "
- + "device isn't provisioned yet.");
- doKeyguardLocked();
- } else {
- resetStateLocked();
- }
- }
- }
- break;
- case PIN_REQUIRED:
- case PUK_REQUIRED:
- synchronized (this) {
- if (!isShowing()) {
- if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, "
- + "we need to show keyguard so user can enter their sim pin");
- doKeyguardLocked();
- } else {
- resetStateLocked();
- }
- }
- break;
- case PERM_DISABLED:
- synchronized (this) {
- if (!isShowing()) {
- if (DEBUG) Log.d(TAG, "PERM_DISABLED and "
- + "keygaurd isn't showing.");
- doKeyguardLocked();
- } else {
- if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
- + "show permanently disabled message in lockscreen.");
- resetStateLocked();
- }
- }
- break;
- case READY:
- synchronized (this) {
- if (isShowing()) {
- resetStateLocked();
- }
- }
- break;
- }
- }
-
public boolean isSecure() {
return mKeyguardViewProperties.isSecure();
}
- private void onUserSwitched(int userId) {
- mLockPatternUtils.setCurrentUser(userId);
- synchronized (KeyguardViewMediator.this) {
- resetStateLocked();
- }
- }
-
- private void onUserRemoved(int userId) {
- mLockPatternUtils.removeUser(userId);
- }
-
- private BroadcastReceiver mUserChangeReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (Intent.ACTION_USER_SWITCHED.equals(action)) {
- onUserSwitched(intent.getIntExtra(Intent.EXTRA_USERID, 0));
- } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
- onUserRemoved(intent.getIntExtra(Intent.EXTRA_USERID, 0));
- }
- }
- };
-
- private BroadcastReceiver mBroadCastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (action.equals(DELAYED_KEYGUARD_ACTION)) {
-
- int sequence = intent.getIntExtra("seq", 0);
-
+ if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) {
+ final int sequence = intent.getIntExtra("seq", 0);
if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = "
+ sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence);
-
synchronized (KeyguardViewMediator.this) {
if (mDelayedShowingSequence == sequence) {
- // Don't play lockscreen SFX if the screen went off due to
- // timeout.
+ // Don't play lockscreen SFX if the screen went off due to timeout.
mSuppressNextLockSound = true;
-
- doKeyguardLocked();
- }
- }
- } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
- mPhoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
-
- synchronized (KeyguardViewMediator.this) {
- if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState) // call ending
- && !mScreenOn // screen off
- && mExternallyEnabled) { // not disabled by any app
-
- // note: this is a way to gracefully reenable the keyguard when the call
- // ends and the screen is off without always reenabling the keyguard
- // each time the screen turns off while in call (and having an occasional ugly
- // flicker while turning back on the screen and disabling the keyguard again).
- if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the "
- + "keyguard is showing");
doKeyguardLocked();
}
}
@@ -850,7 +820,6 @@
}
};
-
/**
* When a key is received when the screen is off and the keyguard is showing,
* we need to decide whether to actually turn on the screen, and if so, tell
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 041211c..32aec10 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -17,13 +17,10 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallback;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
-import com.android.internal.policy.impl.LockPatternKeyguardView.UnlockMode;
+import com.android.internal.policy.impl.KeyguardUpdateMonitor.BatteryStatus;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockScreenWidgetCallback;
-import com.android.internal.widget.LockScreenWidgetInterface;
import com.android.internal.widget.TransportControlView;
import android.accounts.Account;
@@ -40,10 +37,8 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
@@ -449,9 +444,8 @@
mWindowController = controller;
mSuppressBiometricUnlock = sIsFirstAppearanceAfterBoot;
sIsFirstAppearanceAfterBoot = false;
- mPluggedIn = mUpdateMonitor.isDevicePluggedIn();
mScreenOn = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isScreenOn();
- mUpdateMonitor.registerInfoCallback(mInfoCallback);
+ mUpdateMonitor.registerCallback(mInfoCallback);
/**
* We'll get key events the current screen doesn't use. see
@@ -692,17 +686,17 @@
post(mRecreateRunnable);
}
- InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
+ KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
- public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn,
- int batteryLevel) {
+ public void onRefreshBatteryInfo(BatteryStatus status) {
// When someone plugs in or unplugs the device, we hide the biometric sensor area and
// suppress its startup for the next onScreenTurnedOn(). Since plugging/unplugging
// causes the screen to turn on, the biometric unlock would start if it wasn't
// suppressed.
//
// However, if the biometric unlock is already running, we do not want to interrupt it.
+ final boolean pluggedIn = status.isPluggedIn();
if (mBiometricUnlock != null && mPluggedIn != pluggedIn
&& !mBiometricUnlock.isRunning()) {
mBiometricUnlock.stop();
@@ -732,7 +726,7 @@
}
@Override
- public void onUserChanged(int userId) {
+ public void onUserSwitched(int userId) {
if (mBiometricUnlock != null) {
mBiometricUnlock.stop();
}
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 26078ec..82181d3 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -17,8 +17,6 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.InfoCallbackImpl;
-import com.android.internal.policy.impl.KeyguardUpdateMonitor.SimStateCallback;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.SlidingTab;
@@ -86,7 +84,7 @@
// Is there a vibrator
private final boolean mHasVibrator;
- InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
+ KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onRingerModeChanged(int state) {
@@ -102,9 +100,7 @@
updateTargets();
}
- };
-
- SimStateCallback mSimStateCallback = new SimStateCallback() {
+ @Override
public void onSimStateChanged(IccCardConstants.State simState) {
updateTargets();
}
@@ -582,7 +578,6 @@
/** {@inheritDoc} */
public void onPause() {
mUpdateMonitor.removeCallback(mInfoCallback);
- mUpdateMonitor.removeCallback(mSimStateCallback);
mStatusViewManager.onPause();
mUnlockWidgetMethods.reset(false);
}
@@ -597,8 +592,7 @@
public void onResume() {
// We don't want to show the camera target if SIM state prevents us from
// launching the camera. So watch for SIM changes...
- mUpdateMonitor.registerSimStateCallback(mSimStateCallback);
- mUpdateMonitor.registerInfoCallback(mInfoCallback);
+ mUpdateMonitor.registerCallback(mInfoCallback);
mStatusViewManager.onResume();
postDelayed(mOnResumePing, ON_RESUME_PING_DELAY);
@@ -607,7 +601,6 @@
/** {@inheritDoc} */
public void cleanUp() {
mUpdateMonitor.removeCallback(mInfoCallback); // this must be first
- mUpdateMonitor.removeCallback(mSimStateCallback);
mUnlockWidgetMethods.cleanUp();
mLockPatternUtils = null;
mUpdateMonitor = null;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index cca9cbb..867f4f4 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -340,8 +340,6 @@
boolean mSystemReady;
boolean mSystemBooted;
boolean mHdmiPlugged;
- int mExternalDisplayWidth;
- int mExternalDisplayHeight;
int mUiMode;
int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
int mLidOpenRotation;
@@ -998,9 +996,6 @@
}
}
- mExternalDisplayWidth = mDisplay.getRawExternalWidth();
- mExternalDisplayHeight = mDisplay.getRawExternalHeight();
-
mStatusBarHeight = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height);
@@ -3037,10 +3032,6 @@
void setHdmiPlugged(boolean plugged) {
if (mHdmiPlugged != plugged) {
mHdmiPlugged = plugged;
- if (plugged && mDisplay != null) {
- mExternalDisplayWidth = mDisplay.getRawExternalWidth();
- mExternalDisplayHeight = mDisplay.getRawExternalHeight();
- }
updateRotation(true, true);
Intent intent = new Intent(ACTION_HDMI_PLUGGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 77b3b50..8836bac 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -36,6 +36,7 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
+import android.graphics.Point;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -49,6 +50,7 @@
import android.util.Slog;
import android.util.TypedValue;
import android.util.Xml;
+import android.view.Display;
import android.view.WindowManager;
import android.widget.RemoteViews;
@@ -188,11 +190,12 @@
void computeMaximumWidgetBitmapMemory() {
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
- int height = wm.getDefaultDisplay().getRawHeight();
- int width = wm.getDefaultDisplay().getRawWidth();
+ Display display = wm.getDefaultDisplay();
+ Point size = new Point();
+ display.getRealSize(size);
// Cap memory usage at 1.5 times the size of the display
// 1.5 * 4 bytes/pixel * w * h ==> 6 * w * h
- mMaxWidgetBitmapMemory = 6 * width * height;
+ mMaxWidgetBitmapMemory = 6 * size.x * size.y;
}
public void systemReady(boolean safeMode) {
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index c23a1d9..087e8db 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -35,6 +35,7 @@
import android.util.Slog;
import java.util.ArrayList;
+import java.util.List;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.net.NetworkInterface;
@@ -109,7 +110,7 @@
private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
- private CellInfo mCellInfo = null;
+ private List<CellInfo> mCellInfo = null;
static final int PHONE_STATE_PERMISSION_MASK =
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
@@ -242,7 +243,7 @@
}
if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
try {
- r.callback.onCellInfoChanged(new CellInfo(mCellInfo));
+ r.callback.onCellInfoChanged(mCellInfo);
} catch (RemoteException ex) {
remove(r.binder);
}
@@ -336,7 +337,7 @@
broadcastSignalStrengthChanged(signalStrength);
}
- public void notifyCellInfo(CellInfo cellInfo) {
+ public void notifyCellInfo(List<CellInfo> cellInfo) {
if (!checkNotifyPermission("notifyCellInfo()")) {
return;
}
@@ -346,7 +347,7 @@
for (Record r : mRecords) {
if ((r.events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
try {
- r.callback.onCellInfoChanged(new CellInfo(cellInfo));
+ r.callback.onCellInfoChanged(cellInfo);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
diff --git a/telephony/java/android/telephony/CdmaCellIdentity.java b/telephony/java/android/telephony/CdmaCellIdentity.java
deleted file mode 100644
index 5b8454f..0000000
--- a/telephony/java/android/telephony/CdmaCellIdentity.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2008 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.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * CellIdentity is to represent a unique CDMA cell
- *
- * @hide pending API review
- */
-public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
- // Network Id 0..65535
- private final int mNetworkId;
- // CDMA System Id 0..32767
- private final int mSystemId;
- // Base Station Id 0..65535
- private final int mBasestationId;
- /**
- * Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
- * It is represented in units of 0.25 seconds and ranges from -2592000
- * to 2592000, both values inclusive (corresponding to a range of -180
- * to +180 degrees).
- */
- private final int mLongitude;
- /**
- * Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
- * It is represented in units of 0.25 seconds and ranges from -1296000
- * to 1296000, both values inclusive (corresponding to a range of -90
- * to +90 degrees).
- */
- private final int mLatitude;
-
- /**
- * public constructor
- * @param nid Network Id 0..65535
- * @param sid CDMA System Id 0..32767
- * @param bid Base Station Id 0..65535
- * @param lon Longitude is a decimal number ranges from -2592000
- * to 2592000
- * @param lat Latitude is a decimal number ranges from -1296000
- * to 1296000
- * @param attr is comma separated “key=value” attribute pairs.
- */
- public CdmaCellIdentity (int nid, int sid,
- int bid, int lon, int lat, String attr) {
- super(CELLID_TYPE_CDMA, attr);
- mNetworkId = nid;
- mSystemId = sid;
- mBasestationId = bid;
- mLongitude = lon;
- mLatitude = lat;
- }
-
- private CdmaCellIdentity(Parcel in) {
- super(in);
- mNetworkId = in.readInt();
- mSystemId = in.readInt();
- mBasestationId = in.readInt();
- mLongitude = in.readInt();
- mLatitude = in.readInt();
- }
-
- CdmaCellIdentity(CdmaCellIdentity cid) {
- super(cid);
- mNetworkId = cid.mNetworkId;
- mSystemId = cid.mSystemId;
- mBasestationId = cid.mBasestationId;
- mLongitude = cid.mLongitude;
- mLatitude = cid.mLatitude;
- }
-
- /**
- * @return Network Id 0..65535
- */
- public int getNetworkId() {
- return mNetworkId;
- }
-
- /**
- * @return System Id 0..32767
- */
- public int getSystemId() {
- return mSystemId;
- }
-
- /**
- * @return Base Station Id 0..65535
- */
- public int getBasestationId() {
- return mBasestationId;
- }
-
- /**
- * @return Base station longitude, which is a decimal number as
- * specified in 3GPP2 C.S0005-A v6.0. It is represented in units
- * of 0.25 seconds and ranges from -2592000 to 2592000, both
- * values inclusive (corresponding to a range of -180
- * to +180 degrees).
- */
- public int getLongitude() {
- return mLongitude;
- }
-
- /**
- * @return Base station
- */
- /**
- * @return Base station latitude, which is a decimal number as
- * specified in 3GPP2 C.S0005-A v6.0. It is represented in units
- * of 0.25 seconds and ranges from -1296000 to 1296000, both
- * values inclusive (corresponding to a range of -90
- * to +90 degrees).
- */
- public int getLatitude() {
- return mLatitude;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mNetworkId);
- dest.writeInt(mSystemId);
- dest.writeInt(mBasestationId);
- dest.writeInt(mLongitude);
- dest.writeInt(mLatitude);
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<CdmaCellIdentity> CREATOR =
- new Creator<CdmaCellIdentity>() {
- @Override
- public CdmaCellIdentity createFromParcel(Parcel in) {
- return new CdmaCellIdentity(in);
- }
-
- @Override
- public CdmaCellIdentity[] newArray(int size) {
- return new CdmaCellIdentity[size];
- }
- };
-}
diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java
index 65c220f..1f4f78e 100644
--- a/telephony/java/android/telephony/CellIdentity.java
+++ b/telephony/java/android/telephony/CellIdentity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * 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.
@@ -20,70 +20,79 @@
import android.os.Parcelable;
/**
- * CellIdentity is to represent ONE unique cell in the world
+ * CellIdentity is immutable and represents ONE unique cell in the world
* it contains all levels of info to identity country, carrier, etc.
*
- * @hide pending API review
+ * @hide
*/
public abstract class CellIdentity implements Parcelable {
- // Cell is a GSM Cell {@link GsmCellIdentity}
- public static final int CELLID_TYPE_GSM = 1;
- // Cell is a CMDA Cell {@link CdmaCellIdentity}
- public static final int CELLID_TYPE_CDMA = 2;
- // Cell is a LTE Cell {@link LteCellIdentity}
- public static final int CELLID_TYPE_LTE = 3;
+ // Type fields for parceling
+ protected static final int TYPE_GSM = 1;
+ protected static final int TYPE_CDMA = 2;
+ protected static final int TYPE_LTE = 3;
- private int mCellIdType;
- private String mCellIdAttributes;
-
- protected CellIdentity(int type, String attr) {
- this.mCellIdType = type;
- this.mCellIdAttributes = new String(attr);
+ protected CellIdentity() {
}
protected CellIdentity(Parcel in) {
- this.mCellIdType = in.readInt();
- this.mCellIdAttributes = new String(in.readString());
}
protected CellIdentity(CellIdentity cid) {
- this.mCellIdType = cid.mCellIdType;
- this.mCellIdAttributes = new String(cid.mCellIdAttributes);
}
/**
- * @return Cell Identity type as one of CELLID_TYPE_XXXX
+ * @return a copy of this object with package visibility.
*/
- public int getCellIdType() {
- return mCellIdType;
+ abstract CellIdentity copy();
+
+ @Override
+ public abstract int hashCode();
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (this == other) {
+ return true;
+ }
+ return (other instanceof CellIdentity);
}
-
- /**
- * @return Cell identity attribute pairs
- * Comma separated “key=value” pairs.
- * key := must must an single alpha-numeric word
- * value := “quoted value string”
- *
- * Current list of keys and values:
- * type = fixed | mobile
- */
- public String getCellIdAttributes() {
- return mCellIdAttributes;
+ @Override
+ public String toString() {
+ return "";
}
-
- /** Implement the Parcelable interface {@hide} */
+ /** Implement the Parcelable interface */
@Override
public int describeContents() {
return 0;
}
- /** Implement the Parcelable interface {@hide} */
+ /** Implement the Parcelable interface */
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mCellIdType);
- dest.writeString(mCellIdAttributes);
}
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellIdentity> CREATOR =
+ new Creator<CellIdentity>() {
+ @Override
+ public CellIdentity createFromParcel(Parcel in) {
+ int type = in.readInt();
+ switch (type) {
+ case TYPE_GSM: return CellIdentityGsm.createFromParcelBody(in);
+ case TYPE_CDMA: return CellIdentityCdma.createFromParcelBody(in);
+ case TYPE_LTE: return CellIdentityLte.createFromParcelBody(in);
+ default: throw new RuntimeException("Bad CellIdentity Parcel");
+ }
+ }
+
+ @Override
+ public CellIdentity[] newArray(int size) {
+ return new CellIdentity[size];
+ }
+ };
}
diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java
new file mode 100644
index 0000000..0169d89
--- /dev/null
+++ b/telephony/java/android/telephony/CellIdentityCdma.java
@@ -0,0 +1,237 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * CellIdentity is to represent a unique CDMA cell
+ *
+ * @hide
+ */
+public final class CellIdentityCdma extends CellIdentity implements Parcelable {
+
+ private static final String LOG_TAG = "CellSignalStrengthCdma";
+ private static final boolean DBG = false;
+
+ // Network Id 0..65535
+ private final int mNetworkId;
+ // CDMA System Id 0..32767
+ private final int mSystemId;
+ // Base Station Id 0..65535
+ private final int mBasestationId;
+ /**
+ * Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
+ * It is represented in units of 0.25 seconds and ranges from -2592000
+ * to 2592000, both values inclusive (corresponding to a range of -180
+ * to +180 degrees).
+ */
+ private final int mLongitude;
+ /**
+ * Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
+ * It is represented in units of 0.25 seconds and ranges from -1296000
+ * to 1296000, both values inclusive (corresponding to a range of -90
+ * to +90 degrees).
+ */
+ private final int mLatitude;
+
+ /**
+ * @hide
+ */
+ public CellIdentityCdma() {
+ mNetworkId = Integer.MAX_VALUE;
+ mSystemId = Integer.MAX_VALUE;
+ mBasestationId = Integer.MAX_VALUE;
+ mLongitude = Integer.MAX_VALUE;
+ mLatitude = Integer.MAX_VALUE;
+ }
+
+ /**
+ * public constructor
+ * @param nid Network Id 0..65535
+ * @param sid CDMA System Id 0..32767
+ * @param bid Base Station Id 0..65535
+ * @param lon Longitude is a decimal number ranges from -2592000
+ * to 2592000
+ * @param lat Latitude is a decimal number ranges from -1296000
+ * to 1296000
+ *
+ * @hide
+ */
+ public CellIdentityCdma (int nid, int sid, int bid, int lon, int lat) {
+ mNetworkId = nid;
+ mSystemId = sid;
+ mBasestationId = bid;
+ mLongitude = lon;
+ mLatitude = lat;
+ }
+
+ private CellIdentityCdma(CellIdentityCdma cid) {
+ super(cid);
+ mNetworkId = cid.mNetworkId;
+ mSystemId = cid.mSystemId;
+ mBasestationId = cid.mBasestationId;
+ mLongitude = cid.mLongitude;
+ mLatitude = cid.mLatitude;
+ }
+
+ @Override
+ CellIdentityCdma copy() {
+ return new CellIdentityCdma(this);
+ }
+
+ /**
+ * @return Network Id 0..65535
+ */
+ public int getNetworkId() {
+ return mNetworkId;
+ }
+
+ /**
+ * @return System Id 0..32767
+ */
+ public int getSystemId() {
+ return mSystemId;
+ }
+
+ /**
+ * @return Base Station Id 0..65535
+ */
+ public int getBasestationId() {
+ return mBasestationId;
+ }
+
+ /**
+ * @return Base station longitude, which is a decimal number as
+ * specified in 3GPP2 C.S0005-A v6.0. It is represented in units
+ * of 0.25 seconds and ranges from -2592000 to 2592000, both
+ * values inclusive (corresponding to a range of -180
+ * to +180 degrees).
+ */
+ public int getLongitude() {
+ return mLongitude;
+ }
+
+ /**
+ * @return Base station latitude, which is a decimal number as
+ * specified in 3GPP2 C.S0005-A v6.0. It is represented in units
+ * of 0.25 seconds and ranges from -1296000 to 1296000, both
+ * values inclusive (corresponding to a range of -90
+ * to +90 degrees).
+ */
+ public int getLatitude() {
+ return mLatitude;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return (mNetworkId * primeNum) + (mSystemId * primeNum) + (mBasestationId * primeNum) +
+ (mLatitude * primeNum) + (mLongitude * primeNum);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (super.equals(other)) {
+ try {
+ CellIdentityCdma o = (CellIdentityCdma)other;
+ return mNetworkId == o.mNetworkId &&
+ mSystemId == o.mSystemId &&
+ mBasestationId == o.mBasestationId &&
+ mLatitude == o.mLatitude &&
+ mLongitude == o.mLongitude;
+ } catch (ClassCastException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("CdmaCellIdentitiy:");
+ sb.append(super.toString());
+ sb.append(" mNetworkId="); sb.append(mNetworkId);
+ sb.append(" mSystemId="); sb.append(mSystemId);
+ sb.append(" mBasestationId="); sb.append(mBasestationId);
+ sb.append(" mLongitude="); sb.append(mLongitude);
+ sb.append(" mLatitude="); sb.append(mLatitude);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(TYPE_CDMA);
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mNetworkId);
+ dest.writeInt(mSystemId);
+ dest.writeInt(mBasestationId);
+ dest.writeInt(mLongitude);
+ dest.writeInt(mLatitude);
+ }
+
+ /** Construct from Parcel, type has already been processed */
+ private CellIdentityCdma(Parcel in) {
+ super(in);
+ mNetworkId = in.readInt();
+ mSystemId = in.readInt();
+ mBasestationId = in.readInt();
+ mLongitude = in.readInt();
+ mLatitude = in.readInt();
+ if (DBG) log("CellIdentityCdma(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Creator<CellIdentityCdma> CREATOR =
+ new Creator<CellIdentityCdma>() {
+ @Override
+ public CellIdentityCdma createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellIdentityCdma[] newArray(int size) {
+ return new CellIdentityCdma[size];
+ }
+ };
+
+ /** @hide */
+ static CellIdentityCdma createFromParcelBody(Parcel in) {
+ return new CellIdentityCdma(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java
new file mode 100644
index 0000000..f46cd47
--- /dev/null
+++ b/telephony/java/android/telephony/CellIdentityGsm.java
@@ -0,0 +1,222 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * CellIdentity to represent a unique GSM or UMTS cell
+ *
+ * @hide
+ */
+public final class CellIdentityGsm extends CellIdentity implements Parcelable {
+
+ private static final String LOG_TAG = "CellIdentityGsm";
+ private static final boolean DBG = false;
+
+ // 3-digit Mobile Country Code, 0..999
+ private final int mMcc;
+ // 2 or 3-digit Mobile Network Code, 0..999
+ private final int mMnc;
+ // 16-bit Location Area Code, 0..65535
+ private final int mLac;
+ // 16-bit GSM Cell Identity described in TS 27.007, 0..65535
+ // 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455
+ private final int mCid;
+ // 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
+ private final int mPsc;
+
+ /**
+ * @hide
+ */
+ public CellIdentityGsm() {
+ mMcc = Integer.MAX_VALUE;
+ mMnc = Integer.MAX_VALUE;
+ mLac = Integer.MAX_VALUE;
+ mCid = Integer.MAX_VALUE;
+ mPsc = Integer.MAX_VALUE;
+ }
+ /**
+ * public constructor
+ * @param mcc 3-digit Mobile Country Code, 0..999
+ * @param mnc 2 or 3-digit Mobile Network Code, 0..999
+ * @param lac 16-bit Location Area Code, 0..65535
+ * @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
+ * @param psc 9-bit UMTS Primary Scrambling Code
+ *
+ * @hide
+ */
+ public CellIdentityGsm (int mcc, int mnc, int lac, int cid, int psc) {
+ mMcc = mcc;
+ mMnc = mnc;
+ mLac = lac;
+ mCid = cid;
+ mPsc = psc;
+ }
+
+ private CellIdentityGsm(CellIdentityGsm cid) {
+ super(cid);
+ mMcc = cid.mMcc;
+ mMnc = cid.mMnc;
+ mLac = cid.mLac;
+ mCid = cid.mCid;
+ mPsc = cid.mPsc;
+ }
+
+ @Override
+ CellIdentityGsm copy() {
+ return new CellIdentityGsm(this);
+ }
+
+ /**
+ * @return 3-digit Mobile Country Code, 0..999
+ */
+ public int getMcc() {
+ return mMcc;
+ }
+
+ /**
+ * @return 2 or 3-digit Mobile Network Code, 0..999
+ */
+ public int getMnc() {
+ return mMnc;
+ }
+
+ /**
+ * @return 16-bit Location Area Code, 0..65535
+ */
+ public int getLac() {
+ return mLac;
+ }
+
+ /**
+ * @return CID
+ * Either 16-bit GSM Cell Identity described
+ * in TS 27.007, 0..65535
+ * or 28-bit UMTS Cell Identity described
+ * in TS 25.331, 0..268435455
+ */
+ public int getCid() {
+ return mCid;
+ }
+
+ /**
+ * @return 9-bit UMTS Primary Scrambling Code described in
+ * TS 25.331, 0..511
+ */
+ public int getPsc() {
+ return mPsc;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) +
+ (mPsc * primeNum);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (super.equals(other)) {
+ try {
+ CellIdentityGsm o = (CellIdentityGsm)other;
+ return mMcc == o.mMcc &&
+ mMnc == o.mMnc &&
+ mLac == o.mLac &&
+ mCid == o.mCid &&
+ mPsc == o.mPsc;
+ } catch (ClassCastException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("GsmCellIdentitiy:");
+ sb.append(super.toString());
+ sb.append(" mMcc=").append(mMcc);
+ sb.append(" mMnc=").append(mMcc);
+ sb.append(" mLac=").append(mLac);
+ sb.append(" mCid=").append(mCid);
+ sb.append(" mPsc=").append(mPsc);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(TYPE_GSM);
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mMcc);
+ dest.writeInt(mMnc);
+ dest.writeInt(mLac);
+ dest.writeInt(mCid);
+ dest.writeInt(mPsc);
+ }
+
+ /** Construct from Parcel, type has already been processed */
+ private CellIdentityGsm(Parcel in) {
+ super(in);
+ mMcc = in.readInt();
+ mMnc = in.readInt();
+ mLac = in.readInt();
+ mCid = in.readInt();
+ mPsc = in.readInt();
+ if (DBG) log("CellIdentityGsm(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Creator<CellIdentityGsm> CREATOR =
+ new Creator<CellIdentityGsm>() {
+ @Override
+ public CellIdentityGsm createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellIdentityGsm[] newArray(int size) {
+ return new CellIdentityGsm[size];
+ }
+ };
+
+ /** @hide */
+ static CellIdentityGsm createFromParcelBody(Parcel in) {
+ return new CellIdentityGsm(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java
new file mode 100644
index 0000000..3d8532d
--- /dev/null
+++ b/telephony/java/android/telephony/CellIdentityLte.java
@@ -0,0 +1,217 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * CellIdentity is to represent a unique LTE cell
+ *
+ * @hide
+ */
+public final class CellIdentityLte extends CellIdentity implements Parcelable {
+
+ private static final String LOG_TAG = "CellIdentityLte";
+ private static final boolean DBG = false;
+
+ // 3-digit Mobile Country Code, 0..999
+ private final int mMcc;
+ // 2 or 3-digit Mobile Network Code, 0..999
+ private final int mMnc;
+ // 28-bit cell identity
+ private final int mCi;
+ // physical cell id 0..503
+ private final int mPci;
+ // 16-bit tracking area code
+ private final int mTac;
+
+ /**
+ * @hide
+ */
+ public CellIdentityLte() {
+ mMcc = Integer.MAX_VALUE;
+ mMnc = Integer.MAX_VALUE;
+ mCi = Integer.MAX_VALUE;
+ mPci = Integer.MAX_VALUE;
+ mTac = Integer.MAX_VALUE;
+ }
+
+ /**
+ *
+ * @param mcc 3-digit Mobile Country Code, 0..999
+ * @param mnc 2 or 3-digit Mobile Network Code, 0..999
+ * @param ci 28-bit Cell Identity
+ * @param pci Physical Cell Id 0..503
+ * @param tac 16-bit Tracking Area Code
+ *
+ * @hide
+ */
+ public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac) {
+ mMcc = mcc;
+ mMnc = mnc;
+ mCi = ci;
+ mPci = pci;
+ mTac = tac;
+ }
+
+ private CellIdentityLte(CellIdentityLte cid) {
+ super(cid);
+ mMcc = cid.mMcc;
+ mMnc = cid.mMnc;
+ mCi = cid.mCi;
+ mPci = cid.mPci;
+ mTac = cid.mTac;
+ }
+
+ @Override
+ CellIdentityLte copy() {
+ return new CellIdentityLte(this);
+ }
+
+ /**
+ * @return 3-digit Mobile Country Code, 0..999
+ */
+ public int getMcc() {
+ return mMcc;
+ }
+
+ /**
+ * @return 2 or 3-digit Mobile Network Code, 0..999
+ */
+ public int getMnc() {
+ return mMnc;
+ }
+
+ /**
+ * @return 28-bit Cell Identity
+ */
+ public int getCi() {
+ return mCi;
+ }
+
+ /**
+ * @return Physical Cell Id 0..503
+ */
+ public int getPci() {
+ return mPci;
+ }
+
+ /**
+ * @return 16-bit Tracking Area Code
+ */
+ public int getTac() {
+ return mTac;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return (mMcc * primeNum) + (mMnc * primeNum) + (mCi * primeNum) + (mPci * primeNum) +
+ (mTac * primeNum);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (super.equals(other)) {
+ try {
+ CellIdentityLte o = (CellIdentityLte)other;
+ return mMcc == o.mMcc &&
+ mMnc == o.mMnc &&
+ mCi == o.mCi &&
+ mPci == o.mCi &&
+ mTac == o.mTac;
+ } catch (ClassCastException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("LteCellIdentitiy:");
+ sb.append(super.toString());
+ sb.append(" mMcc="); sb.append(mMcc);
+ sb.append(" mMnc="); sb.append(mMnc);
+ sb.append(" mCi="); sb.append(mCi);
+ sb.append(" mPci="); sb.append(mPci);
+ sb.append(" mTac="); sb.append(mTac);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(TYPE_LTE);
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mMcc);
+ dest.writeInt(mMnc);
+ dest.writeInt(mCi);
+ dest.writeInt(mPci);
+ dest.writeInt(mTac);
+ }
+
+ /** Construct from Parcel, type has already been processed */
+ private CellIdentityLte(Parcel in) {
+ super(in);
+ mMcc = in.readInt();
+ mMnc = in.readInt();
+ mCi = in.readInt();
+ mPci = in.readInt();
+ mTac = in.readInt();
+ if (DBG) log("CellIdentityLte(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Creator<CellIdentityLte> CREATOR =
+ new Creator<CellIdentityLte>() {
+ @Override
+ public CellIdentityLte createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellIdentityLte[] newArray(int size) {
+ return new CellIdentityLte[size];
+ }
+ };
+
+ /** @hide */
+ static CellIdentityLte createFromParcelBody(Parcel in) {
+ return new CellIdentityLte(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellInfo.java b/telephony/java/android/telephony/CellInfo.java
index 9bea30c..5fdf7c0 100644
--- a/telephony/java/android/telephony/CellInfo.java
+++ b/telephony/java/android/telephony/CellInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * 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.
@@ -20,194 +20,171 @@
import android.os.Parcelable;
/**
- * Represent one snapshot observation of one cell info
- * which contains the time of observation.
+ * Immutable cell information from a point in time.
*
- * @hide Pending API review
+ * @hide
*/
-public final class CellInfo implements Parcelable {
+public class CellInfo implements Parcelable {
+
+ // Type fields for parceling
+ protected static final int TYPE_GSM = 1;
+ protected static final int TYPE_CDMA = 2;
+ protected static final int TYPE_LTE = 3;
+
// Type to distinguish where time stamp gets recorded.
- public static final int CELL_INFO_TIMESTAMP_TYPE_UNKNOWN = 0;
- public static final int CELL_INFO_TIMESTAMP_TYPE_ANTENNA = 1;
- public static final int CELL_INFO_TIMESTAMP_TYPE_MODEM = 2;
- public static final int CELL_INFO_TIMESTAMP_TYPE_OEM_RIL = 3;
- public static final int CELL_INFO_TIMESTAMP_TYPE_JAVA_RIL = 4;
+
+ /** @hide */
+ public static final int TIMESTAMP_TYPE_UNKNOWN = 0;
+ /** @hide */
+ public static final int TIMESTAMP_TYPE_ANTENNA = 1;
+ /** @hide */
+ public static final int TIMESTAMP_TYPE_MODEM = 2;
+ /** @hide */
+ public static final int TIMESTAMP_TYPE_OEM_RIL = 3;
+ /** @hide */
+ public static final int TIMESTAMP_TYPE_JAVA_RIL = 4;
+
+ // True if device is mRegistered to the mobile network
+ private boolean mRegistered;
// Observation time stamped as type in nanoseconds since boot
- private final long mTimeStamp;
+ private long mTimeStamp;
+
// Where time stamp gets recorded.
- // Value of CELL_INFO_TIMESTAMP_TYPE_XXXX
- private final int mTimeStampType;
+ // Value of TIMESTAMP_TYPE_XXXX
+ private int mTimeStampType;
- private final boolean mRegistered;
-
- private final SignalStrength mStrength;
- private final long mTimingAdvance;
-
- private final int mCellIdentityType;
- private final CellIdentity mCellIdentity;
-
- /**
- * Public constructor
- * @param timeStampType is one of CELL_INFO_TIMESTAMP_TYPE_XXXX
- * @param timeStamp is observation time in nanoseconds since boot
- * @param timingAdv is observed timing advance
- * @param registered is true when register to this cellIdentity
- * @param strength is observed signal strength
- * @param cellIdentity is observed mobile cell
- */
- public CellInfo(int timeStampType, long timeStamp, long timingAdv,
- boolean registered, SignalStrength strength,
- CellIdentity cellIdentity) {
-
- if (timeStampType < CELL_INFO_TIMESTAMP_TYPE_UNKNOWN ||
- timeStampType > CELL_INFO_TIMESTAMP_TYPE_JAVA_RIL) {
- mTimeStampType = CELL_INFO_TIMESTAMP_TYPE_UNKNOWN;
- } else {
- mTimeStampType = timeStampType;
- }
-
- mRegistered = registered;
- mTimeStamp = timeStamp;
- mTimingAdvance = timingAdv;
- mStrength = new SignalStrength(strength);
-
- mCellIdentityType = cellIdentity.getCellIdType();
- // TODO: make defense copy
- mCellIdentity = cellIdentity;
+ protected CellInfo() {
+ this.mRegistered = false;
+ this.mTimeStampType = TIMESTAMP_TYPE_UNKNOWN;
+ this.mTimeStamp = Long.MAX_VALUE;
}
- public CellInfo(CellInfo ci) {
- this.mTimeStampType = ci.mTimeStampType;
+ protected CellInfo(CellInfo ci) {
this.mRegistered = ci.mRegistered;
+ this.mTimeStampType = ci.mTimeStampType;
this.mTimeStamp = ci.mTimeStamp;
- this.mTimingAdvance = ci.mTimingAdvance;
- this.mCellIdentityType = ci.mCellIdentityType;
- this.mStrength = new SignalStrength(ci.mStrength);
- switch(mCellIdentityType) {
- case CellIdentity.CELLID_TYPE_GSM:
- mCellIdentity = new GsmCellIdentity((GsmCellIdentity)ci.mCellIdentity);
- break;
- default:
- mCellIdentity = null;
- }
}
- private CellInfo(Parcel in) {
- mTimeStampType = in.readInt();
- mRegistered = (in.readInt() == 1) ? true : false;
- mTimeStamp = in.readLong();
- mTimingAdvance = in.readLong();
- mCellIdentityType = in.readInt();
- mStrength = SignalStrength.CREATOR.createFromParcel(in);
- switch(mCellIdentityType) {
- case CellIdentity.CELLID_TYPE_GSM:
- mCellIdentity = GsmCellIdentity.CREATOR.createFromParcel(in);
- break;
- default:
- mCellIdentity = null;
- }
+ /** True if this cell is registered to the mobile network */
+ public boolean isRegistered() {
+ return mRegistered;
+ }
+ /** @hide */
+ public void setRegisterd(boolean registered) {
+ mRegistered = registered;
}
- /**
- * @return the observation time in nanoseconds since boot
- */
+ /** Approximate time of this cell information in nanos since boot */
public long getTimeStamp() {
return mTimeStamp;
}
+ /** @hide */
+ public void setTimeStamp(long timeStamp) {
+ mTimeStamp = timeStamp;
+ }
/**
- * @return Where time stamp gets recorded.
- * one of CELL_INFO_TIMESTAMP_TYPE_XXXX
+ * Where time stamp gets recorded.
+ * @return one of TIMESTAMP_TYPE_XXXX
+ *
+ * @hide
*/
public int getTimeStampType() {
return mTimeStampType;
}
-
- /**
- * @return true when register to this cellIdentity
- */
- public boolean isRegistered() {
- return mRegistered;
+ /** @hide */
+ public void setTimeStampType(int timeStampType) {
+ if (timeStampType < TIMESTAMP_TYPE_UNKNOWN || timeStampType > TIMESTAMP_TYPE_JAVA_RIL) {
+ mTimeStampType = TIMESTAMP_TYPE_UNKNOWN;
+ } else {
+ mTimeStampType = timeStampType;
+ }
}
- /**
- * @return observed timing advance
- */
- public long getTimingAdvance() {
- return mTimingAdvance;
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return ((mRegistered ? 0 : 1) * primeNum) + ((int)(mTimeStamp / 1000) * primeNum)
+ + (mTimeStampType * primeNum);
}
- /**
- * @return observed signal strength
- */
- public SignalStrength getSignalStrength() {
- // make a defense copy
- return new SignalStrength(mStrength);
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (this == other) {
+ return true;
+ }
+ try {
+ CellInfo o = (CellInfo) other;
+ return mRegistered == o.mRegistered
+ && mTimeStamp == o.mTimeStamp && mTimeStampType == o.mTimeStampType;
+ } catch (ClassCastException e) {
+ return false;
+ }
}
- /**
- * @return observed cell identity
- */
- public CellIdentity getCellIdentity() {
- // TODO: make a defense copy
- return mCellIdentity;
+ private static String timeStampTypeToString(int type) {
+ switch (type) {
+ case 1:
+ return "antenna";
+ case 2:
+ return "modem";
+ case 3:
+ return "oem_ril";
+ case 4:
+ return "java_ril";
+ default:
+ return "unknown";
+ }
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
+ String timeStampType;
- sb.append("TimeStampType: ");
- switch(mTimeStampType) {
- case 1:
- sb.append("antenna");
- break;
- case 2:
- sb.append("modem");
- break;
- case 3:
- sb.append("oem_ril");
- break;
- case 4:
- sb.append("java_ril");
- break;
- default:
- sb.append("unknown");
- }
- sb.append(", TimeStamp: ").append(mTimeStamp).append(" ns");
- sb.append(", Registered: ").append(mRegistered ? "YES" : "NO");
- sb.append(", TimingAdvance: ").append(mTimingAdvance);
- sb.append(", Strength : " + mStrength);
- sb.append(", Cell Iden: " + mCellIdentity);
+ sb.append(" mRegistered=").append(mRegistered ? "YES" : "NO");
+ timeStampType = timeStampTypeToString(mTimeStampType);
+ sb.append(" mTimeStampType=").append(timeStampType);
+ sb.append(" mTimeStamp=").append(mTimeStamp).append("ns");
return sb.toString();
}
- /** Implement the Parcelable interface {@hide} */
+ /** Implement the Parcelable interface */
@Override
public int describeContents() {
return 0;
}
- /** Implement the Parcelable interface {@hide} */
+ /** Implement the Parcelable interface */
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mTimeStampType);
dest.writeInt(mRegistered ? 1 : 0);
+ dest.writeInt(mTimeStampType);
dest.writeLong(mTimeStamp);
- dest.writeLong(mTimingAdvance);
- dest.writeInt(mCellIdentityType);
- mStrength.writeToParcel(dest, flags);
- mCellIdentity.writeToParcel(dest, flags);
}
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<CellInfo> CREATOR =
- new Creator<CellInfo>() {
+ protected CellInfo(Parcel in) {
+ mRegistered = (in.readInt() == 1) ? true : false;
+ mTimeStampType = in.readInt();
+ mTimeStamp = in.readLong();
+ }
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellInfo> CREATOR = new Creator<CellInfo>() {
@Override
public CellInfo createFromParcel(Parcel in) {
- return new CellInfo(in);
+ int type = in.readInt();
+ switch (type) {
+ case TYPE_GSM: return CellInfoGsm.createFromParcelBody(in);
+ case TYPE_CDMA: return CellInfoCdma.createFromParcelBody(in);
+ case TYPE_LTE: return CellInfoLte.createFromParcelBody(in);
+ default: throw new RuntimeException("Bad CellInfo Parcel");
+ }
}
@Override
diff --git a/telephony/java/android/telephony/CellInfoCdma.java b/telephony/java/android/telephony/CellInfoCdma.java
new file mode 100644
index 0000000..84c1560
--- /dev/null
+++ b/telephony/java/android/telephony/CellInfoCdma.java
@@ -0,0 +1,152 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * Immutable cell information from a point in time.
+ *
+ * @hide
+ */
+public final class CellInfoCdma extends CellInfo implements Parcelable {
+
+ private static final String LOG_TAG = "CellInfoCdma";
+ private static final boolean DBG = false;
+
+ private CellIdentityCdma mCellIdentityCdma;
+ private CellSignalStrengthCdma mCellSignalStrengthCdma;
+
+ /** @hide */
+ public CellInfoCdma() {
+ super();
+ mCellIdentityCdma = new CellIdentityCdma();
+ mCellSignalStrengthCdma = new CellSignalStrengthCdma();
+ }
+
+ /** @hide */
+ public CellInfoCdma(CellInfoCdma ci) {
+ super(ci);
+ this.mCellIdentityCdma = ci.mCellIdentityCdma.copy();
+ this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
+ }
+
+ public CellIdentityCdma getCellIdentity() {
+ return mCellIdentityCdma;
+ }
+ /** @hide */
+ public void setCellIdentity(CellIdentityCdma cid) {
+ mCellIdentityCdma = cid;
+ }
+
+ public CellSignalStrengthCdma getCellSignalStrength() {
+ return mCellSignalStrengthCdma;
+ }
+ /** @hide */
+ public void setCellSignalStrength(CellSignalStrengthCdma css) {
+ mCellSignalStrengthCdma = css;
+ }
+
+ /**
+ * @return hash code
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() + mCellIdentityCdma.hashCode() + mCellSignalStrengthCdma.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!super.equals(other)) {
+ return false;
+ }
+ try {
+ CellInfoCdma o = (CellInfoCdma) other;
+ return mCellIdentityCdma.equals(o.mCellIdentityCdma)
+ && mCellSignalStrengthCdma.equals(o.mCellSignalStrengthCdma);
+ } catch (ClassCastException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("CellInfoCdma:");
+ sb.append(super.toString());
+ sb.append(", ").append(mCellIdentityCdma);
+ sb.append(", ").append(mCellSignalStrengthCdma);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(TYPE_LTE);
+ super.writeToParcel(dest, flags);
+ mCellIdentityCdma.writeToParcel(dest, flags);
+ mCellSignalStrengthCdma.writeToParcel(dest, flags);
+ }
+
+ /**
+ * Construct a CellInfoCdma object from the given parcel
+ * where the token is already been processed.
+ */
+ private CellInfoCdma(Parcel in) {
+ super(in);
+ mCellIdentityCdma = CellIdentityCdma.CREATOR.createFromParcel(in);
+ mCellSignalStrengthCdma = CellSignalStrengthCdma.CREATOR.createFromParcel(in);
+ if (DBG) log("CellInfoCdma(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellInfoCdma> CREATOR = new Creator<CellInfoCdma>() {
+ @Override
+ public CellInfoCdma createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellInfoCdma[] newArray(int size) {
+ return new CellInfoCdma[size];
+ }
+ };
+
+ /** @hide */
+ protected static CellInfoCdma createFromParcelBody(Parcel in) {
+ return new CellInfoCdma(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellInfoGsm.java b/telephony/java/android/telephony/CellInfoGsm.java
new file mode 100644
index 0000000..f913569
--- /dev/null
+++ b/telephony/java/android/telephony/CellInfoGsm.java
@@ -0,0 +1,150 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * Immutable cell information from a point in time.
+ *
+ * @hide
+ */
+public final class CellInfoGsm extends CellInfo implements Parcelable {
+
+ private static final String LOG_TAG = "CellInfoGsm";
+ private static final boolean DBG = false;
+
+ private CellIdentityGsm mCellIdentityGsm;
+ private CellSignalStrengthGsm mCellSignalStrengthGsm;
+
+ /** @hide */
+ public CellInfoGsm() {
+ super();
+ mCellIdentityGsm = new CellIdentityGsm();
+ mCellSignalStrengthGsm = new CellSignalStrengthGsm();
+ }
+
+ /** @hide */
+ public CellInfoGsm(CellInfoGsm ci) {
+ super(ci);
+ this.mCellIdentityGsm = ci.mCellIdentityGsm.copy();
+ this.mCellSignalStrengthGsm = ci.mCellSignalStrengthGsm.copy();
+ }
+
+ public CellIdentityGsm getCellIdentity() {
+ return mCellIdentityGsm;
+ }
+ /** @hide */
+ public void setCellIdentity(CellIdentityGsm cid) {
+ mCellIdentityGsm = cid;
+ }
+
+ public CellSignalStrengthGsm getCellSignalStrength() {
+ return mCellSignalStrengthGsm;
+ }
+ /** @hide */
+ public void setCellSignalStrength(CellSignalStrengthGsm css) {
+ mCellSignalStrengthGsm = css;
+ }
+
+ /**
+ * @return hash code
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() + mCellIdentityGsm.hashCode() + mCellSignalStrengthGsm.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!super.equals(other)) {
+ return false;
+ }
+ try {
+ CellInfoGsm o = (CellInfoGsm) other;
+ return mCellIdentityGsm.equals(o.mCellIdentityGsm)
+ && mCellSignalStrengthGsm.equals(o.mCellSignalStrengthGsm);
+ } catch (ClassCastException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("CellInfoGsm:");
+ sb.append(super.toString());
+ sb.append(", ").append(mCellIdentityGsm);
+ sb.append(", ").append(mCellSignalStrengthGsm);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(TYPE_LTE);
+ super.writeToParcel(dest, flags);
+ mCellIdentityGsm.writeToParcel(dest, flags);
+ mCellSignalStrengthGsm.writeToParcel(dest, flags);
+ }
+
+ /**
+ * Construct a CellInfoGsm object from the given parcel
+ * where the token is already been processed.
+ */
+ private CellInfoGsm(Parcel in) {
+ super(in);
+ mCellIdentityGsm = CellIdentityGsm.CREATOR.createFromParcel(in);
+ mCellSignalStrengthGsm = CellSignalStrengthGsm.CREATOR.createFromParcel(in);
+ }
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellInfoGsm> CREATOR = new Creator<CellInfoGsm>() {
+ @Override
+ public CellInfoGsm createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellInfoGsm[] newArray(int size) {
+ return new CellInfoGsm[size];
+ }
+ };
+
+ /** @hide */
+ protected static CellInfoGsm createFromParcelBody(Parcel in) {
+ return new CellInfoGsm(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellInfoLte.java b/telephony/java/android/telephony/CellInfoLte.java
new file mode 100644
index 0000000..57b0402
--- /dev/null
+++ b/telephony/java/android/telephony/CellInfoLte.java
@@ -0,0 +1,152 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * Immutable cell information from a point in time.
+ *
+ * @hide
+ */
+public final class CellInfoLte extends CellInfo implements Parcelable {
+
+ private static final String LOG_TAG = "CellInfoLte";
+ private static final boolean DBG = false;
+
+ private CellIdentityLte mCellIdentityLte;
+ private CellSignalStrengthLte mCellSignalStrengthLte;
+
+ /** @hide */
+ public CellInfoLte() {
+ super();
+ mCellIdentityLte = new CellIdentityLte();
+ mCellSignalStrengthLte = new CellSignalStrengthLte();
+ }
+
+ /** @hide */
+ public CellInfoLte(CellInfoLte ci) {
+ super(ci);
+ this.mCellIdentityLte = ci.mCellIdentityLte.copy();
+ this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy();
+ }
+
+ public CellIdentityLte getCellIdentity() {
+ return mCellIdentityLte;
+ }
+ /** @hide */
+ public void setCellIdentity(CellIdentityLte cid) {
+ mCellIdentityLte = cid;
+ }
+
+ public CellSignalStrengthLte getCellSignalStrength() {
+ return mCellSignalStrengthLte;
+ }
+ /** @hide */
+ public void setCellSignalStrength(CellSignalStrengthLte css) {
+ mCellSignalStrengthLte = css;
+ }
+
+ /**
+ * @return hash code
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() + mCellIdentityLte.hashCode() + mCellSignalStrengthLte.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!super.equals(other)) {
+ return false;
+ }
+ try {
+ CellInfoLte o = (CellInfoLte) other;
+ return mCellIdentityLte.equals(o.mCellIdentityLte)
+ && mCellSignalStrengthLte.equals(o.mCellSignalStrengthLte);
+ } catch (ClassCastException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("CellInfoLte:");
+ sb.append(super.toString());
+ sb.append(", ").append(mCellIdentityLte);
+ sb.append(", ").append(mCellSignalStrengthLte);
+
+ return sb.toString();
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(TYPE_LTE);
+ super.writeToParcel(dest, flags);
+ mCellIdentityLte.writeToParcel(dest, flags);
+ mCellSignalStrengthLte.writeToParcel(dest, flags);
+ }
+
+ /**
+ * Construct a CellInfoLte object from the given parcel
+ * where the TYPE_LTE token is already been processed.
+ */
+ private CellInfoLte(Parcel in) {
+ super(in);
+ mCellIdentityLte = CellIdentityLte.CREATOR.createFromParcel(in);
+ mCellSignalStrengthLte = CellSignalStrengthLte.CREATOR.createFromParcel(in);
+ if (DBG) log("CellInfoLte(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() {
+ @Override
+ public CellInfoLte createFromParcel(Parcel in) {
+ in.readInt(); // Skip past token, we know what it is
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellInfoLte[] newArray(int size) {
+ return new CellInfoLte[size];
+ }
+ };
+
+ /** @hide */
+ protected static CellInfoLte createFromParcelBody(Parcel in) {
+ return new CellInfoLte(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellSignalStrength.java b/telephony/java/android/telephony/CellSignalStrength.java
new file mode 100644
index 0000000..4ed7dcf
--- /dev/null
+++ b/telephony/java/android/telephony/CellSignalStrength.java
@@ -0,0 +1,120 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.InputEvent;
+
+/**
+ * Abstract base class for cell phone signal strength related information.
+ *
+ * @hide
+ */
+public abstract class CellSignalStrength implements Parcelable {
+
+ // Type fields for parceling
+ protected static final int TYPE_GSM = 1;
+ protected static final int TYPE_CDMA = 2;
+ protected static final int TYPE_LTE = 3;
+
+
+ /** @hide */
+ public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
+ /** @hide */
+ public static final int SIGNAL_STRENGTH_POOR = 1;
+ /** @hide */
+ public static final int SIGNAL_STRENGTH_MODERATE = 2;
+ /** @hide */
+ public static final int SIGNAL_STRENGTH_GOOD = 3;
+ /** @hide */
+ public static final int SIGNAL_STRENGTH_GREAT = 4;
+ /** @hide */
+ public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
+ /** @hide */
+ public static final String[] SIGNAL_STRENGTH_NAMES = {
+ "none", "poor", "moderate", "good", "great"
+ };
+
+ /** @hide */
+ public abstract void setDefaultValues();
+
+ /**
+ * Get signal level as an int from 0..4
+ *
+ * @hide
+ */
+ public abstract int getLevel();
+
+ /**
+ * Get the signal level as an asu value between 0..31, 99 is unknown
+ *
+ * @hide
+ */
+ public abstract int getAsuLevel();
+
+ /**
+ * Get the signal strength as dBm
+ *
+ * @hide
+ */
+ public abstract int getDbm();
+
+ /**
+ * Copies the CellSignalStrength.
+ *
+ * @return A deep copy of this class.
+ * @hide
+ */
+ public abstract CellSignalStrength copy();
+
+ @Override
+ public abstract int hashCode();
+
+ @Override
+ public abstract boolean equals (Object o);
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public abstract void writeToParcel(Parcel dest, int flags);
+
+ /** Implement the Parcelable interface */
+ public static final Creator<CellSignalStrength> CREATOR =
+ new Creator<CellSignalStrength>() {
+ @Override
+ public CellSignalStrength createFromParcel(Parcel in) {
+ int type = in.readInt();
+ switch (type) {
+ case TYPE_GSM: return CellSignalStrengthGsm.createFromParcelBody(in);
+ case TYPE_CDMA: return CellSignalStrengthCdma.createFromParcelBody(in);
+ case TYPE_LTE: return CellSignalStrengthLte.createFromParcelBody(in);
+ default: throw new RuntimeException("Bad CellSignalStrength Parcel");
+ }
+ }
+
+ @Override
+ public CellSignalStrength[] newArray(int size) {
+ return new CellSignalStrength[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/CellSignalStrengthCdma.java b/telephony/java/android/telephony/CellSignalStrengthCdma.java
new file mode 100644
index 0000000..ee50fad
--- /dev/null
+++ b/telephony/java/android/telephony/CellSignalStrengthCdma.java
@@ -0,0 +1,402 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * LTE signal strength related information.
+ *
+ * @hide
+ */
+public class CellSignalStrengthCdma extends CellSignalStrength implements Parcelable {
+
+ private static final String LOG_TAG = "CellSignalStrengthCdma";
+ private static final boolean DBG = false;
+
+ private int mCdmaDbm; // This value is the RSSI value
+ private int mCdmaEcio; // This value is the Ec/Io
+ private int mEvdoDbm; // This value is the EVDO RSSI value
+ private int mEvdoEcio; // This value is the EVDO Ec/Io
+ private int mEvdoSnr; // Valid values are 0-8. 8 is the highest signal to noise ratio
+
+ /**
+ * Empty constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthCdma() {
+ setDefaultValues();
+ }
+
+ /**
+ * Constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthCdma(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio,
+ int evdoSnr) {
+ initialize(cdmaDbm, cdmaEcio, evdoDbm, evdoEcio, evdoSnr);
+ }
+
+ /**
+ * Copy constructors
+ *
+ * @param s Source SignalStrength
+ *
+ * @hide
+ */
+ public CellSignalStrengthCdma(CellSignalStrengthCdma s) {
+ copyFrom(s);
+ }
+
+ /**
+ * Initialize all the values
+ *
+ * @param cdmaDbm
+ * @param cdmaEcio
+ * @param evdoDbm
+ * @param evdoEcio
+ * @param evdoSnr
+ *
+ * @hide
+ */
+ public void initialize(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr) {
+ mCdmaDbm = cdmaDbm;
+ mCdmaEcio = cdmaEcio;
+ mEvdoDbm = evdoDbm;
+ mEvdoEcio = evdoEcio;
+ mEvdoSnr = evdoSnr;
+ }
+
+ /**
+ * @hide
+ */
+ protected void copyFrom(CellSignalStrengthCdma s) {
+ mCdmaDbm = s.mCdmaDbm;
+ mCdmaEcio = s.mCdmaEcio;
+ mEvdoDbm = s.mEvdoDbm;
+ mEvdoEcio = s.mEvdoEcio;
+ mEvdoSnr = s.mEvdoSnr;
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ public CellSignalStrengthCdma copy() {
+ return new CellSignalStrengthCdma(this);
+ }
+
+ /** @hide */
+ @Override
+ public void setDefaultValues() {
+ mCdmaDbm = Integer.MAX_VALUE;
+ mCdmaEcio = Integer.MAX_VALUE;
+ mEvdoDbm = Integer.MAX_VALUE;
+ mEvdoEcio = Integer.MAX_VALUE;
+ mEvdoSnr = Integer.MAX_VALUE;
+ }
+
+ /**
+ * Get LTE as level 0..4
+ *
+ * @hide
+ */
+ @Override
+ public int getLevel() {
+ int level;
+
+ int cdmaLevel = getCdmaLevel();
+ int evdoLevel = getEvdoLevel();
+ if (evdoLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
+ /* We don't know evdo, use cdma */
+ level = getCdmaLevel();
+ } else if (cdmaLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
+ /* We don't know cdma, use evdo */
+ level = getEvdoLevel();
+ } else {
+ /* We know both, use the lowest level */
+ level = cdmaLevel < evdoLevel ? cdmaLevel : evdoLevel;
+ }
+ if (DBG) log("getLevel=" + level);
+ return level;
+ }
+
+ /**
+ * Get the LTE signal level as an asu value between 0..97, 99 is unknown
+ * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
+ *
+ * @hide
+ */
+ @Override
+ public int getAsuLevel() {
+ final int cdmaDbm = getCdmaDbm();
+ final int cdmaEcio = getCdmaEcio();
+ int cdmaAsuLevel;
+ int ecioAsuLevel;
+
+ if (cdmaDbm >= -75) cdmaAsuLevel = 16;
+ else if (cdmaDbm >= -82) cdmaAsuLevel = 8;
+ else if (cdmaDbm >= -90) cdmaAsuLevel = 4;
+ else if (cdmaDbm >= -95) cdmaAsuLevel = 2;
+ else if (cdmaDbm >= -100) cdmaAsuLevel = 1;
+ else cdmaAsuLevel = 99;
+
+ // Ec/Io are in dB*10
+ if (cdmaEcio >= -90) ecioAsuLevel = 16;
+ else if (cdmaEcio >= -100) ecioAsuLevel = 8;
+ else if (cdmaEcio >= -115) ecioAsuLevel = 4;
+ else if (cdmaEcio >= -130) ecioAsuLevel = 2;
+ else if (cdmaEcio >= -150) ecioAsuLevel = 1;
+ else ecioAsuLevel = 99;
+
+ int level = (cdmaAsuLevel < ecioAsuLevel) ? cdmaAsuLevel : ecioAsuLevel;
+ if (DBG) log("getAsuLevel=" + level);
+ return level;
+ }
+
+ /**
+ * Get cdma as level 0..4
+ *
+ * @hide
+ */
+ public int getCdmaLevel() {
+ final int cdmaDbm = getCdmaDbm();
+ final int cdmaEcio = getCdmaEcio();
+ int levelDbm;
+ int levelEcio;
+
+ if (cdmaDbm >= -75) levelDbm = SIGNAL_STRENGTH_GREAT;
+ else if (cdmaDbm >= -85) levelDbm = SIGNAL_STRENGTH_GOOD;
+ else if (cdmaDbm >= -95) levelDbm = SIGNAL_STRENGTH_MODERATE;
+ else if (cdmaDbm >= -100) levelDbm = SIGNAL_STRENGTH_POOR;
+ else levelDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+
+ // Ec/Io are in dB*10
+ if (cdmaEcio >= -90) levelEcio = SIGNAL_STRENGTH_GREAT;
+ else if (cdmaEcio >= -110) levelEcio = SIGNAL_STRENGTH_GOOD;
+ else if (cdmaEcio >= -130) levelEcio = SIGNAL_STRENGTH_MODERATE;
+ else if (cdmaEcio >= -150) levelEcio = SIGNAL_STRENGTH_POOR;
+ else levelEcio = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+
+ int level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
+ if (DBG) log("getCdmaLevel=" + level);
+ return level;
+ }
+
+ /**
+ * Get Evdo as level 0..4
+ *
+ * @hide
+ */
+ public int getEvdoLevel() {
+ int evdoDbm = getEvdoDbm();
+ int evdoSnr = getEvdoSnr();
+ int levelEvdoDbm;
+ int levelEvdoSnr;
+
+ if (evdoDbm >= -65) levelEvdoDbm = SIGNAL_STRENGTH_GREAT;
+ else if (evdoDbm >= -75) levelEvdoDbm = SIGNAL_STRENGTH_GOOD;
+ else if (evdoDbm >= -90) levelEvdoDbm = SIGNAL_STRENGTH_MODERATE;
+ else if (evdoDbm >= -105) levelEvdoDbm = SIGNAL_STRENGTH_POOR;
+ else levelEvdoDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+
+ if (evdoSnr >= 7) levelEvdoSnr = SIGNAL_STRENGTH_GREAT;
+ else if (evdoSnr >= 5) levelEvdoSnr = SIGNAL_STRENGTH_GOOD;
+ else if (evdoSnr >= 3) levelEvdoSnr = SIGNAL_STRENGTH_MODERATE;
+ else if (evdoSnr >= 1) levelEvdoSnr = SIGNAL_STRENGTH_POOR;
+ else levelEvdoSnr = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+
+ int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
+ if (DBG) log("getEvdoLevel=" + level);
+ return level;
+ }
+
+ /**
+ * Get as dBm
+ *
+ * @hide
+ */
+ @Override
+ public int getDbm() {
+ int cdmaDbm = getCdmaDbm();
+ int evdoDbm = getEvdoDbm();
+
+ // Use the lower value to be conservative
+ return (cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm;
+ }
+
+ /**
+ * Get the CDMA RSSI value in dBm
+ */
+ public int getCdmaDbm() {
+ return mCdmaDbm;
+ }
+ /** @hide */
+ public void setCdmaDbm(int cdmaDbm) {
+ mCdmaDbm = cdmaDbm;
+ }
+
+ /**
+ * Get the CDMA Ec/Io value in dB*10
+ */
+ public int getCdmaEcio() {
+ return mCdmaEcio;
+ }
+ /** @hide */
+ public void setCdmaEcio(int cdmaEcio) {
+ mCdmaEcio = cdmaEcio;
+ }
+
+ /**
+ * Get the EVDO RSSI value in dBm
+ */
+ public int getEvdoDbm() {
+ return mEvdoDbm;
+ }
+ /** @hide */
+ public void setEvdoDbm(int evdoDbm) {
+ mEvdoDbm = evdoDbm;
+ }
+
+ /**
+ * Get the EVDO Ec/Io value in dB*10
+ */
+ public int getEvdoEcio() {
+ return mEvdoEcio;
+ }
+ /** @hide */
+ public void setEvdoEcio(int evdoEcio) {
+ mEvdoEcio = evdoEcio;
+ }
+
+ /**
+ * Get the signal to noise ratio. Valid values are 0-8. 8 is the highest.
+ */
+ public int getEvdoSnr() {
+ return mEvdoSnr;
+ }
+ /** @hide */
+ public void setEvdoSnr(int evdoSnr) {
+ mEvdoSnr = evdoSnr;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return ((mCdmaDbm * primeNum) + (mCdmaEcio * primeNum)
+ + (mEvdoDbm * primeNum) + (mEvdoEcio * primeNum) + (mEvdoSnr * primeNum));
+ }
+
+ @Override
+ public boolean equals (Object o) {
+ CellSignalStrengthCdma s;
+
+ try {
+ s = (CellSignalStrengthCdma) o;
+ } catch (ClassCastException ex) {
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ }
+
+ return mCdmaDbm == s.mCdmaDbm
+ && mCdmaEcio == s.mCdmaEcio
+ && mEvdoDbm == s.mEvdoDbm
+ && mEvdoEcio == s.mEvdoEcio
+ && mEvdoSnr == s.mEvdoSnr;
+ }
+
+ /**
+ * @return string representation.
+ */
+ @Override
+ public String toString() {
+ return "CellSignalStrengthCdma:"
+ + " cdmaDbm=" + mCdmaDbm
+ + " cdmaEcio=" + mCdmaEcio
+ + " evdoDbm=" + mEvdoDbm
+ + " evdoEcio=" + mEvdoEcio
+ + " evdoSnr=" + mEvdoSnr;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(CellSignalStrength.TYPE_CDMA);
+ dest.writeInt(mCdmaDbm);
+ dest.writeInt(mCdmaEcio);
+ dest.writeInt(mEvdoDbm);
+ dest.writeInt(mEvdoEcio);
+ dest.writeInt(mEvdoSnr);
+ }
+
+ /**
+ * Construct a SignalStrength object from the given parcel
+ * where the TYPE_LTE token is already been processed.
+ */
+ private CellSignalStrengthCdma(Parcel in) {
+ mCdmaDbm = in.readInt();
+ mCdmaEcio = in.readInt();
+ mEvdoDbm = in.readInt();
+ mEvdoEcio = in.readInt();
+ mEvdoSnr = in.readInt();
+ if (DBG) log("CellSignalStrengthCdma(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Parcelable.Creator<CellSignalStrengthCdma> CREATOR =
+ new Parcelable.Creator<CellSignalStrengthCdma>() {
+ @Override
+ public CellSignalStrengthCdma createFromParcel(Parcel in) {
+ if (in.readInt() != CellSignalStrength.TYPE_CDMA) {
+ throw new RuntimeException("Expecting TYPE_CDMA");
+ }
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellSignalStrengthCdma[] newArray(int size) {
+ return new CellSignalStrengthCdma[size];
+ }
+ };
+
+ /** @hide */
+ public static CellSignalStrengthCdma createFromParcelBody(Parcel in) {
+ return new CellSignalStrengthCdma(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellSignalStrengthGsm.java b/telephony/java/android/telephony/CellSignalStrengthGsm.java
new file mode 100644
index 0000000..70876fb
--- /dev/null
+++ b/telephony/java/android/telephony/CellSignalStrengthGsm.java
@@ -0,0 +1,251 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * LTE signal strength related information.
+ *
+ * @hide
+ */
+public class CellSignalStrengthGsm extends CellSignalStrength implements Parcelable {
+
+ private static final String LOG_TAG = "CellSignalStrengthGsm";
+ private static final boolean DBG = false;
+
+ private static final int GSM_SIGNAL_STRENGTH_GREAT = 12;
+ private static final int GSM_SIGNAL_STRENGTH_GOOD = 8;
+ private static final int GSM_SIGNAL_STRENGTH_MODERATE = 8;
+
+ private int mSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5
+ private int mBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5
+
+ /**
+ * Empty constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthGsm() {
+ setDefaultValues();
+ }
+
+ /**
+ * Constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthGsm(int ss, int ber) {
+ initialize(ss, ber);
+ }
+
+ /**
+ * Copy constructors
+ *
+ * @param s Source SignalStrength
+ *
+ * @hide
+ */
+ public CellSignalStrengthGsm(CellSignalStrengthGsm s) {
+ copyFrom(s);
+ }
+
+ /**
+ * Initialize all the values
+ *
+ * @param SignalStrength
+ *
+ * @hide
+ */
+ public void initialize(int ss, int ber) {
+ mSignalStrength = ss;
+ mBitErrorRate = ber;
+ }
+
+ /**
+ * @hide
+ */
+ protected void copyFrom(CellSignalStrengthGsm s) {
+ mSignalStrength = s.mSignalStrength;
+ mBitErrorRate = s.mBitErrorRate;
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ public CellSignalStrengthGsm copy() {
+ return new CellSignalStrengthGsm(this);
+ }
+
+ /** @hide */
+ @Override
+ public void setDefaultValues() {
+ mSignalStrength = Integer.MAX_VALUE;
+ mBitErrorRate = Integer.MAX_VALUE;
+ }
+
+ /**
+ * Get LTE as level 0..4
+ *
+ * @hide
+ */
+ @Override
+ public int getLevel() {
+ int level;
+
+ // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
+ // asu = 0 (-113dB or less) is very weak
+ // signal, its better to show 0 bars to the user in such cases.
+ // asu = 99 is a special case, where the signal strength is unknown.
+ int asu = mSignalStrength;
+ if (asu <= 2 || asu == 99) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ else if (asu >= GSM_SIGNAL_STRENGTH_GREAT) level = SIGNAL_STRENGTH_GREAT;
+ else if (asu >= GSM_SIGNAL_STRENGTH_GOOD) level = SIGNAL_STRENGTH_GOOD;
+ else if (asu >= GSM_SIGNAL_STRENGTH_MODERATE) level = SIGNAL_STRENGTH_MODERATE;
+ else level = SIGNAL_STRENGTH_POOR;
+ if (DBG) log("getLevel=" + level);
+ return level;
+ }
+
+ /**
+ * Get LTE as dBm
+ *
+ * @hide
+ */
+ @Override
+ public int getDbm() {
+ int dBm;
+
+ int level = mSignalStrength;
+ int asu = (level == 99 ? Integer.MAX_VALUE : level);
+ if (asu != Integer.MAX_VALUE) {
+ dBm = -113 + (2 * asu);
+ } else {
+ dBm = Integer.MAX_VALUE;
+ }
+ if (DBG) log("getDbm=" + dBm);
+ return dBm;
+ }
+
+ /**
+ * Get the LTE signal level as an asu value between 0..97, 99 is unknown
+ * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
+ *
+ * @hide
+ */
+ @Override
+ public int getAsuLevel() {
+ // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
+ // asu = 0 (-113dB or less) is very weak
+ // signal, its better to show 0 bars to the user in such cases.
+ // asu = 99 is a special case, where the signal strength is unknown.
+ int level = mSignalStrength;
+ if (DBG) log("getAsuLevel=" + level);
+ return level;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return (mSignalStrength * primeNum) + (mBitErrorRate * primeNum);
+ }
+
+ @Override
+ public boolean equals (Object o) {
+ CellSignalStrengthGsm s;
+
+ try {
+ s = (CellSignalStrengthGsm) o;
+ } catch (ClassCastException ex) {
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ }
+
+ return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate;
+ }
+
+ /**
+ * @return string representation.
+ */
+ @Override
+ public String toString() {
+ return "CellSignalStrengthGsm:"
+ + " ss=" + mSignalStrength
+ + " ber=" + mBitErrorRate;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(CellSignalStrength.TYPE_GSM);
+ dest.writeInt(mSignalStrength);
+ dest.writeInt(mBitErrorRate);
+ }
+
+ /**
+ * Construct a SignalStrength object from the given parcel
+ * where the token is already been processed.
+ */
+ private CellSignalStrengthGsm(Parcel in) {
+ mSignalStrength = in.readInt();
+ mBitErrorRate = in.readInt();
+ if (DBG) log("CellSignalStrengthGsm(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Parcelable.Creator<CellSignalStrengthGsm> CREATOR =
+ new Parcelable.Creator<CellSignalStrengthGsm>() {
+ @Override
+ public CellSignalStrengthGsm createFromParcel(Parcel in) {
+ if (in.readInt() != CellSignalStrength.TYPE_GSM) {
+ throw new RuntimeException("Expecting TYPE_GSM");
+ }
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellSignalStrengthGsm[] newArray(int size) {
+ return new CellSignalStrengthGsm[size];
+ }
+ };
+
+ /** @hide */
+ public static CellSignalStrengthGsm createFromParcelBody(Parcel in) {
+ return new CellSignalStrengthGsm(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/CellSignalStrengthLte.java b/telephony/java/android/telephony/CellSignalStrengthLte.java
new file mode 100644
index 0000000..3caea3d
--- /dev/null
+++ b/telephony/java/android/telephony/CellSignalStrengthLte.java
@@ -0,0 +1,299 @@
+/*
+ * 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.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * LTE signal strength related information.
+ *
+ * @hide
+ */
+public class CellSignalStrengthLte extends CellSignalStrength implements Parcelable {
+
+ private static final String LOG_TAG = "CellSignalStrengthLte";
+ private static final boolean DBG = false;
+
+ private int mSignalStrength;
+ private int mRsrp;
+ private int mRsrq;
+ private int mRssnr;
+ private int mCqi;
+ private int mTimingAdvance;
+
+ /**
+ * Empty constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthLte() {
+ setDefaultValues();
+ }
+
+ /**
+ * Constructor
+ *
+ * @hide
+ */
+ public CellSignalStrengthLte(int signalStrength, int rsrp, int rsrq, int rssnr, int cqi,
+ int timingAdvance) {
+ initialize(signalStrength, rsrp, rsrq, rssnr, cqi, timingAdvance);
+ }
+
+ /**
+ * Copy constructors
+ *
+ * @param s Source SignalStrength
+ *
+ * @hide
+ */
+ public CellSignalStrengthLte(CellSignalStrengthLte s) {
+ copyFrom(s);
+ }
+
+ /**
+ * Initialize all the values
+ *
+ * @param lteSignalStrength
+ * @param rsrp
+ * @param rsrq
+ * @param rssnr
+ * @param cqi
+ *
+ * @hide
+ */
+ public void initialize(int lteSignalStrength, int rsrp, int rsrq, int rssnr, int cqi,
+ int timingAdvance) {
+ mSignalStrength = lteSignalStrength;
+ mRsrp = rsrp;
+ mRsrq = rsrq;
+ mRssnr = rssnr;
+ mCqi = cqi;
+ mTimingAdvance = timingAdvance;
+ }
+
+ /**
+ * @hide
+ */
+ protected void copyFrom(CellSignalStrengthLte s) {
+ mSignalStrength = s.mSignalStrength;
+ mRsrp = s.mRsrp;
+ mRsrq = s.mRsrq;
+ mRssnr = s.mRssnr;
+ mCqi = s.mCqi;
+ mTimingAdvance = s.mTimingAdvance;
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ public CellSignalStrengthLte copy() {
+ return new CellSignalStrengthLte(this);
+ }
+
+ /** @hide */
+ @Override
+ public void setDefaultValues() {
+ mSignalStrength = Integer.MAX_VALUE;
+ mRsrp = Integer.MAX_VALUE;
+ mRsrq = Integer.MAX_VALUE;
+ mRssnr = Integer.MAX_VALUE;
+ mCqi = Integer.MAX_VALUE;
+ mTimingAdvance = Integer.MAX_VALUE;
+ }
+
+ /**
+ * Get LTE as level 0..4
+ *
+ * @hide
+ */
+ @Override
+ public int getLevel() {
+ int levelRsrp = 0;
+ int levelRssnr = 0;
+
+ if (mRsrp == Integer.MAX_VALUE) levelRsrp = 0;
+ else if (mRsrp >= -95) levelRsrp = SIGNAL_STRENGTH_GREAT;
+ else if (mRsrp >= -105) levelRsrp = SIGNAL_STRENGTH_GOOD;
+ else if (mRsrp >= -115) levelRsrp = SIGNAL_STRENGTH_MODERATE;
+ else levelRsrp = SIGNAL_STRENGTH_POOR;
+
+ // See RIL_LTE_SignalStrength in ril.h
+ if (mRssnr == Integer.MAX_VALUE) levelRssnr = 0;
+ else if (mRssnr >= 45) levelRssnr = SIGNAL_STRENGTH_GREAT;
+ else if (mRssnr >= 10) levelRssnr = SIGNAL_STRENGTH_GOOD;
+ else if (mRssnr >= -30) levelRssnr = SIGNAL_STRENGTH_MODERATE;
+ else levelRssnr = SIGNAL_STRENGTH_POOR;
+
+ int level;
+ if (mRsrp == Integer.MAX_VALUE)
+ level = levelRssnr;
+ else if (mRssnr == Integer.MAX_VALUE)
+ level = levelRsrp;
+ else
+ level = (levelRssnr < levelRsrp) ? levelRssnr : levelRsrp;
+
+ if (DBG) log("Lte rsrp level: " + levelRsrp
+ + " snr level: " + levelRssnr + " level: " + level);
+ return level;
+ }
+
+ /**
+ * Get LTE as dBm
+ *
+ * @hide
+ */
+ @Override
+ public int getDbm() {
+ return mRsrp;
+ }
+
+ /**
+ * Get the LTE signal level as an asu value between 0..97, 99 is unknown
+ * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
+ *
+ * @hide
+ */
+ @Override
+ public int getAsuLevel() {
+ int lteAsuLevel = 99;
+ int lteDbm = getDbm();
+ if (lteDbm <= -140) lteAsuLevel = 0;
+ else if (lteDbm >= -43) lteAsuLevel = 97;
+ else lteAsuLevel = lteDbm + 140;
+ if (DBG) log("Lte Asu level: "+lteAsuLevel);
+ return lteAsuLevel;
+ }
+
+ /**
+ * Get the timing advance value for LTE.
+ * See 3GPP xxxx
+ */
+ public int getTimingAdvance() {
+ return mTimingAdvance;
+ }
+
+ @Override
+ public int hashCode() {
+ int primeNum = 31;
+ return (mSignalStrength * primeNum) + (mRsrp * primeNum)
+ + (mRsrq * primeNum) + (mRssnr * primeNum) + (mCqi * primeNum)
+ + (mTimingAdvance * primeNum);
+ }
+
+ @Override
+ public boolean equals (Object o) {
+ CellSignalStrengthLte s;
+
+ try {
+ s = (CellSignalStrengthLte) o;
+ } catch (ClassCastException ex) {
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ }
+
+ return mSignalStrength == s.mSignalStrength
+ && mRsrp == s.mRsrp
+ && mRsrq == s.mRsrq
+ && mRssnr == s.mRssnr
+ && mCqi == s.mCqi
+ && mTimingAdvance == s.mTimingAdvance;
+ }
+
+ /**
+ * @return string representation.
+ */
+ @Override
+ public String toString() {
+ return "CellSignalStrengthLte:"
+ + " ss=" + mSignalStrength
+ + " rsrp=" + mRsrp
+ + " rsrq=" + mRsrq
+ + " rssnr=" + mRssnr
+ + " cqi=" + mCqi
+ + " ta=" + mTimingAdvance;
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (DBG) log("writeToParcel(Parcel, int): " + toString());
+ dest.writeInt(CellSignalStrength.TYPE_LTE);
+ dest.writeInt(mSignalStrength);
+ dest.writeInt(mRsrp);
+ dest.writeInt(mRsrq);
+ dest.writeInt(mRssnr);
+ dest.writeInt(mCqi);
+ dest.writeInt(mTimingAdvance);
+ }
+
+ /**
+ * Construct a SignalStrength object from the given parcel
+ * where the token is already been processed.
+ */
+ private CellSignalStrengthLte(Parcel in) {
+ mSignalStrength = in.readInt();
+ mRsrp = in.readInt();
+ mRsrq = in.readInt();
+ mRssnr = in.readInt();
+ mCqi = in.readInt();
+ mTimingAdvance = in.readInt();
+ if (DBG) log("CellSignalStrengthLte(Parcel): " + toString());
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface */
+ @SuppressWarnings("hiding")
+ public static final Parcelable.Creator<CellSignalStrengthLte> CREATOR =
+ new Parcelable.Creator<CellSignalStrengthLte>() {
+ @Override
+ public CellSignalStrengthLte createFromParcel(Parcel in) {
+ if (in.readInt() != CellSignalStrength.TYPE_LTE) {
+ throw new RuntimeException("Expecting TYPE_LTE");
+ }
+ return createFromParcelBody(in);
+ }
+
+ @Override
+ public CellSignalStrengthLte[] newArray(int size) {
+ return new CellSignalStrengthLte[size];
+ }
+ };
+
+ /** @hide */
+ public static CellSignalStrengthLte createFromParcelBody(Parcel in) {
+ return new CellSignalStrengthLte(in);
+ }
+
+ /**
+ * log
+ */
+ private static void log(String s) {
+ Log.w(LOG_TAG, s);
+ }
+}
diff --git a/telephony/java/android/telephony/GsmCellIdentity.java b/telephony/java/android/telephony/GsmCellIdentity.java
deleted file mode 100644
index 159cb52..0000000
--- a/telephony/java/android/telephony/GsmCellIdentity.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2008 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.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * CellIdentity to represent a unique GSM or UMTS cell
- *
- * @hide pending API review
- */
-public final class GsmCellIdentity extends CellIdentity implements Parcelable {
-
- // 3-digit Mobile Country Code, 0..999
- private final int mMcc;
- // 2 or 3-digit Mobile Network Code, 0..999
- private final int mMnc;
- // 16-bit Location Area Code, 0..65535
- private final int mLac;
- // 16-bit GSM Cell Identity described in TS 27.007, 0..65535
- // 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455
- private final int mCid;
- // 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
- private final int mPsc;
-
- /**
- * public constructor
- * @param mcc 3-digit Mobile Country Code, 0..999
- * @param mnc 2 or 3-digit Mobile Network Code, 0..999
- * @param lac 16-bit Location Area Code, 0..65535
- * @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
- * @param psc 9-bit UMTS Primary Scrambling Code
- * @param attr is comma separated “key=value” attribute pairs.
- */
- public GsmCellIdentity (int mcc, int mnc,
- int lac, int cid, int psc, String attr) {
- super(CELLID_TYPE_GSM, attr);
- mMcc = mcc;
- mMnc = mnc;
- mLac = lac;
- mCid = cid;
- mPsc = psc;
- }
-
- private GsmCellIdentity(Parcel in) {
- super(in);
- mMcc = in.readInt();
- mMnc = in.readInt();
- mLac = in.readInt();
- mCid = in.readInt();
- mPsc = in.readInt();
- }
-
- GsmCellIdentity(GsmCellIdentity cid) {
- super(cid);
- mMcc = cid.mMcc;
- mMnc = cid.mMnc;
- mLac = cid.mLac;
- mCid = cid.mCid;
- mPsc = cid.mPsc;
- }
-
- /**
- * @return 3-digit Mobile Country Code, 0..999
- */
- public int getMcc() {
- return mMcc;
- }
-
- /**
- * @return 2 or 3-digit Mobile Network Code, 0..999
- */
- public int getMnc() {
- return mMnc;
- }
-
- /**
- * @return 16-bit Location Area Code, 0..65535
- */
- public int getLac() {
- return mLac;
- }
-
- /**
- * @return CID
- * Either 16-bit GSM Cell Identity described
- * in TS 27.007, 0..65535
- * or 28-bit UMTS Cell Identity described
- * in TS 25.331, 0..268435455
- */
- public int getCid() {
- return mCid;
- }
-
- /**
- * @return 9-bit UMTS Primary Scrambling Code described in
- * TS 25.331, 0..511
- */
- public int getPsc() {
- return mPsc;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mMcc);
- dest.writeInt(mMnc);
- dest.writeInt(mLac);
- dest.writeInt(mCid);
- dest.writeInt(mPsc);
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<GsmCellIdentity> CREATOR =
- new Creator<GsmCellIdentity>() {
- @Override
- public GsmCellIdentity createFromParcel(Parcel in) {
- return new GsmCellIdentity(in);
- }
-
- @Override
- public GsmCellIdentity[] newArray(int size) {
- return new GsmCellIdentity[size];
- }
- };
-}
diff --git a/telephony/java/android/telephony/LteCellIdentity.java b/telephony/java/android/telephony/LteCellIdentity.java
deleted file mode 100644
index 396922e..0000000
--- a/telephony/java/android/telephony/LteCellIdentity.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2008 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.telephony;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * CellIdentity is to represent a unique LTE cell
- *
- * @hide pending API review
- */
-public final class LteCellIdentity extends CellIdentity implements Parcelable {
-
- // 3-digit Mobile Country Code, 0..999
- private final int mMcc;
- // 2 or 3-digit Mobile Network Code, 0..999
- private final int mMnc;
- // 28-bit cell identity
- private final int mCi;
- // physical cell id 0..503
- private final int mPci;
- // 16-bit tracking area code
- private final int mTac;
-
- /**
- *
- * @param mcc 3-digit Mobile Country Code, 0..999
- * @param mnc 2 or 3-digit Mobile Network Code, 0..999
- * @param ci 28-bit Cell Identity
- * @param pci Physical Cell Id 0..503
- * @param tac 16-bit Tracking Area Code
- * @param attr is comma separated “key=value” attribute pairs.
- */
- public LteCellIdentity (int mcc, int mnc,
- int ci, int pci, int tac, String attr) {
- super(CELLID_TYPE_CDMA, attr);
- mMcc = mcc;
- mMnc = mnc;
- mCi = ci;
- mPci = pci;
- mTac = tac;
- }
-
- private LteCellIdentity(Parcel in) {
- super(in);
- mMcc = in.readInt();
- mMnc = in.readInt();
- mCi = in.readInt();
- mPci = in.readInt();
- mTac = in.readInt();
- }
-
- LteCellIdentity(LteCellIdentity cid) {
- super(cid);
- mMcc = cid.mMcc;
- mMnc = cid.mMnc;
- mCi = cid.mCi;
- mPci = cid.mPci;
- mTac = cid.mTac;
- }
-
- /**
- * @return 3-digit Mobile Country Code, 0..999
- */
- public int getMcc() {
- return mMcc;
- }
-
- /**
- * @return 2 or 3-digit Mobile Network Code, 0..999
- */
- public int getMnc() {
- return mMnc;
- }
-
- /**
- * @return 28-bit Cell Identity
- */
- public int getCi() {
- return mCi;
- }
-
- /**
- * @return Physical Cell Id 0..503
- */
- public int getPci() {
- return mPci;
- }
-
- /**
- * @return 16-bit Tracking Area Code
- */
- public int getTac() {
- return mTac;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mMcc);
- dest.writeInt(mMnc);
- dest.writeInt(mCi);
- dest.writeInt(mPci);
- dest.writeInt(mTac);
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<LteCellIdentity> CREATOR =
- new Creator<LteCellIdentity>() {
- @Override
- public LteCellIdentity createFromParcel(Parcel in) {
- return new LteCellIdentity(in);
- }
-
- @Override
- public LteCellIdentity[] newArray(int size) {
- return new LteCellIdentity[size];
- }
- };
-}
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index def6939..63d81e9 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -27,6 +27,8 @@
import com.android.internal.telephony.IPhoneStateListener;
+import java.util.List;
+
/**
* A listener class for monitoring changes in specific telephony states
* on the device, including service state, signal strength, message
@@ -160,7 +162,8 @@
* Listen for changes to observed cell info.
*
* @see #onCellInfoChanged
- * @hide pending API review
+ *
+ * @hide
*/
public static final int LISTEN_CELL_INFO = 0x00000400;
@@ -284,17 +287,13 @@
}
/**
- * Callback invoked when a observed cell info gets changed.
+ * Callback invoked when a observed cell info has changed,
+ * or new cells have been added or removed.
+ * @param cellInfo is the list of currently visible cells.
*
- * A notification should be sent when:
- * 1. a cell is newly-observed.
- * 2. a observed cell is not visible.
- * 3. any of the cell info of a observed cell has changed.
- *
- * @hide pending API review
+ * @hide
*/
- public void onCellInfoChanged(CellInfo cellInfo) {
- // default implementation empty
+ public void onCellInfoChanged(List<CellInfo> cellInfo) {
}
/**
@@ -346,8 +345,8 @@
Message.obtain(mHandler, LISTEN_OTASP_CHANGED, otaspMode, 0).sendToTarget();
}
- public void onCellInfoChanged(CellInfo cellInfo) {
- Message.obtain(mHandler, LISTEN_CELL_INFO, 0, 0).sendToTarget();
+ public void onCellInfoChanged(List<CellInfo> cellInfo) {
+ Message.obtain(mHandler, LISTEN_CELL_INFO, 0, 0, cellInfo).sendToTarget();
}
};
@@ -387,7 +386,7 @@
PhoneStateListener.this.onOtaspChanged(msg.arg1);
break;
case LISTEN_CELL_INFO:
- PhoneStateListener.this.onCellInfoChanged((CellInfo)msg.obj);
+ PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
}
}
};
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index 1049669..d80425c 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved.
- * Copyright (C) 2009 The Android Open Source Project
+ * 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.
@@ -28,7 +27,7 @@
public class SignalStrength implements Parcelable {
private static final String LOG_TAG = "SignalStrength";
- private static final boolean DBG = false;
+ private static final boolean DBG = true;
/** @hide */
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
@@ -114,19 +113,9 @@
int evdoDbm, int evdoEcio, int evdoSnr,
int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi,
boolean gsm) {
- mGsmSignalStrength = gsmSignalStrength;
- mGsmBitErrorRate = gsmBitErrorRate;
- mCdmaDbm = cdmaDbm;
- mCdmaEcio = cdmaEcio;
- mEvdoDbm = evdoDbm;
- mEvdoEcio = evdoEcio;
- mEvdoSnr = evdoSnr;
- mLteSignalStrength = lteSignalStrength;
- mLteRsrp = lteRsrp;
- mLteRsrq = lteRsrq;
- mLteRssnr = lteRssnr;
- mLteCqi = lteCqi;
- isGsm = gsm;
+ initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
+ evdoDbm, evdoEcio, evdoSnr, lteSignalStrength, lteRsrp,
+ lteRsrq, lteRssnr, lteCqi, gsm);
}
/**
@@ -138,7 +127,7 @@
int cdmaDbm, int cdmaEcio,
int evdoDbm, int evdoEcio, int evdoSnr,
boolean gsm) {
- this(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
+ initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
evdoDbm, evdoEcio, evdoSnr, -1, -1,
-1, INVALID_SNR, -1, gsm);
}
@@ -155,6 +144,69 @@
}
/**
+ * Initialize gsm/cdma values, sets lte values to defaults.
+ *
+ * @param gsmSignalStrength
+ * @param gsmBitErrorRate
+ * @param cdmaDbm
+ * @param cdmaEcio
+ * @param evdoDbm
+ * @param evdoEcio
+ * @param evdoSnr
+ * @param gsm
+ *
+ * @hide
+ */
+ public void initialize(int gsmSignalStrength, int gsmBitErrorRate,
+ int cdmaDbm, int cdmaEcio,
+ int evdoDbm, int evdoEcio, int evdoSnr,
+ boolean gsm) {
+ initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
+ evdoDbm, evdoEcio, evdoSnr, -1, -1,
+ -1, INVALID_SNR, -1, gsm);
+ }
+
+ /**
+ * Initialize all the values
+ *
+ * @param gsmSignalStrength
+ * @param gsmBitErrorRate
+ * @param cdmaDbm
+ * @param cdmaEcio
+ * @param evdoDbm
+ * @param evdoEcio
+ * @param evdoSnr
+ * @param lteSignalStrength
+ * @param lteRsrp
+ * @param lteRsrq
+ * @param lteRssnr
+ * @param lteCqi
+ * @param gsm
+ *
+ * @hide
+ */
+ public void initialize(int gsmSignalStrength, int gsmBitErrorRate,
+ int cdmaDbm, int cdmaEcio,
+ int evdoDbm, int evdoEcio, int evdoSnr,
+ int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi,
+ boolean gsm) {
+ mGsmSignalStrength = gsmSignalStrength;
+ mGsmBitErrorRate = gsmBitErrorRate;
+ mCdmaDbm = cdmaDbm;
+ mCdmaEcio = cdmaEcio;
+ mEvdoDbm = evdoDbm;
+ mEvdoEcio = evdoEcio;
+ mEvdoSnr = evdoSnr;
+ mLteSignalStrength = lteSignalStrength;
+ mLteRsrp = lteRsrp;
+ mLteRsrq = lteRsrq;
+ mLteRssnr = lteRssnr;
+ mLteCqi = lteCqi;
+ isGsm = gsm;
+ if (DBG) log("initialize: " + toString());
+ }
+
+ /**
* @hide
*/
protected void copyFrom(SignalStrength s) {
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index fa4b7cd..2b0fcd8 100755
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -1272,7 +1272,7 @@
* <p>Requires Permission:
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
*
- * @hide pending API review
+ * @hide
*/
public List<CellInfo> getAllCellInfo() {
try {
diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
index d6a1edd..3a04ceb 100644
--- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -34,6 +34,6 @@
void onDataActivity(int direction);
void onSignalStrengthsChanged(in SignalStrength signalStrength);
void onOtaspChanged(in int otaspMode);
- void onCellInfoChanged(in CellInfo cellInfo);
+ void onCellInfoChanged(in List<CellInfo> cellInfo);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 3c9a99b..59c8472 100644
--- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -40,5 +40,5 @@
void notifyDataConnectionFailed(String reason, String apnType);
void notifyCellLocation(in Bundle cellLocation);
void notifyOtaspChanged(in int otaspMode);
- void notifyCellInfo(in CellInfo cellInfo);
+ void notifyCellInfo(in List<CellInfo> cellInfo);
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 0e75b80..733e44f 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -22,7 +22,6 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.opengl.GLUtils;
import android.os.Bundle;
@@ -278,7 +277,7 @@
return texture;
}
- private int buildProgram(String vertex, String fragment) {
+ private static int buildProgram(String vertex, String fragment) {
int vertexShader = buildShader(vertex, GL_VERTEX_SHADER);
if (vertexShader == 0) return 0;
@@ -309,7 +308,7 @@
return program;
}
- private int buildShader(String source, int type) {
+ private static int buildShader(String source, int type) {
int shader = glCreateShader(type);
glShaderSource(shader, source);
@@ -337,7 +336,7 @@
}
}
- private void checkGlError() {
+ private static void checkGlError() {
int error = glGetError();
if (error != GL_NO_ERROR) {
Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error));
@@ -420,7 +419,7 @@
return null;
}
- private int[] getConfig() {
+ private static int[] getConfig() {
return new int[] {
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_RED_SIZE, 8,
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
index 36f13b1..f0ce458 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
@@ -67,6 +67,7 @@
unitTests.add(new UT_primitives(this, mRes, mCtx));
unitTests.add(new UT_constant(this, mRes, mCtx));
unitTests.add(new UT_vector(this, mRes, mCtx));
+ unitTests.add(new UT_unsigned(this, mRes, mCtx));
unitTests.add(new UT_array_init(this, mRes, mCtx));
unitTests.add(new UT_array_alloc(this, mRes, mCtx));
unitTests.add(new UT_clamp(this, mRes, mCtx));
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
index 9d94ba5..ca49344 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
@@ -299,40 +299,6 @@
float[] rand_f2_1 = randvec_float(2);
float[] rand_f3_1 = randvec_float(3);
float[] rand_f4_1 = randvec_float(4);
- byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_0 = randvec_char(2);
- byte[] rand_sc3_0 = randvec_char(3);
- byte[] rand_sc4_0 = randvec_char(4);
- byte rand_sc1_1 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_1 = randvec_char(2);
- byte[] rand_sc3_1 = randvec_char(3);
- byte[] rand_sc4_1 = randvec_char(4);
- short rand_ss1_0 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_0 = randvec_short(2);
- short[] rand_ss3_0 = randvec_short(3);
- short[] rand_ss4_0 = randvec_short(4);
- short rand_ss1_1 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_1 = randvec_short(2);
- short[] rand_ss3_1 = randvec_short(3);
- short[] rand_ss4_1 = randvec_short(4);
- int rand_si1_0 = rand.nextInt();
- int[] rand_si2_0 = randvec_int(2);
- int[] rand_si3_0 = randvec_int(3);
- int[] rand_si4_0 = randvec_int(4);
- int rand_si1_1 = rand.nextInt();
- int[] rand_si2_1 = randvec_int(2);
- int[] rand_si3_1 = randvec_int(3);
- int[] rand_si4_1 = randvec_int(4);
- long rand_sl1_0 = rand.nextLong();
- long[] rand_sl2_0 = randvec_long(2);
- long[] rand_sl3_0 = randvec_long(3);
- long[] rand_sl4_0 = randvec_long(4);
- long rand_sl1_1 = rand.nextLong();
- long[] rand_sl2_1 = randvec_long(2);
- long[] rand_sl3_1 = randvec_long(3);
- long[] rand_sl4_1 = randvec_long(4);
- // FIXME: generate unsigned input vectors once bug 6764163 is fixed
- /*
short rand_uc1_0 = (short)rand.nextInt(0x1 << 8);
short[] rand_uc2_0 = randvec_uchar(2);
short[] rand_uc3_0 = randvec_uchar(3);
@@ -341,6 +307,14 @@
short[] rand_uc2_1 = randvec_uchar(2);
short[] rand_uc3_1 = randvec_uchar(3);
short[] rand_uc4_1 = randvec_uchar(4);
+ short rand_ss1_0 = (short)rand.nextInt(0x1 << 16);
+ short[] rand_ss2_0 = randvec_short(2);
+ short[] rand_ss3_0 = randvec_short(3);
+ short[] rand_ss4_0 = randvec_short(4);
+ short rand_ss1_1 = (short)rand.nextInt(0x1 << 16);
+ short[] rand_ss2_1 = randvec_short(2);
+ short[] rand_ss3_1 = randvec_short(3);
+ short[] rand_ss4_1 = randvec_short(4);
int rand_us1_0 = rand.nextInt(0x1 << 16);
int[] rand_us2_0 = randvec_ushort(2);
int[] rand_us3_0 = randvec_ushort(3);
@@ -349,6 +323,14 @@
int[] rand_us2_1 = randvec_ushort(2);
int[] rand_us3_1 = randvec_ushort(3);
int[] rand_us4_1 = randvec_ushort(4);
+ int rand_si1_0 = rand.nextInt();
+ int[] rand_si2_0 = randvec_int(2);
+ int[] rand_si3_0 = randvec_int(3);
+ int[] rand_si4_0 = randvec_int(4);
+ int rand_si1_1 = rand.nextInt();
+ int[] rand_si2_1 = randvec_int(2);
+ int[] rand_si3_1 = randvec_int(3);
+ int[] rand_si4_1 = randvec_int(4);
long rand_ui1_0 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
long[] rand_ui2_0 = randvec_uint(2);
long[] rand_ui3_0 = randvec_uint(3);
@@ -357,6 +339,24 @@
long[] rand_ui2_1 = randvec_uint(2);
long[] rand_ui3_1 = randvec_uint(3);
long[] rand_ui4_1 = randvec_uint(4);
+ long rand_sl1_0 = rand.nextLong();
+ long[] rand_sl2_0 = randvec_long(2);
+ long[] rand_sl3_0 = randvec_long(3);
+ long[] rand_sl4_0 = randvec_long(4);
+ long rand_sl1_1 = rand.nextLong();
+ long[] rand_sl2_1 = randvec_long(2);
+ long[] rand_sl3_1 = randvec_long(3);
+ long[] rand_sl4_1 = randvec_long(4);
+ // FIXME: generate signed char vectors once bug 6865598 is fixed
+ /*
+ byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8);
+ byte[] rand_sc2_0 = randvec_char(2);
+ byte[] rand_sc3_0 = randvec_char(3);
+ byte[] rand_sc4_0 = randvec_char(4);
+ byte rand_sc1_1 = (byte)rand.nextInt(0x1 << 8);
+ byte[] rand_sc2_1 = randvec_char(2);
+ byte[] rand_sc3_1 = randvec_char(3);
+ byte[] rand_sc4_1 = randvec_char(4);
*/
// TODO: generate unsigned long vectors
@@ -369,10 +369,10 @@
s.set_rand_f2_1(pack_f2(rand_f2_1));
s.set_rand_f3_1(pack_f3(rand_f3_1));
s.set_rand_f4_1(pack_f4(rand_f4_1));
- s.set_rand_sc1_1(rand_sc1_1);
- s.set_rand_sc2_1(pack_b2(rand_sc2_1));
- s.set_rand_sc3_1(pack_b3(rand_sc3_1));
- s.set_rand_sc4_1(pack_b4(rand_sc4_1));
+ s.set_rand_uc1_1(rand_uc1_1);
+ s.set_rand_uc2_1(pack_s2(rand_uc2_1));
+ s.set_rand_uc3_1(pack_s3(rand_uc3_1));
+ s.set_rand_uc4_1(pack_s4(rand_uc4_1));
s.set_rand_ss1_0(rand_ss1_0);
s.set_rand_ss2_0(pack_s2(rand_ss2_0));
s.set_rand_ss3_0(pack_s3(rand_ss3_0));
@@ -381,31 +381,6 @@
s.set_rand_ss2_1(pack_s2(rand_ss2_1));
s.set_rand_ss3_1(pack_s3(rand_ss3_1));
s.set_rand_ss4_1(pack_s4(rand_ss4_1));
- s.set_rand_si1_0(rand_si1_0);
- s.set_rand_si2_0(pack_i2(rand_si2_0));
- s.set_rand_si3_0(pack_i3(rand_si3_0));
- s.set_rand_si4_0(pack_i4(rand_si4_0));
- s.set_rand_si1_1(rand_si1_1);
- s.set_rand_si2_1(pack_i2(rand_si2_1));
- s.set_rand_si3_1(pack_i3(rand_si3_1));
- s.set_rand_si4_1(pack_i4(rand_si4_1));
- s.set_rand_sl1_0(rand_sl1_0);
- s.set_rand_sl2_0(pack_l2(rand_sl2_0));
- s.set_rand_sl3_0(pack_l3(rand_sl3_0));
- s.set_rand_sl4_0(pack_l4(rand_sl4_0));
- s.set_rand_sl1_1(rand_sl1_1);
- s.set_rand_sl2_1(pack_l2(rand_sl2_1));
- s.set_rand_sl3_1(pack_l3(rand_sl3_1));
- s.set_rand_sl4_1(pack_l4(rand_sl4_1));
- // FIXME: set signed char input vectors once bug is fixed
- /*
- s.set_rand_sc1_0(rand_sc1_0);
- s.set_rand_sc2_0(pack_b2(rand_sc2_0));
- s.set_rand_sc3_0(pack_b3(rand_sc3_0));
- s.set_rand_sc4_0(pack_b4(rand_sc4_0));
- */
- // FIXME: set unsigned input vectors once bug 6764163 is fixed
- /*
s.set_rand_us1_0(rand_us1_0);
s.set_rand_us2_0(pack_i2(rand_us2_0));
s.set_rand_us3_0(pack_i3(rand_us3_0));
@@ -414,14 +389,14 @@
s.set_rand_us2_1(pack_i2(rand_us2_1));
s.set_rand_us3_1(pack_i3(rand_us3_1));
s.set_rand_us4_1(pack_i4(rand_us4_1));
- s.set_rand_uc1_0(rand_uc1_0);
- s.set_rand_uc2_0(pack_s2(rand_uc2_0));
- s.set_rand_uc3_0(pack_s3(rand_uc3_0));
- s.set_rand_uc4_0(pack_s4(rand_uc4_0));
- s.set_rand_uc1_1(rand_uc1_1);
- s.set_rand_uc2_1(pack_s2(rand_uc2_1));
- s.set_rand_uc3_1(pack_s3(rand_uc3_1));
- s.set_rand_uc4_1(pack_s4(rand_uc4_1));
+ s.set_rand_si1_0(rand_si1_0);
+ s.set_rand_si2_0(pack_i2(rand_si2_0));
+ s.set_rand_si3_0(pack_i3(rand_si3_0));
+ s.set_rand_si4_0(pack_i4(rand_si4_0));
+ s.set_rand_si1_1(rand_si1_1);
+ s.set_rand_si2_1(pack_i2(rand_si2_1));
+ s.set_rand_si3_1(pack_i3(rand_si3_1));
+ s.set_rand_si4_1(pack_i4(rand_si4_1));
s.set_rand_ui1_0(rand_ui1_0);
s.set_rand_ui2_0(pack_l2(rand_ui2_0));
s.set_rand_ui3_0(pack_l3(rand_ui3_0));
@@ -430,6 +405,28 @@
s.set_rand_ui2_1(pack_l2(rand_ui2_1));
s.set_rand_ui3_1(pack_l3(rand_ui3_1));
s.set_rand_ui4_1(pack_l4(rand_ui4_1));
+ s.set_rand_sl1_0(rand_sl1_0);
+ s.set_rand_sl2_0(pack_l2(rand_sl2_0));
+ s.set_rand_sl3_0(pack_l3(rand_sl3_0));
+ s.set_rand_sl4_0(pack_l4(rand_sl4_0));
+ s.set_rand_sl1_1(rand_sl1_1);
+ s.set_rand_sl2_1(pack_l2(rand_sl2_1));
+ s.set_rand_sl3_1(pack_l3(rand_sl3_1));
+ s.set_rand_sl4_1(pack_l4(rand_sl4_1));
+ s.set_rand_uc1_0(rand_uc1_0);
+ s.set_rand_uc2_0(pack_s2(rand_uc2_0));
+ s.set_rand_uc3_0(pack_s3(rand_uc3_0));
+ s.set_rand_uc4_0(pack_s4(rand_uc4_0));
+ // FIXME: set char input vectors once bug 6865598 is fixed
+ /*
+ s.set_rand_sc1_0(rand_sc1_0);
+ s.set_rand_sc2_0(pack_b2(rand_sc2_0));
+ s.set_rand_sc3_0(pack_b3(rand_sc3_0));
+ s.set_rand_sc4_0(pack_b4(rand_sc4_0));
+ s.set_rand_sc1_1(rand_sc1_1);
+ s.set_rand_sc2_1(pack_b2(rand_sc2_1));
+ s.set_rand_sc3_1(pack_b3(rand_sc3_1));
+ s.set_rand_sc4_1(pack_b4(rand_sc4_1));
*/
// TODO: set unsigned long vectors
@@ -438,40 +435,37 @@
s.set_min_rand_f2_f2(pack_f2(min(rand_f2_0, rand_f2_1)));
s.set_min_rand_f3_f3(pack_f3(min(rand_f3_0, rand_f3_1)));
s.set_min_rand_f4_f4(pack_f4(min(rand_f4_0, rand_f4_1)));
+ s.set_min_rand_uc1_uc1(min(rand_uc1_0, rand_uc1_1));
+ s.set_min_rand_uc2_uc2(pack_s2(min(rand_uc2_0, rand_uc2_1)));
+ s.set_min_rand_uc3_uc3(pack_s3(min(rand_uc3_0, rand_uc3_1)));
+ s.set_min_rand_uc4_uc4(pack_s4(min(rand_uc4_0, rand_uc4_1)));
s.set_min_rand_ss1_ss1(min(rand_ss1_0, rand_ss1_1));
s.set_min_rand_ss2_ss2(pack_s2(min(rand_ss2_0, rand_ss2_1)));
s.set_min_rand_ss3_ss3(pack_s3(min(rand_ss3_0, rand_ss3_1)));
s.set_min_rand_ss4_ss4(pack_s4(min(rand_ss4_0, rand_ss4_1)));
+ s.set_min_rand_us1_us1(min(rand_us1_0, rand_us1_1));
+ s.set_min_rand_us2_us2(pack_i2(min(rand_us2_0, rand_us2_1)));
+ s.set_min_rand_us3_us3(pack_i3(min(rand_us3_0, rand_us3_1)));
+ s.set_min_rand_us4_us4(pack_i4(min(rand_us4_0, rand_us4_1)));
s.set_min_rand_si1_si1(min(rand_si1_0, rand_si1_1));
s.set_min_rand_si2_si2(pack_i2(min(rand_si2_0, rand_si2_1)));
s.set_min_rand_si3_si3(pack_i3(min(rand_si3_0, rand_si3_1)));
s.set_min_rand_si4_si4(pack_i4(min(rand_si4_0, rand_si4_1)));
+ s.set_min_rand_ui1_ui1(min(rand_ui1_0, rand_ui1_1));
+ s.set_min_rand_ui2_ui2(pack_l2(min(rand_ui2_0, rand_ui2_1)));
+ s.set_min_rand_ui3_ui3(pack_l3(min(rand_ui3_0, rand_ui3_1)));
+ s.set_min_rand_ui4_ui4(pack_l4(min(rand_ui4_0, rand_ui4_1)));
s.set_min_rand_sl1_sl1(min(rand_sl1_0, rand_sl1_1));
s.set_min_rand_sl2_sl2(pack_l2(min(rand_sl2_0, rand_sl2_1)));
s.set_min_rand_sl3_sl3(pack_l3(min(rand_sl3_0, rand_sl3_1)));
s.set_min_rand_sl4_sl4(pack_l4(min(rand_sl4_0, rand_sl4_1)));
- // FIXME: set signed char min reference vectors once bug is fixed
+ // FIXME: set char min reference vectors once bug 6865598 is fixed
/*
s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
s.set_min_rand_sc2_sc2(pack_b2(min(rand_sc2_0, rand_sc2_1)));
s.set_min_rand_sc3_sc3(pack_b3(min(rand_sc3_0, rand_sc3_1)));
s.set_min_rand_sc4_sc4(pack_b4(min(rand_sc4_0, rand_sc4_1)));
*/
- // FIXME: set unsigned min reference vectors once bug 6764163 is fixed
- /*
- s.set_min_rand_uc1_uc1(min(rand_uc1_0, rand_uc1_1));
- s.set_min_rand_uc2_uc2(pack_s3(min(rand_uc2_0, rand_uc2_1)));
- s.set_min_rand_uc3_uc3(pack_s3(min(rand_uc3_0, rand_uc3_1)));
- s.set_min_rand_uc4_uc4(pack_s4(min(rand_uc4_0, rand_uc4_1)));
- s.set_min_rand_us1_us1(min(rand_us1_0, rand_us1_1));
- s.set_min_rand_us2_us2(pack_i2(min(rand_us2_0, rand_us2_1)));
- s.set_min_rand_us3_us3(pack_i3(min(rand_us3_0, rand_us3_1)));
- s.set_min_rand_us4_us4(pack_i4(min(rand_us4_0, rand_us4_1)));
- s.set_min_rand_ui1_ui1(min(rand_ui1_0, rand_ui1_1));
- s.set_min_rand_ui2_ui2(pack_l2(min(rand_ui2_0, rand_ui2_1)));
- s.set_min_rand_ui3_ui3(pack_l3(min(rand_ui3_0, rand_ui3_1)));
- s.set_min_rand_ui4_ui4(pack_l4(min(rand_ui4_0, rand_ui4_1)));
- */
// TODO: set results for unsigned long min
// Set results for max
@@ -479,40 +473,38 @@
s.set_max_rand_f2_f2(pack_f2(max(rand_f2_0, rand_f2_1)));
s.set_max_rand_f3_f3(pack_f3(max(rand_f3_0, rand_f3_1)));
s.set_max_rand_f4_f4(pack_f4(max(rand_f4_0, rand_f4_1)));
+ s.set_max_rand_uc1_uc1(max(rand_uc1_0, rand_uc1_1));
+ s.set_max_rand_uc2_uc2(pack_s2(max(rand_uc2_0, rand_uc2_1)));
+ s.set_max_rand_uc3_uc3(pack_s3(max(rand_uc3_0, rand_uc3_1)));
+ s.set_max_rand_uc4_uc4(pack_s4(max(rand_uc4_0, rand_uc4_1)));
s.set_max_rand_ss1_ss1(max(rand_ss1_0, rand_ss1_1));
s.set_max_rand_ss2_ss2(pack_s2(max(rand_ss2_0, rand_ss2_1)));
s.set_max_rand_ss3_ss3(pack_s3(max(rand_ss3_0, rand_ss3_1)));
s.set_max_rand_ss4_ss4(pack_s4(max(rand_ss4_0, rand_ss4_1)));
+ s.set_max_rand_us1_us1(max(rand_us1_0, rand_us1_1));
+ s.set_max_rand_us2_us2(pack_i2(max(rand_us2_0, rand_us2_1)));
+ s.set_max_rand_us3_us3(pack_i3(max(rand_us3_0, rand_us3_1)));
+ s.set_max_rand_us4_us4(pack_i4(max(rand_us4_0, rand_us4_1)));
s.set_max_rand_si1_si1(max(rand_si1_0, rand_si1_1));
s.set_max_rand_si2_si2(pack_i2(max(rand_si2_0, rand_si2_1)));
s.set_max_rand_si3_si3(pack_i3(max(rand_si3_0, rand_si3_1)));
s.set_max_rand_si4_si4(pack_i4(max(rand_si4_0, rand_si4_1)));
+ s.set_max_rand_ui1_ui1(max(rand_ui1_0, rand_ui1_1));
+ s.set_max_rand_ui2_ui2(pack_l2(max(rand_ui2_0, rand_ui2_1)));
+ s.set_max_rand_ui3_ui3(pack_l3(max(rand_ui3_0, rand_ui3_1)));
+ s.set_max_rand_ui4_ui4(pack_l4(max(rand_ui4_0, rand_ui4_1)));
s.set_max_rand_sl1_sl1(max(rand_sl1_0, rand_sl1_1));
s.set_max_rand_sl2_sl2(pack_l2(max(rand_sl2_0, rand_sl2_1)));
s.set_max_rand_sl3_sl3(pack_l3(max(rand_sl3_0, rand_sl3_1)));
s.set_max_rand_sl4_sl4(pack_l4(max(rand_sl4_0, rand_sl4_1)));
- // FIXME: set signed char max reference vectors once bug is fixed
+ // FIXME: set signed char max reference vectors once bug 6865598 is fixed
/*
s.set_max_rand_sc1_sc1(max(rand_sc1_0, rand_sc1_1));
s.set_max_rand_sc2_sc2(pack_b2(max(rand_sc2_0, rand_sc2_1)));
s.set_max_rand_sc3_sc3(pack_b3(max(rand_sc3_0, rand_sc3_1)));
s.set_max_rand_sc4_sc4(pack_b4(max(rand_sc4_0, rand_sc4_1)));
*/
- // FIXME: set unsigned max reference vectors once bug 6764163 is fixed
- /*
- s.set_max_rand_uc1_uc1(max(rand_uc1_0, rand_uc1_1));
- s.set_max_rand_uc2_uc2(pack_s3(max(rand_uc2_0, rand_uc2_1)));
- s.set_max_rand_uc3_uc3(pack_s3(max(rand_uc3_0, rand_uc3_1)));
- s.set_max_rand_uc4_uc4(pack_s4(max(rand_uc4_0, rand_uc4_1)));
- s.set_max_rand_us1_us1(max(rand_us1_0, rand_us1_1));
- s.set_max_rand_us2_us2(pack_i2(max(rand_us2_0, rand_us2_1)));
- s.set_max_rand_us3_us3(pack_i3(max(rand_us3_0, rand_us3_1)));
- s.set_max_rand_us4_us4(pack_i4(max(rand_us4_0, rand_us4_1)));
- s.set_max_rand_ui1_ui1(max(rand_ui1_0, rand_ui1_1));
- s.set_max_rand_ui2_ui2(pack_l2(max(rand_ui2_0, rand_ui2_1)));
- s.set_max_rand_ui3_ui3(pack_l3(max(rand_ui3_0, rand_ui3_1)));
- s.set_max_rand_ui4_ui4(pack_l4(max(rand_ui4_0, rand_ui4_1)));
- */
+
// TODO: set results for unsigned long max
// Set results for fmin
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java
new file mode 100644
index 0000000..2164766
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java
@@ -0,0 +1,60 @@
+/*
+ * 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 com.android.rs.test;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.*;
+
+public class UT_unsigned extends UnitTest {
+ private Resources mRes;
+
+ protected UT_unsigned(RSTestCore rstc, Resources res, Context ctx) {
+ super(rstc, "Unsigned", ctx);
+ mRes = res;
+ }
+
+ private boolean initializeGlobals(ScriptC_unsigned s) {
+ short pUC = s.get_uc();
+ if (pUC != 5) {
+ return false;
+ }
+ s.set_uc((short)129);
+
+ long pUI = s.get_ui();
+ if (pUI != 37) {
+ return false;
+ }
+ s.set_ui(0x7fffffff);
+
+ return true;
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ ScriptC_unsigned s = new ScriptC_unsigned(pRS, mRes, R.raw.unsigned);
+ pRS.setMessageHandler(mRsMessage);
+ if (!initializeGlobals(s)) {
+ failTest();
+ } else {
+ s.invoke_unsigned_test();
+ pRS.finish();
+ waitForMessage();
+ }
+ pRS.destroy();
+ }
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
index ac3a3fa..1adb036 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
@@ -337,15 +337,16 @@
TEST_UL4_UL4(func)
#define TEST_VEC_VEC_ALL(func) \
-TEST_FN_FN_ALL(func) \
-TEST_SS_SS_ALL(func) \
-TEST_SI_SI_ALL(func)
-// FIXME: Add tests back in once bug 6764163 is fixed
-#if 0
-TEST_SC_SC_ALL(func) \
-TEST_US_US_ALL(func) \
+TEST_FN_FN_ALL(func) \
TEST_UC_UC_ALL(func) \
+TEST_SS_SS_ALL(func) \
+TEST_US_US_ALL(func) \
+TEST_SI_SI_ALL(func) \
TEST_UI_UI_ALL(func)
+
+// FIXME: Add char tests back in once bug 6865598 is fixed
+#if 0
+TEST_SC_SC_ALL(func)
#endif
// TODO: add long types to ALL macro
#if 0
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs
new file mode 100644
index 0000000..2c056f4
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs
@@ -0,0 +1,36 @@
+#include "shared.rsh"
+
+// Testing unsigned types for Bug 6764163
+unsigned int ui = 37;
+unsigned char uc = 5;
+
+static bool test_unsigned() {
+ bool failed = false;
+
+ rsDebug("ui", ui);
+ rsDebug("uc", uc);
+ _RS_ASSERT(ui == 0x7fffffff);
+ _RS_ASSERT(uc == 129);
+
+ if (failed) {
+ rsDebug("test_unsigned FAILED", -1);
+ }
+ else {
+ rsDebug("test_unsigned PASSED", 0);
+ }
+
+ return failed;
+}
+
+void unsigned_test() {
+ bool failed = false;
+ failed |= test_unsigned();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 36f38f9..6e58a2d 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -23,13 +23,17 @@
import android.os.Binder;
import android.os.IBinder;
import android.os.Handler;
+import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.WorkSource;
import android.os.Messenger;
+import android.util.Log;
import android.util.SparseArray;
+import java.util.concurrent.CountDownLatch;
+
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
@@ -58,6 +62,7 @@
*/
public class WifiManager {
+ private static final String TAG = "WifiManager";
// Supplicant error codes:
/**
* The error code if there was a problem authenticating.
@@ -481,9 +486,6 @@
/** @hide */
public static final int DATA_ACTIVITY_INOUT = 0x03;
- IWifiManager mService;
- Handler mHandler;
-
/* Maximum number of active locks we allow.
* This limit was added to prevent apps from creating a ridiculous number
* of locks and crashing the system by overflowing the global ref table.
@@ -493,19 +495,33 @@
/* Number of currently active WifiLocks and MulticastLocks */
private int mActiveLockCount;
+ private Context mContext;
+ IWifiManager mService;
+
+ private static final int INVALID_KEY = 0;
+ private int mListenerKey = 1;
+ private final SparseArray mListenerMap = new SparseArray();
+ private final Object mListenerMapLock = new Object();
+
+ private AsyncChannel mAsyncChannel = new AsyncChannel();
+ private ServiceHandler mHandler;
+ private Messenger mWifiServiceMessenger;
+ private final CountDownLatch mConnected = new CountDownLatch(1);
+
/**
* Create a new WifiManager instance.
* Applications will almost always want to use
* {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve
* the standard {@link android.content.Context#WIFI_SERVICE Context.WIFI_SERVICE}.
+ * @param context the application context
* @param service the Binder interface
- * @param handler target for messages
* @hide - hide this because it takes in a parameter of type IWifiManager, which
* is a system private class.
*/
- public WifiManager(IWifiManager service, Handler handler) {
+ public WifiManager(Context context, IWifiManager service) {
+ mContext = context;
mService = service;
- mHandler = handler;
+ init();
}
/**
@@ -1168,15 +1184,6 @@
/** WPS timed out {@hide} */
public static final int WPS_TIMED_OUT = 7;
- /** Interface for callback invocation when framework channel is lost {@hide} */
- public interface ChannelListener {
- /**
- * The channel to the framework has been disconnected.
- * Application could try re-initializing using {@link #initialize}
- */
- public void onChannelDisconnected();
- }
-
/** Interface for callback invocation on an application action {@hide} */
public interface ActionListener {
/** The operation succeeded */
@@ -1205,132 +1212,120 @@
public void onFailure(int reason);
}
- /**
- * A channel that connects the application to the Wifi framework.
- * Most operations require a Channel as an argument. An instance of Channel is obtained
- * by doing a call on {@link #initialize}
- * @hide
- */
- public static class Channel {
- Channel(Looper looper, ChannelListener l) {
- mAsyncChannel = new AsyncChannel();
- mHandler = new WifiHandler(looper);
- mChannelListener = l;
- }
- private ChannelListener mChannelListener;
- private SparseArray<Object> mListenerMap = new SparseArray<Object>();
- private Object mListenerMapLock = new Object();
- private int mListenerKey = 0;
- private static final int INVALID_KEY = -1;
-
- AsyncChannel mAsyncChannel;
- WifiHandler mHandler;
- class WifiHandler extends Handler {
- WifiHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message message) {
- Object listener = removeListener(message.arg2);
- switch (message.what) {
- case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
- if (mChannelListener != null) {
- mChannelListener.onChannelDisconnected();
- mChannelListener = null;
- }
- break;
- /* ActionListeners grouped together */
- case WifiManager.CONNECT_NETWORK_FAILED:
- case WifiManager.FORGET_NETWORK_FAILED:
- case WifiManager.SAVE_NETWORK_FAILED:
- case WifiManager.CANCEL_WPS_FAILED:
- case WifiManager.DISABLE_NETWORK_FAILED:
- if (listener != null) {
- ((ActionListener) listener).onFailure(message.arg1);
- }
- break;
- /* ActionListeners grouped together */
- case WifiManager.CONNECT_NETWORK_SUCCEEDED:
- case WifiManager.FORGET_NETWORK_SUCCEEDED:
- case WifiManager.SAVE_NETWORK_SUCCEEDED:
- case WifiManager.CANCEL_WPS_SUCCEDED:
- case WifiManager.DISABLE_NETWORK_SUCCEEDED:
- if (listener != null) {
- ((ActionListener) listener).onSuccess();
- }
- break;
- case WifiManager.START_WPS_SUCCEEDED:
- if (listener != null) {
- WpsResult result = (WpsResult) message.obj;
- ((WpsListener) listener).onStartSuccess(result.pin);
- //Listener needs to stay until completion or failure
- synchronized(mListenerMapLock) {
- mListenerMap.put(message.arg2, listener);
- }
- }
- break;
- case WifiManager.WPS_COMPLETED:
- if (listener != null) {
- ((WpsListener) listener).onCompletion();
- }
- break;
- case WifiManager.WPS_FAILED:
- if (listener != null) {
- ((WpsListener) listener).onFailure(message.arg1);
- }
- break;
- default:
- //ignore
- break;
- }
- }
+ private class ServiceHandler extends Handler {
+ ServiceHandler(Looper looper) {
+ super(looper);
}
- int putListener(Object listener) {
- if (listener == null) return INVALID_KEY;
- int key;
- synchronized (mListenerMapLock) {
- do {
- key = mListenerKey++;
- } while (key == INVALID_KEY);
- mListenerMap.put(key, listener);
- }
- return key;
- }
-
- Object removeListener(int key) {
- if (key == INVALID_KEY) return null;
- synchronized (mListenerMapLock) {
- Object listener = mListenerMap.get(key);
- mListenerMap.remove(key);
- return listener;
+ @Override
+ public void handleMessage(Message message) {
+ Object listener = removeListener(message.arg2);
+ switch (message.what) {
+ case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
+ if (message.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
+ mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
+ } else {
+ Log.e(TAG, "Failed to set up channel connection");
+ // This will cause all further async API calls on the WifiManager
+ // to fail and throw an exception
+ mAsyncChannel = null;
+ }
+ mConnected.countDown();
+ break;
+ case AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED:
+ // Ignore
+ break;
+ case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
+ Log.e(TAG, "Channel connection lost");
+ // This will cause all further async API calls on the WifiManager
+ // to fail and throw an exception
+ mAsyncChannel = null;
+ break;
+ /* ActionListeners grouped together */
+ case WifiManager.CONNECT_NETWORK_FAILED:
+ case WifiManager.FORGET_NETWORK_FAILED:
+ case WifiManager.SAVE_NETWORK_FAILED:
+ case WifiManager.CANCEL_WPS_FAILED:
+ case WifiManager.DISABLE_NETWORK_FAILED:
+ if (listener != null) {
+ ((ActionListener) listener).onFailure(message.arg1);
+ }
+ break;
+ /* ActionListeners grouped together */
+ case WifiManager.CONNECT_NETWORK_SUCCEEDED:
+ case WifiManager.FORGET_NETWORK_SUCCEEDED:
+ case WifiManager.SAVE_NETWORK_SUCCEEDED:
+ case WifiManager.CANCEL_WPS_SUCCEDED:
+ case WifiManager.DISABLE_NETWORK_SUCCEEDED:
+ if (listener != null) {
+ ((ActionListener) listener).onSuccess();
+ }
+ break;
+ case WifiManager.START_WPS_SUCCEEDED:
+ if (listener != null) {
+ WpsResult result = (WpsResult) message.obj;
+ ((WpsListener) listener).onStartSuccess(result.pin);
+ //Listener needs to stay until completion or failure
+ synchronized(mListenerMapLock) {
+ mListenerMap.put(message.arg2, listener);
+ }
+ }
+ break;
+ case WifiManager.WPS_COMPLETED:
+ if (listener != null) {
+ ((WpsListener) listener).onCompletion();
+ }
+ break;
+ case WifiManager.WPS_FAILED:
+ if (listener != null) {
+ ((WpsListener) listener).onFailure(message.arg1);
+ }
+ break;
+ default:
+ //ignore
+ break;
}
}
}
- /**
- * Registers the application with the Wi-Fi framework. This function
- * must be the first to be called before any Wi-Fi operations are performed.
- *
- * @param srcContext is the context of the source
- * @param srcLooper is the Looper on which the callbacks are receivied
- * @param listener for callback at loss of framework communication. Can be null.
- * @return Channel instance that is necessary for performing any further Wi-Fi operations.
- * A null is returned upon failure to initialize.
- * @hide
- */
- public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) {
- Messenger messenger = getWifiServiceMessenger();
- if (messenger == null) return null;
-
- Channel c = new Channel(srcLooper, listener);
- if (c.mAsyncChannel.connectSync(srcContext, c.mHandler, messenger)
- == AsyncChannel.STATUS_SUCCESSFUL) {
- return c;
- } else {
- return null;
+ private int putListener(Object listener) {
+ if (listener == null) return INVALID_KEY;
+ int key;
+ synchronized (mListenerMapLock) {
+ do {
+ key = mListenerKey++;
+ } while (key == INVALID_KEY);
+ mListenerMap.put(key, listener);
}
+ return key;
+ }
+
+ private Object removeListener(int key) {
+ if (key == INVALID_KEY) return null;
+ synchronized (mListenerMapLock) {
+ Object listener = mListenerMap.get(key);
+ mListenerMap.remove(key);
+ return listener;
+ }
+ }
+
+ private void init() {
+ mWifiServiceMessenger = getWifiServiceMessenger();
+ if (mWifiServiceMessenger == null) throw new RuntimeException("Failed to initialize");
+ HandlerThread t = new HandlerThread("WifiManager");
+ t.start();
+ mHandler = new ServiceHandler(t.getLooper());
+ mAsyncChannel.connect(mContext, mHandler, mWifiServiceMessenger);
+ try {
+ mConnected.await();
+ } catch (InterruptedException e) {
+ Log.e(TAG, "interrupted wait at init");
+ }
+ }
+
+ private void validateChannel() {
+ if (mAsyncChannel == null) throw new IllegalStateException(
+ "Bad WifiManager instance state, re-initialize");
}
/**
@@ -1341,20 +1336,21 @@
* sequence of addNetwork(), enableNetwork(), saveConfiguration() and
* reconnect()
*
- * @param c is the channel created at {@link #initialize}
* @param config the set of variables that describe the configuration,
* contained in a {@link WifiConfiguration} object.
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
+ *
* @hide
*/
- public void connect(Channel c, WifiConfiguration config, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void connect(WifiConfiguration config, ActionListener listener) {
if (config == null) throw new IllegalArgumentException("config cannot be null");
-
+ validateChannel();
// Use INVALID_NETWORK_ID for arg1 when passing a config object
// arg1 is used to pass network id when the network already exists
- c.mAsyncChannel.sendMessage(CONNECT_NETWORK, WifiConfiguration.INVALID_NETWORK_ID,
- c.putListener(listener), config);
+ mAsyncChannel.sendMessage(CONNECT_NETWORK, WifiConfiguration.INVALID_NETWORK_ID,
+ putListener(listener), config);
}
/**
@@ -1363,17 +1359,17 @@
* This function is used instead of a enableNetwork(), saveConfiguration() and
* reconnect()
*
- * @param c is the channel created at {@link #initialize}
* @param networkId the network id identifiying the network in the
* supplicant configuration list
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void connect(Channel c, int networkId, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void connect(int networkId, ActionListener listener) {
if (networkId < 0) throw new IllegalArgumentException("Network id cannot be negative");
-
- c.mAsyncChannel.sendMessage(CONNECT_NETWORK, networkId, c.putListener(listener));
+ validateChannel();
+ mAsyncChannel.sendMessage(CONNECT_NETWORK, networkId, putListener(listener));
}
/**
@@ -1387,17 +1383,17 @@
* For an existing network, it accomplishes the task of updateNetwork()
* and saveConfiguration()
*
- * @param c is the channel created at {@link #initialize}
* @param config the set of variables that describe the configuration,
* contained in a {@link WifiConfiguration} object.
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void save(Channel c, WifiConfiguration config, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void save(WifiConfiguration config, ActionListener listener) {
if (config == null) throw new IllegalArgumentException("config cannot be null");
-
- c.mAsyncChannel.sendMessage(SAVE_NETWORK, 0, c.putListener(listener), config);
+ validateChannel();
+ mAsyncChannel.sendMessage(SAVE_NETWORK, 0, putListener(listener), config);
}
/**
@@ -1406,64 +1402,62 @@
* This function is used instead of a sequence of removeNetwork()
* and saveConfiguration().
*
- * @param c is the channel created at {@link #initialize}
* @param config the set of variables that describe the configuration,
* contained in a {@link WifiConfiguration} object.
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void forget(Channel c, int netId, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void forget(int netId, ActionListener listener) {
if (netId < 0) throw new IllegalArgumentException("Network id cannot be negative");
-
- c.mAsyncChannel.sendMessage(FORGET_NETWORK, netId, c.putListener(listener));
+ validateChannel();
+ mAsyncChannel.sendMessage(FORGET_NETWORK, netId, putListener(listener));
}
/**
* Disable network
*
- * @param c is the channel created at {@link #initialize}
* @param netId is the network Id
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void disable(Channel c, int netId, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void disable(int netId, ActionListener listener) {
if (netId < 0) throw new IllegalArgumentException("Network id cannot be negative");
-
- c.mAsyncChannel.sendMessage(DISABLE_NETWORK, netId, c.putListener(listener));
+ validateChannel();
+ mAsyncChannel.sendMessage(DISABLE_NETWORK, netId, putListener(listener));
}
/**
* Start Wi-fi Protected Setup
*
- * @param c is the channel created at {@link #initialize}
* @param config WPS configuration
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void startWps(Channel c, WpsInfo config, WpsListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
+ public void startWps(WpsInfo config, WpsListener listener) {
if (config == null) throw new IllegalArgumentException("config cannot be null");
-
- c.mAsyncChannel.sendMessage(START_WPS, 0, c.putListener(listener), config);
+ validateChannel();
+ mAsyncChannel.sendMessage(START_WPS, 0, putListener(listener), config);
}
/**
* Cancel any ongoing Wi-fi Protected Setup
*
- * @param c is the channel created at {@link #initialize}
* @param listener for callbacks on success or failure. Can be null.
+ * @throws IllegalStateException if the WifiManager instance needs to be
+ * initialized again
* @hide
*/
- public void cancelWps(Channel c, ActionListener listener) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
-
- c.mAsyncChannel.sendMessage(CANCEL_WPS, 0, c.putListener(listener));
+ public void cancelWps(ActionListener listener) {
+ validateChannel();
+ mAsyncChannel.sendMessage(CANCEL_WPS, 0, putListener(listener));
}
-
-
/**
* Get a reference to WifiService handler. This is used by a client to establish
* an AsyncChannel communication with WifiService
@@ -1492,8 +1486,6 @@
}
}
-
-
/**
* Returns the file in which IP and proxy configuration data is stored
* @hide