Merge "Fix build warning; LOG_TAG was misplaced"
diff --git a/Android.mk b/Android.mk
index 9fbdde7..335fb73 100644
--- a/Android.mk
+++ b/Android.mk
@@ -36,6 +36,7 @@
# EventLogTags files.
LOCAL_SRC_FILES += \
core/java/android/content/EventLogTags.logtags \
+ core/java/android/speech/tts/EventLogTags.logtags \
core/java/android/webkit/EventLogTags.logtags \
telephony/java/com/android/internal/telephony/EventLogTags.logtags \
diff --git a/api/14.txt b/api/14.txt
index 050540b..d25d2b9 100644
--- a/api/14.txt
+++ b/api/14.txt
@@ -16272,20 +16272,10 @@
public class AllocationAdapter extends android.renderscript.Allocation {
method public static android.renderscript.AllocationAdapter create2D(android.renderscript.RenderScript, android.renderscript.Allocation);
- method public void readData(int[]);
- method public void readData(float[]);
method public void setFace(android.renderscript.Type.CubemapFace);
method public void setLOD(int);
method public void setY(int);
method public void setZ(int);
- method public void subData(int, android.renderscript.FieldPacker);
- method public void subData1D(int, int, int[]);
- method public void subData1D(int, int, short[]);
- method public void subData1D(int, int, byte[]);
- method public void subData1D(int, int, float[]);
- method public void subData2D(int, int, int, int, int[]);
- method public void subData2D(int, int, int, int, float[]);
- method public void subElementData(int, int, android.renderscript.FieldPacker);
}
class BaseObj {
diff --git a/api/current.txt b/api/current.txt
index 9ad7b4e..d507940 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -598,10 +598,10 @@
field public static final int layout_centerInParent = 16843151; // 0x101018f
field public static final int layout_centerVertical = 16843153; // 0x1010191
field public static final int layout_column = 16843084; // 0x101014c
- field public static final int layout_columnSpan = 16843644; // 0x101037c
+ field public static final int layout_columnFlexibility = 16843646; // 0x101037e
+ field public static final int layout_columnSpan = 16843645; // 0x101037d
field public static final int layout_gravity = 16842931; // 0x10100b3
field public static final int layout_height = 16842997; // 0x10100f5
- field public static final int layout_heightSpec = 16843646; // 0x101037e
field public static final int layout_margin = 16842998; // 0x10100f6
field public static final int layout_marginBottom = 16843002; // 0x10100fa
field public static final int layout_marginEnd = 16843674; // 0x101039a
@@ -610,6 +610,7 @@
field public static final int layout_marginStart = 16843673; // 0x1010399
field public static final int layout_marginTop = 16843000; // 0x10100f8
field public static final int layout_row = 16843642; // 0x101037a
+ field public static final int layout_rowFlexibility = 16843644; // 0x101037c
field public static final int layout_rowSpan = 16843643; // 0x101037b
field public static final int layout_scale = 16843155; // 0x1010193
field public static final int layout_span = 16843085; // 0x101014d
@@ -617,7 +618,6 @@
field public static final int layout_toRightOf = 16843139; // 0x1010183
field public static final int layout_weight = 16843137; // 0x1010181
field public static final int layout_width = 16842996; // 0x10100f4
- field public static final int layout_widthSpec = 16843645; // 0x101037d
field public static final int layout_x = 16843135; // 0x101017f
field public static final int layout_y = 16843136; // 0x1010180
field public static final int left = 16843181; // 0x10101ad
@@ -941,6 +941,7 @@
field public static final int tension = 16843370; // 0x101026a
field public static final int testOnly = 16843378; // 0x1010272
field public static final int text = 16843087; // 0x101014f
+ field public static final int textAllCaps = 16843680; // 0x10103a0
field public static final int textAppearance = 16842804; // 0x1010034
field public static final int textAppearanceButton = 16843271; // 0x1010207
field public static final int textAppearanceInverse = 16842805; // 0x1010035
@@ -1512,6 +1513,7 @@
field public static final int TextAppearance_Holo_Small = 16974081; // 0x1030101
field public static final int TextAppearance_Holo_Small_Inverse = 16974082; // 0x1030102
field public static final int TextAppearance_Holo_Widget = 16974085; // 0x1030105
+ field public static final int TextAppearance_Holo_Widget_ActionBar_Menu = 16974113; // 0x1030121
field public static final int TextAppearance_Holo_Widget_ActionBar_Subtitle = 16974099; // 0x1030113
field public static final int TextAppearance_Holo_Widget_ActionBar_Subtitle_Inverse = 16974110; // 0x103011e
field public static final int TextAppearance_Holo_Widget_ActionBar_Title = 16974098; // 0x1030112
@@ -1582,16 +1584,16 @@
field public static final int Theme_Holo_Light_NoActionBar = 16974064; // 0x10300f0
field public static final int Theme_Holo_Light_NoActionBar_Fullscreen = 16974065; // 0x10300f1
field public static final int Theme_Holo_Light_Panel = 16973948; // 0x103007c
- field public static final int Theme_Holo_Light_SolidActionBar = 16974121; // 0x1030129
- field public static final int Theme_Holo_Light_SolidActionBar_Inverse = 16974122; // 0x103012a
- field public static final int Theme_Holo_Light_SolidActionBar_Inverse_SplitActionBarWhenNarrow = 16974125; // 0x103012d
- field public static final int Theme_Holo_Light_SolidActionBar_SplitActionBarWhenNarrow = 16974124; // 0x103012c
+ field public static final int Theme_Holo_Light_SolidActionBar = 16974122; // 0x103012a
+ field public static final int Theme_Holo_Light_SolidActionBar_Inverse = 16974123; // 0x103012b
+ field public static final int Theme_Holo_Light_SolidActionBar_Inverse_SplitActionBarWhenNarrow = 16974126; // 0x103012e
+ field public static final int Theme_Holo_Light_SolidActionBar_SplitActionBarWhenNarrow = 16974125; // 0x103012d
field public static final int Theme_Holo_Light_SplitActionBarWhenNarrow = 16974106; // 0x103011a
field public static final int Theme_Holo_NoActionBar = 16973932; // 0x103006c
field public static final int Theme_Holo_NoActionBar_Fullscreen = 16973933; // 0x103006d
field public static final int Theme_Holo_Panel = 16973947; // 0x103007b
- field public static final int Theme_Holo_SolidActionBar = 16974120; // 0x1030128
- field public static final int Theme_Holo_SolidActionBar_SplitActionBarWhenNarrow = 16974123; // 0x103012b
+ field public static final int Theme_Holo_SolidActionBar = 16974121; // 0x1030129
+ field public static final int Theme_Holo_SolidActionBar_SplitActionBarWhenNarrow = 16974124; // 0x103012c
field public static final int Theme_Holo_SplitActionBarWhenNarrow = 16974105; // 0x1030119
field public static final int Theme_Holo_Wallpaper = 16973949; // 0x103007d
field public static final int Theme_Holo_Wallpaper_NoTitleBar = 16973950; // 0x103007e
@@ -1643,7 +1645,7 @@
field public static final int Widget_GridView = 16973874; // 0x1030032
field public static final int Widget_Holo = 16973962; // 0x103008a
field public static final int Widget_Holo_ActionBar = 16974004; // 0x10300b4
- field public static final int Widget_Holo_ActionBar_Solid = 16974113; // 0x1030121
+ field public static final int Widget_Holo_ActionBar_Solid = 16974114; // 0x1030122
field public static final int Widget_Holo_ActionBar_TabBar = 16974071; // 0x10300f7
field public static final int Widget_Holo_ActionBar_TabText = 16974070; // 0x10300f6
field public static final int Widget_Holo_ActionBar_TabView = 16974069; // 0x10300f5
@@ -1673,19 +1675,19 @@
field public static final int Widget_Holo_ImageButton = 16973974; // 0x1030096
field public static final int Widget_Holo_Light = 16974005; // 0x10300b5
field public static final int Widget_Holo_Light_ActionBar = 16974049; // 0x10300e1
- field public static final int Widget_Holo_Light_ActionBar_Solid = 16974114; // 0x1030122
- field public static final int Widget_Holo_Light_ActionBar_Solid_Inverse = 16974115; // 0x1030123
+ field public static final int Widget_Holo_Light_ActionBar_Solid = 16974115; // 0x1030123
+ field public static final int Widget_Holo_Light_ActionBar_Solid_Inverse = 16974116; // 0x1030124
field public static final int Widget_Holo_Light_ActionBar_TabBar = 16974074; // 0x10300fa
- field public static final int Widget_Holo_Light_ActionBar_TabBar_Inverse = 16974116; // 0x1030124
+ field public static final int Widget_Holo_Light_ActionBar_TabBar_Inverse = 16974117; // 0x1030125
field public static final int Widget_Holo_Light_ActionBar_TabText = 16974073; // 0x10300f9
- field public static final int Widget_Holo_Light_ActionBar_TabText_Inverse = 16974118; // 0x1030126
+ field public static final int Widget_Holo_Light_ActionBar_TabText_Inverse = 16974119; // 0x1030127
field public static final int Widget_Holo_Light_ActionBar_TabView = 16974072; // 0x10300f8
- field public static final int Widget_Holo_Light_ActionBar_TabView_Inverse = 16974117; // 0x1030125
+ field public static final int Widget_Holo_Light_ActionBar_TabView_Inverse = 16974118; // 0x1030126
field public static final int Widget_Holo_Light_ActionButton = 16974045; // 0x10300dd
field public static final int Widget_Holo_Light_ActionButton_CloseMode = 16974048; // 0x10300e0
field public static final int Widget_Holo_Light_ActionButton_Overflow = 16974046; // 0x10300de
field public static final int Widget_Holo_Light_ActionMode = 16974047; // 0x10300df
- field public static final int Widget_Holo_Light_ActionMode_Inverse = 16974119; // 0x1030127
+ field public static final int Widget_Holo_Light_ActionMode_Inverse = 16974120; // 0x1030128
field public static final int Widget_Holo_Light_AutoCompleteTextView = 16974011; // 0x10300bb
field public static final int Widget_Holo_Light_Button = 16974006; // 0x10300b6
field public static final int Widget_Holo_Light_Button_Borderless_Small = 16974108; // 0x103011c
@@ -7605,6 +7607,8 @@
method public int getHeight();
method public void getMatrix(android.graphics.Matrix);
method public final android.graphics.Matrix getMatrix();
+ method public int getMaximumBitmapHeight();
+ method public int getMaximumBitmapWidth();
method public int getSaveCount();
method public int getWidth();
method public boolean isHardwareAccelerated();
@@ -15620,6 +15624,10 @@
field public static final java.lang.String PHOTO = "data15";
}
+ public static final class ContactsContract.Contacts.StreamItems implements android.provider.ContactsContract.StreamItemsColumns {
+ field public static final java.lang.String CONTENT_DIRECTORY = "stream_items";
+ }
+
protected static abstract interface ContactsContract.ContactsColumns {
field public static final java.lang.String DISPLAY_NAME = "display_name";
field public static final java.lang.String HAS_PHONE_NUMBER = "has_phone_number";
@@ -15853,6 +15861,10 @@
field public static final java.lang.String DATA_ID = "data_id";
}
+ public static final class ContactsContract.RawContacts.StreamItems implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemsColumns {
+ field public static final java.lang.String CONTENT_DIRECTORY = "stream_items";
+ }
+
protected static abstract interface ContactsContract.RawContactsColumns {
field public static final java.lang.String AGGREGATION_MODE = "aggregation_mode";
field public static final java.lang.String CONTACT_ID = "contact_id";
@@ -15912,6 +15924,41 @@
field public static final android.net.Uri CONTENT_URI;
}
+ public static final class ContactsContract.StreamItemPhotos implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemPhotosColumns {
+ }
+
+ protected static abstract interface ContactsContract.StreamItemPhotosColumns {
+ field public static final java.lang.String ACTION = "action";
+ field public static final java.lang.String ACTION_URI = "action_uri";
+ field public static final java.lang.String PICTURE = "picture";
+ field public static final java.lang.String SORT_INDEX = "sort_index";
+ field public static final java.lang.String STREAM_ITEM_ID = "stream_item_id";
+ }
+
+ public static final class ContactsContract.StreamItems implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemsColumns {
+ field public static final android.net.Uri CONTENT_LIMIT_URI;
+ field public static final android.net.Uri CONTENT_PHOTO_URI;
+ field public static final android.net.Uri CONTENT_URI;
+ field public static final java.lang.String MAX_ITEMS = "max_items";
+ field public static final java.lang.String PHOTO_MAX_BYTES = "photo_max_bytes";
+ }
+
+ public static final class ContactsContract.StreamItems.StreamItemPhotos implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemPhotosColumns {
+ field public static final java.lang.String CONTENT_DIRECTORY = "photo";
+ }
+
+ protected static abstract interface ContactsContract.StreamItemsColumns {
+ field public static final java.lang.String ACTION = "action";
+ field public static final java.lang.String ACTION_URI = "action_uri";
+ field public static final java.lang.String COMMENTS = "comments";
+ field public static final java.lang.String RAW_CONTACT_ID = "raw_contact_id";
+ field public static final java.lang.String RES_ICON = "icon";
+ field public static final java.lang.String RES_LABEL = "label";
+ field public static final java.lang.String RES_PACKAGE = "res_package";
+ field public static final java.lang.String TEXT = "text";
+ field public static final java.lang.String TIMESTAMP = "timestamp";
+ }
+
protected static abstract interface ContactsContract.SyncColumns implements android.provider.ContactsContract.BaseSyncColumns {
field public static final java.lang.String ACCOUNT_NAME = "account_name";
field public static final java.lang.String ACCOUNT_TYPE = "account_type";
@@ -16635,23 +16682,12 @@
}
public class AllocationAdapter extends android.renderscript.Allocation {
+ method public static android.renderscript.AllocationAdapter create1D(android.renderscript.RenderScript, android.renderscript.Allocation);
method public static android.renderscript.AllocationAdapter create2D(android.renderscript.RenderScript, android.renderscript.Allocation);
- method public void readData(int[]);
- method public void readData(float[]);
method public void setFace(android.renderscript.Type.CubemapFace);
method public void setLOD(int);
method public void setY(int);
method public void setZ(int);
- method public void subData(int, android.renderscript.FieldPacker);
- method public void subData1D(int, int, int[]);
- method public void subData1D(int, int, short[]);
- method public void subData1D(int, int, byte[]);
- method public void subData1D(int, int, float[]);
- method public void subData1D(int, int, android.renderscript.AllocationAdapter, int);
- method public void subData2D(int, int, int, int, int[]);
- method public void subData2D(int, int, int, int, float[]);
- method public void subData2D(int, int, int, int, android.renderscript.AllocationAdapter, int, int);
- method public void subElementData(int, int, android.renderscript.FieldPacker);
}
public class BaseObj {
@@ -24953,11 +24989,9 @@
field public static final int ALIGN_MARGINS = 1; // 0x1
field public static final android.widget.GridLayout.Alignment BASELINE;
field public static final android.widget.GridLayout.Alignment BOTTOM;
- field public static final android.widget.GridLayout.Spec CAN_SHRINK;
- field public static final android.widget.GridLayout.Spec CAN_STRETCH;
+ field public static final int CAN_STRETCH = 2; // 0x2
field public static final android.widget.GridLayout.Alignment CENTER;
field public static final android.widget.GridLayout.Alignment FILL;
- field public static final android.widget.GridLayout.Spec FIXED;
field public static final int HORIZONTAL = 0; // 0x0
field public static final android.widget.GridLayout.Alignment LEFT;
field public static final android.widget.GridLayout.Alignment RIGHT;
@@ -24973,6 +25007,7 @@
ctor public GridLayout.Group(int, int, android.widget.GridLayout.Alignment);
ctor public GridLayout.Group(int, android.widget.GridLayout.Alignment);
field public final android.widget.GridLayout.Alignment alignment;
+ field public int flexibility;
}
public static class GridLayout.LayoutParams extends android.view.ViewGroup.MarginLayoutParams {
@@ -24984,13 +25019,7 @@
ctor public GridLayout.LayoutParams(android.content.Context, android.util.AttributeSet);
method public void setGravity(int);
field public android.widget.GridLayout.Group columnGroup;
- field public android.widget.GridLayout.Spec heightSpec;
field public android.widget.GridLayout.Group rowGroup;
- field public android.widget.GridLayout.Spec widthSpec;
- }
-
- public static abstract class GridLayout.Spec {
- ctor public GridLayout.Spec();
}
public class GridView extends android.widget.AbsListView {
@@ -26123,6 +26152,7 @@
method public boolean onTextContextMenuItem(int);
method public void removeTextChangedListener(android.text.TextWatcher);
method protected void resetLayoutDirectionResolution();
+ method public void setAllCaps(boolean);
method public final void setAutoLinkMask(int);
method public void setCompoundDrawablePadding(int);
method public void setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index 38d0d2a..2666b41 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -23,6 +23,8 @@
import android.os.RemoteException;
import android.os.ServiceManager;
+import java.util.HashSet;
+
public final class Bmgr {
IBackupManager mBmgr;
IRestoreSession mRestore;
@@ -45,7 +47,6 @@
}
public void run(String[] args) {
- boolean validCommand = false;
if (args.length < 1) {
showUsage();
return;
@@ -329,7 +330,13 @@
} else {
try {
long token = Long.parseLong(arg, 16);
- doRestoreAll(token);
+ HashSet<String> filter = null;
+ while ((arg = nextArg()) != null) {
+ if (filter == null) filter = new HashSet<String>();
+ filter.add(arg);
+ }
+
+ doRestoreAll(token, filter);
} catch (NumberFormatException e) {
showUsage();
return;
@@ -364,7 +371,7 @@
}
}
- private void doRestoreAll(long token) {
+ private void doRestoreAll(long token, HashSet<String> filter) {
RestoreObserver observer = new RestoreObserver();
try {
@@ -383,7 +390,13 @@
for (RestoreSet s : sets) {
if (s.token == token) {
System.out.println("Scheduling restore: " + s.name);
- didRestore = (mRestore.restoreAll(token, observer) == 0);
+ if (filter == null) {
+ didRestore = (mRestore.restoreAll(token, observer) == 0);
+ } else {
+ String[] names = new String[filter.size()];
+ filter.toArray(names);
+ didRestore = (mRestore.restoreSome(token, observer, names) == 0);
+ }
break;
}
}
@@ -430,6 +443,7 @@
System.err.println(" bmgr list sets");
System.err.println(" bmgr transport WHICH");
System.err.println(" bmgr restore TOKEN");
+ System.err.println(" bmgr restore TOKEN PACKAGE...");
System.err.println(" bmgr restore PACKAGE");
System.err.println(" bmgr run");
System.err.println(" bmgr wipe PACKAGE");
@@ -457,12 +471,18 @@
System.err.println("The 'transport' command designates the named transport as the currently");
System.err.println("active one. This setting is persistent across reboots.");
System.err.println("");
- System.err.println("The 'restore' command when given a restore token initiates a full-system");
+ System.err.println("The 'restore' command when given just a restore token initiates a full-system");
System.err.println("restore operation from the currently active transport. It will deliver");
System.err.println("the restore set designated by the TOKEN argument to each application");
System.err.println("that had contributed data to that restore set.");
System.err.println("");
- System.err.println("The 'restore' command when given a package name intiates a restore of");
+ System.err.println("The 'restore' command when given a token and one or more package names");
+ System.err.println("initiates a restore operation of just those given packages from the restore");
+ System.err.println("set designated by the TOKEN argument. It is effectively the same as the");
+ System.err.println("'restore' operation supplying only a token, but applies a filter to the");
+ System.err.println("set of applications to be restored.");
+ System.err.println("");
+ System.err.println("The 'restore' command when given just a package name intiates a restore of");
System.err.println("just that one package according to the restore set selection algorithm");
System.err.println("used by the RestoreSession.restorePackage() method.");
System.err.println("");
diff --git a/cmds/stagefright/recordvideo.cpp b/cmds/stagefright/recordvideo.cpp
index 1264215..c402286 100644
--- a/cmds/stagefright/recordvideo.cpp
+++ b/cmds/stagefright/recordvideo.cpp
@@ -34,7 +34,7 @@
fprintf(stderr, "usage: %s\n", me);
fprintf(stderr, " -h(elp)\n");
fprintf(stderr, " -b bit rate in bits per second (default: 300000)\n");
- fprintf(stderr, " -c YUV420 color format: [0] semi planar or [1] planar (default: 1)\n");
+ fprintf(stderr, " -c YUV420 color format: [0] semi planar or [1] planar or other omx YUV420 color format (default: 1)\n");
fprintf(stderr, " -f frame rate in frames per second (default: 30)\n");
fprintf(stderr, " -i I frame interval in seconds (default: 1)\n");
fprintf(stderr, " -n number of frames to be recorded (default: 300)\n");
@@ -59,11 +59,6 @@
mSize((width * height * 3) / 2) {
mGroup.add_buffer(new MediaBuffer(mSize));
-
- // Check the color format to make sure
- // that the buffer size mSize it set correctly above.
- CHECK(colorFormat == OMX_COLOR_FormatYUV420SemiPlanar ||
- colorFormat == OMX_COLOR_FormatYUV420Planar);
}
virtual sp<MetaData> getFormat() {
@@ -144,9 +139,13 @@
case kYUV420P:
return OMX_COLOR_FormatYUV420Planar;
default:
- fprintf(stderr, "Unsupported color: %d\n", color);
- return -1;
+ fprintf(stderr, "Custom OMX color format: %d\n", color);
+ if (color == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar ||
+ color == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) {
+ return color;
+ }
}
+ return -1;
}
int main(int argc, char **argv) {
diff --git a/core/java/android/app/backup/IRestoreSession.aidl b/core/java/android/app/backup/IRestoreSession.aidl
index 1dddbb0..14731ee 100644
--- a/core/java/android/app/backup/IRestoreSession.aidl
+++ b/core/java/android/app/backup/IRestoreSession.aidl
@@ -52,6 +52,25 @@
int restoreAll(long token, IRestoreObserver observer);
/**
+ * Restore select packages from the given set onto the device, replacing the
+ * current data of any app contained in the set with the data previously
+ * backed up.
+ *
+ * <p>Callers must hold the android.permission.BACKUP permission to use this method.
+ *
+ * @return Zero on success, nonzero on error. The observer will only receive
+ * progress callbacks if this method returned zero.
+ * @param token The token from {@link getAvailableRestoreSets()} corresponding to
+ * the restore set that should be used.
+ * @param observer If non-null, this binder points to an object that will receive
+ * progress callbacks during the restore operation.
+ * @param packages The set of packages for which to attempt a restore. Regardless of
+ * the contents of the actual back-end dataset named by {@code token}, only
+ * applications mentioned in this list will have their data restored.
+ */
+ int restoreSome(long token, IRestoreObserver observer, in String[] packages);
+
+ /**
* Restore a single application from backup. The data will be restored from the
* current backup dataset if the given package has stored data there, or from
* the dataset used during the last full device setup operation if the current
diff --git a/core/java/android/app/backup/RestoreSession.java b/core/java/android/app/backup/RestoreSession.java
index 24ddb99..7181c61 100644
--- a/core/java/android/app/backup/RestoreSession.java
+++ b/core/java/android/app/backup/RestoreSession.java
@@ -87,6 +87,40 @@
}
/**
+ * Restore select packages from the given set onto the device, replacing the
+ * current data of any app contained in the set with the data previously
+ * backed up.
+ *
+ * <p>Callers must hold the android.permission.BACKUP permission to use this method.
+ *
+ * @return Zero on success, nonzero on error. The observer will only receive
+ * progress callbacks if this method returned zero.
+ * @param token The token from {@link getAvailableRestoreSets()} corresponding to
+ * the restore set that should be used.
+ * @param observer If non-null, this binder points to an object that will receive
+ * progress callbacks during the restore operation.
+ * @param packages The set of packages for which to attempt a restore. Regardless of
+ * the contents of the actual back-end dataset named by {@code token}, only
+ * applications mentioned in this list will have their data restored.
+ *
+ * @hide
+ */
+ public int restoreSome(long token, RestoreObserver observer, String[] packages) {
+ int err = -1;
+ if (mObserver != null) {
+ Log.d(TAG, "restoreAll() called during active restore");
+ return -1;
+ }
+ mObserver = new RestoreObserverWrapper(mContext, observer);
+ try {
+ err = mBinder.restoreSome(token, mObserver, packages);
+ } catch (RemoteException e) {
+ Log.d(TAG, "Can't contact server to restore packages");
+ }
+ return err;
+ }
+
+ /**
* Restore a single application from backup. The data will be restored from the
* current backup dataset if the given package has stored data there, or from
* the dataset used during the last full device setup operation if the current
diff --git a/core/java/android/content/XmlDocumentProvider.java b/core/java/android/content/XmlDocumentProvider.java
deleted file mode 100644
index 76539c7..0000000
--- a/core/java/android/content/XmlDocumentProvider.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (C) 2010 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.content;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpGet;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import android.content.ContentResolver.OpenResourceIdResult;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.net.Uri;
-import android.net.http.AndroidHttpClient;
-import android.util.Log;
-import android.widget.CursorAdapter;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.BitSet;
-import java.util.Stack;
-import java.util.regex.Pattern;
-
-/**
- * @hide -- not yet ready to support, should be provided just as a static lib.
- *
- * A read-only content provider which extracts data out of an XML document.
- *
- * <p>A XPath-like selection pattern is used to select some nodes in the XML document. Each such
- * node will create a row in the {@link Cursor} result.</p>
- *
- * Each row is then populated with columns that are also defined as XPath-like projections. These
- * projections fetch attributes values or text in the matching row node or its children.
- *
- * <p>To add this provider in your application, you should add its declaration to your application
- * manifest:
- * <pre class="prettyprint">
- * <provider android:name="android.content.XmlDocumentProvider" android:authorities="xmldocument" />
- * </pre>
- * </p>
- *
- * <h2>Node selection syntax</h2>
- * The node selection syntax is made of the concatenation of an arbitrary number (at least one) of
- * <code>/node_name</code> node selection patterns.
- *
- * <p>The <code>/root/child1/child2</code> pattern will for instance match all nodes named
- * <code>child2</code> which are children of a node named <code>child1</code> which are themselves
- * children of a root node named <code>root</code>.</p>
- *
- * Any <code>/</code> separator in the previous expression can be replaced by a <code>//</code>
- * separator instead, which indicated a <i>descendant</i> instead of a child.
- *
- * <p>The <code>//node1//node2</code> pattern will for instance match all nodes named
- * <code>node2</code> which are descendant of a node named <code>node1</code> located anywhere in
- * the document hierarchy.</p>
- *
- * Node names can contain namespaces in the form <code>namespace:node</code>.
- *
- * <h2>Projection syntax</h2>
- * For every selected node, the projection will then extract actual data from this node and its
- * descendant.
- *
- * <p>Use a syntax similar to the selection syntax described above to select the text associated
- * with a child of the selected node. The implicit root of this projection pattern is the selected
- * node. <code>/</code> will hence refer to the text of the selected node, while
- * <code>/child1</code> will fetch the text of its child named <code>child1</code> and
- * <code>//child1</code> will match any <i>descendant</i> named <code>child1</code>. If several
- * nodes match the projection pattern, their texts are appended as a result.</p>
- *
- * A projection can also fetch any node attribute by appending a <code>@attribute_name</code>
- * pattern to the previously described syntax. <code>//child1@price</code> will for instance match
- * the attribute <code>price</code> of any <code>child1</code> descendant.
- *
- * <p>If a projection does not match any node/attribute, its associated value will be an empty
- * string.</p>
- *
- * <h2>Example</h2>
- * Using the following XML document:
- * <pre class="prettyprint">
- * <library>
- * <book id="EH94">
- * <title>The Old Man and the Sea</title>
- * <author>Ernest Hemingway</author>
- * </book>
- * <book id="XX10">
- * <title>The Arabian Nights: Tales of 1,001 Nights</title>
- * </book>
- * <no-id>
- * <book>
- * <title>Animal Farm</title>
- * <author>George Orwell</author>
- * </book>
- * </no-id>
- * </library>
- * </pre>
- * A selection pattern of <code>/library//book</code> will match the three book entries (while
- * <code>/library/book</code> will only match the first two ones).
- *
- * <p>Defining the projections as <code>/title</code>, <code>/author</code> and <code>@id</code>
- * will retrieve the associated data. Note that the author of the second book as well as the id of
- * the third are empty strings.
- */
-public class XmlDocumentProvider extends ContentProvider {
- /*
- * Ideas for improvement:
- * - Expand XPath-like syntax to allow for [nb] child number selector
- * - Address the starting . bug in AbstractCursor which prevents a true XPath syntax.
- * - Provide an alternative to concatenation when several node match (list-like).
- * - Support namespaces in attribute names.
- * - Incremental Cursor creation, pagination
- */
- private static final String LOG_TAG = "XmlDocumentProvider";
- private AndroidHttpClient mHttpClient;
-
- @Override
- public boolean onCreate() {
- return true;
- }
-
- /**
- * Query data from the XML document referenced in the URI.
- *
- * <p>The XML document can be a local resource or a file that will be downloaded from the
- * Internet. In the latter case, your application needs to request the INTERNET permission in
- * its manifest.</p>
- *
- * The URI will be of the form <code>content://xmldocument/?resource=R.xml.myFile</code> for a
- * local resource. <code>xmldocument</code> should match the authority declared for this
- * provider in your manifest. Internet documents are referenced using
- * <code>content://xmldocument/?url=</code> followed by an encoded version of the URL of your
- * document (see {@link Uri#encode(String)}).
- *
- * <p>The number of columns of the resulting Cursor is equal to the size of the projection
- * array plus one, named <code>_id</code> which will contain a unique row id (allowing the
- * Cursor to be used with a {@link CursorAdapter}). The other columns' names are the projection
- * patterns.</p>
- *
- * @param uri The URI of your local resource or Internet document.
- * @param projection A set of patterns that will be used to extract data from each selected
- * node. See class documentation for pattern syntax.
- * @param selection A selection pattern which will select the nodes that will create the
- * Cursor's rows. See class documentation for pattern syntax.
- * @param selectionArgs This parameter is ignored.
- * @param sortOrder The row order in the resulting cursor is determined from the node order in
- * the XML document. This parameter is ignored.
- * @return A Cursor or null in case of error.
- */
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
-
- XmlPullParser parser = null;
- mHttpClient = null;
-
- final String url = uri.getQueryParameter("url");
- if (url != null) {
- parser = getUriXmlPullParser(url);
- } else {
- final String resource = uri.getQueryParameter("resource");
- if (resource != null) {
- Uri resourceUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
- getContext().getPackageName() + "/" + resource);
- parser = getResourceXmlPullParser(resourceUri);
- }
- }
-
- if (parser != null) {
- XMLCursor xmlCursor = new XMLCursor(selection, projection);
- try {
- xmlCursor.parseWith(parser);
- return xmlCursor;
- } catch (IOException e) {
- Log.w(LOG_TAG, "I/O error while parsing XML " + uri, e);
- } catch (XmlPullParserException e) {
- Log.w(LOG_TAG, "Error while parsing XML " + uri, e);
- } finally {
- if (mHttpClient != null) {
- mHttpClient.close();
- }
- }
- }
-
- return null;
- }
-
- /**
- * Creates an XmlPullParser for the provided URL. Can be overloaded to provide your own parser.
- * @param url The URL of the XML document that is to be parsed.
- * @return An XmlPullParser on this document.
- */
- protected XmlPullParser getUriXmlPullParser(String url) {
- XmlPullParser parser = null;
- try {
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- parser = factory.newPullParser();
- } catch (XmlPullParserException e) {
- Log.e(LOG_TAG, "Unable to create XmlPullParser", e);
- return null;
- }
-
- InputStream inputStream = null;
- try {
- final HttpGet get = new HttpGet(url);
- mHttpClient = AndroidHttpClient.newInstance("Android");
- HttpResponse response = mHttpClient.execute(get);
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- if (entity != null) {
- inputStream = entity.getContent();
- }
- }
- } catch (IOException e) {
- Log.w(LOG_TAG, "Error while retrieving XML file " + url, e);
- return null;
- }
-
- try {
- parser.setInput(inputStream, null);
- } catch (XmlPullParserException e) {
- Log.w(LOG_TAG, "Error while reading XML file from " + url, e);
- return null;
- }
-
- return parser;
- }
-
- /**
- * Creates an XmlPullParser for the provided local resource. Can be overloaded to provide your
- * own parser.
- * @param resourceUri A fully qualified resource name referencing a local XML resource.
- * @return An XmlPullParser on this resource.
- */
- protected XmlPullParser getResourceXmlPullParser(Uri resourceUri) {
- OpenResourceIdResult resourceId;
- try {
- resourceId = getContext().getContentResolver().getResourceId(resourceUri);
- return resourceId.r.getXml(resourceId.id);
- } catch (FileNotFoundException e) {
- Log.w(LOG_TAG, "XML resource not found: " + resourceUri.toString(), e);
- return null;
- }
- }
-
- /**
- * Returns "vnd.android.cursor.dir/xmldoc".
- */
- @Override
- public String getType(Uri uri) {
- return "vnd.android.cursor.dir/xmldoc";
- }
-
- /**
- * This ContentProvider is read-only. This method throws an UnsupportedOperationException.
- **/
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * This ContentProvider is read-only. This method throws an UnsupportedOperationException.
- **/
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * This ContentProvider is read-only. This method throws an UnsupportedOperationException.
- **/
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-
- private static class XMLCursor extends MatrixCursor {
- private final Pattern mSelectionPattern;
- private Pattern[] mProjectionPatterns;
- private String[] mAttributeNames;
- private String[] mCurrentValues;
- private BitSet[] mActiveTextDepthMask;
- private final int mNumberOfProjections;
-
- public XMLCursor(String selection, String[] projections) {
- super(projections);
- // The first column in projections is used for the _ID
- mNumberOfProjections = projections.length - 1;
- mSelectionPattern = createPattern(selection);
- createProjectionPattern(projections);
- }
-
- private Pattern createPattern(String input) {
- String pattern = input.replaceAll("//", "/(.*/|)").replaceAll("^/", "^/") + "$";
- return Pattern.compile(pattern);
- }
-
- private void createProjectionPattern(String[] projections) {
- mProjectionPatterns = new Pattern[mNumberOfProjections];
- mAttributeNames = new String[mNumberOfProjections];
- mActiveTextDepthMask = new BitSet[mNumberOfProjections];
- // Add a column to store _ID
- mCurrentValues = new String[mNumberOfProjections + 1];
-
- for (int i=0; i<mNumberOfProjections; i++) {
- mActiveTextDepthMask[i] = new BitSet();
- String projection = projections[i + 1]; // +1 to skip the _ID column
- int atIndex = projection.lastIndexOf('@', projection.length());
- if (atIndex >= 0) {
- mAttributeNames[i] = projection.substring(atIndex+1);
- projection = projection.substring(0, atIndex);
- } else {
- mAttributeNames[i] = null;
- }
-
- // Conforms to XPath standard: reference to local context starts with a .
- if (projection.charAt(0) == '.') {
- projection = projection.substring(1);
- }
- mProjectionPatterns[i] = createPattern(projection);
- }
- }
-
- public void parseWith(XmlPullParser parser) throws IOException, XmlPullParserException {
- StringBuilder path = new StringBuilder();
- Stack<Integer> pathLengthStack = new Stack<Integer>();
-
- // There are two parsing mode: in root mode, rootPath is updated and nodes matching
- // selectionPattern are searched for and currentNodeDepth is negative.
- // When a node matching selectionPattern is found, currentNodeDepth is set to 0 and
- // updated as children are parsed and projectionPatterns are searched in nodePath.
- int currentNodeDepth = -1;
-
- // Index where local selected node path starts from in path
- int currentNodePathStartIndex = 0;
-
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
-
- if (eventType == XmlPullParser.START_TAG) {
- // Update path
- pathLengthStack.push(path.length());
- path.append('/');
- String prefix = null;
- try {
- // getPrefix is not supported by local Xml resource parser
- prefix = parser.getPrefix();
- } catch (RuntimeException e) {
- prefix = null;
- }
- if (prefix != null) {
- path.append(prefix);
- path.append(':');
- }
- path.append(parser.getName());
-
- if (currentNodeDepth >= 0) {
- currentNodeDepth++;
- } else {
- // A node matching selection is found: initialize child parsing mode
- if (mSelectionPattern.matcher(path.toString()).matches()) {
- currentNodeDepth = 0;
- currentNodePathStartIndex = path.length();
- mCurrentValues[0] = Integer.toString(getCount()); // _ID
- for (int i = 0; i < mNumberOfProjections; i++) {
- // Reset values to default (empty string)
- mCurrentValues[i + 1] = "";
- mActiveTextDepthMask[i].clear();
- }
- }
- }
-
- // This test has to be separated from the previous one as currentNodeDepth can
- // be modified above (when a node matching selection is found).
- if (currentNodeDepth >= 0) {
- final String localNodePath = path.substring(currentNodePathStartIndex);
- for (int i = 0; i < mNumberOfProjections; i++) {
- if (mProjectionPatterns[i].matcher(localNodePath).matches()) {
- String attribute = mAttributeNames[i];
- if (attribute != null) {
- mCurrentValues[i + 1] =
- parser.getAttributeValue(null, attribute);
- } else {
- mActiveTextDepthMask[i].set(currentNodeDepth, true);
- }
- }
- }
- }
-
- } else if (eventType == XmlPullParser.END_TAG) {
- // Pop last node from path
- final int length = pathLengthStack.pop();
- path.setLength(length);
-
- if (currentNodeDepth >= 0) {
- if (currentNodeDepth == 0) {
- // Leaving a selection matching node: add a new row with results
- addRow(mCurrentValues);
- } else {
- for (int i = 0; i < mNumberOfProjections; i++) {
- mActiveTextDepthMask[i].set(currentNodeDepth, false);
- }
- }
- currentNodeDepth--;
- }
-
- } else if ((eventType == XmlPullParser.TEXT) && (!parser.isWhitespace())) {
- for (int i = 0; i < mNumberOfProjections; i++) {
- if ((currentNodeDepth >= 0) &&
- (mActiveTextDepthMask[i].get(currentNodeDepth))) {
- mCurrentValues[i + 1] += parser.getText();
- }
- }
- }
-
- eventType = parser.next();
- }
- }
- }
-}
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index b492615..f9dc257 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -687,7 +687,7 @@
/**
* Fields and helpers for interacting with Attendees. Each row of this table
* represents a single attendee or guest of an event. Calling
- * {@link #query(ContentResolver, long)} will return a list of attendees for
+ * {@link #query(ContentResolver, long, String[])} will return a list of attendees for
* the event with the given eventId. Both apps and sync adapters may write
* to this table. There are six writable fields and all of them except
* {@link #ATTENDEE_NAME} must be included when inserting a new attendee.
@@ -708,24 +708,20 @@
*/
@SuppressWarnings("hiding")
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees");
- /**
- * the projection used by the attendees query
- */
- public static final String[] PROJECTION = new String[] {
- _ID, ATTENDEE_NAME, ATTENDEE_EMAIL, ATTENDEE_RELATIONSHIP, ATTENDEE_STATUS,};
private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?";
/**
* Queries all attendees associated with the given event. This is a
* blocking call and should not be done on the UI thread.
- *
+ *
* @param cr The content resolver to use for the query
* @param eventId The id of the event to retrieve attendees for
+ * @param projection the columns to return in the cursor
* @return A Cursor containing all attendees for the event
*/
- public static final Cursor query(ContentResolver cr, long eventId) {
+ public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
String[] attArgs = {Long.toString(eventId)};
- return cr.query(CONTENT_URI, PROJECTION, ATTENDEES_WHERE, attArgs /* selection args */,
+ return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */,
null /* sort order */);
}
}
@@ -1746,13 +1742,6 @@
public static final class EventDays implements EventDaysColumns {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
+ "/instances/groupbyday");
-
- /**
- * The projection used by the EventDays query.
- */
- public static final String[] PROJECTION = {
- STARTDAY, ENDDAY
- };
private static final String SELECTION = "selected=1";
/**
@@ -1761,14 +1750,16 @@
* endday representing the max range of days for all events beginning on
* each startday.This is a blocking function and should not be done on
* the UI thread.
- *
+ *
* @param cr the ContentResolver
* @param startDay the first Julian day in the range
* @param numDays the number of days to load (must be at least 1)
+ * @param projection the columns to return in the cursor
* @return a database cursor containing a list of start and end days for
* events
*/
- public static final Cursor query(ContentResolver cr, int startDay, int numDays) {
+ public static final Cursor query(ContentResolver cr, int startDay, int numDays,
+ String[] projection) {
if (numDays < 1) {
return null;
}
@@ -1776,7 +1767,7 @@
Uri.Builder builder = CONTENT_URI.buildUpon();
ContentUris.appendId(builder, startDay);
ContentUris.appendId(builder, endDay);
- return cr.query(builder.build(), PROJECTION, SELECTION,
+ return cr.query(builder.build(), projection, SELECTION,
null /* selection args */, STARTDAY);
}
}
@@ -1821,7 +1812,7 @@
/**
* Fields and helpers for accessing reminders for an event. Each row of this
* table represents a single reminder for an event. Calling
- * {@link #query(ContentResolver, long)} will return a list of reminders for
+ * {@link #query(ContentResolver, long, String[])} will return a list of reminders for
* the event with the given eventId. Both apps and sync adapters may write
* to this table. There are three writable fields and all of them must be
* included when inserting a new reminder. They are:
@@ -1833,25 +1824,21 @@
*/
public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns {
private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?";
- /**
- * The projection used by the reminders query.
- */
- public static final String[] PROJECTION = new String[] {
- _ID, MINUTES, METHOD,};
@SuppressWarnings("hiding")
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders");
/**
* Queries all reminders associated with the given event. This is a
* blocking call and should not be done on the UI thread.
- *
+ *
* @param cr The content resolver to use for the query
* @param eventId The id of the event to retrieve reminders for
+ * @param projection the columns to return in the cursor
* @return A Cursor containing all reminders for the event
*/
- public static final Cursor query(ContentResolver cr, long eventId) {
+ public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
String[] remArgs = {Long.toString(eventId)};
- return cr.query(CONTENT_URI, PROJECTION, REMINDERS_WHERE, remArgs /* selection args */,
+ return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/,
null /* sort order */);
}
}
@@ -2134,7 +2121,7 @@
* given event id, begin time and alarm time. If one is found then this
* alarm already exists and this method returns true. TODO Move to
* provider
- *
+ *
* @param cr the ContentResolver
* @param eventId the event id to match
* @param begin the start time of the event in UTC millis
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index ad71061..61deea4 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -1536,6 +1536,23 @@
}
/**
+ * A sub-directory of a single contact that contains all of the constituent raw contact
+ * {@link ContactsContract.StreamItems} rows. This directory can be used either
+ * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
+ */
+ public static final class StreamItems implements StreamItemsColumns {
+ /**
+ * no public constructor since this is a utility class
+ */
+ private StreamItems() {}
+
+ /**
+ * The directory twig for this sub-table
+ */
+ public static final String CONTENT_DIRECTORY = "stream_items";
+ }
+
+ /**
* <p>
* A <i>read-only</i> sub-directory of a single contact aggregate that
* contains all aggregation suggestions (other contacts). The
@@ -2443,6 +2460,28 @@
}
/**
+ * <p>
+ * A sub-directory of a single raw contact that contains all of its
+ * {@link ContactsContract.StreamItems} rows. To access this directory append
+ * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
+ * {@link ContactsContract.StreamItems} for a stand-alone table containing the
+ * same data.
+ * </p>
+ */
+ public static final class StreamItems implements BaseColumns, StreamItemsColumns {
+ /**
+ * No public constructor since this is a utility class
+ */
+ private StreamItems() {
+ }
+
+ /**
+ * The directory twig for this sub-table
+ */
+ public static final String CONTENT_DIRECTORY = "stream_items";
+ }
+
+ /**
* TODO: javadoc
* @param cursor
* @return
@@ -2661,6 +2700,483 @@
}
/**
+ * <p>
+ * Constants for the stream_items table, which contains social stream updates from
+ * the user's contact list.
+ * </p>
+ * <p>
+ * Only a certain number of stream items will ever be stored under a given raw contact.
+ * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
+ * determine this limit, and should restrict the number of items inserted in any given
+ * transaction correspondingly. Insertion of more items beyond the limit will
+ * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
+ * </p>
+ * <h3>Operations</h3>
+ * <dl>
+ * <dt><b>Insert</b></dt>
+ * <dd>
+ * <p>Social stream updates are always associated with a raw contact. There are a couple
+ * of ways to insert these entries.
+ * <dl>
+ * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
+ * <dd>
+ * <pre>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
+ * values.put(StreamItems.TIMESTAMP, timestamp);
+ * values.put(StreamItems.COMMENT, "3 people reshared this");
+ * values.put(StreamItems.ACTION, action);
+ * values.put(StreamItems.ACTION_URI, actionUri);
+ * Uri streamItemUri = getContentResolver().insert(
+ * Uri.withAppendedPath(ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
+ * RawContacts.StreamItems.CONTENT_DIRECTORY), values);
+ * long streamItemId = ContentUris.parseId(streamItemUri);
+ * </pre>
+ * </dd>
+ * <dt>Via the {@link StreamItems#CONTENT_URI} URI:</dt>
+ * <dd>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
+ * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
+ * values.put(StreamItems.TIMESTAMP, timestamp);
+ * values.put(StreamItems.COMMENT, "3 people reshared this");
+ * values.put(StreamItems.ACTION, action);
+ * values.put(StreamItems.ACTION_URI, actionUri);
+ * Uri streamItemUri = getContentResolver().insert(StreamItems.CONTENT_URI, values);
+ * long streamItemId = ContentUris.parseId(streamItemUri);
+ * </dd>
+ * </dl>
+ * </dd>
+ * </p>
+ * <p>
+ * Once a {@link StreamItems} entry has been inserted, photos associated with that
+ * social update can be inserted. For example, after one of the insertions above,
+ * photos could be added to the stream item in one of the following ways:
+ * <dl>
+ * <dt>Via a URI including the stream item ID:</dt>
+ * <dd>
+ * <pre>
+ * values.clear();
+ * values.put(StreamItemPhotos.SORT_INDEX, 1);
+ * values.put(StreamItemPhotos.PICTURE, photoData);
+ * values.put(StreamItemPhotos.ACTION, action);
+ * values.put(StreamItemPhotos.ACTION_URI, actionUri);
+ * getContentResolver().insert(Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
+ * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
+ * </pre>
+ * </dd>
+ * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}</dt>
+ * <dd>
+ * <pre>
+ * values.clear();
+ * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
+ * values.put(StreamItemPhotos.SORT_INDEX, 1);
+ * values.put(StreamItemPhotos.PICTURE, photoData);
+ * values.put(StreamItemPhotos.ACTION, action);
+ * values.put(StreamItemPhotos.ACTION_URI, actionUri);
+ * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
+ * </pre>
+ * Note that this latter form allows the insertion of a stream item and its
+ * photos in a single transaction, by using {@link ContentProviderOperation} with
+ * back references to populate the stream item ID in the {@link ContentValues}.
+ * </dd>
+ * </dl>
+ * </p>
+ * </dd>
+ * <dt><b>Update</b></dt>
+ * <dd>Updates can be performed by appending the stream item ID to the
+ * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
+ * created by the calling package can be updated.</dd>
+ * <dt><b>Delete</b></dt>
+ * <dd>Deletes can be performed by appending the stream item ID to the
+ * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
+ * created by the calling package can be deleted.</dd>
+ * <dt><b>Query</b></dt>
+ * <dl>
+ * <dt>Finding all social stream updates for a given contact</dt>
+ * <dd>By Contact ID:
+ * <pre>
+ * Cursor c = getContentResolver().query(Uri.withAppendedPath(
+ * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
+ * Contacts.StreamItems.CONTENT_DIRECTORY),
+ * null, null, null, null);
+ * </pre>
+ * </dd>
+ * <dd>By lookup key:
+ * <pre>
+ * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
+ * .appendPath(lookupKey)
+ * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
+ * null, null, null, null);
+ * </pre>
+ * </dd>
+ * <dt>Finding all social stream updates for a given raw contact</dt>
+ * <dd>
+ * <pre>
+ * Cursor c = getContentResolver().query(Uri.withAppendedPath(
+ * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
+ * RawContacts.StreamItems.CONTENT_DIRECTORY)),
+ * null, null, null, null);
+ * </pre>
+ * </dd>
+ * <dt>Querying for a specific stream item by ID</dt>
+ * <dd>
+ * <pre>
+ * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
+ * StreamItems.CONTENT_URI, streamItemId),
+ * null, null, null, null);
+ * </pre>
+ * </dd>
+ * </dl>
+ */
+ public static final class StreamItems implements BaseColumns, StreamItemsColumns {
+ /**
+ * This utility class cannot be instantiated
+ */
+ private StreamItems() {
+ }
+
+ /**
+ * The content:// style URI for this table, which handles social network stream
+ * updates for the user's contacts.
+ */
+ public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
+
+ /**
+ * <p>
+ * A content:// style URI for the photos stored in a sub-table underneath
+ * stream items. This is only used for inserts, and updates - queries and deletes
+ * for photos should be performed by appending
+ * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
+ * specific stream item.
+ * </p>
+ * <p>
+ * When using this URI, the stream item ID for the photo(s) must be identified
+ * in the {@link ContentValues} passed in.
+ * </p>
+ */
+ public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
+
+ /**
+ * This URI allows the caller to query for the maximum number of stream items
+ * that will be stored under any single raw contact, as well as the maximum
+ * photo size (in bytes) accepted in stream item photos.
+ */
+ public static final Uri CONTENT_LIMIT_URI =
+ Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
+
+ /**
+ * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
+ * contain this column, with the value indicating the maximum number of
+ * stream items that will be stored under any single raw contact.
+ */
+ public static final String MAX_ITEMS = "max_items";
+
+ /**
+ * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
+ * contain this column, with the value indicating the byte limit for
+ * individual photos.
+ */
+ public static final String PHOTO_MAX_BYTES = "photo_max_bytes";
+
+ /**
+ * <p>
+ * A sub-directory of a single stream item entry that contains all of its
+ * photo rows. To access this
+ * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
+ * an individual stream item URI.
+ * </p>
+ */
+ public static final class StreamItemPhotos
+ implements BaseColumns, StreamItemPhotosColumns {
+ /**
+ * No public constructor since this is a utility class
+ */
+ private StreamItemPhotos() {
+ }
+
+ /**
+ * The directory twig for this sub-table
+ */
+ public static final String CONTENT_DIRECTORY = "photo";
+ }
+ }
+
+ /**
+ * Columns in the StreamItems table.
+ *
+ * @see ContactsContract.StreamItems
+ */
+ protected interface StreamItemsColumns {
+ /**
+ * A reference to the {@link RawContacts#_ID}
+ * that this stream item belongs to.
+ */
+ public static final String RAW_CONTACT_ID = "raw_contact_id";
+
+ /**
+ * The package name to use when creating {@link Resources} objects for
+ * this stream item. This value is only designed for use when building
+ * user interfaces, and should not be used to infer the owner.
+ * <P>Type: NUMBER</P>
+ */
+ public static final String RES_PACKAGE = "res_package";
+
+ /**
+ * The resource ID of the icon for the source of the stream item.
+ * This resource should be scoped by the {@link #RES_PACKAGE}.
+ * <P>Type: NUMBER</P>
+ */
+ public static final String RES_ICON = "icon";
+
+ /**
+ * The resource ID of the label describing the source of the status update, e.g. "Google
+ * Talk". This resource should be scoped by the {@link #RES_PACKAGE}.
+ * <p>Type: NUMBER</p>
+ */
+ public static final String RES_LABEL = "label";
+
+ /**
+ * <P>
+ * The main textual contents of the item. Typically this is content
+ * that was posted by the source of this stream item, but it can also
+ * be a textual representation of an action (e.g. ”Checked in at Joe's”).
+ * This text is displayed to the user and allows formatting and embedded
+ * resource images via HTML (as parseable via
+ * {@link android.text.Html#fromHtml}).
+ * </P>
+ * <P>
+ * Long content may be truncated and/or ellipsized - the exact behavior
+ * is unspecified, but it should not break tags.
+ * </P>
+ * <P>Type: TEXT</P>
+ */
+ public static final String TEXT = "text";
+
+ /**
+ * The absolute time (milliseconds since epoch) when this stream item was
+ * inserted/updated.
+ * <P>Type: NUMBER</P>
+ */
+ public static final String TIMESTAMP = "timestamp";
+
+ /**
+ * <P>
+ * Summary information about the stream item, for example to indicate how
+ * many people have reshared it, how many have liked it, how many thumbs
+ * up and/or thumbs down it has, what the original source was, etc.
+ * </P>
+ * <P>
+ * This text is displayed to the user and allows simple formatting via
+ * HTML, in the same manner as {@link #TEXT} allows.
+ * </P>
+ * <P>
+ * Long content may be truncated and/or ellipsized - the exact behavior
+ * is unspecified, but it should not break tags.
+ * </P>
+ * <P>Type: TEXT</P>
+ */
+ public static final String COMMENTS = "comments";
+
+ /**
+ * The activity action to execute when the item is tapped.
+ * <P>Type: TEXT</P>
+ */
+ public static final String ACTION = "action";
+
+ /**
+ * The URI that is launched when the item is pressed. May be handled by
+ * the source app, but could also reference a website (e.g. YouTube).
+ * <P>Type: TEXT</P>
+ */
+ public static final String ACTION_URI = "action_uri";
+ }
+
+ /**
+ * <p>
+ * Constants for the stream_item_photos table, which contains photos associated with
+ * social stream updates.
+ * </p>
+ * <h3>Operations</h3>
+ * <dl>
+ * <dt><b>Insert</b></dt>
+ * <dd>
+ * <p>Social stream photo entries are associated with a social stream item. Photos
+ * can be inserted into a social stream item in a couple of ways:
+ * <dl>
+ * <dt>
+ * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
+ * stream item:
+ * </dt>
+ * <dd>
+ * <pre>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItemPhotos.SORT_INDEX, 1);
+ * values.put(StreamItemPhotos.PICTURE, photoData);
+ * values.put(StreamItemPhotos.ACTION, action);
+ * values.put(StreamItemPhotos.ACTION_URI, actionUri);
+ * Uri photoUri = getContentResolver().insert(Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), values);
+ * long photoId = ContentUris.parseId(photoUri);
+ * </pre>
+ * </dd>
+ * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
+ * <dd>
+ * <pre>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
+ * values.put(StreamItemPhotos.SORT_INDEX, 1);
+ * values.put(StreamItemPhotos.PICTURE, photoData);
+ * values.put(StreamItemPhotos.ACTION, action);
+ * values.put(StreamItemPhotos.ACTION_URI, actionUri);
+ * Uri photoUri = getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
+ * long photoId = ContentUris.parseId(photoUri);
+ * </pre>
+ * </dd>
+ * </dl>
+ * </p>
+ * </dd>
+ * <dt><b>Update</b></dt>
+ * <dd>
+ * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
+ * identified by both the stream item ID it belongs to and the stream item photo ID.
+ * This can be specified in two ways.
+ * <dl>
+ * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
+ * stream item:
+ * </dt>
+ * <dd>
+ * <pre>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItemPhotos.PICTURE, newPhotoData);
+ * getContentResolver().update(
+ * ContentUris.withAppendedId(
+ * Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
+ * streamItemPhotoId), values, null, null);
+ * </pre>
+ * </dd>
+ * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
+ * <dd>
+ * <pre>
+ * ContentValues values = new ContentValues();
+ * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
+ * values.put(StreamItemPhotos.PICTURE, newPhotoData);
+ * getContentResolver().update(StreamItems.CONTENT_PHOTO_URI, values);
+ * </pre>
+ * </dd>
+ * </dl>
+ * </p>
+ * </dd>
+ * <dt><b>Delete</b></dt>
+ * <dd>Deletes can be made against either a specific photo item in a stream item, or
+ * against all or a selected subset of photo items under a stream item.
+ * For example:
+ * <dl>
+ * <dt>Deleting a single photo via the
+ * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
+ * </dt>
+ * <dd>
+ * <pre>
+ * getContentResolver().delete(
+ * ContentUris.withAppendedId(
+ * Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
+ * streamItemPhotoId), null, null);
+ * </pre>
+ * </dd>
+ * <dt>Deleting all photos under a stream item</dt>
+ * <dd>
+ * <pre>
+ * getContentResolver().delete(
+ * Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), null, null);
+ * </pre>
+ * </dd>
+ * </dl>
+ * </dd>
+ * <dt><b>Query</b></dt>
+ * <dl>
+ * <dt>Querying for a specific photo in a stream item</dt>
+ * <dd>
+ * <pre>
+ * Cursor c = getContentResolver().query(
+ * ContentUris.withAppendedId(
+ * Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
+ * streamItemPhotoId), null, null, null, null);
+ * </pre>
+ * </dd>
+ * <dt>Querying for all photos in a stream item</dt>
+ * <dd>
+ * <pre>
+ * Cursor c = getContentResolver().query(
+ * Uri.withAppendedPath(
+ * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
+ * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
+ * null, null, null, StreamItemPhotos.SORT_INDEX);
+ * </pre>
+ * </dl>
+ * </dd>
+ * </dl>
+ */
+ public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
+ /**
+ * No public constructor since this is a utility class
+ */
+ private StreamItemPhotos() {
+ }
+ }
+
+ /**
+ * Columns in the StreamItemPhotos table.
+ *
+ * @see ContactsContract.StreamItemPhotos
+ */
+ protected interface StreamItemPhotosColumns {
+ /**
+ * A reference to the {@link StreamItems#_ID} this photo is associated with.
+ * <P>Type: NUMBER</P>
+ */
+ public static final String STREAM_ITEM_ID = "stream_item_id";
+
+ /**
+ * An integer to use for sort order for photos in the stream item. If not
+ * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
+ * <P>Type: NUMBER</P>
+ */
+ public static final String SORT_INDEX = "sort_index";
+
+ /**
+ * The binary representation of the picture. Pictures larger than
+ * {@link ContactsContract.StreamItems#PHOTO_MAX_BYTES} bytes in size (as
+ * queryable from {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI})
+ * will be rejected.
+ * <P>Type: BLOB</P>
+ */
+ public static final String PICTURE = "picture";
+
+ /**
+ * The activity action to execute when the photo is tapped.
+ * <P>Type: TEXT</P>
+ */
+ public static final String ACTION = "action";
+
+ /**
+ * The URI that is launched when the photo is pressed. May be handled by
+ * the source app, but could also reference a website (e.g. YouTube).
+ * <P>Type: TEXT</P>
+ */
+ public static final String ACTION_URI = "action_uri";
+ }
+
+ /**
* Columns in the Data table.
*
* @see ContactsContract.Data
diff --git a/core/java/android/speech/tts/AudioPlaybackHandler.java b/core/java/android/speech/tts/AudioPlaybackHandler.java
index c7603ee..8ef4295 100644
--- a/core/java/android/speech/tts/AudioPlaybackHandler.java
+++ b/core/java/android/speech/tts/AudioPlaybackHandler.java
@@ -384,11 +384,16 @@
}
count += written;
}
+
+ param.mLogger.onPlaybackStart();
}
private void handleSynthesisDone(MessageParams msg) {
final SynthesisMessageParams params = (SynthesisMessageParams) msg;
handleSynthesisDone(params);
+ // This call is delayed more than it should be, but we are
+ // certain at this point that we have all the data we want.
+ params.mLogger.onWriteData();
}
// Flush all remaining data to the audio track, stop it and release
@@ -416,6 +421,8 @@
final SynthesisMessageParams params = (SynthesisMessageParams) msg;
if (DBG) Log.d(TAG, "completeAudioAvailable(" + params + ")");
+ params.mLogger.onPlaybackStart();
+
// Channel config and bytes per frame are checked before
// this message is sent.
int channelConfig = AudioPlaybackHandler.getChannelConfig(params.mChannelCount);
diff --git a/core/java/android/speech/tts/EventLogTags.logtags b/core/java/android/speech/tts/EventLogTags.logtags
new file mode 100644
index 0000000..1a9f5fe
--- /dev/null
+++ b/core/java/android/speech/tts/EventLogTags.logtags
@@ -0,0 +1,6 @@
+# See system/core/logcat/event.logtags for a description of the format of this file.
+
+option java_package android.speech.tts;
+
+76001 tts_speak_success (engine|3),(caller|3),(length|1),(locale|3),(rate|1),(pitch|1),(engine_latency|2|3),(engine_total|2|3),(audio_latency|2|3)
+76002 tts_speak_failure (engine|3),(caller|3),(length|1),(locale|3),(rate|1),(pitch|1)
diff --git a/core/java/android/speech/tts/EventLogger.java b/core/java/android/speech/tts/EventLogger.java
new file mode 100644
index 0000000..63b954b
--- /dev/null
+++ b/core/java/android/speech/tts/EventLogger.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package android.speech.tts;
+
+import android.os.SystemClock;
+import android.text.TextUtils;
+
+/**
+ * Writes data about a given speech synthesis request to the event logs.
+ * The data that is logged includes the calling app, length of the utterance,
+ * speech rate / pitch and the latency and overall time taken.
+ *
+ * Note that {@link EventLogger#onStopped()} and {@link EventLogger#onError()}
+ * might be called from any thread, but on {@link EventLogger#onPlaybackStart()} and
+ * {@link EventLogger#onComplete()} must be called from a single thread
+ * (usually the audio playback thread}
+ */
+class EventLogger {
+ private final SynthesisRequest mRequest;
+ private final String mCallingApp;
+ private final String mServiceApp;
+ private final long mReceivedTime;
+ private long mPlaybackStartTime = -1;
+ private volatile long mRequestProcessingStartTime = -1;
+ private volatile long mEngineStartTime = -1;
+ private volatile long mEngineCompleteTime = -1;
+
+ private volatile boolean mError = false;
+ private volatile boolean mStopped = false;
+ private boolean mLogWritten = false;
+
+ EventLogger(SynthesisRequest request, String callingApp,
+ String serviceApp) {
+ mRequest = request;
+ mCallingApp = callingApp;
+ mServiceApp = serviceApp;
+ mReceivedTime = SystemClock.elapsedRealtime();
+ }
+
+ /**
+ * Notifies the logger that this request has been selected from
+ * the processing queue for processing. Engine latency / total time
+ * is measured from this baseline.
+ */
+ public void onRequestProcessingStart() {
+ mRequestProcessingStartTime = SystemClock.elapsedRealtime();
+ }
+
+ /**
+ * Notifies the logger that a chunk of data has been received from
+ * the engine. Might be called multiple times.
+ */
+ public void onEngineDataReceived() {
+ if (mEngineStartTime == -1) {
+ mEngineStartTime = SystemClock.elapsedRealtime();
+ }
+ }
+
+ /**
+ * Notifies the logger that the engine has finished processing data.
+ * Will be called exactly once.
+ */
+ public void onEngineComplete() {
+ mEngineCompleteTime = SystemClock.elapsedRealtime();
+ }
+
+ /**
+ * Notifies the logger that audio playback has started for some section
+ * of the synthesis. This is normally some amount of time after the engine
+ * has synthesized data and varides depending on utterances and
+ * other audio currently in the queue.
+ */
+ public void onPlaybackStart() {
+ // For now, keep track of only the first chunk of audio
+ // that was played.
+ if (mPlaybackStartTime == -1) {
+ mPlaybackStartTime = SystemClock.elapsedRealtime();
+ }
+ }
+
+ /**
+ * Notifies the logger that the current synthesis was stopped.
+ * Latency numbers are not reported for stopped syntheses.
+ */
+ public void onStopped() {
+ mStopped = false;
+ }
+
+ /**
+ * Notifies the logger that the current synthesis resulted in
+ * an error. This is logged using {@link EventLogTags#writeTtsSpeakFailure}.
+ */
+ public void onError() {
+ mError = true;
+ }
+
+ /**
+ * Notifies the logger that the current synthesis has completed.
+ * All available data is not logged.
+ */
+ public void onWriteData() {
+ if (mLogWritten) {
+ return;
+ } else {
+ mLogWritten = true;
+ }
+
+ long completionTime = SystemClock.elapsedRealtime();
+ // onPlaybackStart() should normally always be called if an
+ // error does not occur.
+ if (mError || mPlaybackStartTime == -1 || mEngineCompleteTime == -1) {
+ EventLogTags.writeTtsSpeakFailure(mServiceApp, mCallingApp,
+ getUtteranceLength(), getLocaleString(),
+ mRequest.getSpeechRate(), mRequest.getPitch());
+ return;
+ }
+
+ // We don't report stopped syntheses because their overall
+ // total time spent will be innacurate (will not correlate with
+ // the length of the utterance).
+ if (mStopped) {
+ return;
+ }
+
+ final long audioLatency = mPlaybackStartTime - mReceivedTime;
+ final long engineLatency = mEngineStartTime - mRequestProcessingStartTime;
+ final long engineTotal = mEngineCompleteTime - mRequestProcessingStartTime;
+ EventLogTags.writeTtsSpeakSuccess(mServiceApp, mCallingApp,
+ getUtteranceLength(), getLocaleString(),
+ mRequest.getSpeechRate(), mRequest.getPitch(),
+ engineLatency, engineTotal, audioLatency);
+ }
+
+ /**
+ * @return the length of the utterance for the given synthesis, 0
+ * if the utterance was {@code null}.
+ */
+ private int getUtteranceLength() {
+ final String utterance = mRequest.getText();
+ return utterance == null ? 0 : utterance.length();
+ }
+
+ /**
+ * Returns a formatted locale string from the synthesis params of the
+ * form lang-country-variant.
+ */
+ private String getLocaleString() {
+ StringBuilder sb = new StringBuilder(mRequest.getLanguage());
+ if (!TextUtils.isEmpty(mRequest.getCountry())) {
+ sb.append('-');
+ sb.append(mRequest.getCountry());
+
+ if (!TextUtils.isEmpty(mRequest.getVariant())) {
+ sb.append('-');
+ sb.append(mRequest.getVariant());
+ }
+ }
+
+ return sb.toString();
+ }
+
+}
diff --git a/core/java/android/speech/tts/PlaybackSynthesisCallback.java b/core/java/android/speech/tts/PlaybackSynthesisCallback.java
index bdaa1b8..38030a6 100644
--- a/core/java/android/speech/tts/PlaybackSynthesisCallback.java
+++ b/core/java/android/speech/tts/PlaybackSynthesisCallback.java
@@ -65,29 +65,42 @@
private final UtteranceCompletedDispatcher mDispatcher;
private final String mCallingApp;
+ private final EventLogger mLogger;
PlaybackSynthesisCallback(int streamType, float volume, float pan,
AudioPlaybackHandler audioTrackHandler, UtteranceCompletedDispatcher dispatcher,
- String callingApp) {
+ String callingApp, EventLogger logger) {
mStreamType = streamType;
mVolume = volume;
mPan = pan;
mAudioTrackHandler = audioTrackHandler;
mDispatcher = dispatcher;
mCallingApp = callingApp;
+ mLogger = logger;
}
@Override
void stop() {
if (DBG) Log.d(TAG, "stop()");
+ // Note that mLogger.mError might be true too at this point.
+ mLogger.onStopped();
+
synchronized (mStateLock) {
- if (mToken == null || mStopped) {
- Log.w(TAG, "stop() called twice, before start(), or after done()");
+ if (mStopped) {
+ Log.w(TAG, "stop() called twice");
return;
}
- mAudioTrackHandler.stop(mToken);
- mToken = null;
+ // mToken will be null if the engine encounters
+ // an error before it called start().
+ if (mToken != null) {
+ mAudioTrackHandler.stop(mToken);
+ mToken = null;
+ } else {
+ // In all other cases, mAudioTrackHandler.stop() will
+ // result in onComplete being called.
+ mLogger.onWriteData();
+ }
mStopped = true;
}
}
@@ -124,7 +137,7 @@
}
SynthesisMessageParams params = new SynthesisMessageParams(
mStreamType, sampleRateInHz, audioFormat, channelCount, mVolume, mPan,
- mDispatcher, mCallingApp);
+ mDispatcher, mCallingApp, mLogger);
mAudioTrackHandler.enqueueSynthesisStart(params);
mToken = params;
@@ -157,6 +170,8 @@
mAudioTrackHandler.enqueueSynthesisDataAvailable(mToken);
}
+ mLogger.onEngineDataReceived();
+
return TextToSpeech.SUCCESS;
}
@@ -177,6 +192,7 @@
}
mAudioTrackHandler.enqueueSynthesisDone(mToken);
+ mLogger.onEngineComplete();
}
return TextToSpeech.SUCCESS;
}
@@ -184,6 +200,9 @@
@Override
public void error() {
if (DBG) Log.d(TAG, "error() [will call stop]");
+ // Currently, this call will not be logged if error( ) is called
+ // before start.
+ mLogger.onError();
stop();
}
@@ -208,7 +227,7 @@
}
SynthesisMessageParams params = new SynthesisMessageParams(
mStreamType, sampleRateInHz, audioFormat, channelCount, mVolume, mPan,
- mDispatcher, mCallingApp);
+ mDispatcher, mCallingApp, mLogger);
params.addBuffer(buffer, offset, length);
mAudioTrackHandler.enqueueSynthesisCompleteDataAvailable(params);
diff --git a/core/java/android/speech/tts/SynthesisMessageParams.java b/core/java/android/speech/tts/SynthesisMessageParams.java
index 51f3d2e..caf02ef 100644
--- a/core/java/android/speech/tts/SynthesisMessageParams.java
+++ b/core/java/android/speech/tts/SynthesisMessageParams.java
@@ -30,6 +30,7 @@
final int mChannelCount;
final float mVolume;
final float mPan;
+ final EventLogger mLogger;
public volatile AudioTrack mAudioTrack;
@@ -38,7 +39,7 @@
SynthesisMessageParams(int streamType, int sampleRate,
int audioFormat, int channelCount,
float volume, float pan, UtteranceCompletedDispatcher dispatcher,
- String callingApp) {
+ String callingApp, EventLogger logger) {
super(dispatcher, callingApp);
mStreamType = streamType;
@@ -47,6 +48,7 @@
mChannelCount = channelCount;
mVolume = volume;
mPan = pan;
+ mLogger = logger;
// initially null.
mAudioTrack = null;
diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java
index 7ea9373..010c155 100644
--- a/core/java/android/speech/tts/TextToSpeechService.java
+++ b/core/java/android/speech/tts/TextToSpeechService.java
@@ -82,8 +82,7 @@
private AudioPlaybackHandler mAudioPlaybackHandler;
private CallbackMap mCallbacks;
-
- private int mDefaultAvailability = TextToSpeech.LANG_NOT_SUPPORTED;
+ private String mPackageName;
@Override
public void onCreate() {
@@ -99,9 +98,10 @@
mCallbacks = new CallbackMap();
+ mPackageName = getApplicationInfo().packageName;
+
// Load default language
- mDefaultAvailability = onLoadLanguage(getDefaultLanguage(),
- getDefaultCountry(), getDefaultVariant());
+ onLoadLanguage(getDefaultLanguage(), getDefaultCountry(), getDefaultVariant());
}
@Override
@@ -457,12 +457,14 @@
// Non null after synthesis has started, and all accesses
// guarded by 'this'.
private AbstractSynthesisCallback mSynthesisCallback;
+ private final EventLogger mEventLogger;
public SynthesisSpeechItem(String callingApp, Bundle params, String text) {
super(callingApp, params);
mText = text;
mSynthesisRequest = new SynthesisRequest(mText, mParams);
setRequestParams(mSynthesisRequest);
+ mEventLogger = new EventLogger(mSynthesisRequest, getCallingApp(), mPackageName);
}
public String getText() {
@@ -485,6 +487,7 @@
@Override
protected int playImpl() {
AbstractSynthesisCallback synthesisCallback;
+ mEventLogger.onRequestProcessingStart();
synchronized (this) {
mSynthesisCallback = createSynthesisCallback();
synthesisCallback = mSynthesisCallback;
@@ -495,7 +498,7 @@
protected AbstractSynthesisCallback createSynthesisCallback() {
return new PlaybackSynthesisCallback(getStreamType(), getVolume(), getPan(),
- mAudioPlaybackHandler, this, getCallingApp());
+ mAudioPlaybackHandler, this, getCallingApp(), mEventLogger);
}
private void setRequestParams(SynthesisRequest request) {
diff --git a/core/java/android/text/method/AllCapsTransformationMethod.java b/core/java/android/text/method/AllCapsTransformationMethod.java
new file mode 100644
index 0000000..f9920dd
--- /dev/null
+++ b/core/java/android/text/method/AllCapsTransformationMethod.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.text.method;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.Log;
+import android.view.View;
+
+import java.util.Locale;
+
+/**
+ * Transforms source text into an ALL CAPS string, locale-aware.
+ *
+ * @hide
+ */
+public class AllCapsTransformationMethod implements TransformationMethod2 {
+ private static final String TAG = "AllCapsTransformationMethod";
+
+ private boolean mEnabled;
+ private Locale mLocale;
+
+ public AllCapsTransformationMethod(Context context) {
+ mLocale = context.getResources().getConfiguration().locale;
+ }
+
+ @Override
+ public CharSequence getTransformation(CharSequence source, View view) {
+ if (mEnabled) {
+ return source != null ? source.toString().toUpperCase(mLocale) : null;
+ }
+ Log.w(TAG, "Caller did not enable length changes; not transforming text");
+ return source;
+ }
+
+ @Override
+ public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction,
+ Rect previouslyFocusedRect) {
+ }
+
+ @Override
+ public void setLengthChangesAllowed(boolean allowLengthChanges) {
+ mEnabled = allowLengthChanges;
+ }
+
+}
diff --git a/core/java/android/text/method/TransformationMethod2.java b/core/java/android/text/method/TransformationMethod2.java
new file mode 100644
index 0000000..ef00ecd
--- /dev/null
+++ b/core/java/android/text/method/TransformationMethod2.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.text.method;
+
+/**
+ * TransformationMethod2 extends the TransformationMethod interface
+ * and adds the ability to relax restrictions of TransformationMethod.
+ *
+ * @hide
+ */
+public interface TransformationMethod2 extends TransformationMethod {
+ /**
+ * Relax the contract of TransformationMethod to allow length changes,
+ * or revert to the length-restricted behavior.
+ *
+ * @param allowLengthChanges true to allow the transformation to change the length
+ * of the input string.
+ */
+ public void setLengthChangesAllowed(boolean allowLengthChanges);
+}
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 04f35dc..4987e2f 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -189,6 +189,19 @@
return mHeight;
}
+ @Override
+ public int getMaximumBitmapWidth() {
+ return nGetMaximumTextureWidth();
+ }
+
+ @Override
+ public int getMaximumBitmapHeight() {
+ return nGetMaximumTextureHeight();
+ }
+
+ private static native int nGetMaximumTextureWidth();
+ private static native int nGetMaximumTextureHeight();
+
///////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////
@@ -233,8 +246,19 @@
return nIsBackBufferPreserved();
}
- private static native boolean nIsBackBufferPreserved();
-
+ private static native boolean nIsBackBufferPreserved();
+
+ /**
+ * Disables v-sync. For performance testing only.
+ *
+ * @hide
+ */
+ public static void disableVsync() {
+ nDisableVsync();
+ }
+
+ private static native void nDisableVsync();
+
@Override
void onPreDraw(Rect dirty) {
if (dirty != null) {
@@ -252,7 +276,7 @@
void onPostDraw() {
nFinish(mRenderer);
}
-
+
private static native void nFinish(int renderer);
@Override
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index bbfb4c1..188970c 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -57,6 +57,16 @@
* "false", to disable partial invalidates
*/
static final String RENDER_DIRTY_REGIONS_PROPERTY = "hwui.render_dirty_regions";
+
+ /**
+ * System property used to enable or disable vsync.
+ * The default value of this property is assumed to be false.
+ *
+ * Possible values:
+ * "true", to disable vsync
+ * "false", to enable vsync
+ */
+ static final String DISABLE_VSYNC_PROPERTY = "hwui.disable_vsync";
/**
* Turn on to draw dirty regions every other frame.
@@ -303,6 +313,7 @@
boolean mDirtyRegions;
final boolean mDirtyRegionsRequested;
+ final boolean mVsyncDisabled;
final int mGlVersion;
final boolean mTranslucent;
@@ -314,10 +325,17 @@
GlRenderer(int glVersion, boolean translucent) {
mGlVersion = glVersion;
mTranslucent = translucent;
+
final String dirtyProperty = SystemProperties.get(RENDER_DIRTY_REGIONS_PROPERTY, "true");
//noinspection PointlessBooleanExpression,ConstantConditions
mDirtyRegions = RENDER_DIRTY_REGIONS && "true".equalsIgnoreCase(dirtyProperty);
mDirtyRegionsRequested = mDirtyRegions;
+
+ final String vsyncProperty = SystemProperties.get(DISABLE_VSYNC_PROPERTY, "false");
+ mVsyncDisabled = "true".equalsIgnoreCase(vsyncProperty);
+ if (mVsyncDisabled) {
+ Log.d(LOG_TAG, "Disabling v-sync");
+ }
}
/**
@@ -765,6 +783,14 @@
}
@Override
+ void setup(int width, int height) {
+ super.setup(width, height);
+ if (mVsyncDisabled) {
+ GLES20Canvas.disableVsync();
+ }
+ }
+
+ @Override
DisplayList createDisplayList(View v) {
return new GLES20DisplayList(v);
}
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 72263a7..88f59d4 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -2881,10 +2881,6 @@
msg.append(", id[").append(i).append("]=").append(getPointerId(i));
msg.append(", x[").append(i).append("]=").append(getX(i));
msg.append(", y[").append(i).append("]=").append(getY(i));
- msg.append(", pressure[").append(i).append("]=").append(getPressure(i));
- msg.append(", touchMajor[").append(i).append("]=").append(getTouchMajor(i));
- msg.append(", touchMinor[").append(i).append("]=").append(getTouchMinor(i));
- msg.append(", orientation[").append(i).append("]=").append(getOrientation(i));
msg.append(", toolType[").append(i).append("]=").append(
toolTypeToString(getToolType(i)));
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 41412de..e6fdb17 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -46,7 +46,6 @@
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Locale;
/**
* <p>
@@ -5019,7 +5018,7 @@
*/
@Override
protected void resolveTextDirection() {
- int resolvedTextDirection = TEXT_DIRECTION_UNDEFINED;
+ int resolvedTextDirection;
switch(mTextDirection) {
default:
case TEXT_DIRECTION_INHERIT:
diff --git a/core/java/android/webkit/L10nUtils.java b/core/java/android/webkit/L10nUtils.java
index 4c42cde..f9d0067d 100644
--- a/core/java/android/webkit/L10nUtils.java
+++ b/core/java/android/webkit/L10nUtils.java
@@ -74,7 +74,8 @@
com.android.internal.R.string.autofill_country_code_re, // IDS_AUTOFILL_COUNTRY_CODE_RE
com.android.internal.R.string.autofill_area_code_notext_re, // IDS_AUTOFILL_AREA_CODE_NOTEXT_RE
com.android.internal.R.string.autofill_phone_prefix_separator_re, // IDS_AUTOFILL_PHONE_PREFIX_SEPARATOR_RE
- com.android.internal.R.string.autofill_phone_suffix_separator_re // IDS_AUTOFILL_PHONE_SUFFIX_SEPARATOR_RE
+ com.android.internal.R.string.autofill_phone_suffix_separator_re, // IDS_AUTOFILL_PHONE_SUFFIX_SEPARATOR_RE
+ com.android.internal.R.string.credit_card_number_preview_format // IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT
};
private static Context mApplicationContext;
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index ffa52d1..7ba86a5 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -3467,40 +3467,6 @@
return Math.min(duration, MAX_DURATION);
}
-
- // Helper to build a TouchEventData object from a MotionEvent object.
- // A few fields are allocated now but will be set later:
- // mAction, mPoints and mPointsInView.
- private static TouchEventData buildTouchFromEvent(MotionEvent ev) {
- TouchEventData ted = new TouchEventData();
- ted.mAction = ev.getActionMasked();
- ted.mEventTime = ev.getEventTime();
-
- final int count = ev.getPointerCount();
- ted.mIds = new int[count];
- ted.mPoints = new Point[count];
- ted.mPointsInView = new Point[count];
- ted.mPressures = new float[count];
- ted.mTouchMajor = new int[count];
- ted.mTouchMinor = new int[count];
- ted.mOrientation = new float[count];
- for (int c = 0; c < count; c++) {
- ted.mIds[c] = ev.getPointerId(c);
- ted.mPressures[c] = ev.getPressure(c);
- ted.mTouchMajor[c] = (int) ev.getTouchMajor(c);
- ted.mTouchMinor[c] = (int) ev.getTouchMinor(c);
- ted.mOrientation[c] = ev.getOrientation(c);
- }
-
- if (ted.mAction == MotionEvent.ACTION_POINTER_DOWN
- || ted.mAction == MotionEvent.ACTION_POINTER_UP) {
- ted.mActionIndex = ev.getActionIndex();
- }
- ted.mMetaState = ev.getMetaState();
-
- return ted;
- }
-
// helper to pin the scrollBy parameters (already in view coordinates)
// returns true if the scroll was changed
private boolean pinScrollBy(int dx, int dy, boolean animate, int animationDuration) {
@@ -5899,10 +5865,15 @@
}
// pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent()) {
- TouchEventData ted = buildTouchFromEvent(ev);
+ TouchEventData ted = new TouchEventData();
ted.mAction = action;
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
+ ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
ted.mPointsInView[0] = new Point(x, y);
+ ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = nativeScrollableLayer(
contentX, contentY, ted.mNativeLayerRect, null);
@@ -5944,10 +5915,15 @@
// pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent() && mConfirmMove && (firstMove
|| eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
- TouchEventData ted = buildTouchFromEvent(ev);
+ TouchEventData ted = new TouchEventData();
ted.mAction = action;
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
+ ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
ted.mPointsInView[0] = new Point(x, y);
+ ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = mScrollingLayer;
ted.mNativeLayerRect.set(mScrollingLayerRect);
@@ -6117,10 +6093,15 @@
if (!isFocused()) requestFocus();
// pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent()) {
- TouchEventData ted = buildTouchFromEvent(ev);
+ TouchEventData ted = new TouchEventData();
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mAction = action;
+ ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
ted.mPointsInView[0] = new Point(x, y);
+ ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = mScrollingLayer;
ted.mNativeLayerRect.set(mScrollingLayerRect);
@@ -6137,10 +6118,15 @@
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
if (inFullScreenMode() || mDeferTouchProcess) {
- TouchEventData ted = buildTouchFromEvent(ev);
+ TouchEventData ted = new TouchEventData();
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mAction = WebViewCore.ACTION_DOUBLETAP;
+ ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
ted.mPointsInView[0] = new Point(x, y);
+ ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = nativeScrollableLayer(
contentX, contentY,
@@ -6272,14 +6258,24 @@
}
private void passMultiTouchToWebKit(MotionEvent ev, long sequence) {
- TouchEventData ted = buildTouchFromEvent(ev);
- for (int c = 0; c < ev.getPointerCount(); c++) {
+ TouchEventData ted = new TouchEventData();
+ ted.mAction = ev.getActionMasked();
+ final int count = ev.getPointerCount();
+ ted.mIds = new int[count];
+ ted.mPoints = new Point[count];
+ ted.mPointsInView = new Point[count];
+ for (int c = 0; c < count; c++) {
ted.mIds[c] = ev.getPointerId(c);
int x = viewToContentX((int) ev.getX(c) + mScrollX);
int y = viewToContentY((int) ev.getY(c) + mScrollY);
ted.mPoints[c] = new Point(x, y);
ted.mPointsInView[c] = new Point((int) ev.getX(c), (int) ev.getY(c));
}
+ if (ted.mAction == MotionEvent.ACTION_POINTER_DOWN
+ || ted.mAction == MotionEvent.ACTION_POINTER_UP) {
+ ted.mActionIndex = ev.getActionIndex();
+ }
+ ted.mMetaState = ev.getMetaState();
ted.mReprocess = true;
ted.mMotionEvent = MotionEvent.obtain(ev);
ted.mSequence = sequence;
@@ -6353,11 +6349,7 @@
if (removeEvents) {
mWebViewCore.removeMessages(EventHub.TOUCH_EVENT);
}
-
TouchEventData ted = new TouchEventData();
- ted.mAction = MotionEvent.ACTION_CANCEL;
- ted.mEventTime = mLastTouchTime;
- ted.mMetaState = 0;
ted.mIds = new int[1];
ted.mIds[0] = 0;
ted.mPoints = new Point[1];
@@ -6366,15 +6358,7 @@
int viewX = contentToViewX(x) - mScrollX;
int viewY = contentToViewY(y) - mScrollY;
ted.mPointsInView[0] = new Point(viewX, viewY);
- ted.mPressures = new float[1];
- ted.mPressures[0] = 1;
- ted.mTouchMajor = new int[1];
- ted.mTouchMajor[0] = 1;
- ted.mTouchMinor = new int[1];
- ted.mTouchMinor[0] = 1;
- ted.mOrientation = new float[1];
- ted.mOrientation[0] = 0;
-
+ ted.mAction = MotionEvent.ACTION_CANCEL;
ted.mNativeLayer = nativeScrollableLayer(
x, y, ted.mNativeLayerRect, null);
ted.mSequence = mTouchEventQueue.nextTouchSequence();
@@ -8053,7 +8037,6 @@
if (inFullScreenMode() || mDeferTouchProcess) {
TouchEventData ted = new TouchEventData();
ted.mAction = WebViewCore.ACTION_LONGPRESS;
- ted.mEventTime = mLastTouchTime;
ted.mIds = new int[1];
ted.mIds[0] = 0;
ted.mPoints = new Point[1];
@@ -8061,15 +8044,6 @@
viewToContentY(mLastTouchY + mScrollY));
ted.mPointsInView = new Point[1];
ted.mPointsInView[0] = new Point(mLastTouchX, mLastTouchY);
- ted.mPressures = new float[1];
- ted.mPressures[0] = 1;
- ted.mTouchMajor = new int[1];
- ted.mTouchMajor[0] = 1;
- ted.mTouchMinor = new int[1];
- ted.mTouchMinor[0] = 1;
- ted.mOrientation = new float[1];
- ted.mOrientation[0] = 0;
-
// metaState for long press is tricky. Should it be the
// state when the press started or when the press was
// released? Or some intermediary key state? For
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 3357220..c652e55 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -577,10 +577,8 @@
private native void nativeTouchUp(int touchGeneration,
int framePtr, int nodePtr, int x, int y);
- private native boolean nativeHandleTouchEvent(int action, long eventTime,
- int[] idArray, int[] xArray, int[] yArray, float[] pressureArray,
- int[] touchMajorArray, int[] touchMinorArray, float[] orientationArray,
- int count, int actionIndex, int metaState);
+ private native boolean nativeHandleTouchEvent(int action, int[] idArray,
+ int[] xArray, int[] yArray, int count, int actionIndex, int metaState);
private native void nativeUpdateFrameCache();
@@ -835,21 +833,16 @@
static class TouchEventData {
int mAction;
- long mEventTime; // Time (in ms) this event was generated.
- int[] mIds; // Ids of the touch points.
+ int[] mIds; // Ids of the touch points
Point[] mPoints;
- Point[] mPointsInView; // Point coordinates in view axis.
- float[] mPressures; // Pressures of the touch points.
- int[] mTouchMajor; // Length of the major axis of the touch area.
- int[] mTouchMinor; // Length of the minor axis of the touch area.
- float[] mOrientation; // The orientation of the touch area.
- int mActionIndex; // Associated pointer index for ACTION_POINTER_DOWN/UP.
+ Point[] mPointsInView; // the point coordinates in view axis.
+ int mActionIndex; // Associated pointer index for ACTION_POINTER_DOWN/UP
int mMetaState;
boolean mReprocess;
- MotionEvent mMotionEvent; // Only used for multi-touch.
+ MotionEvent mMotionEvent;
int mNativeLayer;
Rect mNativeLayerRect = new Rect();
- long mSequence; // For queuing the events.
+ long mSequence;
boolean mNativeResult;
}
@@ -1358,11 +1351,8 @@
nativeScrollLayer(ted.mNativeLayer,
ted.mNativeLayerRect);
}
- ted.mNativeResult = nativeHandleTouchEvent(
- ted.mAction, ted.mEventTime, ted.mIds,
- xArray, yArray, ted.mPressures,
- ted.mTouchMajor, ted.mTouchMinor, ted.mOrientation,
- count, ted.mActionIndex, ted.mMetaState);
+ ted.mNativeResult = nativeHandleTouchEvent(ted.mAction, ted.mIds,
+ xArray, yArray, count, ted.mActionIndex, ted.mMetaState);
Message.obtain(
mWebView.mPrivateHandler,
WebView.PREVENT_TOUCH_ID,
@@ -2245,16 +2235,15 @@
// called by JNI
private void updateViewport() {
- // if updateViewport is called before first layout, wait until first
- // layout to update the viewport. In the rare case, this is called after
- // first layout, force an update as we have just parsed the viewport
- // meta tag.
- if (mBrowserFrame.firstLayoutDone()) {
- setupViewport(true);
- }
+ // Update viewport asap to make sure we get correct one.
+ setupViewport(true);
}
private void setupViewport(boolean updateViewState) {
+ if (mWebView == null || mSettings == null) {
+ // We've been destroyed or are being destroyed, return early
+ return;
+ }
// set the viewport settings from WebKit
setViewportSettingsFromNative();
@@ -2385,8 +2374,12 @@
(float) webViewWidth / mViewportWidth;
} else {
mInitialViewState.mTextWrapScale = adjust;
- // 0 will trigger WebView to turn on zoom overview mode
- mInitialViewState.mViewScale = 0;
+ if (mSettings.getUseWideViewPort()) {
+ // 0 will trigger WebView to turn on zoom overview mode
+ mInitialViewState.mViewScale = 0;
+ } else {
+ mInitialViewState.mViewScale = adjust;
+ }
}
}
@@ -2417,7 +2410,7 @@
mEventHub.removeMessages(EventHub.VIEW_SIZE_CHANGED);
mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,
EventHub.VIEW_SIZE_CHANGED, data));
- } else if (mSettings.getUseWideViewPort()) {
+ } else {
if (viewportWidth == 0) {
// Trick to ensure VIEW_SIZE_CHANGED will be sent from WebView
// to WebViewCore
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index 7c0470e..c2759e5 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -92,10 +92,8 @@
*
* <h4>Excess Space Distribution</h4>
*
- * Like {@link LinearLayout}, a child's ability to stretch is controlled
- * using <em>weights</em>, which are specified using the
- * {@link GridLayout.LayoutParams#widthSpec widthSpec} and
- * {@link GridLayout.LayoutParams#heightSpec heightSpec} layout parameters.
+ * A child's ability to stretch is controlled using the {@link Group#flexibility flexibility}
+ * properties of its row and column groups.
* <p>
* <p>
* See {@link GridLayout.LayoutParams} for a full description of the
@@ -1055,7 +1053,7 @@
if (isGone(c)) continue;
LayoutParams lp = getLayoutParams(c);
Group g = horizontal ? lp.columnGroup : lp.rowGroup;
- groupBounds.getValue(i).include(c, g, GridLayout.this, this, lp);
+ groupBounds.getValue(i).include(c, g, GridLayout.this, this);
}
}
@@ -1087,13 +1085,17 @@
spans[i].reset();
}
- // use getter to trigger a re-evaluation
+ // Use getter to trigger a re-evaluation
Bounds[] bounds = getGroupBounds().values;
for (int i = 0; i < bounds.length; i++) {
int size = bounds[i].size(min);
- int value = min ? size : -size;
MutableInt valueHolder = links.getValue(i);
- valueHolder.value = max(valueHolder.value, value);
+ if (min) {
+ valueHolder.value = max(valueHolder.value, size);
+ }
+ else {
+ valueHolder.value = -max(-valueHolder.value, size);
+ }
}
}
@@ -1155,7 +1157,7 @@
int[] sizes = new int[N];
for (Arc arc : arcs) {
sizes[arc.span.min]++;
- }
+ }
for (int i = 0; i < sizes.length; i++) {
result[i] = new Arc[sizes[i]];
}
@@ -1622,16 +1624,14 @@
* <li>{@link #rowGroup}{@code .alignment} = {@link #BASELINE} </li>
* <li>{@link #columnGroup}{@code .span} = {@code [0, 1]} </li>
* <li>{@link #columnGroup}{@code .alignment} = {@link #LEFT} </li>
- * <li>{@link #widthSpec} = {@link #FIXED} </li>
- * <li>{@link #heightSpec} = {@link #FIXED} </li>
* </ul>
*
* @attr ref android.R.styleable#GridLayout_Layout_layout_row
* @attr ref android.R.styleable#GridLayout_Layout_layout_rowSpan
- * @attr ref android.R.styleable#GridLayout_Layout_layout_heightSpec
+ * @attr ref android.R.styleable#GridLayout_Layout_layout_rowFlexibility
* @attr ref android.R.styleable#GridLayout_Layout_layout_column
* @attr ref android.R.styleable#GridLayout_Layout_layout_columnSpan
- * @attr ref android.R.styleable#GridLayout_Layout_layout_widthSpec
+ * @attr ref android.R.styleable#GridLayout_Layout_layout_columnFlexibility
* @attr ref android.R.styleable#GridLayout_Layout_layout_gravity
*/
public static class LayoutParams extends MarginLayoutParams {
@@ -1647,19 +1647,12 @@
private static final int DEFAULT_SPAN_SIZE = DEFAULT_SPAN.size();
private static final Alignment DEFAULT_COLUMN_ALIGNMENT = LEFT;
private static final Alignment DEFAULT_ROW_ALIGNMENT = BASELINE;
- private static final Group DEFAULT_COLUMN_GROUP =
- new Group(DEFAULT_SPAN, DEFAULT_COLUMN_ALIGNMENT);
- private static final Group DEFAULT_ROW_GROUP =
- new Group(DEFAULT_SPAN, DEFAULT_ROW_ALIGNMENT);
- private static final Spec DEFAULT_SPEC = FIXED;
- private static final int DEFAULT_SPEC_INDEX = 0;
// Misc
private static final Rect CONTAINER_BOUNDS = new Rect(0, 0, 2, 2);
private static final Alignment[] COLUMN_ALIGNMENTS = { LEFT, CENTER, RIGHT };
private static final Alignment[] ROW_ALIGNMENTS = { TOP, CENTER, BOTTOM };
- private static final Spec[] SPECS = { FIXED, CAN_SHRINK, CAN_STRETCH };
// TypedArray indices
@@ -1672,10 +1665,14 @@
private static final int COLUMN = styleable.GridLayout_Layout_layout_column;
private static final int COLUMN_SPAN = styleable.GridLayout_Layout_layout_columnSpan;
- private static final int WIDTH_SPEC = styleable.GridLayout_Layout_layout_widthSpec;
+ private static final int COLUMN_FLEXIBILITY =
+ styleable.GridLayout_Layout_layout_columnFlexibility;
+
private static final int ROW = styleable.GridLayout_Layout_layout_row;
private static final int ROW_SPAN = styleable.GridLayout_Layout_layout_rowSpan;
- private static final int HEIGHT_SPEC = styleable.GridLayout_Layout_layout_heightSpec;
+ private static final int ROW_FLEXIBILITY =
+ styleable.GridLayout_Layout_layout_rowFlexibility;
+
private static final int GRAVITY = styleable.GridLayout_Layout_layout_gravity;
// Instance variables
@@ -1690,30 +1687,17 @@
* described by these layout parameters.
*/
public Group columnGroup;
- /**
- * The proportional space that should be taken by the associated column group
- * during excess space distribution.
- */
- public Spec widthSpec;
- /**
- * The proportional space that should be taken by the associated row group
- * during excess space distribution.
- */
- public Spec heightSpec;
// Constructors
private LayoutParams(
int width, int height,
int left, int top, int right, int bottom,
- Group rowGroup, Group columnGroup,
- Spec widthSpec, Spec heightSpec) {
+ Group rowGroup, Group columnGroup) {
super(width, height);
setMargins(left, top, right, bottom);
this.rowGroup = rowGroup;
this.columnGroup = columnGroup;
- this.heightSpec = heightSpec;
- this.widthSpec = widthSpec;
}
/**
@@ -1727,14 +1711,15 @@
public LayoutParams(Group rowGroup, Group columnGroup) {
this(DEFAULT_WIDTH, DEFAULT_HEIGHT,
DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN,
- rowGroup, columnGroup, DEFAULT_SPEC, DEFAULT_SPEC);
+ rowGroup, columnGroup);
}
/**
* Constructs a new LayoutParams with default values as defined in {@link LayoutParams}.
*/
public LayoutParams() {
- this(DEFAULT_ROW_GROUP, DEFAULT_COLUMN_GROUP);
+ this(new Group(DEFAULT_SPAN, DEFAULT_ROW_ALIGNMENT),
+ new Group(DEFAULT_SPAN, DEFAULT_COLUMN_ALIGNMENT));
}
// Copying constructors
@@ -1758,10 +1743,8 @@
*/
public LayoutParams(LayoutParams that) {
super(that);
- this.columnGroup = that.columnGroup;
- this.rowGroup = that.rowGroup;
- this.widthSpec = that.widthSpec;
- this.heightSpec = that.heightSpec;
+ this.columnGroup = new Group(that.columnGroup);
+ this.rowGroup = new Group(that.rowGroup);
}
// AttributeSet constructors
@@ -1825,7 +1808,7 @@
// Gravity. For conversion from the static the integers defined in the Gravity class,
// use Gravity.apply() to apply gravity to a view of zero size and see where it ends up.
- private static Alignment getColumnAlignment(int gravity, int width) {
+ private static Alignment getColAlignment(int gravity, int width) {
Rect r = new Rect(0, 0, 0, 0);
Gravity.apply(gravity, 0, 0, CONTAINER_BOUNDS, r);
@@ -1853,14 +1836,14 @@
int column = a.getInt(COLUMN, DEFAULT_COLUMN);
int columnSpan = a.getInt(COLUMN_SPAN, DEFAULT_SPAN_SIZE);
Interval hSpan = new Interval(column, column + columnSpan);
- this.columnGroup = new Group(hSpan, getColumnAlignment(gravity, width));
- this.widthSpec = SPECS[a.getInt(WIDTH_SPEC, DEFAULT_SPEC_INDEX)];
+ int hFlexibility = a.getInt(COLUMN_FLEXIBILITY, Group.DEFAULT_FLEXIBILITY);
+ this.columnGroup = new Group(hSpan, getColAlignment(gravity, width), hFlexibility);
int row = a.getInt(ROW, DEFAULT_ROW);
int rowSpan = a.getInt(ROW_SPAN, DEFAULT_SPAN_SIZE);
Interval vSpan = new Interval(row, row + rowSpan);
- this.rowGroup = new Group(vSpan, getRowAlignment(gravity, height));
- this.heightSpec = SPECS[a.getInt(HEIGHT_SPEC, DEFAULT_SPEC_INDEX)];
+ int vFlexibility = a.getInt(ROW_FLEXIBILITY, Group.DEFAULT_FLEXIBILITY);
+ this.rowGroup = new Group(vSpan, getRowAlignment(gravity, height), vFlexibility);
} finally {
a.recycle();
}
@@ -1875,7 +1858,7 @@
* @attr ref android.R.styleable#GridLayout_Layout_layout_gravity
*/
public void setGravity(int gravity) {
- columnGroup = columnGroup.copyWriteAlignment(getColumnAlignment(gravity, width));
+ columnGroup = columnGroup.copyWriteAlignment(getColAlignment(gravity, width));
rowGroup = rowGroup.copyWriteAlignment(getRowAlignment(gravity, height));
}
@@ -2051,7 +2034,7 @@
public int before;
public int after;
- public boolean canStretch;
+ public int flexibility;
private Bounds() {
reset();
@@ -2060,7 +2043,7 @@
protected void reset() {
before = Integer.MIN_VALUE;
after = Integer.MIN_VALUE;
- canStretch = false;
+ flexibility = UNDEFINED_FLEXIBILITY;
}
protected void include(int before, int after) {
@@ -2069,8 +2052,13 @@
}
protected int size(boolean min) {
- if (!min && canStretch) {
- return MAX_SIZE;
+ if (!min) {
+ // Note in the usual case, components don't define anything
+ // leaving their flexibility is undefined and their stretchability
+ // defined as if the CAN_STRETCH flag was false.
+ if (canStretch(flexibility) && !isUndefined(flexibility)) {
+ return MAX_SIZE;
+ }
}
return before + after;
}
@@ -2079,14 +2067,11 @@
return before - alignment.getAlignmentValue(c, size);
}
- protected void include(View c, Group g, GridLayout gridLayout, Axis axis, LayoutParams lp) {
- Spec spec = axis.horizontal ? lp.widthSpec : lp.heightSpec;
- if (spec == CAN_STRETCH) {
- canStretch = true;
- }
+ protected void include(View c, Group group, GridLayout gridLayout, Axis axis) {
+ this.flexibility &= group.flexibility;
int size = gridLayout.getMeasurementIncludingMargin(c, axis.horizontal);
// todo test this works correctly when the returned value is UNDEFINED
- int before = g.alignment.getAlignmentValue(c, size);
+ int before = group.alignment.getAlignmentValue(c, size);
include(before, size - before);
}
@@ -2198,6 +2183,8 @@
* {@code span} and {@code alignment}.
*/
public static class Group {
+ private static final int DEFAULT_FLEXIBILITY = UNDEFINED_FLEXIBILITY;
+
private static final Group GONE = new Group(Interval.GONE, Alignment.GONE);
/**
@@ -2216,6 +2203,18 @@
public final Alignment alignment;
/**
+ * The flexibility field tells GridLayout how to derive minimum and maximum size
+ * values for a component. Specifications are made with respect to a child's
+ * 'measured size'. A child's measured size is, in turn, controlled by its
+ * height and width layout parameters which either specify a size or, in
+ * the case of {@link LayoutParams#WRAP_CONTENT WRAP_CONTENT}, defer to
+ * the computed size of the component.
+ *
+ * @see GridLayout#CAN_STRETCH
+ */
+ public int flexibility = DEFAULT_FLEXIBILITY;
+
+ /**
* Construct a new Group, {@code group}, where:
* <ul>
* <li> {@code group.span = span} </li>
@@ -2225,11 +2224,24 @@
* @param span the span
* @param alignment the alignment
*/
- Group(Interval span, Alignment alignment) {
+ private Group(Interval span, Alignment alignment) {
this.span = span;
this.alignment = alignment;
}
+ private Group(Interval span, Alignment alignment, int flexibility) {
+ this.span = span;
+ this.alignment = alignment;
+ this.flexibility = flexibility;
+ }
+
+ /* Copying constructor */
+ private Group(Group that) {
+ this.span = that.span;
+ this.alignment = that.alignment;
+ this.flexibility = that.flexibility;
+ }
+
/**
* Construct a new Group, {@code group}, where:
* <ul>
@@ -2260,11 +2272,11 @@
}
private Group copyWriteSpan(Interval span) {
- return new Group(span, alignment);
+ return new Group(span, alignment, flexibility);
}
private Group copyWriteAlignment(Alignment alignment) {
- return new Group(span, alignment);
+ return new Group(span, alignment, flexibility);
}
/**
@@ -2490,40 +2502,54 @@
}
};
- /**
- * Spec's tell GridLayout how to derive minimum and maximum size values for a
- * component. Specifications are made with respect to a child's 'measured size'.
- * A child's measured size is, in turn, controlled by its height and width
- * layout parameters which either specify a size or, in the case of
- * WRAP_CONTENT, defer to the computed size of the component.
- */
- public static abstract class Spec {
+ private static boolean canStretch(int flexibility) {
+ return (flexibility & CAN_STRETCH) != 0;
+ }
+
+ private static boolean isUndefined(int flexibility) {
+ return (flexibility & UNDEFINED) != 0;
}
/**
* Indicates that a view requests precisely the size specified by its layout parameters.
*
- * @see Spec
+ * @see Group#flexibility
+ *
+ * @hide
*/
- public static final Spec FIXED = new Spec() {
- };
+ public static final int FIXED = 0;
/**
* Indicates that a view's size should lie between its minimum and the size specified by
* its layout parameters.
*
- * @see Spec
+ * @see Group#flexibility
+ *
+ * @hide
*/
- public static final Spec CAN_SHRINK = new Spec() {
- };
+ public static final int CAN_SHRINK = 1;
/**
* Indicates that a view's size should be greater than or equal to the size specified by
* its layout parameters.
*
- * @see Spec
+ * @see Group#flexibility
*/
- public static final Spec CAN_STRETCH = new Spec() {
- };
+ public static final int CAN_STRETCH = 2;
+
+ /**
+ * Indicates that a view will ignore its measurement, and can take any size that is greater
+ * than its minimum.
+ *
+ * @see Group#flexibility
+ */
+ private static final int CAN_SHRINK_OR_STRETCH = CAN_SHRINK | CAN_STRETCH;
+
+ /**
+ * A default value for flexibility.
+ *
+ * @see Group#flexibility
+ */
+ private static final int UNDEFINED_FLEXIBILITY = UNDEFINED | CAN_SHRINK | CAN_STRETCH;
}
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index b23a855..485c678 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -231,7 +231,8 @@
}
if (child != null) {
- return child.getTop() + child.getBaseline();
+ final int childBaseline = child.getBaseline();
+ return childBaseline >= 0 ? child.getTop() + childBaseline : -1;
} else {
return -1;
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 772e8e9..1e63e26 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -16,6 +16,11 @@
package android.widget;
+import com.android.internal.util.FastMath;
+import com.android.internal.widget.EditableInputConnection;
+
+import org.xmlpull.v1.XmlPullParserException;
+
import android.R;
import android.content.ClipData;
import android.content.ClipData.Item;
@@ -62,6 +67,7 @@
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
+import android.text.method.AllCapsTransformationMethod;
import android.text.method.ArrowKeyMovementMethod;
import android.text.method.DateKeyListener;
import android.text.method.DateTimeKeyListener;
@@ -76,6 +82,7 @@
import android.text.method.TextKeyListener;
import android.text.method.TimeKeyListener;
import android.text.method.TransformationMethod;
+import android.text.method.TransformationMethod2;
import android.text.method.WordIterator;
import android.text.style.ClickableSpan;
import android.text.style.ParagraphStyle;
@@ -125,11 +132,6 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.RemoteViews.RemoteView;
-import com.android.internal.util.FastMath;
-import com.android.internal.widget.EditableInputConnection;
-
-import org.xmlpull.v1.XmlPullParserException;
-
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.BreakIterator;
@@ -424,6 +426,7 @@
int textSize = 15;
int typefaceIndex = -1;
int styleIndex = -1;
+ boolean allCaps = false;
/*
* Look the appearance up without checking first if it exists because
@@ -471,6 +474,10 @@
case com.android.internal.R.styleable.TextAppearance_textStyle:
styleIndex = appearance.getInt(attr, -1);
break;
+
+ case com.android.internal.R.styleable.TextAppearance_textAllCaps:
+ allCaps = appearance.getBoolean(attr, false);
+ break;
}
}
@@ -822,6 +829,10 @@
case com.android.internal.R.styleable.TextView_suggestionsEnabled:
mSuggestionsEnabled = a.getBoolean(attr, true);
break;
+
+ case com.android.internal.R.styleable.TextView_textAllCaps:
+ allCaps = a.getBoolean(attr, false);
+ break;
}
}
a.recycle();
@@ -1004,6 +1015,10 @@
}
setRawTextSize(textSize);
+ if (allCaps) {
+ setTransformationMethod(new AllCapsTransformationMethod(getContext()));
+ }
+
if (password || passwordInputType || webPasswordInputType || numberPasswordInputType) {
setTransformationMethod(PasswordTransformationMethod.getInstance());
typefaceIndex = MONOSPACE;
@@ -1331,6 +1346,14 @@
mTransformation = method;
+ if (method instanceof TransformationMethod2) {
+ TransformationMethod2 method2 = (TransformationMethod2) method;
+ mAllowTransformationLengthChange = !mTextIsSelectable && !(mText instanceof Editable);
+ method2.setLengthChangesAllowed(mAllowTransformationLengthChange);
+ } else {
+ mAllowTransformationLengthChange = false;
+ }
+
setText(mText);
}
@@ -1775,6 +1798,11 @@
setTypefaceByIndex(typefaceIndex, styleIndex);
+ if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps,
+ false)) {
+ setTransformationMethod(new AllCapsTransformationMethod(getContext()));
+ }
+
appearance.recycle();
}
@@ -2823,14 +2851,15 @@
mBufferType = type;
mText = text;
- if (mTransformation == null)
+ if (mTransformation == null) {
mTransformed = text;
- else
+ } else {
mTransformed = mTransformation.getTransformation(text, this);
+ }
final int textLength = text.length();
- if (text instanceof Spannable) {
+ if (text instanceof Spannable && !mAllowTransformationLengthChange) {
Spannable sp = (Spannable) text;
// Remove any ChangeWatchers that might have come
@@ -2852,7 +2881,6 @@
if (mTransformation != null) {
sp.setSpan(mTransformation, 0, textLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
}
if (mMovement != null) {
@@ -6570,6 +6598,26 @@
}
/**
+ * Sets the properties of this field to transform input to ALL CAPS
+ * display. This may use a "small caps" formatting if available.
+ * This setting will be ignored if this field is editable or selectable.
+ *
+ * This call replaces the current transformation method. Disabling this
+ * will not necessarily restore the previous behavior from before this
+ * was enabled.
+ *
+ * @see #setTransformationMethod(TransformationMethod)
+ * @attr ref android.R.styleable#TextView_textAllCaps
+ */
+ public void setAllCaps(boolean allCaps) {
+ if (allCaps) {
+ setTransformationMethod(new AllCapsTransformationMethod(getContext()));
+ } else {
+ setTransformationMethod(null);
+ }
+ }
+
+ /**
* If true, sets the properties of this field (number of lines, horizontally scrolling,
* transformation method) to be for a single-line input; if false, restores these to the default
* conditions.
@@ -10254,6 +10302,7 @@
private MovementMethod mMovement;
private TransformationMethod mTransformation;
+ private boolean mAllowTransformationLengthChange;
private ChangeWatcher mChangeWatcher;
private ArrayList<TextWatcher> mListeners = null;
diff --git a/core/java/com/android/internal/util/Protocol.java b/core/java/com/android/internal/util/Protocol.java
index 2e7ec58..b754d94 100644
--- a/core/java/com/android/internal/util/Protocol.java
+++ b/core/java/com/android/internal/util/Protocol.java
@@ -26,6 +26,9 @@
* codes with Message.what starting at Protocol.WIFI + 1 and less than or equal to Protocol.WIFI +
* Protocol.MAX_MESSAGE
*
+ * NOTE: After a value is created and source released a value shouldn't be changed to
+ * maintain backwards compatibility.
+ *
* {@hide}
*/
public class Protocol {
@@ -40,7 +43,7 @@
public static final int BASE_DHCP = 0x00030000;
public static final int BASE_DATA_CONNECTION = 0x00040000;
public static final int BASE_DATA_CONNECTION_AC = 0x00041000;
- public static final int BASE_DATA_CONNECTION_TRACKER = 0x00050000;
+ public static final int BASE_DATA_CONNECTION_TRACKER = 0x00042000;
//TODO: define all used protocols
}
diff --git a/core/java/com/android/internal/view/menu/ActionMenuItemView.java b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
index 3b497e4..09bebae 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
@@ -154,12 +154,7 @@
// populate accessibility description with title
setContentDescription(title);
- if (mShowTextAllCaps && title != null) {
- mTextButton.setText(title.toString().toUpperCase(
- getContext().getResources().getConfiguration().locale));
- } else {
- mTextButton.setText(mTitle);
- }
+ mTextButton.setText(mTitle);
updateTextButtonVisibility();
}
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index cfe9e59..bf2965b 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -112,7 +112,7 @@
int cellsRemaining = cellCount;
int maxChildHeight = 0;
int maxCellsUsed = 0;
- int multiCellItemCount = 0;
+ int expandableItemCount = 0;
if (mReserveOverflow) cellsRemaining--;
@@ -123,7 +123,7 @@
lp.expanded = false;
lp.extraPixels = 0;
lp.cellsUsed = 0;
- lp.multiCell = false;
+ lp.expandable = false;
// Overflow always gets 1 cell. No more, no less.
final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining;
@@ -132,7 +132,7 @@
heightMeasureSpec, heightPadding);
maxCellsUsed = Math.max(maxCellsUsed, cellsUsed);
- if (lp.multiCell) multiCellItemCount++;
+ if (lp.expandable) expandableItemCount++;
cellsRemaining -= cellsUsed;
maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight());
@@ -142,8 +142,8 @@
// Try distributing whole leftover cells to smaller items first.
boolean needsExpansion = false;
- long smallestMultiCellItemsAt = 0;
- while (multiCellItemCount > 0 && cellsRemaining > 0) {
+ long smallestExpandableItemsAt = 0;
+ while (expandableItemCount > 0 && cellsRemaining > 0) {
int minCells = Integer.MAX_VALUE;
long minCellsAt = 0; // Bit locations are indices of relevant child views
int minCellsItemCount = 0;
@@ -152,7 +152,7 @@
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
// Don't try to expand items that shouldn't.
- if (!lp.multiCell) continue;
+ if (!lp.expandable) continue;
// Mark indices of children that can receive an extra cell.
if (lp.cellsUsed < minCells) {
@@ -165,10 +165,10 @@
}
}
- if (minCellsItemCount < cellsRemaining) break; // Couldn't expand anything evenly. Stop.
+ if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop.
// Items that get expanded will always be in the set of smallest items when we're done.
- smallestMultiCellItemsAt |= minCellsAt;
+ smallestExpandableItemsAt |= minCellsAt;
for (int i = 0; i < childCount; i++) {
if ((minCellsAt & (1 << i)) == 0) continue;
@@ -186,12 +186,12 @@
// Divide any space left that wouldn't divide along cell boundaries
// evenly among the smallest multi-cell (expandable) items.
- if (cellsRemaining > 0 && smallestMultiCellItemsAt != 0) {
- final int expandCount = Long.bitCount(smallestMultiCellItemsAt);
+ if (cellsRemaining > 0 && smallestExpandableItemsAt != 0) {
+ final int expandCount = Long.bitCount(smallestExpandableItemsAt);
final int extraPixels = cellsRemaining * cellSize / expandCount;
for (int i = 0; i < childCount; i++) {
- if ((smallestMultiCellItemsAt & (1 << i)) == 0) continue;
+ if ((smallestExpandableItemsAt & (1 << i)) == 0) continue;
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
@@ -229,7 +229,7 @@
* Measure a child view to fit within cell-based formatting. The child's width
* will be measured to a whole multiple of cellSize.
*
- * <p>Sets the multiCell and cellsUsed fields of LayoutParams.
+ * <p>Sets the expandable and cellsUsed fields of LayoutParams.
*
* @param child Child to measure
* @param cellSize Size of one cell
@@ -241,21 +241,14 @@
static int measureChildForCells(View child, int cellSize, int cellsRemaining,
int parentHeightMeasureSpec, int parentHeightPadding) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
- (ActionMenuItemView) child : null;
final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) -
parentHeightPadding;
final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec);
final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode);
- int cellsUsed = cellsRemaining > 0 ? 1 : 0;
- final boolean multiCell = !lp.isOverflowButton &&
- (itemView == null || itemView.hasText());
-
- lp.multiCell = multiCell;
-
- if (multiCell && cellsRemaining > 0) {
+ int cellsUsed = 0;
+ if (cellsRemaining > 0) {
final int childWidthSpec = MeasureSpec.makeMeasureSpec(
cellSize * cellsRemaining, MeasureSpec.AT_MOST);
child.measure(childWidthSpec, childHeightSpec);
@@ -264,6 +257,12 @@
cellsUsed = measuredWidth / cellSize;
if (measuredWidth % cellSize != 0) cellsUsed++;
}
+
+ final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
+ (ActionMenuItemView) child : null;
+ final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText();
+ lp.expandable = expandable;
+
lp.cellsUsed = cellsUsed;
final int targetWidth = cellsUsed * cellSize;
child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
@@ -426,9 +425,10 @@
@ViewDebug.ExportedProperty(category = "layout")
public int cellsUsed;
@ViewDebug.ExportedProperty(category = "layout")
- public boolean multiCell;
- @ViewDebug.ExportedProperty(category = "layout")
public int extraPixels;
+ @ViewDebug.ExportedProperty(category = "layout")
+ public boolean expandable;
+
public boolean expanded;
public LayoutParams(Context c, AttributeSet attrs) {
diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
index 2f7adf0..40e5e8a 100644
--- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java
+++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
@@ -260,7 +260,6 @@
if (mTextView == null) {
TextView textView = new TextView(getContext(), null,
com.android.internal.R.attr.actionBarTabTextStyle);
- textView.setSingleLine();
textView.setEllipsize(TruncateAt.END);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 537aae6..681f43f 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -115,6 +115,18 @@
return error == EGL_SUCCESS && value == EGL_BUFFER_PRESERVED;
}
+static void android_view_GLES20Canvas_disableVsync(JNIEnv* env, jobject clazz) {
+ EGLDisplay display = eglGetCurrentDisplay();
+
+ eglGetError();
+ eglSwapInterval(display, 0);
+
+ EGLint error = eglGetError();
+ if (error != EGL_SUCCESS) {
+ RENDERER_LOGD("Could not disable v-sync (%x)", error);
+ }
+}
+
// ----------------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------------
@@ -161,6 +173,14 @@
return renderer->callDrawGLFunction(functor, dirty);
}
+static jint android_view_GLES20Canvas_getMaxTextureWidth(JNIEnv* env, jobject clazz) {
+ return Caches::getInstance().maxTextureSize;
+}
+
+static jint android_view_GLES20Canvas_getMaxTextureHeight(JNIEnv* env, jobject clazz) {
+ return Caches::getInstance().maxTextureSize;
+}
+
// ----------------------------------------------------------------------------
// State
// ----------------------------------------------------------------------------
@@ -613,7 +633,7 @@
if (layer) {
jint* storage = env->GetIntArrayElements(layerInfo, NULL);
- storage[0] = layer->texture;
+ storage[0] = layer->getTexture();
env->ReleaseIntArrayElements(layerInfo, storage, 0);
}
@@ -626,8 +646,8 @@
if (layer) {
jint* storage = env->GetIntArrayElements(layerInfo, NULL);
- storage[0] = layer->width;
- storage[1] = layer->height;
+ storage[0] = layer->getWidth();
+ storage[1] = layer->getHeight();
env->ReleaseIntArrayElements(layerInfo, storage, 0);
}
@@ -639,8 +659,8 @@
LayerRenderer::resizeLayer(layer, width, height);
jint* storage = env->GetIntArrayElements(layerInfo, NULL);
- storage[0] = layer->width;
- storage[1] = layer->height;
+ storage[0] = layer->getWidth();
+ storage[1] = layer->getHeight();
env->ReleaseIntArrayElements(layerInfo, storage, 0);
}
@@ -714,6 +734,7 @@
#ifdef USE_OPENGL_RENDERER
{ "nIsBackBufferPreserved", "()Z", (void*) android_view_GLES20Canvas_isBackBufferPreserved },
{ "nPreserveBackBuffer", "()Z", (void*) android_view_GLES20Canvas_preserveBackBuffer },
+ { "nDisableVsync", "()V", (void*) android_view_GLES20Canvas_disableVsync },
{ "nCreateRenderer", "()I", (void*) android_view_GLES20Canvas_createRenderer },
{ "nDestroyRenderer", "(I)V", (void*) android_view_GLES20Canvas_destroyRenderer },
@@ -803,6 +824,9 @@
{ "nDrawLayer", "(IIFFI)V", (void*) android_view_GLES20Canvas_drawLayer },
{ "nCopyLayer", "(II)Z", (void*) android_view_GLES20Canvas_copyLayer },
+ { "nGetMaximumTextureWidth", "()I", (void*) android_view_GLES20Canvas_getMaxTextureWidth },
+ { "nGetMaximumTextureHeight", "()I", (void*) android_view_GLES20Canvas_getMaxTextureHeight },
+
#endif
};
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index 30df91b..e867fe0 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -24,15 +24,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:rowCount="11"
+ android:rowCount="10"
android:id="@+id/root"
android:clipChildren="false">
<!-- Column 0 -->
- <Space android:height="20dip"/>
-
<com.android.internal.widget.DigitalClock android:id="@+id/time"
- android:layout_marginTop="16dip"
+ android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:layout_gravity="right">
@@ -120,7 +118,10 @@
android:layout_gravity="right"
/>
- <Space android:height="20dip"/>
+ <Space
+ android:layout_rowFlexibility="canStretch"
+ android:layout_columnFlexibility="canStretch"
+ />
<TextView
android:id="@+id/carrier"
@@ -156,15 +157,13 @@
/>
<!-- Column 1 -->
- <Space android:layout_widthSpec="canStretch" android:layout_rowSpan="11" />
+ <Space android:layout_width="32dip" android:layout_rowSpan="10" />
<!-- Column 2 - password entry field and PIN keyboard -->
<LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_gravity="center|fill"
- android:layout_rowSpan="11">
+ android:layout_rowSpan="10">
<EditText android:id="@+id/passwordEntry"
android:layout_height="wrap_content"
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
index c859720..7aab04e 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
@@ -24,15 +24,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:rowCount="10"
+ android:rowCount="8"
android:id="@+id/root"
android:clipChildren="false">
<!-- Column 0 -->
- <Space android:height="20dip"/>
-
<com.android.internal.widget.DigitalClock android:id="@+id/time"
- android:layout_marginTop="16dip"
+ android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:layout_gravity="right">
@@ -120,7 +118,10 @@
android:layout_gravity="right"
/>
- <Space android:height="20dip"/>
+ <Space
+ android:layout_rowFlexibility="canStretch"
+ android:layout_columnFlexibility="canStretch"
+ />
<LinearLayout android:orientation="vertical"
android:layout_gravity="right"
@@ -169,17 +170,14 @@
</LinearLayout>
<!-- Column 1 -->
- <Space
- android:width="20dip"
- android:layout_heightSpec="canStretch"
- android:layout_rowSpan="10" />
+ <Space android:layout_width="32dip" android:layout_rowSpan="8" />
<!-- Column 2 -->
<com.android.internal.widget.multiwaveview.MultiWaveView
android:id="@+id/unlock_widget"
- android:layout_width="300dip"
+ android:layout_width="200dip"
android:layout_height="match_parent"
- android:layout_rowSpan="10"
+ android:layout_rowSpan="8"
android:targetDrawables="@array/lockscreen_targets_when_silent"
android:handleDrawable="@drawable/ic_lockscreen_handle"
diff --git a/core/res/res/layout/keyguard_screen_unlock_landscape.xml b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
index 0070ed0..8f083a0 100644
--- a/core/res/res/layout/keyguard_screen_unlock_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
@@ -30,8 +30,6 @@
<!-- Column 0: Time, date and status -->
<com.android.internal.widget.DigitalClock android:id="@+id/time"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:layout_marginBottom="12dip"
android:layout_gravity="right">
@@ -66,8 +64,6 @@
<TextView
android:id="@+id/date"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceMedium"
@@ -77,8 +73,6 @@
<TextView
android:id="@+id/alarm_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceMedium"
@@ -89,8 +83,6 @@
<TextView
android:id="@+id/status1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceMedium"
@@ -100,10 +92,8 @@
<!-- TODO: remove hard coded height since layout_rowWeight doesn't seem to be working -->
<Space
- android:layout_height="43dip"
- android:layout_gravity="fill"
- android:layout_heightSpec="canStretch"
- android:layout_widthSpec="canStretch"
+ android:layout_rowFlexibility="canStretch"
+ android:layout_columnFlexibility="canStretch"
/>
<TextView android:id="@+id/carrier"
@@ -117,8 +107,6 @@
<LinearLayout
style="?android:attr/buttonBarStyle"
android:orientation="vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="right">
<Button android:id="@+id/emergencyCallButton"
diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
index 28c5302..35fd473 100644
--- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
@@ -125,7 +125,7 @@
android:layout_marginBottom="4dip"
android:layout_marginLeft="8dip"
android:layout_gravity="center|bottom"
- android:layout_heightSpec="canStretch"
+ android:layout_rowFlexibility="canStretch"
/>
<TextView
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index b92ce6a..39de054 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2810,6 +2810,8 @@
<attr name="textColorHint" />
<!-- Color of the links. -->
<attr name="textColorLink" />
+ <!-- Present the text in ALL CAPS. This may use a small-caps form when available. -->
+ <attr name="textAllCaps" format="boolean" />
</declare-styleable>
<declare-styleable name="TextSwitcher">
</declare-styleable>
@@ -3074,6 +3076,8 @@
<attr name="textIsSelectable" />
<!-- Suggestions will be displayed when the user double taps on editable text. -->
<attr name="suggestionsEnabled" />
+ <!-- Present the text in ALL CAPS. This may use a small-caps form when available. -->
+ <attr name="textAllCaps" />
</declare-styleable>
<!-- An <code>input-extras</code> is a container for extra data to supply to
an input method. Contains
@@ -3342,28 +3346,16 @@
<attr name="layout_gravity" />
<!-- A value specifying how much deficit or excess width this component can accomodate.
The default is FIXED.
- See {@link android.widget.GridLayout.LayoutParams#widthSpec}.-->
- <attr name="layout_widthSpec" >
- <!-- If possible, width should be exactly as specified.
- See {@link android.widget.GridLayout#FIXED}. -->
- <enum name="fixed" value="0" />
- <!-- If possible, width should be less than or equal to the specified width.
- See {@link android.widget.GridLayout#CAN_SHRINK}. -->
- <enum name="canShrink" value="1" />
+ See {@link android.widget.GridLayout.Group#flexibility}.-->
+ <attr name="layout_columnFlexibility" >
<!-- If possible, width should be greater than or equal to the specified width.
See {@link android.widget.GridLayout#CAN_STRETCH}. -->
<enum name="canStretch" value="2" />
</attr>
<!-- A value specifying how much deficit or excess height this component can accomodate.
The default is FIXED.
- See {@link android.widget.GridLayout.LayoutParams#heightSpec}.-->
- <attr name="layout_heightSpec" >
- <!-- If possible, height should be exactly as specified.
- See {@link android.widget.GridLayout#FIXED}. -->
- <enum name="fixed" value="0" />
- <!-- If possible, height should be less than or equal to the specified height.
- See {@link android.widget.GridLayout#CAN_SHRINK}. -->
- <enum name="canShrink" value="1" />
+ See {@link android.widget.GridLayout.Group#flexibility}.-->
+ <attr name="layout_rowFlexibility" >
<!-- If possible, height should be greater than or equal to the specified height.
See {@link android.widget.GridLayout#CAN_STRETCH}. -->
<enum name="canStretch" value="2" />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 75acb37..3c23add 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1732,10 +1732,10 @@
<public type="attr" name="layout_row" />
<public type="attr" name="layout_rowSpan" />
- <public type="attr" name="layout_columnSpan" />
+ <public type="attr" name="layout_rowFlexibility" />
- <public type="attr" name="layout_widthSpec" />
- <public type="attr" name="layout_heightSpec" />
+ <public type="attr" name="layout_columnSpan" />
+ <public type="attr" name="layout_columnFlexibility" />
<public type="attr" name="actionModeSelectAllDrawable" />
@@ -1779,6 +1779,8 @@
<public type="attr" name="backgroundStacked" />
<public type="attr" name="backgroundSplit" />
+ <public type="attr" name="textAllCaps" />
+
<public type="style" name="TextAppearance.SuggestionHighlight" />
<public type="style" name="Theme.Holo.SplitActionBarWhenNarrow" />
<public type="style" name="Theme.Holo.Light.SplitActionBarWhenNarrow" />
@@ -1789,6 +1791,7 @@
<public type="style" name="TextAppearance.Holo.Widget.ActionBar.Subtitle.Inverse" />
<public type="style" name="TextAppearance.Holo.Widget.ActionMode.Title.Inverse" />
<public type="style" name="TextAppearance.Holo.Widget.ActionMode.Subtitle.Inverse" />
+ <public type="style" name="TextAppearance.Holo.Widget.ActionBar.Menu" />
<public type="style" name="Widget.Holo.ActionBar.Solid" />
<public type="style" name="Widget.Holo.Light.ActionBar.Solid" />
<public type="style" name="Widget.Holo.Light.ActionBar.Solid.Inverse" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 50f8df7..97a8c0b 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2085,6 +2085,10 @@
<!-- Do not translate. Regex used by AutoFill. -->
<string name="autofill_phone_suffix_separator_re">^-$</string>
+ <!-- Do not translate. Regex used by AutoFill. -->
+ <!-- Ex: ************1234 -->
+ <string name="credit_card_number_preview_format">$1</string>
+
<!-- Title of an application permission, listed so the user can choose whether
they want to allow the application to do this. -->
<string name="permlab_readHistoryBookmarks">read Browser\'s history and bookmarks</string>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 9ee4b6a..8a8f81a 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1314,6 +1314,14 @@
<item name="android:textSize">@android:dimen/action_bar_subtitle_text_size</item>
</style>
+ <style name="TextAppearance.Holo.Widget.ActionBar.Menu"
+ parent="TextAppearance.Holo.Small">
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textColor">?android:attr/actionMenuTextColor</item>
+ <item name="android:textAllCaps">true</item>
+ </style>
+
<style name="TextAppearance.Holo.Widget.ActionMode">
</style>
@@ -1848,7 +1856,9 @@
<style name="Widget.Holo.ActionBar.TabText" parent="Widget.ActionBar.TabText">
<item name="android:textAppearance">@style/TextAppearance.Holo.Medium</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
- <item name="android:textSize">18sp</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textAllCaps">true</item>
</style>
<style name="Widget.Holo.ActionMode" parent="Widget.ActionMode">
@@ -2203,9 +2213,7 @@
</style>
<style name="Widget.Holo.Light.ActionBar.TabText.Inverse">
- <item name="android:textAppearance">@style/TextAppearance.Holo.Medium</item>
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
- <item name="android:textSize">18sp</item>
</style>
<style name="Widget.Holo.Light.ActionMode" parent="Widget.Holo.ActionMode">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 23111e6..9a52cff 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -283,7 +283,7 @@
<item name="actionBarSplitStyle">?android:attr/actionBarStyle</item>
<item name="actionBarSize">@dimen/action_bar_default_height</item>
<item name="actionModePopupWindowStyle">?android:attr/popupWindowStyle</item>
- <item name="actionMenuTextAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="actionMenuTextAppearance">@android:style/TextAppearance.Holo.Widget.ActionBar.Menu</item>
<item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
<item name="dividerVertical">@drawable/divider_vertical_dark</item>
@@ -1389,6 +1389,7 @@
<item name="actionOverflowButtonStyle">@android:style/Widget.Holo.ActionButton.Overflow</item>
<item name="actionModeBackground">@android:drawable/cab_background_holo_dark</item>
<item name="actionModeCloseDrawable">@android:drawable/cab_ic_close_holo</item>
+ <item name="homeAsUpIndicator">@android:drawable/ic_ab_back_holo_dark</item>
<item name="actionBarTabStyle">@style/Widget.Holo.Light.ActionBar.TabView.Inverse</item>
<item name="actionBarTabBarStyle">@style/Widget.Holo.Light.ActionBar.TabBar.Inverse</item>
<item name="actionBarTabTextStyle">@style/Widget.Holo.Light.ActionBar.TabText.Inverse</item>
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 0b488c9..5b50f8f 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -73,7 +73,11 @@
* @hide
*/
public static final int DIRECTION_RTL = 1;
-
+
+ // Maximum bitmap size as defined in Skia's native code
+ // (see SkCanvas.cpp, SkDraw.cpp)
+ private static final int MAXMIMUM_BITMAP_SIZE = 32766;
+
// This field is used to finalize the native Canvas properly
@SuppressWarnings({"UnusedDeclaration"})
private final CanvasFinalizer mFinalizer;
@@ -259,7 +263,29 @@
public void setScreenDensity(int density) {
mScreenDensity = density;
}
+
+ /**
+ * Returns the maximum allowed width for bitmaps drawn with this canvas.
+ * Attempting to draw with a bitmap wider than this value will result
+ * in an error.
+ *
+ * @see #getMaximumBitmapHeight()
+ */
+ public int getMaximumBitmapWidth() {
+ return MAXMIMUM_BITMAP_SIZE;
+ }
+ /**
+ * Returns the maximum allowed height for bitmaps drawn with this canvas.
+ * Attempting to draw with a bitmap taller than this value will result
+ * in an error.
+ *
+ * @see #getMaximumBitmapWidth()
+ */
+ public int getMaximumBitmapHeight() {
+ return MAXMIMUM_BITMAP_SIZE;
+ }
+
// the SAVE_FLAG constants must match their native equivalents
/** restore the current matrix when restore() is called */
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index e900584..6254192 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -67,6 +67,22 @@
Type mType;
Bitmap mBitmap;
int mUsage;
+ Allocation mAdaptedAllocation;
+
+ boolean mConstrainedLOD;
+ boolean mConstrainedFace;
+ boolean mConstrainedY;
+ boolean mConstrainedZ;
+ int mSelectedY;
+ int mSelectedZ;
+ int mSelectedLOD;
+ Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITIVE_X;
+
+ int mCurrentDimX;
+ int mCurrentDimY;
+ int mCurrentDimZ;
+ int mCurrentCount;
+
/**
* The usage of the allocation. These signal to renderscript
@@ -139,6 +155,19 @@
}
}
+ private void updateCacheInfo(Type t) {
+ mCurrentDimX = t.getX();
+ mCurrentDimY = t.getY();
+ mCurrentDimZ = t.getZ();
+ mCurrentCount = mCurrentDimX;
+ if (mCurrentDimY > 1) {
+ mCurrentCount *= mCurrentDimY;
+ }
+ if (mCurrentDimZ > 1) {
+ mCurrentCount *= mCurrentDimZ;
+ }
+ }
+
Allocation(int id, RenderScript rs, Type t, int usage) {
super(id, rs);
if ((usage & ~(USAGE_SCRIPT |
@@ -149,6 +178,10 @@
throw new RSIllegalArgumentException("Unknown usage specified.");
}
mType = t;
+
+ if (t != null) {
+ updateCacheInfo(t);
+ }
}
private void validateIsInt32() {
@@ -210,6 +243,7 @@
if(typeID != 0) {
mType = new Type(typeID, mRS);
mType.updateFromNative();
+ updateCacheInfo(mType);
}
}
@@ -234,15 +268,15 @@
public void copyFrom(BaseObj[] d) {
mRS.validate();
validateIsObject();
- if (d.length != mType.getCount()) {
+ if (d.length != mCurrentCount) {
throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " +
- mType.getCount() + ", array length = " + d.length);
+ mCurrentCount + ", array length = " + d.length);
}
int i[] = new int[d.length];
for (int ct=0; ct < d.length; ct++) {
i[ct] = d[ct].getID();
}
- copy1DRangeFromUnchecked(0, mType.getCount(), i);
+ copy1DRangeFromUnchecked(0, mCurrentCount, i);
}
private void validateBitmapFormat(Bitmap b) {
@@ -292,8 +326,7 @@
}
private void validateBitmapSize(Bitmap b) {
- if(mType.getX() != b.getWidth() ||
- mType.getY() != b.getHeight()) {
+ if((mCurrentDimX != b.getWidth()) || (mCurrentDimY != b.getHeight())) {
throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch");
}
}
@@ -307,7 +340,7 @@
*/
public void copyFromUnchecked(int[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mType.getCount(), d);
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
/**
* Copy an allocation from an array. This variant is not type
@@ -318,7 +351,7 @@
*/
public void copyFromUnchecked(short[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mType.getCount(), d);
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
/**
* Copy an allocation from an array. This variant is not type
@@ -329,7 +362,7 @@
*/
public void copyFromUnchecked(byte[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mType.getCount(), d);
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
/**
* Copy an allocation from an array. This variant is not type
@@ -340,7 +373,7 @@
*/
public void copyFromUnchecked(float[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mType.getCount(), d);
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
/**
@@ -352,7 +385,7 @@
*/
public void copyFrom(int[] d) {
mRS.validate();
- copy1DRangeFrom(0, mType.getCount(), d);
+ copy1DRangeFrom(0, mCurrentCount, d);
}
/**
@@ -364,7 +397,7 @@
*/
public void copyFrom(short[] d) {
mRS.validate();
- copy1DRangeFrom(0, mType.getCount(), d);
+ copy1DRangeFrom(0, mCurrentCount, d);
}
/**
@@ -376,7 +409,7 @@
*/
public void copyFrom(byte[] d) {
mRS.validate();
- copy1DRangeFrom(0, mType.getCount(), d);
+ copy1DRangeFrom(0, mCurrentCount, d);
}
/**
@@ -388,7 +421,7 @@
*/
public void copyFrom(float[] d) {
mRS.validate();
- copy1DRangeFrom(0, mType.getCount(), d);
+ copy1DRangeFrom(0, mCurrentCount, d);
}
/**
@@ -420,8 +453,7 @@
throw new RSIllegalArgumentException("Field packer length " + data.length +
" not divisible by element size " + eSize + ".");
}
- data1DChecks(xoff, count, data.length, data.length);
- mRS.nAllocationData1D(getID(), xoff, 0, count, data, data.length);
+ copy1DRangeFromUnchecked(xoff, count, data);
}
/**
@@ -448,7 +480,8 @@
" does not match component size " + eSize + ".");
}
- mRS.nAllocationElementData1D(getID(), xoff, 0, component_number, data, data.length);
+ mRS.nAllocationElementData1D(getID(), xoff, mSelectedLOD,
+ component_number, data, data.length);
}
private void data1DChecks(int off, int count, int len, int dataSize) {
@@ -459,11 +492,11 @@
if(count < 1) {
throw new RSIllegalArgumentException("Count must be >= 1.");
}
- if((off + count) > mType.getCount()) {
- throw new RSIllegalArgumentException("Overflow, Available count " + mType.getCount() +
+ if((off + count) > mCurrentCount) {
+ throw new RSIllegalArgumentException("Overflow, Available count " + mCurrentCount +
", got " + count + " at offset " + off + ".");
}
- if((len) < dataSize) {
+ if(len < dataSize) {
throw new RSIllegalArgumentException("Array too small for allocation type.");
}
}
@@ -494,7 +527,7 @@
public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize);
+ mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
}
/**
* Copy part of an allocation from an array. This variant is
@@ -508,7 +541,7 @@
public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
data1DChecks(off, count, d.length * 2, dataSize);
- mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize);
+ mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
}
/**
* Copy part of an allocation from an array. This variant is
@@ -522,7 +555,7 @@
public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
data1DChecks(off, count, d.length, dataSize);
- mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize);
+ mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
}
/**
* Copy part of an allocation from an array. This variant is
@@ -536,7 +569,7 @@
public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize);
+ mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
}
/**
@@ -606,21 +639,25 @@
*/
public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
mRS.nAllocationData2D(getID(), off, 0,
- 0, Type.CubemapFace.POSITIVE_X.mID,
+ mSelectedLOD, mSelectedFace.mID,
count, 1, data.getID(), dataOff, 0,
- 0, Type.CubemapFace.POSITIVE_X.mID);
+ data.mSelectedLOD, data.mSelectedFace.mID);
}
private void validate2DRange(int xoff, int yoff, int w, int h) {
- if (xoff < 0 || yoff < 0) {
- throw new RSIllegalArgumentException("Offset cannot be negative.");
- }
- if (h < 0 || w < 0) {
- throw new RSIllegalArgumentException("Height or width cannot be negative.");
- }
- if ((xoff + w) > mType.mDimX ||
- (yoff + h) > mType.mDimY) {
- throw new RSIllegalArgumentException("Updated region larger than allocation.");
+ if (mAdaptedAllocation != null) {
+
+ } else {
+
+ if (xoff < 0 || yoff < 0) {
+ throw new RSIllegalArgumentException("Offset cannot be negative.");
+ }
+ if (h < 0 || w < 0) {
+ throw new RSIllegalArgumentException("Height or width cannot be negative.");
+ }
+ if (((xoff + w) > mCurrentDimX) || ((yoff + h) > mCurrentDimY)) {
+ throw new RSIllegalArgumentException("Updated region larger than allocation.");
+ }
}
}
@@ -637,25 +674,29 @@
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
mRS.validate();
validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
mRS.validate();
validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 2);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 2);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
mRS.validate();
validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 4);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
mRS.validate();
validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 4);
}
/**
@@ -675,9 +716,9 @@
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getID(), xoff, yoff,
- 0, Type.CubemapFace.POSITIVE_X.mID,
+ mSelectedLOD, mSelectedFace.mID,
w, h, data.getID(), dataXoff, dataYoff,
- 0, Type.CubemapFace.POSITIVE_X.mID);
+ data.mSelectedLOD, data.mSelectedFace.mID);
}
/**
@@ -693,7 +734,7 @@
mRS.validate();
validateBitmapFormat(data);
validate2DRange(xoff, yoff, data.getWidth(), data.getHeight());
- mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, data);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, data);
}
@@ -750,6 +791,7 @@
int typeID = mRS.nAllocationGetType(getID());
mType = new Type(typeID, mRS);
mType.updateFromNative();
+ updateCacheInfo(mType);
}
/*
diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java
index 77dd86a..ca5246a 100644
--- a/graphics/java/android/renderscript/AllocationAdapter.java
+++ b/graphics/java/android/renderscript/AllocationAdapter.java
@@ -17,228 +17,92 @@
package android.renderscript;
import android.content.res.Resources;
-import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.util.Log;
import android.util.TypedValue;
/**
*
**/
public class AllocationAdapter extends Allocation {
- private boolean mConstrainedLOD;
- private boolean mConstrainedFace;
- private boolean mConstrainedY;
- private boolean mConstrainedZ;
-
- private int mSelectedDimX;
- private int mSelectedDimY;
- private int mSelectedDimZ;
- private int mSelectedCount;
- private Allocation mAlloc;
-
- private int mSelectedLOD = 0;
- private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITIVE_X;
-
AllocationAdapter(int id, RenderScript rs, Allocation alloc) {
- super(id, rs, null, alloc.mUsage);
- mAlloc = alloc;
+ super(id, rs, alloc.mType, alloc.mUsage);
+ mAdaptedAllocation = alloc;
}
-
int getID() {
- return mAlloc.getID();
+ return mAdaptedAllocation.getID();
}
- public void copyFrom(BaseObj[] d) {
- mRS.validate();
- if (d.length != mSelectedCount) {
- throw new RSIllegalArgumentException("Array size mismatch, allocation size = " +
- mSelectedCount + ", array length = " + d.length);
- }
- int i[] = new int[d.length];
- for (int ct=0; ct < d.length; ct++) {
- i[ct] = d[ct].getID();
- }
- subData1D(0, mAlloc.mType.getCount(), i);
- }
-
- void validateBitmap(Bitmap b) {
- mRS.validate();
- if(mSelectedDimX != b.getWidth() ||
- mSelectedDimY != b.getHeight()) {
- throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch");
- }
- }
-
- public void copyFrom(int[] d) {
- mRS.validate();
- subData1D(0, mSelectedCount, d);
- }
- public void copyFrom(short[] d) {
- mRS.validate();
- subData1D(0, mSelectedCount, d);
- }
- public void copyFrom(byte[] d) {
- mRS.validate();
- subData1D(0, mSelectedCount, d);
- }
- public void copyFrom(float[] d) {
- mRS.validate();
- subData1D(0, mSelectedCount, d);
- }
- public void copyFrom(Bitmap b) {
- validateBitmap(b);
- mRS.nAllocationCopyFromBitmap(getID(), b);
- }
-
- public void copyTo(Bitmap b) {
- validateBitmap(b);
- mRS.nAllocationCopyToBitmap(getID(), b);
- }
-
-
+ /**
+ * @hide
+ */
public void subData(int xoff, FieldPacker fp) {
- int eSize = mAlloc.mType.mElement.getSizeBytes();
- final byte[] data = fp.getData();
-
- int count = data.length / eSize;
- if ((eSize * count) != data.length) {
- throw new RSIllegalArgumentException("Field packer length " + data.length +
- " not divisible by element size " + eSize + ".");
- }
- data1DChecks(xoff, count, data.length, data.length);
- mRS.nAllocationData1D(getID(), xoff, mSelectedLOD, count, data, data.length);
+ super.setFromFieldPacker(xoff, fp);
}
-
-
+ /**
+ * @hide
+ */
public void subElementData(int xoff, int component_number, FieldPacker fp) {
- if (component_number >= mAlloc.mType.mElement.mElements.length) {
- throw new RSIllegalArgumentException("Component_number " + component_number + " out of range.");
- }
- if(xoff < 0) {
- throw new RSIllegalArgumentException("Offset must be >= 0.");
- }
-
- final byte[] data = fp.getData();
- int eSize = mAlloc.mType.mElement.mElements[component_number].getSizeBytes();
-
- if (data.length != eSize) {
- throw new RSIllegalArgumentException("Field packer sizelength " + data.length +
- " does not match component size " + eSize + ".");
- }
-
- mRS.nAllocationElementData1D(getID(), xoff, mSelectedLOD, component_number, data, data.length);
+ super.setFromFieldPacker(xoff, component_number, fp);
}
-
- void data1DChecks(int off, int count, int len, int dataSize) {
- mRS.validate();
- if(off < 0) {
- throw new RSIllegalArgumentException("Offset must be >= 0.");
- }
- if(count < 1) {
- throw new RSIllegalArgumentException("Count must be >= 1.");
- }
- if((off + count) > mSelectedCount) {
- throw new RSIllegalArgumentException("Overflow, Available count " + mAlloc.mType.getCount() +
- ", got " + count + " at offset " + off + ".");
- }
- if((len) < dataSize) {
- throw new RSIllegalArgumentException("Array too small for allocation type. len = " +
- len + ", dataSize = " + dataSize);
- }
- }
-
+ /**
+ * @hide
+ */
public void subData1D(int off, int count, int[] d) {
- int dataSize = mAlloc.mType.mElement.getSizeBytes() * count;
- data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
+ super.copy1DRangeFrom(off, count, d);
}
+ /**
+ * @hide
+ */
public void subData1D(int off, int count, short[] d) {
- int dataSize = mAlloc.mType.mElement.getSizeBytes() * count;
- data1DChecks(off, count, d.length * 2, dataSize);
- mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
+ super.copy1DRangeFrom(off, count, d);
}
+ /**
+ * @hide
+ */
public void subData1D(int off, int count, byte[] d) {
- int dataSize = mAlloc.mType.mElement.getSizeBytes() * count;
- data1DChecks(off, count, d.length, dataSize);
- mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
+ super.copy1DRangeFrom(off, count, d);
}
+ /**
+ * @hide
+ */
public void subData1D(int off, int count, float[] d) {
- int dataSize = mAlloc.mType.mElement.getSizeBytes() * count;
- data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
+ super.copy1DRangeFrom(off, count, d);
}
-
/**
- * Copy part of an allocation from another allocation.
- *
- * @param off The offset of the first element to be copied.
- * @param count The number of elements to be copied.
- * @param data the source data allocation.
- * @param dataOff off The offset of the first element in data to
- * be copied.
+ * @hide
*/
- public void subData1D(int off, int count, AllocationAdapter data, int dataOff) {
- mRS.nAllocationData2D(getID(), off, 0,
- mSelectedLOD, mSelectedFace.mID,
- count, 1, data.getID(), dataOff, 0,
- data.mSelectedLOD, data.mSelectedFace.mID);
- }
-
-
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
- mRS.validate();
- mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, d, d.length * 4);
+ super.copy2DRangeFrom(xoff, yoff, w, h, d);
}
-
- public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
- mRS.validate();
- mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, d, d.length * 4);
- }
-
/**
- * Copy a rectangular region into the allocation from another
- * allocation.
- *
- * @param xoff X offset of the region to update.
- * @param yoff Y offset of the region to update.
- * @param w Width of the incoming region to update.
- * @param h Height of the incoming region to update.
- * @param data source allocation.
- * @param dataXoff X offset in data of the region to update.
- * @param dataYoff Y offset in data of the region to update.
+ * @hide
*/
- public void subData2D(int xoff, int yoff, int w, int h,
- AllocationAdapter data, int dataXoff, int dataYoff) {
- mRS.validate();
- mRS.nAllocationData2D(getID(), xoff, yoff,
- mSelectedLOD, mSelectedFace.mID,
- w, h, data.getID(), dataXoff, dataYoff,
- data.mSelectedLOD, data.mSelectedFace.mID);
+ public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
+ super.copy2DRangeFrom(xoff, yoff, w, h, d);
}
-
+ /**
+ * @hide
+ */
public void readData(int[] d) {
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ super.copyTo(d);
}
-
+ /**
+ * @hide
+ */
public void readData(float[] d) {
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ super.copyTo(d);
}
- private void initLOD(int lod) {
+ void initLOD(int lod) {
if (lod < 0) {
throw new RSIllegalArgumentException("Attempting to set negative lod (" + lod + ").");
}
- int tx = mAlloc.mType.getX();
- int ty = mAlloc.mType.getY();
- int tz = mAlloc.mType.getZ();
+ int tx = mAdaptedAllocation.mType.getX();
+ int ty = mAdaptedAllocation.mType.getY();
+ int tz = mAdaptedAllocation.mType.getZ();
for (int ct=0; ct < lod; ct++) {
if ((tx==1) && (ty == 1) && (tz == 1)) {
@@ -250,25 +114,31 @@
if (tz > 1) tz >>= 1;
}
- mSelectedDimX = tx;
- mSelectedDimY = ty;
- mSelectedCount = tx;
- if (ty > 1) {
- mSelectedCount *= ty;
+ mCurrentDimX = tx;
+ mCurrentDimY = ty;
+ mCurrentDimZ = tz;
+ mCurrentCount = mCurrentDimX;
+ if (mCurrentDimY > 1) {
+ mCurrentCount *= mCurrentDimY;
}
- if (tz > 1) {
- mSelectedCount *= tz;
+ if (mCurrentDimZ > 1) {
+ mCurrentCount *= mCurrentDimZ;
}
+ mSelectedY = 0;
+ mSelectedZ = 0;
}
/**
* Set the active LOD. The LOD must be within the range for the
- * type being adapted.
+ * type being adapted. The base allocation must have mipmaps.
+ *
+ * Because this changes the dimensions of the adapter the
+ * current Y and Z will be reset.
*
* @param lod The LOD to make active.
*/
public void setLOD(int lod) {
- if (!mAlloc.getType().hasMipmaps()) {
+ if (!mAdaptedAllocation.getType().hasMipmaps()) {
throw new RSInvalidStateException("Cannot set LOD when the allocation type does not include mipmaps.");
}
if (!mConstrainedLOD) {
@@ -278,22 +148,81 @@
initLOD(lod);
}
+ /**
+ * Set the active Face. The base allocation must be of a type
+ * that includes faces.
+ *
+ * @param cf The face to make active.
+ */
public void setFace(Type.CubemapFace cf) {
+ if (!mAdaptedAllocation.getType().hasFaces()) {
+ throw new RSInvalidStateException("Cannot set Face when the allocation type does not include faces.");
+ }
+ if (!mConstrainedFace) {
+ throw new RSInvalidStateException("Cannot set LOD when the adapter includes mipmaps.");
+ }
+ if (cf == null) {
+ throw new RSIllegalArgumentException("Cannot set null face.");
+ }
+
mSelectedFace = cf;
}
+ /**
+ * Set the active Y. The y value must be within the range for
+ * the allocation being adapted. The base allocation must
+ * contain the Y dimension.
+ *
+ * @param y The y to make active.
+ */
public void setY(int y) {
- mSelectedDimY = y;
+ if (mAdaptedAllocation.getType().getY() == 0) {
+ throw new RSInvalidStateException("Cannot set Y when the allocation type does not include Y dim.");
+ }
+ if (mAdaptedAllocation.getType().getY() <= y) {
+ throw new RSInvalidStateException("Cannot set Y greater than dimension of allocation.");
+ }
+ if (!mConstrainedY) {
+ throw new RSInvalidStateException("Cannot set Y when the adapter includes Y.");
+ }
+
+ mSelectedY = y;
}
+ /**
+ * Set the active Z. The z value must be within the range for
+ * the allocation being adapted. The base allocation must
+ * contain the Z dimension.
+ *
+ * @param z The z to make active.
+ */
public void setZ(int z) {
+ if (mAdaptedAllocation.getType().getZ() == 0) {
+ throw new RSInvalidStateException("Cannot set Z when the allocation type does not include Z dim.");
+ }
+ if (mAdaptedAllocation.getType().getZ() <= z) {
+ throw new RSInvalidStateException("Cannot set Z greater than dimension of allocation.");
+ }
+ if (!mConstrainedZ) {
+ throw new RSInvalidStateException("Cannot set Z when the adapter includes Z.");
+ }
+
+ mSelectedZ = z;
}
- // creation
- //static public AllocationAdapter create1D(RenderScript rs, Allocation a) {
- //}
+ static public AllocationAdapter create1D(RenderScript rs, Allocation a) {
+ rs.validate();
+ AllocationAdapter aa = new AllocationAdapter(0, rs, a);
+ aa.mConstrainedLOD = true;
+ aa.mConstrainedFace = true;
+ aa.mConstrainedY = true;
+ aa.mConstrainedZ = true;
+ aa.initLOD(0);
+ return aa;
+ }
static public AllocationAdapter create2D(RenderScript rs, Allocation a) {
+ android.util.Log.e("rs", "create2d " + a);
rs.validate();
AllocationAdapter aa = new AllocationAdapter(0, rs, a);
aa.mConstrainedLOD = true;
@@ -305,6 +234,16 @@
}
+ /**
+ * Override the Allocation resize. Resizing adapters is not
+ * allowed and will throw a RSInvalidStateException.
+ *
+ * @param dimX ignored.
+ */
+ public synchronized void resize(int dimX) {
+ throw new RSInvalidStateException("Resize not allowed for Adapters.");
+ }
+
}
diff --git a/include/media/EffectBassBoostApi.h b/include/media/EffectBassBoostApi.h
deleted file mode 100644
index 56119eb..0000000
--- a/include/media/EffectBassBoostApi.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTBASSBOOSTAPI_H_
-#define ANDROID_EFFECTBASSBOOSTAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_BASSBOOST_ = { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
-const effect_uuid_t * const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_;
-#endif //OPENSL_ES_H_
-
-/* enumerated parameter settings for BassBoost effect */
-typedef enum
-{
- BASSBOOST_PARAM_STRENGTH_SUPPORTED,
- BASSBOOST_PARAM_STRENGTH
-} t_bassboost_params;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTBASSBOOSTAPI_H_*/
diff --git a/include/media/EffectEnvironmentalReverbApi.h b/include/media/EffectEnvironmentalReverbApi.h
deleted file mode 100644
index f11c5ec..0000000
--- a/include/media/EffectEnvironmentalReverbApi.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTENVIRONMENTALREVERBAPI_H_
-#define ANDROID_EFFECTENVIRONMENTALREVERBAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_ENVIRONMENTALREVERB_ = { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x6, 0x83, 0x9e } };
-const effect_uuid_t * const SL_IID_ENVIRONMENTALREVERB = &SL_IID_ENVIRONMENTALREVERB_;
-#endif //OPENSL_ES_H_
-
-/* enumerated parameter settings for environmental reverb effect */
-typedef enum
-{
- // Parameters below are as defined in OpenSL ES specification for environmental reverb interface
- REVERB_PARAM_ROOM_LEVEL, // in millibels, range -6000 to 0
- REVERB_PARAM_ROOM_HF_LEVEL, // in millibels, range -4000 to 0
- REVERB_PARAM_DECAY_TIME, // in milliseconds, range 100 to 20000
- REVERB_PARAM_DECAY_HF_RATIO, // in permilles, range 100 to 1000
- REVERB_PARAM_REFLECTIONS_LEVEL, // in millibels, range -6000 to 0
- REVERB_PARAM_REFLECTIONS_DELAY, // in milliseconds, range 0 to 65
- REVERB_PARAM_REVERB_LEVEL, // in millibels, range -6000 to 0
- REVERB_PARAM_REVERB_DELAY, // in milliseconds, range 0 to 65
- REVERB_PARAM_DIFFUSION, // in permilles, range 0 to 1000
- REVERB_PARAM_DENSITY, // in permilles, range 0 to 1000
- REVERB_PARAM_PROPERTIES,
- REVERB_PARAM_BYPASS
-} t_env_reverb_params;
-
-//t_reverb_settings is equal to SLEnvironmentalReverbSettings defined in OpenSL ES specification.
-typedef struct s_reverb_settings {
- int16_t roomLevel;
- int16_t roomHFLevel;
- uint32_t decayTime;
- int16_t decayHFRatio;
- int16_t reflectionsLevel;
- uint32_t reflectionsDelay;
- int16_t reverbLevel;
- uint32_t reverbDelay;
- int16_t diffusion;
- int16_t density;
-} __attribute__((packed)) t_reverb_settings;
-
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTENVIRONMENTALREVERBAPI_H_*/
diff --git a/include/media/EffectEqualizerApi.h b/include/media/EffectEqualizerApi.h
deleted file mode 100644
index 950d138..0000000
--- a/include/media/EffectEqualizerApi.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTEQUALIZERAPI_H_
-#define ANDROID_EFFECTEQUALIZERAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_EQUALIZER_ = { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
-const effect_uuid_t * const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_;
-#endif //OPENSL_ES_H_
-
-#if __cplusplus
-extern "C" {
-#endif
-
-/* enumerated parameters for Equalizer effect */
-typedef enum
-{
- EQ_PARAM_NUM_BANDS, // Gets the number of frequency bands that the equalizer supports.
- EQ_PARAM_LEVEL_RANGE, // Returns the minimum and maximum band levels supported.
- EQ_PARAM_BAND_LEVEL, // Gets/Sets the gain set for the given equalizer band.
- EQ_PARAM_CENTER_FREQ, // Gets the center frequency of the given band.
- EQ_PARAM_BAND_FREQ_RANGE, // Gets the frequency range of the given frequency band.
- EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given frequency.
- EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset.
- EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports.
- EQ_PARAM_GET_PRESET_NAME, // Gets the preset name based on the index.
- EQ_PARAM_PROPERTIES // Gets/Sets all parameters at a time.
-} t_equalizer_params;
-
-//t_equalizer_settings groups all current equalizer setting for backup and restore.
-typedef struct s_equalizer_settings {
- uint16_t curPreset;
- uint16_t numBands;
- uint16_t bandLevels[];
-} t_equalizer_settings;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTEQUALIZERAPI_H_*/
diff --git a/include/media/EffectPresetReverbApi.h b/include/media/EffectPresetReverbApi.h
deleted file mode 100644
index e5b168a6..0000000
--- a/include/media/EffectPresetReverbApi.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTPRESETREVERBAPI_H_
-#define ANDROID_EFFECTPRESETREVERBAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_PRESETREVERB_ = { 0x47382d60, 0xddd8, 0x11db, 0xbf3a, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
-const effect_uuid_t * const SL_IID_PRESETREVERB = &SL_IID_PRESETREVERB_;
-#endif //OPENSL_ES_H_
-
-/* enumerated parameter settings for preset reverb effect */
-typedef enum
-{
- REVERB_PARAM_PRESET
-} t_preset_reverb_params;
-
-
-typedef enum
-{
- REVERB_PRESET_NONE,
- REVERB_PRESET_SMALLROOM,
- REVERB_PRESET_MEDIUMROOM,
- REVERB_PRESET_LARGEROOM,
- REVERB_PRESET_MEDIUMHALL,
- REVERB_PRESET_LARGEHALL,
- REVERB_PRESET_PLATE,
- REVERB_PRESET_LAST = REVERB_PRESET_PLATE
-} t_reverb_presets;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTPRESETREVERBAPI_H_*/
diff --git a/include/media/EffectVirtualizerApi.h b/include/media/EffectVirtualizerApi.h
deleted file mode 100644
index 2e216e2..0000000
--- a/include/media/EffectVirtualizerApi.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTVIRTUALIZERAPI_H_
-#define ANDROID_EFFECTVIRTUALIZERAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_VIRTUALIZER_ = { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
-const effect_uuid_t * const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_;
-#endif //OPENSL_ES_H_
-
-/* enumerated parameter settings for virtualizer effect */
-typedef enum
-{
- VIRTUALIZER_PARAM_STRENGTH_SUPPORTED,
- VIRTUALIZER_PARAM_STRENGTH
-} t_virtualizer_params;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTVIRTUALIZERAPI_H_*/
diff --git a/include/media/EffectVisualizerApi.h b/include/media/EffectVisualizerApi.h
deleted file mode 100644
index e0fa328..0000000
--- a/include/media/EffectVisualizerApi.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ANDROID_EFFECTVISUALIZERAPI_H_
-#define ANDROID_EFFECTVISUALIZERAPI_H_
-
-#include <hardware/audio_effect.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef OPENSL_ES_H_
-static const effect_uuid_t SL_IID_VISUALIZATION_ =
- { 0xe46b26a0, 0xdddd, 0x11db, 0x8afd, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
-const effect_uuid_t * const SL_IID_VISUALIZATION = &SL_IID_VISUALIZATION_;
-#endif //OPENSL_ES_H_
-
-#define VISUALIZER_CAPTURE_SIZE_MAX 1024 // maximum capture size in samples
-#define VISUALIZER_CAPTURE_SIZE_MIN 128 // minimum capture size in samples
-
-/* enumerated parameters for Visualizer effect */
-typedef enum
-{
- VISU_PARAM_CAPTURE_SIZE, // Sets the number PCM samples in the capture.
-} t_visualizer_params;
-
-/* commands */
-typedef enum
-{
- VISU_CMD_CAPTURE = EFFECT_CMD_FIRST_PROPRIETARY, // Gets the latest PCM capture.
-}t_visualizer_cmds;
-
-// VISU_CMD_CAPTURE retrieves the latest PCM snapshot captured by the visualizer engine.
-// It returns the number of samples specified by VISU_PARAM_CAPTURE_SIZE
-// in 8 bit unsigned format (0 = 0x80)
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /*ANDROID_EFFECTVISUALIZERAPI_H_*/
diff --git a/include/media/Visualizer.h b/include/media/Visualizer.h
index b8746c2..5d2c874 100644
--- a/include/media/Visualizer.h
+++ b/include/media/Visualizer.h
@@ -18,7 +18,7 @@
#define ANDROID_MEDIA_VISUALIZER_H
#include <media/AudioEffect.h>
-#include <media/EffectVisualizerApi.h>
+#include <audio_effects/effect_visualizer.h>
#include <string.h>
/**
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
index c06400e..88433fb 100644
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ b/libs/gui/tests/SurfaceTexture_test.cpp
@@ -1180,8 +1180,7 @@
sp<FrameCondition> mFC;
};
-// XXX: This test is disabled because it causes hangs on some devices.
-TEST_F(SurfaceTextureGLToGLTest, DISABLED_UpdateTexImageBeforeFrameFinishedWorks) {
+TEST_F(SurfaceTextureGLToGLTest, UpdateTexImageBeforeFrameFinishedWorks) {
class PT : public ProducerThread {
virtual void render() {
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
@@ -1199,8 +1198,7 @@
// TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
}
-// XXX: This test is disabled because it causes hangs on some devices.
-TEST_F(SurfaceTextureGLToGLTest, DISABLED_UpdateTexImageAfterFrameFinishedWorks) {
+TEST_F(SurfaceTextureGLToGLTest, UpdateTexImageAfterFrameFinishedWorks) {
class PT : public ProducerThread {
virtual void render() {
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
@@ -1218,8 +1216,7 @@
// TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
}
-// XXX: This test is disabled because it causes hangs on some devices.
-TEST_F(SurfaceTextureGLToGLTest, DISABLED_RepeatedUpdateTexImageBeforeFrameFinishedWorks) {
+TEST_F(SurfaceTextureGLToGLTest, RepeatedUpdateTexImageBeforeFrameFinishedWorks) {
enum { NUM_ITERATIONS = 1024 };
class PT : public ProducerThread {
@@ -1247,8 +1244,7 @@
}
}
-// XXX: This test is disabled because it causes hangs on some devices.
-TEST_F(SurfaceTextureGLToGLTest, DISABLED_RepeatedUpdateTexImageAfterFrameFinishedWorks) {
+TEST_F(SurfaceTextureGLToGLTest, RepeatedUpdateTexImageAfterFrameFinishedWorks) {
enum { NUM_ITERATIONS = 1024 };
class PT : public ProducerThread {
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 0310bc3..3c2d80d 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -27,6 +27,7 @@
#include "Rect.h"
#include "SkiaColorFilter.h"
+#include "Texture.h"
#include "Vertex.h"
namespace android {
@@ -40,14 +41,18 @@
* A layer has dimensions and is backed by an OpenGL texture or FBO.
*/
struct Layer {
- Layer(const uint32_t layerWidth, const uint32_t layerHeight):
- width(layerWidth), height(layerHeight) {
+ Layer(const uint32_t layerWidth, const uint32_t layerHeight) {
mesh = NULL;
meshIndices = NULL;
meshElementCount = 0;
- isCacheable = true;
- isTextureLayer = false;
+ cacheable = true;
+ textureLayer = false;
renderTarget = GL_TEXTURE_2D;
+ texture.width = layerWidth;
+ texture.height = layerHeight;
+ colorFilter = NULL;
+ firstFilter = true;
+ firstWrap = true;
}
~Layer() {
@@ -64,12 +69,152 @@
regionRect.set(bounds.leftTop().x, bounds.leftTop().y,
bounds.rightBottom().x, bounds.rightBottom().y);
- const float texX = 1.0f / float(width);
- const float texY = 1.0f / float(height);
+ const float texX = 1.0f / float(texture.width);
+ const float texY = 1.0f / float(texture.height);
const float height = layer.getHeight();
texCoords.set(
regionRect.left * texX, (height - regionRect.top) * texY,
regionRect.right * texX, (height - regionRect.bottom) * texY);
+
+ regionRect.translate(layer.left, layer.top);
+ }
+
+ inline uint32_t getWidth() {
+ return texture.width;
+ }
+
+ inline uint32_t getHeight() {
+ return texture.height;
+ }
+
+ void setSize(uint32_t width, uint32_t height) {
+ texture.width = width;
+ texture.height = height;
+ }
+
+ inline void setBlend(bool blend) {
+ texture.blend = blend;
+ }
+
+ inline bool isBlend() {
+ return texture.blend;
+ }
+
+ inline void setAlpha(int alpha) {
+ this->alpha = alpha;
+ }
+
+ inline void setAlpha(int alpha, SkXfermode::Mode mode) {
+ this->alpha = alpha;
+ this->mode = mode;
+ }
+
+ inline int getAlpha() {
+ return alpha;
+ }
+
+ inline SkXfermode::Mode getMode() {
+ return mode;
+ }
+
+ inline void setEmpty(bool empty) {
+ this->empty = empty;
+ }
+
+ inline bool isEmpty() {
+ return empty;
+ }
+
+ inline void setFbo(GLuint fbo) {
+ this->fbo = fbo;
+ }
+
+ inline GLuint getFbo() {
+ return fbo;
+ }
+
+ inline GLuint* getTexturePointer() {
+ return &texture.id;
+ }
+
+ inline GLuint getTexture() {
+ return texture.id;
+ }
+
+ inline GLenum getRenderTarget() {
+ return renderTarget;
+ }
+
+ inline void setRenderTarget(GLenum renderTarget) {
+ this->renderTarget = renderTarget;
+ }
+
+ void setWrap(GLenum wrapS, GLenum wrapT, bool bindTexture = false, bool force = false) {
+ if (firstWrap || force || wrapS != texture.wrapS || wrapT != texture.wrapT) {
+ firstWrap = true;
+ texture.setWrap(wrapS, wrapT);
+ if (bindTexture) {
+ glBindTexture(renderTarget, texture.id);
+ }
+ glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS);
+ glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT);
+ }
+ }
+
+ void setFilter(GLenum min, GLenum mag, bool bindTexture = false, bool force = false) {
+ if (firstFilter || force || min != texture.minFilter || mag != texture.magFilter) {
+ firstFilter = false;
+ texture.setFilter(min, mag);
+ if (bindTexture) {
+ glBindTexture(renderTarget, texture.id);
+ }
+ glTexParameteri(renderTarget, GL_TEXTURE_MIN_FILTER, min);
+ glTexParameteri(renderTarget, GL_TEXTURE_MAG_FILTER, mag);
+ }
+ }
+
+ inline bool isCacheable() {
+ return cacheable;
+ }
+
+ inline void setCacheable(bool cacheable) {
+ this->cacheable = cacheable;
+ }
+
+ inline bool isTextureLayer() {
+ return textureLayer;
+ }
+
+ inline void setTextureLayer(bool textureLayer) {
+ this->textureLayer = textureLayer;
+ }
+
+ inline SkiaColorFilter* getColorFilter() {
+ return colorFilter;
+ }
+
+ inline void setColorFilter(SkiaColorFilter* filter) {
+ colorFilter = filter;
+ }
+
+ inline void bindTexture() {
+ glBindTexture(renderTarget, texture.id);
+ }
+
+ inline void generateTexture() {
+ glGenTextures(1, &texture.id);
+ }
+
+ inline void deleteTexture() {
+ if (texture.id) glDeleteTextures(1, &texture.id);
+ }
+
+ inline void allocateTexture(GLenum format, GLenum storage) {
+ glTexImage2D(renderTarget, 0, format, getWidth(), getHeight(), 0, format, storage, NULL);
+ }
+
+ inline mat4& getTexTransform() {
+ return texTransform;
}
/**
@@ -82,43 +227,6 @@
Rect texCoords;
/**
- * Name of the FBO used to render the layer. If the name is 0
- * this layer is not backed by an FBO, but a simple texture.
- */
- GLuint fbo;
-
- /**
- * Opacity of the layer.
- */
- int alpha;
- /**
- * Blending mode of the layer.
- */
- SkXfermode::Mode mode;
- /**
- * Indicates whether this layer should be blended.
- */
- bool blend;
-
- /**
- * Indicates whether this layer has been used already.
- */
- bool empty;
-
- /**
- * Name of the texture used to render the layer.
- */
- GLuint texture;
- /**
- * Width of the layer texture.
- */
- uint32_t width;
- /**
- * Height of the layer texture.
- */
- uint32_t height;
-
- /**
* Dirty region indicating what parts of the layer
* have been drawn.
*/
@@ -130,37 +238,66 @@
Rect regionRect;
/**
- * Color filter used to draw this layer. Optional.
- */
- SkiaColorFilter* colorFilter;
-
- /**
* If the layer can be rendered as a mesh, this is non-null.
*/
TextureVertex* mesh;
uint16_t* meshIndices;
GLsizei meshElementCount;
+private:
+ /**
+ * Name of the FBO used to render the layer. If the name is 0
+ * this layer is not backed by an FBO, but a simple texture.
+ */
+ GLuint fbo;
+
+ /**
+ * Indicates whether this layer has been used already.
+ */
+ bool empty;
+
+ /**
+ * The texture backing this layer.
+ */
+ Texture texture;
+
/**
* If set to true (by default), the layer can be reused.
*/
- bool isCacheable;
+ bool cacheable;
/**
* When set to true, this layer must be treated as a texture
* layer.
*/
- bool isTextureLayer;
+ bool textureLayer;
+
+ /**
+ * Indicates the render target.
+ */
+ GLenum renderTarget;
+
+ /**
+ * Color filter used to draw this layer. Optional.
+ */
+ SkiaColorFilter* colorFilter;
+
+ /**
+ * Opacity of the layer.
+ */
+ int alpha;
+ /**
+ * Blending mode of the layer.
+ */
+ SkXfermode::Mode mode;
/**
* Optional texture coordinates transform.
*/
mat4 texTransform;
- /**
- * Indicates the render target.
- */
- GLenum renderTarget;
+ bool firstFilter;
+ bool firstWrap;
}; // struct Layer
}; // namespace uirenderer
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index b2d795f..1a15e87 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -68,8 +68,8 @@
void LayerCache::deleteLayer(Layer* layer) {
if (layer) {
- mSize -= layer->width * layer->height * 4;
- glDeleteTextures(1, &layer->texture);
+ mSize -= layer->getWidth() * layer->getHeight() * 4;
+ layer->deleteTexture();
delete layer;
}
}
@@ -93,29 +93,23 @@
mCache.removeAt(index);
layer = entry.mLayer;
- mSize -= layer->width * layer->height * 4;
+ mSize -= layer->getWidth() * layer->getHeight() * 4;
- LAYER_LOGD("Reusing layer %dx%d", layer->width, layer->height);
+ LAYER_LOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight());
} else {
LAYER_LOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight);
layer = new Layer(entry.mWidth, entry.mHeight);
- layer->blend = true;
- layer->empty = true;
- layer->fbo = 0;
- layer->colorFilter = NULL;
+ layer->setBlend(true);
+ layer->setEmpty(true);
+ layer->setFbo(0);
- glGenTextures(1, &layer->texture);
- glBindTexture(GL_TEXTURE_2D, layer->texture);
-
+ layer->generateTexture();
+ layer->bindTexture();
+ layer->setFilter(GL_NEAREST, GL_NEAREST);
+ layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
#if DEBUG_LAYERS
size_t size = mCache.size();
for (size_t i = 0; i < size; i++) {
@@ -133,30 +127,30 @@
// size already in the cache, and reuse it instead of creating a new one
LayerEntry entry(width, height);
- if (entry.mWidth <= layer->width && entry.mHeight <= layer->height) {
+ if (entry.mWidth <= layer->getWidth() && entry.mHeight <= layer->getHeight()) {
return true;
}
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, layer->texture);
+ uint32_t oldWidth = layer->getWidth();
+ uint32_t oldHeight = layer->getHeight();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, entry.mWidth, entry.mHeight, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glActiveTexture(GL_TEXTURE0);
+ layer->bindTexture();
+ layer->setSize(entry.mWidth, entry.mHeight);
+ layer->allocateTexture(GL_RGBA, GL_UNSIGNED_BYTE);
if (glGetError() != GL_NO_ERROR) {
+ layer->setSize(oldWidth, oldHeight);
return false;
}
- layer->width = entry.mWidth;
- layer->height = entry.mHeight;
-
return true;
}
bool LayerCache::put(Layer* layer) {
- if (!layer->isCacheable) return false;
+ if (!layer->isCacheable()) return false;
- const uint32_t size = layer->width * layer->height * 4;
+ const uint32_t size = layer->getWidth() * layer->getHeight() * 4;
// Don't even try to cache a layer that's bigger than the cache
if (size < mMaxSize) {
// TODO: Use an LRU
diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h
index d2d5f39..81b8bf3 100644
--- a/libs/hwui/LayerCache.h
+++ b/libs/hwui/LayerCache.h
@@ -119,7 +119,7 @@
}
LayerEntry(Layer* layer):
- mLayer(layer), mWidth(layer->width), mHeight(layer->height) {
+ mLayer(layer), mWidth(layer->getWidth()), mHeight(layer->getHeight()) {
}
bool operator<(const LayerEntry& rhs) const {
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index e034a868..1fa343b 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -32,9 +32,9 @@
///////////////////////////////////////////////////////////////////////////////
void LayerRenderer::prepareDirty(float left, float top, float right, float bottom, bool opaque) {
- LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo);
+ LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->getFbo());
- glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, mLayer->getFbo());
const float width = mLayer->layer.getWidth();
const float height = mLayer->layer.getHeight();
@@ -62,14 +62,14 @@
generateMesh();
- LAYER_RENDERER_LOGD("Finished rendering into layer, fbo = %d", mLayer->fbo);
+ LAYER_RENDERER_LOGD("Finished rendering into layer, fbo = %d", mLayer->getFbo());
// No need to unbind our FBO, this will be taken care of by the caller
// who will invoke OpenGLRenderer::resume()
}
GLint LayerRenderer::getTargetFbo() {
- return mLayer->fbo;
+ return mLayer->getFbo();
}
///////////////////////////////////////////////////////////////////////////////
@@ -128,8 +128,8 @@
}
mLayer->meshElementCount = elementCount;
- const float texX = 1.0f / float(mLayer->width);
- const float texY = 1.0f / float(mLayer->height);
+ const float texX = 1.0f / float(mLayer->getWidth());
+ const float texY = 1.0f / float(mLayer->getHeight());
const float height = mLayer->layer.getHeight();
TextureVertex* mesh = mLayer->mesh;
@@ -182,40 +182,41 @@
return NULL;
}
- layer->fbo = fbo;
+ layer->setFbo(fbo);
layer->layer.set(0.0f, 0.0f, width, height);
- layer->texCoords.set(0.0f, height / float(layer->height),
- width / float(layer->width), 0.0f);
- layer->alpha = 255;
- layer->mode = SkXfermode::kSrcOver_Mode;
- layer->blend = !isOpaque;
- layer->colorFilter = NULL;
+ layer->texCoords.set(0.0f, height / float(layer->getHeight()),
+ width / float(layer->getWidth()), 0.0f);
+ layer->setAlpha(255, SkXfermode::kSrcOver_Mode);
+ layer->setBlend(!isOpaque);
+ layer->setColorFilter(NULL);
layer->region.clear();
GLuint previousFbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
- glBindFramebuffer(GL_FRAMEBUFFER, layer->fbo);
- glBindTexture(GL_TEXTURE_2D, layer->texture);
+ glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
+ layer->bindTexture();
// Initialize the texture if needed
- if (layer->empty) {
- layer->empty = false;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->width, layer->height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (layer->isEmpty()) {
+ layer->setEmpty(false);
+ layer->allocateTexture(GL_RGBA, GL_UNSIGNED_BYTE);
if (glGetError() != GL_NO_ERROR) {
LOGD("Could not allocate texture");
+
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
- glDeleteTextures(1, &layer->texture);
Caches::getInstance().fboCache.put(fbo);
+
+ layer->deleteTexture();
delete layer;
+
return NULL;
}
}
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- layer->texture, 0);
+ layer->getTexture(), 0);
glDisable(GL_SCISSOR_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -229,14 +230,14 @@
bool LayerRenderer::resizeLayer(Layer* layer, uint32_t width, uint32_t height) {
if (layer) {
- LAYER_RENDERER_LOGD("Resizing layer fbo = %d to %dx%d", layer->fbo, width, height);
+ LAYER_RENDERER_LOGD("Resizing layer fbo = %d to %dx%d", layer->getFbo(), width, height);
if (Caches::getInstance().layerCache.resize(layer, width, height)) {
layer->layer.set(0.0f, 0.0f, width, height);
- layer->texCoords.set(0.0f, height / float(layer->height),
- width / float(layer->width), 0.0f);
+ layer->texCoords.set(0.0f, height / float(layer->getHeight()),
+ width / float(layer->getWidth()), 0.0f);
} else {
- if (layer->texture) glDeleteTextures(1, &layer->texture);
+ layer->deleteTexture();
delete layer;
return false;
}
@@ -245,37 +246,23 @@
return true;
}
-static void setTextureParameters(Layer* layer) {
- glBindTexture(layer->renderTarget, layer->texture);
-
- glTexParameteri(layer->renderTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(layer->renderTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-}
-
Layer* LayerRenderer::createTextureLayer(bool isOpaque) {
LAYER_RENDERER_LOGD("Creating new texture layer");
Layer* layer = new Layer(0, 0);
- layer->isCacheable = false;
- layer->isTextureLayer = true;
- layer->blend = !isOpaque;
- layer->empty = true;
- layer->fbo = 0;
- layer->colorFilter = NULL;
- layer->fbo = 0;
+ layer->setCacheable(false);
+ layer->setTextureLayer(true);
+ layer->setBlend(!isOpaque);
+ layer->setEmpty(true);
+ layer->setFbo(0);
+ layer->setAlpha(255, SkXfermode::kSrcOver_Mode);
layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f);
layer->texCoords.set(0.0f, 1.0f, 0.0f, 1.0f);
- layer->alpha = 255;
- layer->mode = SkXfermode::kSrcOver_Mode;
- layer->colorFilter = NULL;
layer->region.clear();
- layer->renderTarget = GL_NONE; // see ::updateTextureLayer()
+ layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
glActiveTexture(GL_TEXTURE0);
- glGenTextures(1, &layer->texture);
+ layer->generateTexture();
return layer;
}
@@ -283,31 +270,32 @@
void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
bool isOpaque, GLenum renderTarget, float* transform) {
if (layer) {
- layer->blend = !isOpaque;
- layer->width = width;
- layer->height = height;
+ layer->setBlend(!isOpaque);
+ layer->setSize(width, height);
layer->layer.set(0.0f, 0.0f, width, height);
layer->region.set(width, height);
layer->regionRect.set(0.0f, 0.0f, width, height);
- layer->texTransform.load(transform);
+ layer->getTexTransform().load(transform);
- if (renderTarget != layer->renderTarget) {
- layer->renderTarget = renderTarget;
- setTextureParameters(layer);
+ if (renderTarget != layer->getRenderTarget()) {
+ layer->setRenderTarget(renderTarget);
+ layer->bindTexture();
+ layer->setFilter(GL_NEAREST, GL_NEAREST, false, true);
+ layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false, true);
}
}
}
void LayerRenderer::destroyLayer(Layer* layer) {
if (layer) {
- LAYER_RENDERER_LOGD("Destroying layer, fbo = %d", layer->fbo);
+ LAYER_RENDERER_LOGD("Destroying layer, fbo = %d", layer->getFbo());
- if (layer->fbo) {
- Caches::getInstance().fboCache.put(layer->fbo);
+ if (layer->getFbo()) {
+ Caches::getInstance().fboCache.put(layer->getFbo());
}
if (!Caches::getInstance().layerCache.put(layer)) {
- if (layer->texture) glDeleteTextures(1, &layer->texture);
+ layer->deleteTexture();
delete layer;
} else {
layer->region.clear();
@@ -317,7 +305,7 @@
void LayerRenderer::destroyLayerDeferred(Layer* layer) {
if (layer) {
- LAYER_RENDERER_LOGD("Deferring layer destruction, fbo = %d", layer->fbo);
+ LAYER_RENDERER_LOGD("Deferring layer destruction, fbo = %d", layer->getFbo());
Caches::getInstance().deleteLayerDeferred(layer);
}
@@ -325,7 +313,7 @@
bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
Caches& caches = Caches::getInstance();
- if (layer && layer->isTextureLayer && bitmap->width() <= caches.maxTextureSize &&
+ if (layer && layer->isTextureLayer() && bitmap->width() <= caches.maxTextureSize &&
bitmap->height() <= caches.maxTextureSize) {
GLuint fbo = caches.fboCache.get();
@@ -365,12 +353,11 @@
break;
}
- float alpha = layer->alpha;
- SkXfermode::Mode mode = layer->mode;
+ float alpha = layer->getAlpha();
+ SkXfermode::Mode mode = layer->getMode();
- layer->mode = SkXfermode::kSrc_Mode;
- layer->alpha = 255;
- layer->fbo = fbo;
+ layer->setAlpha(255, SkXfermode::kSrc_Mode);
+ layer->setFbo(fbo);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -381,8 +368,8 @@
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -399,7 +386,7 @@
LayerRenderer renderer(layer);
renderer.setViewport(bitmap->width(), bitmap->height());
renderer.OpenGLRenderer::prepareDirty(0.0f, 0.0f,
- bitmap->width(), bitmap->height(), !layer->blend);
+ bitmap->width(), bitmap->height(), !layer->isBlend());
if ((error = glGetError()) != GL_NO_ERROR) goto error;
{
@@ -424,9 +411,8 @@
#endif
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
- layer->mode = mode;
- layer->alpha = alpha;
- layer->fbo = 0;
+ layer->setAlpha(alpha, mode);
+ layer->setFbo(0);
glDeleteTextures(1, &texture);
caches.fboCache.put(fbo);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 1c06a0b..a349121 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -449,12 +449,11 @@
return false;
}
- layer->mode = mode;
- layer->alpha = alpha;
+ layer->setAlpha(alpha, mode);
layer->layer.set(bounds);
- layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->height),
- bounds.getWidth() / float(layer->width), 0.0f);
- layer->colorFilter = mColorFilter;
+ layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->getHeight()),
+ bounds.getWidth() / float(layer->getWidth()), 0.0f);
+ layer->setColorFilter(mColorFilter);
// Save the layer in the snapshot
snapshot->flags |= Snapshot::kFlagIsLayer;
@@ -464,12 +463,13 @@
return createFboLayer(layer, bounds, snapshot, previousFbo);
} else {
// Copy the framebuffer into the layer
- glBindTexture(GL_TEXTURE_2D, layer->texture);
+ layer->bindTexture();
if (!bounds.isEmpty()) {
- if (layer->empty) {
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left,
- snapshot->height - bounds.bottom, layer->width, layer->height, 0);
- layer->empty = false;
+ if (layer->isEmpty()) {
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ bounds.left, snapshot->height - bounds.bottom,
+ layer->getWidth(), layer->getHeight(), 0);
+ layer->setEmpty(false);
} else {
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left,
snapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight());
@@ -485,7 +485,7 @@
bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, sp<Snapshot> snapshot,
GLuint previousFbo) {
- layer->fbo = mCaches.fboCache.get();
+ layer->setFbo(mCaches.fboCache.get());
#if RENDER_LAYERS_AS_REGIONS
snapshot->region = &snapshot->layer->region;
@@ -507,7 +507,7 @@
clip.translate(-bounds.left, -bounds.top);
snapshot->flags |= Snapshot::kFlagIsFboLayer;
- snapshot->fbo = layer->fbo;
+ snapshot->fbo = layer->getFbo();
snapshot->resetTransform(-bounds.left, -bounds.top, 0.0f);
snapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom);
snapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight());
@@ -516,18 +516,17 @@
snapshot->orthoMatrix.load(mOrthoMatrix);
// Bind texture to FBO
- glBindFramebuffer(GL_FRAMEBUFFER, layer->fbo);
- glBindTexture(GL_TEXTURE_2D, layer->texture);
+ glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
+ layer->bindTexture();
// Initialize the texture if needed
- if (layer->empty) {
- layer->empty = false;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->width, layer->height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (layer->isEmpty()) {
+ layer->allocateTexture(GL_RGBA, GL_UNSIGNED_BYTE);
+ layer->setEmpty(false);
}
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- layer->texture, 0);
+ layer->getTexture(), 0);
#if DEBUG_LAYERS_AS_REGIONS
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -535,8 +534,8 @@
LOGE("Framebuffer incomplete (GL error code 0x%x)", status);
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
- glDeleteTextures(1, &layer->texture);
- mCaches.fboCache.put(layer->fbo);
+ layer->deleteTexture();
+ mCaches.fboCache.put(layer->getFbo());
delete layer;
@@ -578,11 +577,11 @@
Layer* layer = current->layer;
const Rect& rect = layer->layer;
- if (!fboLayer && layer->alpha < 255) {
+ if (!fboLayer && layer->getAlpha() < 255) {
drawColorRect(rect.left, rect.top, rect.right, rect.bottom,
- layer->alpha << 24, SkXfermode::kDstIn_Mode, true);
+ layer->getAlpha() << 24, SkXfermode::kDstIn_Mode, true);
// Required below, composeLayerRect() will divide by 255
- layer->alpha = 255;
+ layer->setAlpha(255);
}
mCaches.unbindMeshBuffer();
@@ -593,18 +592,16 @@
// drawing only the dirty region
if (fboLayer) {
dirtyLayer(rect.left, rect.top, rect.right, rect.bottom, *previous->transform);
- if (layer->colorFilter) {
- setupColorFilter(layer->colorFilter);
+ if (layer->getColorFilter()) {
+ setupColorFilter(layer->getColorFilter());
}
composeLayerRegion(layer, rect);
- if (layer->colorFilter) {
+ if (layer->getColorFilter()) {
resetColorFilter();
}
- } else {
- if (!rect.isEmpty()) {
- dirtyLayer(rect.left, rect.top, rect.right, rect.bottom);
- composeLayerRect(layer, rect, true);
- }
+ } else if (!rect.isEmpty()) {
+ dirtyLayer(rect.left, rect.top, rect.right, rect.bottom);
+ composeLayerRect(layer, rect, true);
}
if (fboLayer) {
@@ -622,16 +619,16 @@
// Failing to add the layer to the cache should happen only if the layer is too large
if (!mCaches.layerCache.put(layer)) {
LAYER_LOGD("Deleting layer");
- glDeleteTextures(1, &layer->texture);
+ layer->deleteTexture();
delete layer;
}
}
void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) {
- float alpha = layer->alpha / 255.0f;
+ float alpha = layer->getAlpha() / 255.0f;
setupDraw();
- if (layer->renderTarget == GL_TEXTURE_2D) {
+ if (layer->getRenderTarget() == GL_TEXTURE_2D) {
setupDrawWithTexture();
} else {
setupDrawWithExternalTexture();
@@ -639,17 +636,28 @@
setupDrawTextureTransform();
setupDrawColor(alpha, alpha, alpha, alpha);
setupDrawColorFilter();
- setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode);
+ setupDrawBlending(layer->isBlend() || alpha < 1.0f, layer->getMode());
setupDrawProgram();
- setupDrawModelView(rect.left, rect.top, rect.right, rect.bottom);
setupDrawPureColorUniforms();
setupDrawColorFilterUniforms();
- if (layer->renderTarget == GL_TEXTURE_2D) {
- setupDrawTexture(layer->texture);
+ if (layer->getRenderTarget() == GL_TEXTURE_2D) {
+ setupDrawTexture(layer->getTexture());
} else {
- setupDrawExternalTexture(layer->texture);
+ setupDrawExternalTexture(layer->getTexture());
}
- setupDrawTextureTransformUniforms(layer->texTransform);
+ if (mSnapshot->transform->isPureTranslate() &&
+ layer->getWidth() == (uint32_t) rect.getWidth() &&
+ layer->getHeight() == (uint32_t) rect.getHeight()) {
+ const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f);
+ const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f);
+
+ layer->setFilter(GL_NEAREST, GL_NEAREST);
+ setupDrawModelView(x, y, x + rect.getWidth(), y + rect.getHeight(), true);
+ } else {
+ layer->setFilter(GL_LINEAR, GL_LINEAR);
+ setupDrawModelView(rect.left, rect.top, rect.right, rect.bottom);
+ }
+ setupDrawTextureTransformUniforms(layer->getTexTransform());
setupDrawMesh(&mMeshVertices[0].position[0], &mMeshVertices[0].texture[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount);
@@ -658,14 +666,34 @@
}
void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) {
- if (!layer->isTextureLayer) {
+ if (!layer->isTextureLayer()) {
const Rect& texCoords = layer->texCoords;
resetDrawTextureTexCoords(texCoords.left, texCoords.top,
texCoords.right, texCoords.bottom);
- drawTextureMesh(rect.left, rect.top, rect.right, rect.bottom, layer->texture,
- layer->alpha / 255.0f, layer->mode, layer->blend, &mMeshVertices[0].position[0],
- &mMeshVertices[0].texture[0], GL_TRIANGLE_STRIP, gMeshCount, swap, swap);
+ float x = rect.left;
+ float y = rect.top;
+ bool simpleTransform = mSnapshot->transform->isPureTranslate() &&
+ layer->getWidth() == (uint32_t) rect.getWidth() &&
+ layer->getHeight() == (uint32_t) rect.getHeight();
+
+ if (simpleTransform) {
+ // When we're swapping, the layer is already in screen coordinates
+ if (!swap) {
+ x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f);
+ y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f);
+ }
+
+ layer->setFilter(GL_NEAREST, GL_NEAREST, true);
+ } else {
+ layer->setFilter(GL_LINEAR, GL_LINEAR, true);
+ }
+
+ drawTextureMesh(x, y, x + rect.getWidth(), y + rect.getHeight(),
+ layer->getTexture(), layer->getAlpha() / 255.0f,
+ layer->getMode(), layer->isBlend(),
+ &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0],
+ GL_TRIANGLE_STRIP, gMeshCount, swap, swap || simpleTransform);
resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
} else {
@@ -690,9 +718,9 @@
size_t count;
const android::Rect* rects = layer->region.getArray(&count);
- const float alpha = layer->alpha / 255.0f;
- const float texX = 1.0f / float(layer->width);
- const float texY = 1.0f / float(layer->height);
+ const float alpha = layer->getAlpha() / 255.0f;
+ const float texX = 1.0f / float(layer->getWidth());
+ const float texY = 1.0f / float(layer->getHeight());
const float height = rect.getHeight();
TextureVertex* mesh = mCaches.getRegionMesh();
@@ -702,13 +730,22 @@
setupDrawWithTexture();
setupDrawColor(alpha, alpha, alpha, alpha);
setupDrawColorFilter();
- setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false);
+ setupDrawBlending(layer->isBlend() || alpha < 1.0f, layer->getMode(), false);
setupDrawProgram();
setupDrawDirtyRegionsDisabled();
setupDrawPureColorUniforms();
setupDrawColorFilterUniforms();
- setupDrawTexture(layer->texture);
- setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom);
+ setupDrawTexture(layer->getTexture());
+ if (mSnapshot->transform->isPureTranslate()) {
+ const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f);
+ const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f);
+
+ layer->setFilter(GL_NEAREST, GL_NEAREST);
+ setupDrawModelViewTranslate(x, y, x + rect.getWidth(), y + rect.getHeight(), true);
+ } else {
+ layer->setFilter(GL_LINEAR, GL_LINEAR);
+ setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom);
+ }
setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]);
for (size_t i = 0; i < count; i++) {
@@ -2154,8 +2191,7 @@
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
- layer->alpha = alpha;
- layer->mode = mode;
+ layer->setAlpha(alpha, mode);
#if RENDER_LAYERS_AS_REGIONS
if (!layer->region.isEmpty()) {
@@ -2169,13 +2205,23 @@
setupDrawWithTexture();
setupDrawColor(a, a, a, a);
setupDrawColorFilter();
- setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false);
+ setupDrawBlending(layer->isBlend() || a < 1.0f, layer->getMode(), false);
setupDrawProgram();
- setupDrawModelViewTranslate(x, y,
- x + layer->layer.getWidth(), y + layer->layer.getHeight());
setupDrawPureColorUniforms();
setupDrawColorFilterUniforms();
- setupDrawTexture(layer->texture);
+ setupDrawTexture(layer->getTexture());
+ if (mSnapshot->transform->isPureTranslate()) {
+ x = (int) floorf(x + mSnapshot->transform->getTranslateX() + 0.5f);
+ y = (int) floorf(y + mSnapshot->transform->getTranslateY() + 0.5f);
+
+ layer->setFilter(GL_NEAREST, GL_NEAREST);
+ setupDrawModelViewTranslate(x, y,
+ x + layer->layer.getWidth(), y + layer->layer.getHeight(), true);
+ } else {
+ layer->setFilter(GL_LINEAR, GL_LINEAR);
+ setupDrawModelViewTranslate(x, y,
+ x + layer->layer.getWidth(), y + layer->layer.getHeight());
+ }
setupDrawMesh(&layer->mesh[0].position[0], &layer->mesh[0].texture[0]);
glDrawElements(GL_TRIANGLES, layer->meshElementCount,
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index 4922bb3..c6ae326 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -29,8 +29,22 @@
Texture() {
cleanup = false;
bitmapSize = 0;
+
wrapS = GL_CLAMP_TO_EDGE;
wrapT = GL_CLAMP_TO_EDGE;
+
+ minFilter = GL_NEAREST;
+ magFilter = GL_NEAREST;
+ }
+
+ void setWrap(GLenum wrapS, GLenum wrapT) {
+ this->wrapS = wrapS;
+ this->wrapT = wrapT;
+ }
+
+ void setFilter(GLenum min, GLenum mag) {
+ minFilter = min;
+ magFilter = mag;
}
/**
@@ -67,6 +81,12 @@
*/
GLenum wrapS;
GLenum wrapT;
+
+ /**
+ * Last filters set on this texture. Defaults to GL_NEAREST.
+ */
+ GLenum minFilter;
+ GLenum magFilter;
}; // struct Texture
class AutoTexture {
diff --git a/media/jni/audioeffect/Android.mk b/media/jni/audioeffect/Android.mk
index 4c5cf71..3e493b1 100644
--- a/media/jni/audioeffect/Android.mk
+++ b/media/jni/audioeffect/Android.mk
@@ -12,6 +12,9 @@
libnativehelper \
libmedia
+LOCAL_C_INCLUDES := \
+ system/media/audio_effects/include
+
LOCAL_MODULE:= libaudioeffect_jni
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
index 99cfdfa..ab13605 100644
--- a/media/libeffects/lvm/wrapper/Android.mk
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -30,7 +30,8 @@
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/Bundle \
$(LOCAL_PATH)/../lib/Common/lib/ \
- $(LOCAL_PATH)/../lib/Bundle/lib/
+ $(LOCAL_PATH)/../lib/Bundle/lib/ \
+ system/media/audio_effects/include
include $(BUILD_SHARED_LIBRARY)
@@ -64,6 +65,6 @@
$(LOCAL_PATH)/Reverb \
$(LOCAL_PATH)/../lib/Common/lib/ \
$(LOCAL_PATH)/../lib/Reverb/lib/ \
-
+ system/media/audio_effects/include
include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index 2b51029..5634ca1 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -17,9 +17,9 @@
#ifndef ANDROID_EFFECTBUNDLE_H_
#define ANDROID_EFFECTBUNDLE_H_
-#include <media/EffectEqualizerApi.h>
-#include <media/EffectBassBoostApi.h>
-#include <media/EffectVirtualizerApi.h>
+#include <audio_effects/effect_bassboost.h>
+#include <audio_effects/effect_equalizer.h>
+#include <audio_effects/effect_virtualizer.h>
#include <LVM.h>
#include <limits.h>
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
index 093992b..7c15b18 100644
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_EFFECTREVERB_H_
#define ANDROID_EFFECTREVERB_H_
-#include <media/EffectEnvironmentalReverbApi.h>
-#include <media/EffectPresetReverbApi.h>
+#include <audio_effects/effect_environmentalreverb.h>
+#include <audio_effects/effect_presetreverb.h>
#if __cplusplus
extern "C" {
diff --git a/media/libeffects/testlibs/Android.mk_ b/media/libeffects/testlibs/Android.mk_
index 98d477b..249ebf4 100644
--- a/media/libeffects/testlibs/Android.mk_
+++ b/media/libeffects/testlibs/Android.mk_
@@ -23,6 +23,7 @@
endif
LOCAL_C_INCLUDES := \
+ system/media/audio_effects/include \
$(call include-path-for, graphics corecg)
LOCAL_MODULE_TAGS := optional
@@ -58,7 +59,8 @@
endif
LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg)
+ $(call include-path-for, graphics corecg) \
+ system/media/audio_effects/include
LOCAL_MODULE_TAGS := optional
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 43dfa82..c2ffce5 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -26,7 +26,8 @@
#include "AudioEqualizer.h"
#include "AudioBiquadFilter.h"
#include "AudioFormatAdapter.h"
-#include <media/EffectEqualizerApi.h>
+#include <audio_effects/effect_equalizer.h>
+
// effect_handle_t interface implementation for equalizer effect
extern "C" const struct effect_interface_s gEqualizerInterface;
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index a239814..8e2cc31 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_EFFECTREVERB_H_
#define ANDROID_EFFECTREVERB_H_
-#include <media/EffectEnvironmentalReverbApi.h>
-#include <media/EffectPresetReverbApi.h>
+#include <audio_effects/effect_environmentalreverb.h>
+#include <audio_effects/effect_presetreverb.h>
/*------------------------------------
diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk
index 3a0f438..dff585f 100644
--- a/media/libeffects/visualizer/Android.mk
+++ b/media/libeffects/visualizer/Android.mk
@@ -23,8 +23,8 @@
endif
LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg)
-
+ $(call include-path-for, graphics corecg) \
+ system/media/audio_effects/include
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index 80d1f69..aeebd4d 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <new>
-#include <media/EffectVisualizerApi.h>
+#include <audio_effects/effect_visualizer.h>
extern "C" {
@@ -375,7 +375,7 @@
p->status = 0;
*replySize = sizeof(effect_param_t) + sizeof(uint32_t);
if (p->psize != sizeof(uint32_t) ||
- *(uint32_t *)p->data != VISU_PARAM_CAPTURE_SIZE) {
+ *(uint32_t *)p->data != VISUALIZER_PARAM_CAPTURE_SIZE) {
p->status = -EINVAL;
break;
}
@@ -394,7 +394,7 @@
effect_param_t *p = (effect_param_t *)pCmdData;
if (p->psize != sizeof(uint32_t) ||
p->vsize != sizeof(uint32_t) ||
- *(uint32_t *)p->data != VISU_PARAM_CAPTURE_SIZE) {
+ *(uint32_t *)p->data != VISUALIZER_PARAM_CAPTURE_SIZE) {
*(int32_t *)pReplyData = -EINVAL;
break;;
}
@@ -407,9 +407,9 @@
break;
- case VISU_CMD_CAPTURE:
+ case VISUALIZER_CMD_CAPTURE:
if (pReplyData == NULL || *replySize != pContext->mCaptureSize) {
- LOGV("VISU_CMD_CAPTURE() error *replySize %d pContext->mCaptureSize %d",
+ LOGV("VISUALIZER_CMD_CAPTURE() error *replySize %d pContext->mCaptureSize %d",
*replySize, pContext->mCaptureSize);
return -EINVAL;
}
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 121e38a4..f7c54fa 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -68,6 +68,7 @@
$(call include-path-for, graphics corecg) \
$(TOP)/frameworks/base/include/media/stagefright/openmax \
external/icu4c/common \
- external/expat/lib
+ external/expat/lib \
+ system/media/audio_effects/include
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index 366707c..bf40481 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -143,7 +143,7 @@
p->psize = sizeof(uint32_t);
p->vsize = sizeof(uint32_t);
- *(int32_t *)p->data = VISU_PARAM_CAPTURE_SIZE;
+ *(int32_t *)p->data = VISUALIZER_PARAM_CAPTURE_SIZE;
*((int32_t *)p->data + 1)= size;
status_t status = setParameter(p);
@@ -171,7 +171,7 @@
status_t status = NO_ERROR;
if (mEnabled) {
uint32_t replySize = mCaptureSize;
- status = command(VISU_CMD_CAPTURE, 0, NULL, &replySize, waveform);
+ status = command(VISUALIZER_CMD_CAPTURE, 0, NULL, &replySize, waveform);
LOGV("getWaveForm() command returned %d", status);
if (replySize == 0) {
status = NOT_ENOUGH_DATA;
@@ -276,7 +276,7 @@
p->psize = sizeof(uint32_t);
p->vsize = sizeof(uint32_t);
- *(int32_t *)p->data = VISU_PARAM_CAPTURE_SIZE;
+ *(int32_t *)p->data = VISUALIZER_PARAM_CAPTURE_SIZE;
status_t status = getParameter(p);
if (status == NO_ERROR) {
diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
index 4a80489..efdd9ac 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
@@ -22,11 +22,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recents_root"
android:layout_height="match_parent"
- android:layout_width="wrap_content">
+ android:layout_width="match_parent">
<FrameLayout
android:id="@+id/recents_bg_protect"
- android:background="@drawable/recents_bg_protect_tile"
+ android:background="@drawable/status_bar_recents_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
@@ -38,7 +38,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
- android:background="@drawable/recents_blue_glow"
android:orientation="horizontal"
android:clipToPadding="false"
android:clipChildren="false"
@@ -78,6 +77,7 @@
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/ic_sysbar_back_ime"
+ android:visibility="gone"
/>
</com.android.systemui.recent.RecentsPanelView>
diff --git a/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
index 9391f9d..386182d 100644
--- a/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
@@ -26,7 +26,7 @@
<FrameLayout
android:id="@+id/recents_bg_protect"
- android:background="@drawable/recents_bg_protect_tile"
+ android:background="@drawable/status_bar_recents_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
@@ -39,7 +39,6 @@
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_gravity="bottom"
- android:background="@drawable/recents_blue_glow"
android:orientation="horizontal"
android:clipToPadding="false"
android:clipChildren="false"
@@ -79,6 +78,7 @@
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/ic_sysbar_back_ime"
+ android:visibility="gone"
/>
</com.android.systemui.recent.RecentsPanelView>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 9341693..fd5fe7a 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -21,4 +21,5 @@
<drawable name="notification_item_background_color">#ff000000</drawable>
<drawable name="ticker_background_color">#ff1d1d1d</drawable>
<drawable name="status_bar_background">#000000</drawable>
+ <drawable name="status_bar_recents_background">#b3000000</drawable>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java b/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
index 49a65d8..37a9913 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
@@ -18,7 +18,9 @@
import android.animation.Animator;
import android.animation.AnimatorSet;
+import android.animation.AnimatorSet.Builder;
import android.animation.ObjectAnimator;
+import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.Slog;
import android.view.View;
@@ -78,14 +80,14 @@
? new android.view.animation.AccelerateInterpolator(1.0f)
: new android.view.animation.DecelerateInterpolator(1.0f));
- Animator bgAnim = ObjectAnimator.ofInt(mScrimView.getBackground(),
- "alpha", appearing ? 0 : 255, appearing ? 255 : 0);
-
mContentAnim = new AnimatorSet();
- mContentAnim
- .play(bgAnim)
- .with(glowAnim)
- .with(posAnim);
+ final Builder builder = mContentAnim.play(glowAnim).with(posAnim);
+ Drawable background = mScrimView.getBackground();
+ if (background != null) {
+ Animator bgAnim = ObjectAnimator.ofInt(background,
+ "alpha", appearing ? 0 : 255, appearing ? 255 : 0);
+ builder.with(bgAnim);
+ }
mContentAnim.setDuration(appearing ? OPEN_DURATION : CLOSE_DURATION);
mContentAnim.addListener(this);
if (mListener != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/recent/Constants.java b/packages/SystemUI/src/com/android/systemui/recent/Constants.java
new file mode 100644
index 0000000..66f9292
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recent/Constants.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recent;
+
+public class Constants {
+ static final int MAX_ESCAPE_ANIMATION_DURATION = 500; // in ms
+ static final float FADE_CONSTANT = 0.5f; // unitless
+ static final int SNAP_BACK_DURATION = 250; // in ms
+ static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it in dp/s
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 3dbcc59..fb7a0a7 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -25,6 +25,7 @@
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
+import android.content.res.Configuration;
import android.database.DataSetObserver;
import android.graphics.RectF;
import android.util.AttributeSet;
@@ -33,6 +34,7 @@
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.HorizontalScrollView;
@@ -42,12 +44,9 @@
public class RecentsHorizontalScrollView extends HorizontalScrollView
implements View.OnClickListener, View.OnTouchListener {
- private static final float FADE_CONSTANT = 0.5f;
- private static final int SNAP_BACK_DURATION = 250;
- private static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it
- private static final String TAG = RecentsPanelView.TAG;
- private static final float THRESHHOLD = 50;
private static final boolean DEBUG_INVALIDATE = false;
+ private static final String TAG = RecentsPanelView.TAG;
+ private static final boolean DEBUG = RecentsPanelView.DEBUG;
private LinearLayout mLinearLayout;
private ActivityDescriptionAdapter mAdapter;
private RecentsCallback mCallback;
@@ -56,6 +55,8 @@
private float mLastY;
private boolean mDragging;
private VelocityTracker mVelocityTracker;
+ private float mDensityScale;
+ private float mPagingTouchSlop;
public RecentsHorizontalScrollView(Context context) {
this(context, null);
@@ -63,6 +64,8 @@
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
+ mDensityScale = getResources().getDisplayMetrics().density;
+ mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
}
private int scrollPositionOfMostRecent() {
@@ -101,7 +104,8 @@
case MotionEvent.ACTION_MOVE:
float delta = ev.getY() - mLastY;
- if (Math.abs(delta) > THRESHHOLD) {
+ if (DEBUG) Log.v(TAG, "ACTION_MOVE : " + delta);
+ if (Math.abs(delta) > mPagingTouchSlop) {
mDragging = true;
}
break;
@@ -114,13 +118,14 @@
}
private float getAlphaForOffset(View view, float thumbHeight) {
- final float fadeHeight = FADE_CONSTANT * thumbHeight;
+ final float fadeHeight = Constants.FADE_CONSTANT * thumbHeight;
float result = 1.0f;
if (view.getY() >= thumbHeight) {
result = 1.0f - (view.getY() - thumbHeight) / fadeHeight;
} else if (view.getY() < 0.0f) {
result = 1.0f + (thumbHeight + view.getY()) / fadeHeight;
}
+ if (DEBUG) Log.v(TAG, "FADE AMOUNT: " + result);
return result;
}
@@ -155,12 +160,13 @@
final float velocityY = velocityTracker.getYVelocity();
final float curY = animView.getY();
final float newY = (velocityY >= 0.0f ? 1 : -1) * animView.getHeight();
-
+ final float maxVelocity = Constants.ESCAPE_VELOCITY * mDensityScale;
if (Math.abs(velocityY) > Math.abs(velocityX)
- && Math.abs(velocityY) > ESCAPE_VELOCITY
+ && Math.abs(velocityY) > maxVelocity
&& (velocityY >= 0.0f) == (animView.getY() >= 0)) {
- final long duration =
+ long duration =
(long) (Math.abs(newY - curY) * 1000.0f / Math.abs(velocityY));
+ duration = Math.min(duration, Constants.MAX_ESCAPE_ANIMATION_DURATION);
anim = ObjectAnimator.ofFloat(animView, "y", curY, newY);
anim.setInterpolator(new LinearInterpolator());
final int swipeDirection = animView.getY() >= 0.0f ?
@@ -181,9 +187,10 @@
});
anim.setDuration(duration);
} else { // Animate back to position
- final long duration = Math.abs(velocityY) > 0.0f ?
+ long duration = Math.abs(velocityY) > 0.0f ?
(long) (Math.abs(newY - curY) * 1000.0f / Math.abs(velocityY))
- : SNAP_BACK_DURATION;
+ : Constants.SNAP_BACK_DURATION;
+ duration = Math.min(duration, Constants.SNAP_BACK_DURATION);
anim = ObjectAnimator.ofFloat(animView, "y", animView.getY(), 0.0f);
anim.setInterpolator(new DecelerateInterpolator(2.0f));
anim.setDuration(duration);
@@ -241,8 +248,15 @@
setOverScrollEffectPadding(leftPadding, 0);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDensityScale = getResources().getDisplayMetrics().density;
+ mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
+ }
+
private void setOverScrollEffectPadding(int leftPadding, int i) {
- // TODO Add to RecentsHorizontalScrollView
+ // TODO Add to (Vertical)ScrollView
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 408436a..a55fe9c 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -318,7 +318,11 @@
}
private Drawable getFullResIcon(Resources resources, int iconId) {
- return resources.getDrawableForDensity(iconId, mIconDpi);
+ try {
+ return resources.getDrawableForDensity(iconId, mIconDpi);
+ } catch (Resources.NotFoundException e) {
+ return getFullResDefaultActivityIcon();
+ }
}
private Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) {
@@ -413,11 +417,11 @@
mActivityDescriptions = getRecentTasks();
mListAdapter.notifyDataSetInvalidated();
if (mActivityDescriptions.size() > 0) {
- Log.v(TAG, "Showing " + mActivityDescriptions.size() + " apps");
+ if (DEBUG) Log.v(TAG, "Showing " + mActivityDescriptions.size() + " apps");
updateUiElements(getResources().getConfiguration());
} else {
// Immediately hide this panel
- Log.v(TAG, "Nothing to show");
+ if (DEBUG) Log.v(TAG, "Nothing to show");
hide(false);
}
}
@@ -432,7 +436,7 @@
paint.setAlpha(255);
final int srcWidth = thumbnail.getWidth();
final int srcHeight = thumbnail.getHeight();
- Log.v(TAG, "Source thumb: " + srcWidth + "x" + srcHeight);
+ if (DEBUG) Log.v(TAG, "Source thumb: " + srcWidth + "x" + srcHeight);
canvas.drawBitmap(thumbnail,
new Rect(0, 0, srcWidth-1, srcHeight-1),
new RectF(mGlowBitmapPaddingLeftPx, mGlowBitmapPaddingTopPx,
@@ -482,7 +486,7 @@
public void handleSwipe(View view, int direction) {
ActivityDescription ad = ((ViewHolder) view.getTag()).activityDescription;
- Log.v(TAG, "Jettison " + ad.label);
+ if (DEBUG) Log.v(TAG, "Jettison " + ad.label);
mActivityDescriptions.remove(ad);
// Handled by widget containers to enable LayoutTransitions properly
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index 6a962cb..711ffa3 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -25,6 +25,7 @@
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
+import android.content.res.Configuration;
import android.database.DataSetObserver;
import android.graphics.RectF;
import android.util.AttributeSet;
@@ -33,6 +34,7 @@
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.LinearLayout;
@@ -42,12 +44,9 @@
public class RecentsVerticalScrollView extends ScrollView
implements View.OnClickListener, View.OnTouchListener {
- private static final float FADE_CONSTANT = 0.5f;
- private static final int SNAP_BACK_DURATION = 250;
- private static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it
private static final String TAG = RecentsPanelView.TAG;
- private static final float THRESHHOLD = 50;
private static final boolean DEBUG_INVALIDATE = false;
+ private static final boolean DEBUG = RecentsPanelView.DEBUG;
private LinearLayout mLinearLayout;
private ActivityDescriptionAdapter mAdapter;
private RecentsCallback mCallback;
@@ -56,6 +55,8 @@
private float mLastX;
private boolean mDragging;
private VelocityTracker mVelocityTracker;
+ private float mDensityScale;
+ private float mPagingTouchSlop;
public RecentsVerticalScrollView(Context context) {
this(context, null);
@@ -63,6 +64,8 @@
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
+ mDensityScale = getResources().getDisplayMetrics().density;
+ mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
}
private int scrollPositionOfMostRecent() {
@@ -101,8 +104,8 @@
case MotionEvent.ACTION_MOVE:
float delta = ev.getX() - mLastX;
- Log.v(TAG, "ACTION_MOVE : " + delta);
- if (Math.abs(delta) > THRESHHOLD) {
+ if (DEBUG) Log.v(TAG, "ACTION_MOVE : " + delta);
+ if (Math.abs(delta) > mPagingTouchSlop) {
mDragging = true;
}
break;
@@ -115,14 +118,14 @@
}
private float getAlphaForOffset(View view, float thumbWidth) {
- final float fadeWidth = FADE_CONSTANT * thumbWidth;
+ final float fadeWidth = Constants.FADE_CONSTANT * thumbWidth;
float result = 1.0f;
if (view.getX() >= thumbWidth) {
result = 1.0f - (view.getX() - thumbWidth) / fadeWidth;
} else if (view.getX() < 0.0f) {
result = 1.0f + (thumbWidth + view.getX()) / fadeWidth;
}
- Log.v(TAG, "FADE AMOUNT: " + result);
+ if (DEBUG) Log.v(TAG, "FADE AMOUNT: " + result);
return result;
}
@@ -157,12 +160,13 @@
final float velocityY = velocityTracker.getYVelocity();
final float curX = animView.getX();
final float newX = (velocityX >= 0.0f ? 1 : -1) * animView.getWidth();
-
+ final float maxVelocity = Constants.ESCAPE_VELOCITY * mDensityScale;
if (Math.abs(velocityX) > Math.abs(velocityY)
- && Math.abs(velocityX) > ESCAPE_VELOCITY
+ && Math.abs(velocityX) > maxVelocity
&& (velocityX > 0.0f) == (animView.getX() >= 0)) {
- final long duration =
+ long duration =
(long) (Math.abs(newX-curX) * 1000.0f / Math.abs(velocityX));
+ duration = Math.min(duration, Constants.MAX_ESCAPE_ANIMATION_DURATION);
anim = ObjectAnimator.ofFloat(animView, "x", curX, newX);
anim.setInterpolator(new LinearInterpolator());
final int swipeDirection = animView.getX() >= 0.0f ?
@@ -183,9 +187,10 @@
});
anim.setDuration(duration);
} else { // Animate back to position
- final long duration = Math.abs(velocityX) > 0.0f ?
+ long duration = Math.abs(velocityX) > 0.0f ?
(long) (Math.abs(newX-curX) * 1000.0f / Math.abs(velocityX))
- : SNAP_BACK_DURATION;
+ : Constants.SNAP_BACK_DURATION;
+ duration = Math.min(duration, Constants.SNAP_BACK_DURATION);
anim = ObjectAnimator.ofFloat(animView, "x", animView.getX(), 0.0f);
anim.setInterpolator(new DecelerateInterpolator(4.0f));
anim.setDuration(duration);
@@ -243,6 +248,13 @@
setOverScrollEffectPadding(leftPadding, 0);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDensityScale = getResources().getDisplayMetrics().density;
+ mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
+ }
+
private void setOverScrollEffectPadding(int leftPadding, int i) {
// TODO Add to (Vertical)ScrollView
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 4c7b0dd..5eacad7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -53,6 +53,7 @@
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
@@ -318,11 +319,11 @@
return sb;
}
- protected WindowManager.LayoutParams getRecentsLayoutParams() {
+ protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) {
boolean translucent = false;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT,
+ layoutParams.width,
+ layoutParams.height,
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
@@ -344,13 +345,16 @@
visible = mRecentsPanel.getVisibility() == View.VISIBLE;
WindowManagerImpl.getDefault().removeView(mRecentsPanel);
}
- mRecentsPanel = (RecentsPanelView) View.inflate(mContext,
- R.layout.status_bar_recent_panel, null);
+
+ // Provide RecentsPanelView with a temporary parent to allow layout params to work.
+ LinearLayout tmpRoot = new LinearLayout(mContext);
+ mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate(
+ R.layout.status_bar_recent_panel, tmpRoot, false);
mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL,
mRecentsPanel));
mRecentsPanel.setVisibility(View.GONE);
- WindowManager.LayoutParams lp = getRecentsLayoutParams();
+ WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams());
WindowManagerImpl.getDefault().addView(mRecentsPanel, lp);
mRecentsPanel.setBar(this);
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index 2222e8b..75d24a1 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -10,6 +10,9 @@
AudioResamplerCubic.cpp.arm \
AudioPolicyService.cpp
+LOCAL_C_INCLUDES := \
+ system/media/audio_effects/include
+
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index f716e63..daf94f2 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -50,7 +50,7 @@
#include "AudioFlinger.h"
#include <media/EffectsFactoryApi.h>
-#include <media/EffectVisualizerApi.h>
+#include <audio_effects/effect_visualizer.h>
// ----------------------------------------------------------------------------
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 6afccec..786f2fa 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -224,6 +224,7 @@
public PackageInfo pkgInfo;
public int pmToken; // in post-install restore, the PM's token for this transaction
public boolean needFullBackup;
+ public String[] filterSet;
RestoreParams(IBackupTransport _transport, IRestoreObserver _obs,
long _token, PackageInfo _pkg, int _pmToken, boolean _needFullBackup) {
@@ -233,6 +234,7 @@
pkgInfo = _pkg;
pmToken = _pmToken;
needFullBackup = _needFullBackup;
+ filterSet = null;
}
RestoreParams(IBackupTransport _transport, IRestoreObserver _obs, long _token,
@@ -243,6 +245,18 @@
pkgInfo = null;
pmToken = 0;
needFullBackup = _needFullBackup;
+ filterSet = null;
+ }
+
+ RestoreParams(IBackupTransport _transport, IRestoreObserver _obs, long _token,
+ String[] _filterSet, boolean _needFullBackup) {
+ transport = _transport;
+ observer = _obs;
+ token = _token;
+ pkgInfo = null;
+ pmToken = 0;
+ needFullBackup = _needFullBackup;
+ filterSet = _filterSet;
}
}
@@ -404,7 +418,7 @@
Slog.d(TAG, "MSG_RUN_RESTORE observer=" + params.observer);
(new PerformRestoreTask(params.transport, params.observer,
params.token, params.pkgInfo, params.pmToken,
- params.needFullBackup)).run();
+ params.needFullBackup, params.filterSet)).run();
break;
}
@@ -3020,6 +3034,7 @@
private File mStateDir;
private int mPmToken;
private boolean mNeedFullBackup;
+ private HashSet<String> mFilterSet;
class RestoreRequest {
public PackageInfo app;
@@ -3033,7 +3048,7 @@
PerformRestoreTask(IBackupTransport transport, IRestoreObserver observer,
long restoreSetToken, PackageInfo targetPackage, int pmToken,
- boolean needFullBackup) {
+ boolean needFullBackup, String[] filterSet) {
mTransport = transport;
mObserver = observer;
mToken = restoreSetToken;
@@ -3041,6 +3056,15 @@
mPmToken = pmToken;
mNeedFullBackup = needFullBackup;
+ if (filterSet != null) {
+ mFilterSet = new HashSet<String>();
+ for (String pkg : filterSet) {
+ mFilterSet.add(pkg);
+ }
+ } else {
+ mFilterSet = null;
+ }
+
try {
mStateDir = new File(mBaseStateDir, transport.transportDirName());
} catch (RemoteException e) {
@@ -3052,7 +3076,8 @@
long startRealtime = SystemClock.elapsedRealtime();
if (DEBUG) Slog.v(TAG, "Beginning restore process mTransport=" + mTransport
+ " mObserver=" + mObserver + " mToken=" + Long.toHexString(mToken)
- + " mTargetPackage=" + mTargetPackage + " mPmToken=" + mPmToken);
+ + " mTargetPackage=" + mTargetPackage + " mFilterSet=" + mFilterSet
+ + " mPmToken=" + mPmToken);
PackageManagerBackupAgent pmAgent = null;
int error = -1; // assume error
@@ -3071,6 +3096,22 @@
List<PackageInfo> agentPackages = allAgentPackages();
if (mTargetPackage == null) {
+ // if there's a filter set, strip out anything that isn't
+ // present before proceeding
+ if (mFilterSet != null) {
+ for (int i = agentPackages.size() - 1; i >= 0; i--) {
+ final PackageInfo pkg = agentPackages.get(i);
+ if (! mFilterSet.contains(pkg.packageName)) {
+ agentPackages.remove(i);
+ }
+ }
+ if (DEBUG) {
+ Slog.i(TAG, "Post-filter package set for restore:");
+ for (PackageInfo p : agentPackages) {
+ Slog.i(TAG, " " + p);
+ }
+ }
+ }
restorePackages.addAll(agentPackages);
} else {
// Just one package to attempt restore of
@@ -4266,6 +4307,67 @@
return -1;
}
+ public synchronized int restoreSome(long token, IRestoreObserver observer,
+ String[] packages) {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+ "performRestore");
+
+ if (DEBUG) {
+ StringBuilder b = new StringBuilder(128);
+ b.append("restoreSome token=");
+ b.append(Long.toHexString(token));
+ b.append(" observer=");
+ b.append(observer.toString());
+ b.append(" packages=");
+ if (packages == null) {
+ b.append("null");
+ } else {
+ b.append('{');
+ boolean first = true;
+ for (String s : packages) {
+ if (!first) {
+ b.append(", ");
+ } else first = false;
+ b.append(s);
+ }
+ b.append('}');
+ }
+ Slog.d(TAG, b.toString());
+ }
+
+ if (mEnded) {
+ throw new IllegalStateException("Restore session already ended");
+ }
+
+ if (mRestoreTransport == null || mRestoreSets == null) {
+ Slog.e(TAG, "Ignoring restoreAll() with no restore set");
+ return -1;
+ }
+
+ if (mPackageName != null) {
+ Slog.e(TAG, "Ignoring restoreAll() on single-package session");
+ return -1;
+ }
+
+ synchronized (mQueueLock) {
+ for (int i = 0; i < mRestoreSets.length; i++) {
+ if (token == mRestoreSets[i].token) {
+ long oldId = Binder.clearCallingIdentity();
+ mWakelock.acquire();
+ Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
+ msg.obj = new RestoreParams(mRestoreTransport, observer, token,
+ packages, true);
+ mBackupHandler.sendMessage(msg);
+ Binder.restoreCallingIdentity(oldId);
+ return 0;
+ }
+ }
+ }
+
+ Slog.w(TAG, "Restore token " + Long.toHexString(token) + " not found");
+ return -1;
+ }
+
public synchronized int restorePackage(String packageName, IRestoreObserver observer) {
if (DEBUG) Slog.v(TAG, "restorePackage pkg=" + packageName + " obs=" + observer);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 3bf309b..be21ac0 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -231,7 +231,7 @@
// Maximum number of milliseconds to wait for input devices to be enumerated before
// proceding with safe mode detection.
private static final int INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS = 1000;
-
+
// Default input dispatching timeout in nanoseconds.
static final long DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS = 5000 * 1000000L;
@@ -4886,8 +4886,13 @@
int fw = frame.width();
int fh = frame.height();
- // First try reducing to fit in x dimension.
- scale = width/(float)fw;
+ // Constrain thumbnail to smaller of screen width or height. Assumes aspect
+ // of thumbnail is the same as the screen (in landscape) or square.
+ if (dw <= dh) {
+ scale = width / (float) fw; // portrait
+ } else {
+ scale = height / (float) fh; // landscape
+ }
// The screen shot will contain the entire screen.
dw = (int)(dw*scale);
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
index 9695344..1f24b58 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
@@ -76,8 +76,6 @@
+ "' APN: '" + mApn.apn
+ "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
- setHttpProxy (mApn.proxy, mApn.port);
-
createTime = -1;
lastFailTime = -1;
lastFailCause = FailCause.NONE;
@@ -152,38 +150,6 @@
Log.d(LOG_TAG, "[" + getName() + "] " + s);
}
- private void setHttpProxy(String httpProxy, String httpPort) {
-
- if (DBG) log("set http proxy for"
- + "' APN: '" + mActiveApnType
- + "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
- if(TextUtils.equals(mActiveApnType, Phone.APN_TYPE_DEFAULT)) {
- if (httpProxy == null || httpProxy.length() == 0) {
- phone.setSystemProperty("net.gprs.http-proxy", null);
- return;
- }
-
- if (httpPort == null || httpPort.length() == 0) {
- httpPort = "8080"; // Default to port 8080
- }
-
- phone.setSystemProperty("net.gprs.http-proxy",
- "http://" + httpProxy + ":" + httpPort + "/");
- } else {
- if (httpProxy == null || httpProxy.length() == 0) {
- phone.setSystemProperty("net.gprs.http-proxy." + mActiveApnType, null);
- return;
- }
-
- if (httpPort == null || httpPort.length() == 0) {
- httpPort = "8080"; // Default to port 8080
- }
-
- phone.setSystemProperty("net.gprs.http-proxy." + mActiveApnType,
- "http://" + httpProxy + ":" + httpPort + "/");
- }
- }
-
private boolean isIpAddress(String address) {
if (address == null) return false;
diff --git a/tests/GridLayoutTest/res/layout/grid3.xml b/tests/GridLayoutTest/res/layout/grid3.xml
index 536be7e..3c2db54 100644
--- a/tests/GridLayoutTest/res/layout/grid3.xml
+++ b/tests/GridLayoutTest/res/layout/grid3.xml
@@ -66,8 +66,8 @@
<Space
android:layout_row="4"
android:layout_column="2"
- android:layout_heightSpec="canStretch"
- android:layout_widthSpec="canStretch"
+ android:layout_rowFlexibility="canStretch"
+ android:layout_columnFlexibility="canStretch"
/>
<Button
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java b/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java
index cba98c2..b9bf526 100644
--- a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java
+++ b/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java
@@ -97,8 +97,8 @@
Space v = new Space(context);
{
LayoutParams lp = new LayoutParams(row5, col3);
- lp.widthSpec = CAN_STRETCH;
- lp.heightSpec = CAN_STRETCH;
+ lp.columnGroup.flexibility = CAN_STRETCH;
+ lp.rowGroup.flexibility = CAN_STRETCH;
vg.addView(v, lp);
}
}
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 8734143..cb8084d 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -31,6 +31,15 @@
android:hardwareAccelerated="true">
<activity
+ android:name="MaxBitmapSizeActivity"
+ android:label="_MaxBitmapSize">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="TimeDialogActivity"
android:label="_TimeDialog">
<intent-filter>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index e1ca756..949589f 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -39,7 +39,10 @@
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
-
+import java.io.BufferedOutputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
@@ -57,6 +60,25 @@
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
+ mTextureView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Bitmap b = mTextureView.getBitmap(800, 800);
+ BufferedOutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream("/sdcard/out.png"));
+ b.compress(Bitmap.CompressFormat.PNG, 100, out);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } finally {
+ if (out != null) try {
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
setContentView(mTextureView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
@@ -77,7 +99,7 @@
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- ((View) mTextureView.getParent()).invalidate();
+ mTextureView.invalidate();
}
});
animator.start();
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MaxBitmapSizeActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MaxBitmapSizeActivity.java
new file mode 100644
index 0000000..b3b42dc
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MaxBitmapSizeActivity.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 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.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.LinearLayout;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class MaxBitmapSizeActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final LinearLayout layout = new LinearLayout(this);
+
+ CanvasView view = new CanvasView(this);
+ layout.addView(view, new LinearLayout.LayoutParams(200, 200));
+
+ view = new CanvasView(this);
+ view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ layout.addView(view, new LinearLayout.LayoutParams(200, 200));
+
+ setContentView(layout);
+ }
+
+ private static class CanvasView extends View {
+ public CanvasView(Context c) {
+ super(c);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ Log.d("Bitmap", "Hw = " + canvas.isHardwareAccelerated());
+ Log.d("Bitmap", "Max width = " + canvas.getMaximumBitmapWidth());
+ Log.d("Bitmap", "Max height = " + canvas.getMaximumBitmapHeight());
+ }
+ }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index c857ded..634e7e3a 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -16,7 +16,6 @@
package com.android.test.hwui;
-import android.animation.AnimatorSet;
import android.app.Activity;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
@@ -34,7 +33,6 @@
private Camera mCamera;
private TextureView mTextureView;
private FrameLayout mContent;
- private AnimatorSet mAnimatorSet;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -53,7 +51,6 @@
@Override
public void onClick(View v) {
if (mAdded) {
- if (mAnimatorSet != null) mAnimatorSet.cancel();
mContent.removeView(mTextureView);
} else {
mContent.addView(mTextureView);
@@ -62,7 +59,9 @@
}
});
- mContent.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
+ mContent.addView(mTextureView, new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER));
mContent.addView(button, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
@@ -72,6 +71,9 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mCamera = Camera.open();
+ Camera.Size previewSize = mCamera.getParameters().getPreviewSize();
+ mTextureView.setLayoutParams(new FrameLayout.LayoutParams(
+ previewSize.width, previewSize.height, Gravity.CENTER));
try {
mCamera.setPreviewTexture(surface);
@@ -82,20 +84,6 @@
mCamera.startPreview();
mTextureView.setCameraDistance(5000);
-
-// ObjectAnimator rotationY = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
-// rotationY.setRepeatMode(ObjectAnimator.REVERSE);
-// rotationY.setRepeatCount(ObjectAnimator.INFINITE);
-// rotationY.setDuration(4000);
-
-// ObjectAnimator alpha = ObjectAnimator.ofFloat(mTextureView, "alpha", 1.0f, 0.0f);
-// alpha.setRepeatMode(ObjectAnimator.REVERSE);
-// alpha.setRepeatCount(ObjectAnimator.INFINITE);
-// alpha.setDuration(4000);
-
-// mAnimatorSet = new AnimatorSet();
-// mAnimatorSet.play(alpha).with(rotationY);
-// mAnimatorSet.start();
}
@Override