summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java8
-rw-r--r--libs/gui/tests/Android.mk10
-rw-r--r--media/java/android/media/RemoteControlClient.java86
3 files changed, 88 insertions, 16 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index da5baf8..302be57 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -1583,6 +1583,14 @@ public final class InputMethodManager {
/**
* Set additional input method subtypes. Only a process which shares the same uid with the IME
* can add additional input method subtypes to the IME.
+ * Please note that a subtype's status is stored in the system.
+ * For example, enabled subtypes are remembered by the framework even after they are removed
+ * by using this method. If you re-add the same subtypes again,
+ * they will just get enabled. If you want to avoid such conflicts, for instance, you may
+ * want to create a "different" new subtype even with the same locale and mode,
+ * by changing its extra value. The different subtype won't get affected by the stored past
+ * status. (You may want to take a look at {@link InputMethodSubtype#hashCode()} to refer
+ * to the current implementation.)
* @param imiId Id of InputMethodInfo which additional input method subtypes will be added to.
* @param subtypes subtypes will be added as additional subtypes of the current input method.
* @return true if the additional input method subtypes are successfully added.
diff --git a/libs/gui/tests/Android.mk b/libs/gui/tests/Android.mk
index 0308af3..55ac133 100644
--- a/libs/gui/tests/Android.mk
+++ b/libs/gui/tests/Android.mk
@@ -1,4 +1,4 @@
-# Build the unit tests.
+# Build the unit tests,
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -22,17 +22,15 @@ LOCAL_SHARED_LIBRARIES := \
libui \
libutils \
-LOCAL_STATIC_LIBRARIES := \
- libgtest \
- libgtest_main \
-
LOCAL_C_INCLUDES := \
bionic \
bionic/libstdc++/include \
external/gtest/include \
external/stlport/stlport \
-include $(BUILD_EXECUTABLE)
+# Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+# to integrate with auto-test framework.
+include $(BUILD_NATIVE_TEST)
# Include subdirectory makefiles
# ============================================================
diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java
index d59bc2b..d7b85e4 100644
--- a/media/java/android/media/RemoteControlClient.java
+++ b/media/java/android/media/RemoteControlClient.java
@@ -22,6 +22,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
+import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -29,6 +30,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
+import java.lang.IllegalArgumentException;
import java.util.HashMap;
/**
@@ -236,6 +238,23 @@ public class RemoteControlClient
mEventHandler = new EventHandler(this, looper);
}
+ private static final int[] METADATA_KEYS_TYPE_STRING = {
+ MediaMetadataRetriever.METADATA_KEY_ALBUM,
+ MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST,
+ MediaMetadataRetriever.METADATA_KEY_TITLE,
+ MediaMetadataRetriever.METADATA_KEY_ARTIST,
+ MediaMetadataRetriever.METADATA_KEY_AUTHOR,
+ MediaMetadataRetriever.METADATA_KEY_COMPILATION,
+ MediaMetadataRetriever.METADATA_KEY_COMPOSER,
+ MediaMetadataRetriever.METADATA_KEY_DATE,
+ MediaMetadataRetriever.METADATA_KEY_GENRE,
+ MediaMetadataRetriever.METADATA_KEY_TITLE,
+ MediaMetadataRetriever.METADATA_KEY_WRITER };
+ private static final int[] METADATA_KEYS_TYPE_LONG = {
+ MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER,
+ MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER,
+ MediaMetadataRetriever.METADATA_KEY_DURATION };
+
/**
* Class used to modify metadata in a {@link RemoteControlClient} object.
*/
@@ -256,6 +275,11 @@ public class RemoteControlClient
}
/**
+ * The metadata key for the content artwork / album art.
+ */
+ public final static int METADATA_KEY_ARTWORK = 100;
+
+ /**
* Adds textual information to be displayed.
* Note that none of the information added after {@link #apply()} has been called,
* will be displayed.
@@ -265,49 +289,73 @@ public class RemoteControlClient
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_ARTIST},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_AUTHOR},
- * {@link android.media.MediaMetadataRetriever#METADATA_KEY_CD_TRACK_NUMBER},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_COMPILATION},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_COMPOSER},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_DATE},
- * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DISC_NUMBER},
- * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DURATION},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_GENRE},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
* {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER},
- * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}.
- * @param value the text for the given key, or null to signify there is no valid
+ * .
+ * @param value the text for the given key, or {@code null} to signify there is no valid
* information for the field.
* @return FIXME description
*/
- public synchronized MetadataEditor putString(int key, String value) {
+ public synchronized MetadataEditor putString(int key, String value)
+ throws IllegalArgumentException {
if (mApplied) {
Log.e(TAG, "Can't edit a previously applied MetadataEditor");
return this;
}
+ if (!validTypeForKey(key, METADATA_KEYS_TYPE_STRING)) {
+ throw(new IllegalArgumentException("Invalid type 'String' for key "+ key));
+ }
mEditorMetadata.putString(String.valueOf(key), value);
mMetadataChanged = true;
return this;
}
/**
- * The metadata key for the content artwork / album art.
+ * FIXME javadoc
+ * @param key the identifier of a the metadata field to set. Valid values are
+ * {@link android.media.MediaMetadataRetriever#METADATA_KEY_CD_TRACK_NUMBER},
+ * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DISC_NUMBER},
+ * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DURATION} (with a value
+ * expressed in milliseconds),
+ * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}.
+ * @param value FIXME javadoc
+ * @return FIXME javadoc
+ * @throws IllegalArgumentException
*/
- public final int METADATA_KEY_ARTWORK = 100;
+ public synchronized MetadataEditor putLong(int key, long value)
+ throws IllegalArgumentException {
+ if (mApplied) {
+ Log.e(TAG, "Can't edit a previously applied MetadataEditor");
+ return this;
+ }
+ if (!validTypeForKey(key, METADATA_KEYS_TYPE_LONG)) {
+ throw(new IllegalArgumentException("Invalid type 'long' for key "+ key));
+ }
+ mEditorMetadata.putLong(String.valueOf(key), value);
+ mMetadataChanged = true;
+ return this;
+ }
/**
* Sets the album / artwork picture to be displayed on the remote control.
* @param key FIXME description
* @param bitmap the bitmap for the artwork, or null if there isn't any.
* @return FIXME description
+ * @throws IllegalArgumentException
* @see android.graphics.Bitmap
*/
- public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap) {
+ public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap)
+ throws IllegalArgumentException {
if (mApplied) {
Log.e(TAG, "Can't edit a previously applied MetadataEditor");
return this;
}
if (key != METADATA_KEY_ARTWORK) {
- return this;
+ throw(new IllegalArgumentException("Invalid type 'Bitmap' for key "+ key));
}
if ((mArtworkExpectedWidth > 0) && (mArtworkExpectedHeight > 0)) {
mEditorArtwork = scaleBitmapIfTooBig(bitmap,
@@ -740,6 +788,24 @@ public class RemoteControlClient
}
}
return bitmap;
+ }
+ /**
+ * Fast routine to go through an array of allowed keys and return whether the key is part
+ * of that array
+ * @param key the key value
+ * @param validKeys the array of valid keys for a given type
+ * @return true if the key is part of the array, false otherwise
+ */
+ private static boolean validTypeForKey(int key, int[] validKeys) {
+ try {
+ for (int i = 0 ; ; i++) {
+ if (key == validKeys[i]) {
+ return true;
+ }
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return false;
+ }
}
}