summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java11
-rw-r--r--core/java/android/view/LayoutInflater.java33
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java33
3 files changed, 65 insertions, 12 deletions
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 2e0e59b..cf862b8 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -112,6 +112,7 @@ public abstract class NotificationListenerService extends Service {
* {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}.
*/
public final void cancelNotification(String pkg, String tag, int id) {
+ if (!isBound()) return;
try {
getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id);
} catch (android.os.RemoteException ex) {
@@ -131,6 +132,7 @@ public abstract class NotificationListenerService extends Service {
* {@see #cancelNotification(String, String, int)}
*/
public final void cancelAllNotifications() {
+ if (!isBound()) return;
try {
getNotificationInterface().cancelAllNotificationsFromListener(mWrapper);
} catch (android.os.RemoteException ex) {
@@ -145,6 +147,7 @@ public abstract class NotificationListenerService extends Service {
* @return An array of active notifications.
*/
public StatusBarNotification[] getActiveNotifications() {
+ if (!isBound()) return null;
try {
return getNotificationInterface().getActiveNotificationsFromListener(mWrapper);
} catch (android.os.RemoteException ex) {
@@ -161,6 +164,14 @@ public abstract class NotificationListenerService extends Service {
return mWrapper;
}
+ private boolean isBound() {
+ if (mWrapper == null) {
+ Log.w(TAG, "Notification listener service not yet bound.");
+ return false;
+ }
+ return true;
+ }
+
private class INotificationListenerWrapper extends INotificationListener.Stub {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index aaa8b8c..c4fac46 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -90,6 +90,7 @@ public abstract class LayoutInflater {
private static final String TAG_INCLUDE = "include";
private static final String TAG_1995 = "blink";
private static final String TAG_REQUEST_FOCUS = "requestFocus";
+ private static final String TAG_TAG = "tag";
private static final int[] ATTRS_THEME = new int[] {
com.android.internal.R.attr.theme };
@@ -778,6 +779,8 @@ public abstract class LayoutInflater {
if (TAG_REQUEST_FOCUS.equals(name)) {
parseRequestFocus(parser, parent);
+ } else if (TAG_TAG.equals(name)) {
+ parseViewTag(parser, parent, attrs);
} else if (TAG_INCLUDE.equals(name)) {
if (parser.getDepth() == 0) {
throw new InflateException("<include /> cannot be the root element");
@@ -797,10 +800,36 @@ public abstract class LayoutInflater {
if (finishInflate) parent.onFinishInflate();
}
- private void parseRequestFocus(XmlPullParser parser, View parent)
+ /**
+ * Parses a <code>&lt;request-focus&gt;</code> element and requests focus on
+ * the containing View.
+ */
+ private void parseRequestFocus(XmlPullParser parser, View view)
+ throws XmlPullParserException, IOException {
+ int type;
+ view.requestFocus();
+ final int currentDepth = parser.getDepth();
+ while (((type = parser.next()) != XmlPullParser.END_TAG ||
+ parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) {
+ // Empty
+ }
+ }
+
+ /**
+ * Parses a <code>&lt;tag&gt;</code> element and sets a keyed tag on the
+ * containing View.
+ */
+ private void parseViewTag(XmlPullParser parser, View view, AttributeSet attrs)
throws XmlPullParserException, IOException {
int type;
- parent.requestFocus();
+
+ final TypedArray ta = mContext.obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.ViewTag);
+ final int key = ta.getResourceId(com.android.internal.R.styleable.ViewTag_id, 0);
+ final CharSequence value = ta.getText(com.android.internal.R.styleable.ViewTag_value);
+ view.setTag(key, value);
+ ta.recycle();
+
final int currentDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG ||
parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) {
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 61aabea..7603305 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -2814,11 +2814,16 @@ public class AccessibilityNodeInfo implements Parcelable {
* @param columnCount The number of columns.
* @param hierarchical Whether the collection is hierarchical.
*/
- public static CollectionInfo obtain(int rowCount, int columnCount,
- boolean hierarchical) {
- CollectionInfo info = sPool.acquire();
- return (info != null) ? info : new CollectionInfo(rowCount,
- columnCount, hierarchical);
+ public static CollectionInfo obtain(int rowCount, int columnCount, boolean hierarchical) {
+ final CollectionInfo info = sPool.acquire();
+ if (info == null) {
+ return new CollectionInfo(rowCount, columnCount, hierarchical);
+ }
+
+ info.mRowCount = rowCount;
+ info.mColumnCount = columnCount;
+ info.mHierarchical = hierarchical;
+ return info;
}
/**
@@ -2916,11 +2921,19 @@ public class AccessibilityNodeInfo implements Parcelable {
* @param columnSpan The number of columns the item spans.
* @param heading Whether the item is a heading.
*/
- public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
- int columnIndex, int columnSpan, boolean heading) {
- CollectionItemInfo info = sPool.acquire();
- return (info != null) ? info : new CollectionItemInfo(rowIndex,
- rowSpan, columnIndex, columnSpan, heading);
+ public static CollectionItemInfo obtain(int rowIndex, int rowSpan, int columnIndex,
+ int columnSpan, boolean heading) {
+ final CollectionItemInfo info = sPool.acquire();
+ if (info == null) {
+ return new CollectionItemInfo(rowIndex, rowSpan, columnIndex, columnSpan, heading);
+ }
+
+ info.mRowIndex = rowIndex;
+ info.mRowSpan = rowSpan;
+ info.mColumnIndex = columnIndex;
+ info.mColumnSpan = columnSpan;
+ info.mHeading = heading;
+ return info;
}
private boolean mHeading;