summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk1
-rw-r--r--api/current.txt19
-rw-r--r--cmds/bootanimation/BootAnimation.cpp2
-rw-r--r--cmds/stagefright/sf2.cpp1
-rw-r--r--cmds/stagefright/stream.cpp1
-rw-r--r--core/java/android/app/Activity.java12
-rw-r--r--core/java/android/app/backup/WallpaperBackupHelper.java7
-rw-r--r--core/java/android/content/res/Configuration.java4
-rw-r--r--core/java/android/text/Selection.java3
-rw-r--r--core/java/android/text/method/ArrowKeyMovementMethod.java105
-rw-r--r--core/java/android/text/method/WordIterator.java220
-rw-r--r--core/java/android/util/JsonReader.java13
-rw-r--r--core/java/android/view/Display.java141
-rw-r--r--core/java/android/view/IWindowManager.aidl4
-rwxr-xr-xcore/java/android/view/InputDevice.java4
-rw-r--r--core/java/android/view/KeyCharacterMap.java2
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--core/java/android/view/ViewRoot.java5
-rw-r--r--core/java/android/view/WindowManagerPolicy.java13
-rw-r--r--core/java/com/android/internal/app/ActionBarImpl.java4
-rw-r--r--core/java/com/android/internal/view/menu/BaseMenuPresenter.java4
-rw-r--r--core/java/com/android/internal/view/menu/MenuBuilder.java6
-rw-r--r--core/java/com/android/internal/view/menu/MenuItemImpl.java4
-rw-r--r--core/java/com/android/internal/widget/ActionBarView.java32
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp14
-rw-r--r--core/jni/android/graphics/TextLayoutCache.h2
-rw-r--r--core/jni/android_view_Display.cpp16
-rw-r--r--core/jni/android_view_Surface.cpp6
-rw-r--r--core/res/res/layout-large/action_bar_home.xml39
-rw-r--r--core/res/res/layout-large/action_mode_close_item.xml38
-rw-r--r--core/res/res/layout/action_bar_home.xml13
-rw-r--r--core/res/res/layout/action_menu_item_layout.xml10
-rw-r--r--core/res/res/layout/action_mode_close_item.xml14
-rw-r--r--core/res/res/values-land/dimens.xml4
-rw-r--r--core/res/res/values-large/dimens.xml6
-rw-r--r--core/res/res/values-port/dimens.xml24
-rw-r--r--core/res/res/values-w480dp/bools.xml21
-rw-r--r--core/res/res/values/bools.xml21
-rwxr-xr-xcore/res/res/values/config.xml4
-rw-r--r--core/res/res/values/dimens.xml7
-rw-r--r--core/res/res/values/themes.xml6
-rw-r--r--docs/html/sdk/android-3.0.jd2
-rw-r--r--graphics/java/android/graphics/Point.aidl18
-rw-r--r--graphics/java/android/graphics/Point.java53
-rw-r--r--graphics/java/android/graphics/PointF.aidl18
-rw-r--r--graphics/java/android/graphics/PointF.java53
-rw-r--r--include/surfaceflinger/ISurfaceComposerClient.h1
-rw-r--r--include/surfaceflinger/SurfaceComposerClient.h2
-rw-r--r--keystore/java/android/security/IKeyChainService.aidl31
-rw-r--r--keystore/java/android/security/KeyChain.java372
-rw-r--r--libs/gui/ISurfaceComposerClient.cpp5
-rw-r--r--libs/gui/SurfaceComposerClient.cpp6
-rw-r--r--libs/rs/driver/rsdBcc.cpp14
-rw-r--r--libs/rs/driver/rsdCore.cpp42
-rw-r--r--libs/rs/driver/rsdCore.h10
-rw-r--r--libs/rs/driver/rsdRuntimeStubs.cpp2
-rw-r--r--libs/rs/rsContext.cpp192
-rw-r--r--libs/rs/rsContext.h4
-rw-r--r--libs/rs/rs_hal.h6
-rw-r--r--media/java/android/media/MediaScanner.java3
-rw-r--r--media/java/android/mtp/MtpDatabase.java4
-rwxr-xr-xmedia/jni/mediaeditor/VideoBrowserInternal.h2
-rwxr-xr-xmedia/jni/mediaeditor/VideoBrowserMain.c4
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorClasses.cpp3
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorMain.cpp151
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorOsal.cpp15
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorPropertiesMain.cpp2
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorThumbnailMain.cpp6
-rw-r--r--opengl/java/android/opengl/Matrix.java39
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java88
-rw-r--r--services/input/SpriteController.cpp2
-rw-r--r--services/java/com/android/server/WallpaperManagerService.java12
-rw-r--r--services/java/com/android/server/wm/DimSurface.java2
-rw-r--r--services/java/com/android/server/wm/InputMonitor.java4
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java259
-rw-r--r--services/java/com/android/server/wm/WindowState.java4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp12
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h9
-rw-r--r--test-runner/src/android/test/TouchUtils.java21
79 files changed, 1714 insertions, 613 deletions
diff --git a/Android.mk b/Android.mk
index cd9ae7d07734..898d7e29d3f2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -158,6 +158,7 @@ LOCAL_SRC_FILES += \
core/java/com/android/internal/view/IInputMethodSession.aidl \
core/java/com/android/internal/widget/IRemoteViewsFactory.aidl \
core/java/com/android/internal/widget/IRemoteViewsAdapterConnection.aidl \
+ keystore/java/android/security/IKeyChainService.aidl \
location/java/android/location/ICountryDetector.aidl \
location/java/android/location/ICountryListener.aidl \
location/java/android/location/IGeocodeProvider.aidl \
diff --git a/api/current.txt b/api/current.txt
index 0f5c98ac596b..c7e6ee6ceec0 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7941,29 +7941,37 @@ package android.graphics {
ctor public PixelXorXfermode(int);
}
- public class Point {
+ public class Point implements android.os.Parcelable {
ctor public Point();
ctor public Point(int, int);
ctor public Point(android.graphics.Point);
+ method public int describeContents();
method public final boolean equals(int, int);
method public final void negate();
method public final void offset(int, int);
+ method public void readFromParcel(android.os.Parcel);
method public void set(int, int);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator CREATOR;
field public int x;
field public int y;
}
- public class PointF {
+ public class PointF implements android.os.Parcelable {
ctor public PointF();
ctor public PointF(float, float);
ctor public PointF(android.graphics.Point);
+ method public int describeContents();
method public final boolean equals(float, float);
method public final float length();
method public static float length(float, float);
method public final void negate();
method public final void offset(float, float);
+ method public void readFromParcel(android.os.Parcel);
method public final void set(float, float);
method public final void set(android.graphics.PointF);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator CREATOR;
field public float x;
field public float y;
}
@@ -13171,6 +13179,7 @@ package android.opengl {
method public static void multiplyMM(float[], int, float[], int, float[], int);
method public static void multiplyMV(float[], int, float[], int, float[], int);
method public static void orthoM(float[], int, float, float, float, float, float, float);
+ method public static void perspectiveM(float[], int, float, float, float, float);
method public static void rotateM(float[], int, float[], int, float, float, float, float);
method public static void rotateM(float[], int, float, float, float, float);
method public static void scaleM(float[], int, float[], int, float, float, float);
@@ -19895,13 +19904,15 @@ package android.view {
public class Display {
method public int getDisplayId();
- method public int getHeight();
+ method public deprecated int getHeight();
method public void getMetrics(android.util.DisplayMetrics);
method public deprecated int getOrientation();
method public int getPixelFormat();
+ method public void getRectSize(android.graphics.Rect);
method public float getRefreshRate();
method public int getRotation();
- method public int getWidth();
+ method public void getSize(android.graphics.Point);
+ method public deprecated int getWidth();
field public static final int DEFAULT_DISPLAY = 0; // 0x0
}
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index e07495d28dcb..f987d61dce38 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -212,7 +212,7 @@ status_t BootAnimation::readyToRun() {
// create the native surface
sp<SurfaceControl> control = session()->createSurface(
- getpid(), 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
+ 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
session()->openTransaction();
control->setLayer(0x40000000);
session()->closeTransaction();
diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp
index c1d08036d6bd..289665f51b5d 100644
--- a/cmds/stagefright/sf2.cpp
+++ b/cmds/stagefright/sf2.cpp
@@ -543,7 +543,6 @@ int main(int argc, char **argv) {
CHECK_EQ(composerClient->initCheck(), (status_t)OK);
control = composerClient->createSurface(
- getpid(),
String8("A Surface"),
0,
1280,
diff --git a/cmds/stagefright/stream.cpp b/cmds/stagefright/stream.cpp
index be443d0330d6..f780afb80a0a 100644
--- a/cmds/stagefright/stream.cpp
+++ b/cmds/stagefright/stream.cpp
@@ -149,7 +149,6 @@ int main(int argc, char **argv) {
sp<SurfaceControl> control =
composerClient->createSurface(
- getpid(),
String8("A Surface"),
0,
1280,
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 389d485626be..f5849c24e59a 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -818,18 +818,6 @@ public class Activity extends ContextThemeWrapper
return mWindow != null ? mWindow.getCurrentFocus() : null;
}
- @Override
- public int getWallpaperDesiredMinimumWidth() {
- int width = super.getWallpaperDesiredMinimumWidth();
- return width <= 0 ? getWindowManager().getDefaultDisplay().getWidth() : width;
- }
-
- @Override
- public int getWallpaperDesiredMinimumHeight() {
- int height = super.getWallpaperDesiredMinimumHeight();
- return height <= 0 ? getWindowManager().getDefaultDisplay().getHeight() : height;
- }
-
/**
* Called when the activity is starting. This is where most initialization
* should go: calling {@link #setContentView(int)} to inflate the
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java
index 55368d623708..0c034cff9d4a 100644
--- a/core/java/android/app/backup/WallpaperBackupHelper.java
+++ b/core/java/android/app/backup/WallpaperBackupHelper.java
@@ -19,6 +19,7 @@ package android.app.backup;
import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.BitmapFactory;
+import android.graphics.Point;
import android.os.ParcelFileDescriptor;
import android.util.Slog;
import android.view.Display;
@@ -70,8 +71,10 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
if (mDesiredMinWidth <= 0 || mDesiredMinHeight <= 0) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
- mDesiredMinWidth = d.getWidth();
- mDesiredMinHeight = d.getHeight();
+ Point size = new Point();
+ d.getSize(size);
+ mDesiredMinWidth = size.x;
+ mDesiredMinHeight = size.y;
}
if (DEBUG) {
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index ad48786ee596..93b34290e7b7 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -303,9 +303,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
public String toString() {
StringBuilder sb = new StringBuilder(128);
- sb.append("{ fnt=");
+ sb.append("{");
sb.append(fontScale);
- sb.append(" imsi=");
+ sb.append("x imsi=");
sb.append(mcc);
sb.append("/");
sb.append(mnc);
diff --git a/core/java/android/text/Selection.java b/core/java/android/text/Selection.java
index b18570a8b027..679e2ccfa91f 100644
--- a/core/java/android/text/Selection.java
+++ b/core/java/android/text/Selection.java
@@ -16,10 +16,7 @@
package android.text;
-import android.util.Log;
-
import java.text.BreakIterator;
-import java.text.CharacterIterator;
/**
diff --git a/core/java/android/text/method/ArrowKeyMovementMethod.java b/core/java/android/text/method/ArrowKeyMovementMethod.java
index b25ba8d31a64..d432deef44bb 100644
--- a/core/java/android/text/method/ArrowKeyMovementMethod.java
+++ b/core/java/android/text/method/ArrowKeyMovementMethod.java
@@ -17,23 +17,14 @@
package android.text.method;
import android.graphics.Rect;
-import android.text.CharSequenceIterator;
-import android.text.Editable;
import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
-import android.text.Spanned;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.util.MathUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
-import java.text.BreakIterator;
-import java.text.CharacterIterator;
-
/**
* A movement method that provides cursor movement and selection.
* Supports displaying the context menu on DPad Center.
@@ -332,102 +323,6 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
return sInstance;
}
- /**
- * Walks through cursor positions at word boundaries. Internally uses
- * {@link BreakIterator#getWordInstance()}, and caches {@link CharSequence}
- * for performance reasons.
- */
- private static class WordIterator implements Selection.PositionIterator {
- private CharSequence mCurrent;
- private boolean mCurrentDirty = false;
-
- private BreakIterator mIterator;
-
- private TextWatcher mWatcher = new TextWatcher() {
- /** {@inheritDoc} */
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- // ignored
- }
-
- /** {@inheritDoc} */
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- mCurrentDirty = true;
- }
-
- /** {@inheritDoc} */
- public void afterTextChanged(Editable s) {
- // ignored
- }
- };
-
- public void setCharSequence(CharSequence incoming) {
- if (mIterator == null) {
- mIterator = BreakIterator.getWordInstance();
- }
-
- // when incoming is different object, move listeners to new sequence
- // and mark as dirty so we reload contents.
- if (mCurrent != incoming) {
- if (mCurrent instanceof Editable) {
- ((Editable) mCurrent).removeSpan(mWatcher);
- }
-
- if (incoming instanceof Editable) {
- ((Editable) incoming).setSpan(
- mWatcher, 0, incoming.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- }
-
- mCurrent = incoming;
- mCurrentDirty = true;
- }
-
- if (mCurrentDirty) {
- final CharacterIterator charIterator = new CharSequenceIterator(mCurrent);
- mIterator.setText(charIterator);
-
- mCurrentDirty = false;
- }
- }
-
- private boolean isValidOffset(int offset) {
- return offset >= 0 && offset <= mCurrent.length();
- }
-
- private boolean isLetterOrDigit(int offset) {
- if (isValidOffset(offset)) {
- return Character.isLetterOrDigit(mCurrent.charAt(offset));
- } else {
- return false;
- }
- }
-
- /** {@inheritDoc} */
- public int preceding(int offset) {
- // always round cursor index into valid string index
- offset = MathUtils.constrain(offset, 0, mCurrent.length());
-
- do {
- offset = mIterator.preceding(offset);
- if (isLetterOrDigit(offset)) break;
- } while (isValidOffset(offset));
-
- return offset;
- }
-
- /** {@inheritDoc} */
- public int following(int offset) {
- // always round cursor index into valid string index
- offset = MathUtils.constrain(offset, 0, mCurrent.length());
-
- do {
- offset = mIterator.following(offset);
- if (isLetterOrDigit(offset - 1)) break;
- } while (isValidOffset(offset));
-
- return offset;
- }
- }
-
private WordIterator mWordIterator = new WordIterator();
private static final Object LAST_TAP_DOWN = new Object();
diff --git a/core/java/android/text/method/WordIterator.java b/core/java/android/text/method/WordIterator.java
new file mode 100644
index 000000000000..b250414bf78a
--- /dev/null
+++ b/core/java/android/text/method/WordIterator.java
@@ -0,0 +1,220 @@
+
+/*
+ * 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.text.CharSequenceIterator;
+import android.text.Editable;
+import android.text.Selection;
+import android.text.Spanned;
+import android.text.TextWatcher;
+
+import java.text.BreakIterator;
+import java.text.CharacterIterator;
+import java.util.Locale;
+
+/**
+ * Walks through cursor positions at word boundaries. Internally uses
+ * {@link BreakIterator#getWordInstance()}, and caches {@link CharSequence}
+ * for performance reasons.
+ *
+ * Also provides methods to determine word boundaries.
+ * {@hide}
+ */
+public class WordIterator implements Selection.PositionIterator {
+ private CharSequence mCurrent;
+ private boolean mCurrentDirty = false;
+
+ private BreakIterator mIterator;
+
+ /**
+ * Constructs a WordIterator using the default locale.
+ */
+ public WordIterator() {
+ this(Locale.getDefault());
+ }
+
+ /**
+ * Constructs a new WordIterator for the specified locale.
+ * @param locale The locale to be used when analysing the text.
+ */
+ public WordIterator(Locale locale) {
+ mIterator = BreakIterator.getWordInstance(locale);
+ }
+
+ private final TextWatcher mWatcher = new TextWatcher() {
+ /** {@inheritDoc} */
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // ignored
+ }
+
+ /** {@inheritDoc} */
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mCurrentDirty = true;
+ }
+
+ /** {@inheritDoc} */
+ public void afterTextChanged(Editable s) {
+ // ignored
+ }
+ };
+
+ public void setCharSequence(CharSequence incoming) {
+ // When incoming is different object, move listeners to new sequence
+ // and mark as dirty so we reload contents.
+ if (mCurrent != incoming) {
+ if (mCurrent instanceof Editable) {
+ ((Editable) mCurrent).removeSpan(mWatcher);
+ }
+
+ if (incoming instanceof Editable) {
+ ((Editable) incoming).setSpan(
+ mWatcher, 0, incoming.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ mCurrent = incoming;
+ mCurrentDirty = true;
+ }
+
+ if (mCurrentDirty) {
+ final CharacterIterator charIterator = new CharSequenceIterator(mCurrent);
+ mIterator.setText(charIterator);
+
+ mCurrentDirty = false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int preceding(int offset) {
+ do {
+ offset = mIterator.preceding(offset);
+ if (offset == BreakIterator.DONE || isOnLetterOrDigit(offset)) {
+ break;
+ }
+ } while (true);
+
+ return offset;
+ }
+
+ /** {@inheritDoc} */
+ public int following(int offset) {
+ do {
+ offset = mIterator.following(offset);
+ if (offset == BreakIterator.DONE || isAfterLetterOrDigit(offset)) {
+ break;
+ }
+ } while (true);
+
+ return offset;
+ }
+
+ /** If <code>offset</code> is within a word, returns the index of the first character of that
+ * word, otherwise returns BreakIterator.DONE.
+ *
+ * The offsets that are considered to be part of a word are the indexes of its characters,
+ * <i>as well as</i> the index of its last character plus one.
+ * If offset is the index of a low surrogate character, BreakIterator.DONE will be returned.
+ *
+ * Valid range for offset is [0..textLength] (note the inclusive upper bound).
+ * The returned value is within [0..offset] or BreakIterator.DONE.
+ *
+ * @throws IllegalArgumentException is offset is not valid.
+ */
+ public int getBeginning(int offset) {
+ checkOffsetIsValid(offset);
+
+ if (isOnLetterOrDigit(offset)) {
+ if (mIterator.isBoundary(offset)) {
+ return offset;
+ } else {
+ return mIterator.preceding(offset);
+ }
+ } else {
+ if (isAfterLetterOrDigit(offset)) {
+ return mIterator.preceding(offset);
+ }
+ }
+ return BreakIterator.DONE;
+ }
+
+ /** If <code>offset</code> is within a word, returns the index of the last character of that
+ * word plus one, otherwise returns BreakIterator.DONE.
+ *
+ * The offsets that are considered to be part of a word are the indexes of its characters,
+ * <i>as well as</i> the index of its last character plus one.
+ * If offset is the index of a low surrogate character, BreakIterator.DONE will be returned.
+ *
+ * Valid range for offset is [0..textLength] (note the inclusive upper bound).
+ * The returned value is within [offset..textLength] or BreakIterator.DONE.
+ *
+ * @throws IllegalArgumentException is offset is not valid.
+ */
+ public int getEnd(int offset) {
+ checkOffsetIsValid(offset);
+
+ if (isAfterLetterOrDigit(offset)) {
+ if (mIterator.isBoundary(offset)) {
+ return offset;
+ } else {
+ return mIterator.following(offset);
+ }
+ } else {
+ if (isOnLetterOrDigit(offset)) {
+ return mIterator.following(offset);
+ }
+ }
+ return BreakIterator.DONE;
+ }
+
+ private boolean isAfterLetterOrDigit(int offset) {
+ if (offset - 1 >= 0) {
+ final char previousChar = mCurrent.charAt(offset - 1);
+ if (Character.isLetterOrDigit(previousChar)) return true;
+ if (offset - 2 >= 0) {
+ final char previousPreviousChar = mCurrent.charAt(offset - 2);
+ if (Character.isSurrogatePair(previousPreviousChar, previousChar)) {
+ final int codePoint = Character.toCodePoint(previousPreviousChar, previousChar);
+ return Character.isLetterOrDigit(codePoint);
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isOnLetterOrDigit(int offset) {
+ final int length = mCurrent.length();
+ if (offset < length) {
+ final char currentChar = mCurrent.charAt(offset);
+ if (Character.isLetterOrDigit(currentChar)) return true;
+ if (offset + 1 < length) {
+ final char nextChar = mCurrent.charAt(offset + 1);
+ if (Character.isSurrogatePair(currentChar, nextChar)) {
+ final int codePoint = Character.toCodePoint(currentChar, nextChar);
+ return Character.isLetterOrDigit(codePoint);
+ }
+ }
+ }
+ return false;
+ }
+
+ private void checkOffsetIsValid(int offset) {
+ if (offset < 0 || offset > mCurrent.length()) {
+ final String message = "Valid range is [0, " + mCurrent.length() + "]";
+ throw new IllegalArgumentException(message);
+ }
+ }
+}
diff --git a/core/java/android/util/JsonReader.java b/core/java/android/util/JsonReader.java
index 563c50089016..132b5953fa68 100644
--- a/core/java/android/util/JsonReader.java
+++ b/core/java/android/util/JsonReader.java
@@ -16,12 +16,13 @@
package android.util;
+import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
-import java.io.Closeable;
import java.util.ArrayList;
import java.util.List;
+import libcore.internal.StringPool;
/**
* Reads a JSON (<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>)
@@ -177,6 +178,8 @@ public final class JsonReader implements Closeable {
private static final String TRUE = "true";
private static final String FALSE = "false";
+ private final StringPool stringPool = new StringPool();
+
/** The input JSON. */
private final Reader in;
@@ -836,7 +839,7 @@ public final class JsonReader implements Closeable {
if (skipping) {
return "skipped!";
} else if (builder == null) {
- return new String(buffer, start, pos - start - 1);
+ return stringPool.get(buffer, start, pos - start - 1);
} else {
builder.append(buffer, start, pos - start - 1);
return builder.toString();
@@ -934,7 +937,7 @@ public final class JsonReader implements Closeable {
} else if (skipping) {
result = "skipped!";
} else if (builder == null) {
- result = new String(buffer, pos, i);
+ result = stringPool.get(buffer, pos, i);
} else {
builder.append(buffer, pos, i);
result = builder.toString();
@@ -968,7 +971,7 @@ public final class JsonReader implements Closeable {
if (pos + 4 > limit && !fillBuffer(4)) {
throw syntaxError("Unterminated escape sequence");
}
- String hex = new String(buffer, pos, 4);
+ String hex = stringPool.get(buffer, pos, 4);
pos += 4;
return (char) Integer.parseInt(hex, 16);
@@ -1040,7 +1043,7 @@ public final class JsonReader implements Closeable {
value = FALSE;
return JsonToken.BOOLEAN;
} else {
- value = new String(buffer, valuePos, valueLength);
+ value = stringPool.get(buffer, valuePos, valueLength);
return decodeNumber(buffer, valuePos, valueLength);
}
}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 126f409d1dab..8e839c09b1d2 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -16,10 +16,15 @@
package android.view;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
import android.util.DisplayMetrics;
+import android.util.Slog;
-public class Display
-{
+public class Display {
/**
* Specify the default Display
*/
@@ -35,10 +40,10 @@ public class Display
Display(int display) {
// initalize the statics when this class is first instansiated. This is
// done here instead of in the static block because Zygote
- synchronized (mStaticInit) {
- if (!mInitialized) {
+ synchronized (sStaticInit) {
+ if (!sInitialized) {
nativeClassInit();
- mInitialized = true;
+ sInitialized = true;
}
}
mDisplay = display;
@@ -60,29 +65,92 @@ public class Display
native static int getDisplayCount();
/**
- * Returns the raw width of the display, in pixels. Note that this
+ * Returns the raw size of the display, in pixels. Note that this
* should <em>not</em> generally be used for computing layouts, since
* a device will typically have screen decoration (such as a status bar)
* along the edges of the display that reduce the amount of application
* space available from the raw size returned here. This value is
* adjusted for you based on the current rotation of the display.
*/
- native public int getWidth();
+ public void getSize(Point outSize) {
+ try {
+ IWindowManager wm = getWindowManager();
+ if (wm != null) {
+ wm.getDisplaySize(outSize);
+ } else {
+ // This is just for boot-strapping, initializing the
+ // system process before the window manager is up.
+ outSize.y = getRealHeight();
+ }
+ } catch (RemoteException e) {
+ Slog.w("Display", "Unable to get display size", e);
+ }
+ }
/**
- * Returns the raw height of the display, in pixels. Note that this
- * should <em>not</em> generally be used for computing layouts, since
- * a device will typically have screen decoration (such as a status bar)
- * along the edges of the display that reduce the amount of application
- * space available from the raw size returned here. This value is
- * adjusted for you based on the current rotation of the display.
+ * This is just easier for some parts of the framework.
*/
- native public int getHeight();
+ public void getRectSize(Rect outSize) {
+ synchronized (mTmpPoint) {
+ getSize(mTmpPoint);
+ outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y);
+ }
+ }
- /** @hide special for when we are faking the screen size. */
+ /**
+ * Return the maximum screen size dimension that will happen. This is
+ * mostly for wallpapers.
+ * @hide
+ */
+ public int getMaximumSizeDimension() {
+ try {
+ IWindowManager wm = getWindowManager();
+ return wm.getMaximumSizeDimension();
+ } catch (RemoteException e) {
+ Slog.w("Display", "Unable to get display maximum size dimension", e);
+ return 0;
+ }
+ }
+
+ /**
+ * @deprecated Use {@link #getSize(Point)} instead.
+ */
+ @Deprecated
+ public int getWidth() {
+ synchronized (mTmpPoint) {
+ long now = SystemClock.uptimeMillis();
+ if (now > (mLastGetTime+20)) {
+ getSize(mTmpPoint);
+ mLastGetTime = now;
+ }
+ return mTmpPoint.x;
+ }
+ }
+
+ /**
+ * @deprecated Use {@link #getSize(Point)} instead.
+ */
+ @Deprecated
+ public int getHeight() {
+ synchronized (mTmpPoint) {
+ long now = SystemClock.uptimeMillis();
+ if (now > (mLastGetTime+20)) {
+ getSize(mTmpPoint);
+ mLastGetTime = now;
+ }
+ return mTmpPoint.y;
+ }
+ }
+
+ /** @hide Returns the actual screen size, not including any decor. */
native public int getRealWidth();
- /** @hide special for when we are faking the screen size. */
+ /** @hide Returns the actual screen size, not including any decor. */
native public int getRealHeight();
+
+ /** @hide special for when we are faking the screen size. */
+ native public int getRawWidth();
+ /** @hide special for when we are faking the screen size. */
+ native public int getRawHeight();
/**
* Returns the rotation of the screen from its "natural" orientation.
@@ -132,8 +200,27 @@ public class Display
* @param outMetrics
*/
public void getMetrics(DisplayMetrics outMetrics) {
- outMetrics.widthPixels = getWidth();
- outMetrics.heightPixels = getHeight();
+ synchronized (mTmpPoint) {
+ getSize(mTmpPoint);
+ outMetrics.widthPixels = mTmpPoint.x;
+ outMetrics.heightPixels = mTmpPoint.y;
+ }
+ getNonSizeMetrics(outMetrics);
+ }
+
+ /**
+ * Initialize a DisplayMetrics object from this display's data.
+ *
+ * @param outMetrics
+ * @hide
+ */
+ public void getRealMetrics(DisplayMetrics outMetrics) {
+ outMetrics.widthPixels = getRealWidth();
+ outMetrics.heightPixels = getRealHeight();
+ getNonSizeMetrics(outMetrics);
+ }
+
+ private void getNonSizeMetrics(DisplayMetrics outMetrics) {
outMetrics.density = mDensity;
outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f);
outMetrics.scaledDensity= outMetrics.density;
@@ -141,6 +228,16 @@ public class Display
outMetrics.ydpi = mDpiY;
}
+ static IWindowManager getWindowManager() {
+ synchronized (sStaticInit) {
+ if (sWindowManager == null) {
+ sWindowManager = IWindowManager.Stub.asInterface(
+ ServiceManager.getService("window"));
+ }
+ return sWindowManager;
+ }
+ }
+
/*
* We use a class initializer to allow the native code to cache some
* field offsets.
@@ -157,8 +254,12 @@ public class Display
private float mDpiX;
private float mDpiY;
- private static final Object mStaticInit = new Object();
- private static boolean mInitialized = false;
+ private final Point mTmpPoint = new Point();
+ private float mLastGetTime;
+
+ private static final Object sStaticInit = new Object();
+ private static boolean sInitialized = false;
+ private static IWindowManager sWindowManager;
/**
* Returns a display object which uses the metric's width/height instead.
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index dd8242a6fef1..0be02a665bff 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -21,6 +21,7 @@ import com.android.internal.view.IInputMethodClient;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Point;
import android.view.IApplicationToken;
import android.view.IOnKeyguardExitResult;
import android.view.IRotationWatcher;
@@ -52,6 +53,9 @@ interface IWindowManager
in IInputContext inputContext);
boolean inputMethodClientHasFocus(IInputMethodClient client);
+ void getDisplaySize(out Point size);
+ int getMaximumSizeDimension();
+
// These can only be called when injecting events to your own window,
// or by holding the INJECT_EVENTS permission. These methods may block
// until pending input events are finished being dispatched even when 'sync' is false.
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 98d4eb9a8f0c..8cb68f90ec45 100755
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -290,7 +290,7 @@ public final class InputDevice implements Parcelable {
* @return The input device or null if not found.
*/
public static InputDevice getDevice(int id) {
- IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
+ IWindowManager wm = Display.getWindowManager();
try {
return wm.getInputDevice(id);
} catch (RemoteException ex) {
@@ -304,7 +304,7 @@ public final class InputDevice implements Parcelable {
* @return The input device ids.
*/
public static int[] getDeviceIds() {
- IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
+ IWindowManager wm = Display.getWindowManager();
try {
return wm.getInputDeviceIds();
} catch (RemoteException ex) {
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 3ff7fcd6d778..885a75f64168 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -527,7 +527,7 @@ public class KeyCharacterMap {
*/
public static boolean[] deviceHasKeys(int[] keyCodes) {
boolean[] ret = new boolean[keyCodes.length];
- IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
+ IWindowManager wm = Display.getWindowManager();
try {
wm.hasKeys(keyCodes, ret);
} catch (RemoteException e) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index fe8af1974deb..4a6289285d41 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4992,7 +4992,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
return;
}
Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
- outRect.set(0, 0, d.getWidth(), d.getHeight());
+ d.getRectSize(outRect);
}
/**
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 1a6bae710f45..4104b070f4a1 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -263,9 +263,8 @@ public final class ViewRoot extends Handler implements ViewParent,
if (!mInitialized) {
try {
InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
- sWindowSession = IWindowManager.Stub.asInterface(
- ServiceManager.getService("window"))
- .openSession(imm.getClient(), imm.getInputContext());
+ sWindowSession = Display.getWindowManager().openSession(
+ imm.getClient(), imm.getInputContext());
mInitialized = true;
} catch (RemoteException e) {
}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 9d00d023514d..3d19380d5959 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -396,6 +396,12 @@ public interface WindowManagerPolicy {
LocalPowerManager powerManager);
/**
+ * Called by window manager once it has the initial, default native
+ * display dimensions.
+ */
+ public void setInitialDisplaySize(int width, int height);
+
+ /**
* Check permissions when adding a window.
*
* @param attrs The window's LayoutParams.
@@ -810,6 +816,13 @@ public interface WindowManagerPolicy {
boolean displayEnabled);
/**
+ * Return the currently locked screen rotation, if any. Return
+ * Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, or
+ * Surface.ROTATION_270 if locked; return -1 if not locked.
+ */
+ public int getLockedRotationLw();
+
+ /**
* Called when the system is mostly done booting to determine whether
* the system should go into safe mode.
*/
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 16d5539b8cdf..96520858fe95 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -861,7 +861,7 @@ public class ActionBarImpl extends ActionBar {
@Override
public void setIcon(int resId) {
- mActionView.setIcon(mContext.getResources().getDrawable(resId));
+ mActionView.setIcon(resId);
}
@Override
@@ -871,7 +871,7 @@ public class ActionBarImpl extends ActionBar {
@Override
public void setLogo(int resId) {
- mActionView.setLogo(mContext.getResources().getDrawable(resId));
+ mActionView.setLogo(resId);
}
@Override
diff --git a/core/java/com/android/internal/view/menu/BaseMenuPresenter.java b/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
index 71511c62090a..16f51fd20ae0 100644
--- a/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
@@ -104,6 +104,10 @@ public abstract class BaseMenuPresenter implements MenuPresenter {
* @param childIndex Index within the parent to insert at
*/
protected void addItemView(View itemView, int childIndex) {
+ final ViewGroup currentParent = (ViewGroup) itemView.getParent();
+ if (currentParent != null) {
+ currentParent.removeView(itemView);
+ }
((ViewGroup) mMenuView).addView(itemView, childIndex);
}
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index b34814223d97..7fba5cac2aee 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -814,8 +814,10 @@ public class MenuBuilder implements Menu {
* many menu operations are going to be performed as a batch.
*/
public void stopDispatchingItemsChanged() {
- mPreventDispatchingItemsChanged = true;
- mItemsChangedWhileDispatchPrevented = false;
+ if (!mPreventDispatchingItemsChanged) {
+ mPreventDispatchingItemsChanged = true;
+ mItemsChangedWhileDispatchPrevented = false;
+ }
}
public void startDispatchingItemsChanged() {
diff --git a/core/java/com/android/internal/view/menu/MenuItemImpl.java b/core/java/com/android/internal/view/menu/MenuItemImpl.java
index 42ef916c995c..c6d386d1fa48 100644
--- a/core/java/com/android/internal/view/menu/MenuItemImpl.java
+++ b/core/java/com/android/internal/view/menu/MenuItemImpl.java
@@ -523,7 +523,9 @@ public final class MenuItemImpl implements MenuItem {
}
public boolean showsTextAsAction() {
- return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT;
+ return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT &&
+ mMenu.getContext().getResources().getBoolean(
+ com.android.internal.R.bool.allow_action_menu_item_text_with_icon);
}
public void setShowAsAction(int actionEnum) {
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 74a6ae7724ac..587d67895f9d 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -30,11 +30,13 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ActionMode;
import android.view.Gravity;
@@ -85,7 +87,6 @@ public class ActionBarView extends ViewGroup {
private CharSequence mSubtitle;
private Drawable mIcon;
private Drawable mLogo;
- private Drawable mDivider;
private View mHomeLayout;
private View mHomeAsUpView;
@@ -211,8 +212,6 @@ public class ActionBarView extends ViewGroup {
mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
- mDivider = a.getDrawable(R.styleable.ActionBar_divider);
-
a.recycle();
mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
@@ -434,6 +433,10 @@ public class ActionBarView extends ViewGroup {
}
}
+ public void setIcon(int resId) {
+ setIcon(mContext.getResources().getDrawableForDensity(resId, getPreferredIconDensity()));
+ }
+
public void setLogo(Drawable logo) {
mLogo = logo;
if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) {
@@ -441,6 +444,29 @@ public class ActionBarView extends ViewGroup {
}
}
+ public void setLogo(int resId) {
+ mContext.getResources().getDrawable(resId);
+ }
+
+ /**
+ * @return Drawable density to load that will best fit the available height.
+ */
+ private int getPreferredIconDensity() {
+ final Resources res = mContext.getResources();
+ final int availableHeight = getLayoutParams().height -
+ mIconView.getPaddingTop() - mIconView.getPaddingBottom();
+ int iconSize = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
+
+ if (iconSize * DisplayMetrics.DENSITY_LOW > availableHeight) {
+ return DisplayMetrics.DENSITY_LOW;
+ } else if (iconSize * DisplayMetrics.DENSITY_MEDIUM > availableHeight) {
+ return DisplayMetrics.DENSITY_MEDIUM;
+ } else if (iconSize * DisplayMetrics.DENSITY_HIGH > availableHeight) {
+ return DisplayMetrics.DENSITY_HIGH;
+ }
+ return DisplayMetrics.DENSITY_XHIGH;
+ }
+
public void setNavigationMode(int mode) {
final int oldMode = mNavigationMode;
if (mode != oldMode) {
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 77a731a3e948..df017f5d42c3 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -126,11 +126,17 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
// Value not found for the key, we need to add a new value in the cache
if (value == NULL) {
+ if (mDebugEnabled) {
+ startTime = systemTime(SYSTEM_TIME_MONOTONIC);
+ }
+
value = new TextLayoutCacheValue();
// Compute advances and store them
value->computeValues(paint, text, start, count, contextCount, dirFlags);
+ nsecs_t endTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
// Don't bother to add in the cache if the entry is too big
size_t size = key.getSize() + value->getSize();
if (size <= mMaxSize) {
@@ -155,7 +161,7 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
if (mDebugEnabled) {
// Update timing information for statistics
- value->setElapsedTime(systemTime(SYSTEM_TIME_MONOTONIC) - startTime);
+ value->setElapsedTime(endTime - startTime);
LOGD("CACHE MISS: Added entry for text='%s' with start=%d, count=%d, "
"contextCount=%d, entry size %d bytes, remaining space %d bytes"
@@ -168,9 +174,9 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
LOGD("CACHE MISS: Calculated but not storing entry because it is too big "
"for text='%s' with start=%d, count=%d, contextCount=%d, "
"entry size %d bytes, remaining space %d bytes"
- " - Compute time in nanos: %d",
+ " - Compute time in nanos: %lld",
String8(text, contextCount).string(), start, count, contextCount,
- size, mMaxSize - mSize, value->getElapsedTime());
+ size, mMaxSize - mSize, endTime);
}
value.clear();
}
@@ -205,7 +211,9 @@ void TextLayoutCache::dumpCacheStats() {
LOGD("------------------------------------------------");
LOGD("TextLayoutCache stats");
LOGD("------------------------------------------------");
+ LOGD("pid : %d", getpid());
LOGD("running : %.0f seconds", timeRunningInSec);
+ LOGD("entries : %d", mCache.size());
LOGD("size : %d bytes", mMaxSize);
LOGD("remaining : %d bytes or %2.2f percent", mMaxSize - mSize, remainingPercent);
LOGD("hits : %d", mCacheHitCount);
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 62813df154aa..690caacd6c65 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -53,7 +53,7 @@
#define MB(s) s * 1024 * 1024
// Define the default cache size in Mb
-#define DEFAULT_TEXT_LAYOUT_CACHE_SIZE_IN_MB 0.125f
+#define DEFAULT_TEXT_LAYOUT_CACHE_SIZE_IN_MB 0.250f
// Define the interval in number of cache hits between two statistics dump
#define DEFAULT_DUMP_STATS_CACHE_HIT_INTERVAL 100
diff --git a/core/jni/android_view_Display.cpp b/core/jni/android_view_Display.cpp
index 8feeb9a7aa5c..97f9fc34dae6 100644
--- a/core/jni/android_view_Display.cpp
+++ b/core/jni/android_view_Display.cpp
@@ -92,14 +92,14 @@ static jint android_view_Display_getHeight(
return h == gOldSize ? gNewSize : h;
}
-static jint android_view_Display_getRealWidth(
+static jint android_view_Display_getRawWidth(
JNIEnv* env, jobject clazz)
{
DisplayID dpy = env->GetIntField(clazz, offsets.display);
return SurfaceComposerClient::getDisplayWidth(dpy);
}
-static jint android_view_Display_getRealHeight(
+static jint android_view_Display_getRawHeight(
JNIEnv* env, jobject clazz)
{
DisplayID dpy = env->GetIntField(clazz, offsets.display);
@@ -132,14 +132,14 @@ static JNINativeMethod gMethods[] = {
(void*)android_view_Display_getDisplayCount },
{ "init", "(I)V",
(void*)android_view_Display_init },
- { "getWidth", "()I",
- (void*)android_view_Display_getWidth },
- { "getHeight", "()I",
- (void*)android_view_Display_getHeight },
{ "getRealWidth", "()I",
- (void*)android_view_Display_getRealWidth },
+ (void*)android_view_Display_getWidth },
{ "getRealHeight", "()I",
- (void*)android_view_Display_getRealHeight },
+ (void*)android_view_Display_getHeight },
+ { "getRawWidth", "()I",
+ (void*)android_view_Display_getRawWidth },
+ { "getRawHeight", "()I",
+ (void*)android_view_Display_getRawHeight },
{ "getOrientation", "()I",
(void*)android_view_Display_getOrientation }
};
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index f1729137dfcc..ec8b6e07f325 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -204,7 +204,7 @@ static void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface)
static void Surface_init(
JNIEnv* env, jobject clazz,
jobject session,
- jint pid, jstring jname, jint dpy, jint w, jint h, jint format, jint flags)
+ jint, jstring jname, jint dpy, jint w, jint h, jint format, jint flags)
{
if (session == NULL) {
doThrowNPE(env);
@@ -216,12 +216,12 @@ static void Surface_init(
sp<SurfaceControl> surface;
if (jname == NULL) {
- surface = client->createSurface(pid, dpy, w, h, format, flags);
+ surface = client->createSurface(dpy, w, h, format, flags);
} else {
const jchar* str = env->GetStringCritical(jname, 0);
const String8 name(str, env->GetStringLength(jname));
env->ReleaseStringCritical(jname, str);
- surface = client->createSurface(pid, name, dpy, w, h, format, flags);
+ surface = client->createSurface(name, dpy, w, h, format, flags);
}
if (surface == 0) {
diff --git a/core/res/res/layout-large/action_bar_home.xml b/core/res/res/layout-large/action_bar_home.xml
new file mode 100644
index 000000000000..86580bc3e531
--- /dev/null
+++ b/core/res/res/layout-large/action_bar_home.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<view xmlns:android="http://schemas.android.com/apk/res/android"
+ class="com.android.internal.widget.ActionBarView$HomeView"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:background="?android:attr/selectableItemBackground" >
+ <ImageView android:id="@android:id/up"
+ android:src="?android:attr/homeAsUpIndicator"
+ android:layout_gravity="center_vertical|left"
+ android:visibility="gone"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="-12dip" />
+ <ImageView android:id="@android:id/home"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="16dip"
+ android:paddingRight="16dip"
+ android:paddingTop="4dip"
+ android:paddingBottom="4dip"
+ android:adjustViewBounds="true"
+ android:layout_gravity="center"
+ android:scaleType="fitCenter" />
+</view>
diff --git a/core/res/res/layout-large/action_mode_close_item.xml b/core/res/res/layout-large/action_mode_close_item.xml
new file mode 100644
index 000000000000..321622ef387b
--- /dev/null
+++ b/core/res/res/layout-large/action_mode_close_item.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/action_mode_close_button"
+ android:background="@drawable/btn_cab_done"
+ android:focusable="true"
+ android:clickable="true"
+ android:paddingLeft="16dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+ <ImageView android:layout_width="48dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:scaleType="center"
+ android:src="@drawable/ic_cab_close_holo" />
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginLeft="8dip"
+ android:layout_marginRight="16dip"
+ android:textAppearance="@android:style/TextAppearance.Holo.Medium"
+ android:textColor="@android:color/white"
+ android:text="@string/action_mode_done" />
+</LinearLayout>
diff --git a/core/res/res/layout/action_bar_home.xml b/core/res/res/layout/action_bar_home.xml
index c82f91d7dfd8..7f7c55cb4f68 100644
--- a/core/res/res/layout/action_bar_home.xml
+++ b/core/res/res/layout/action_bar_home.xml
@@ -25,12 +25,15 @@
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginRight="-12dip" />
+ android:layout_marginRight="-4dip" />
<ImageView android:id="@android:id/home"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="16dip"
- android:paddingRight="16dip"
+ android:layout_height="wrap_content"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip"
+ android:paddingTop="@dimen/action_bar_icon_vertical_padding"
+ android:paddingBottom="@dimen/action_bar_icon_vertical_padding"
android:layout_gravity="center"
- android:scaleType="center" />
+ android:adjustViewBounds="true"
+ android:scaleType="fitCenter" />
</view>
diff --git a/core/res/res/layout/action_menu_item_layout.xml b/core/res/res/layout/action_menu_item_layout.xml
index 4a7336852e70..5e828fae655d 100644
--- a/core/res/res/layout/action_menu_item_layout.xml
+++ b/core/res/res/layout/action_menu_item_layout.xml
@@ -31,10 +31,9 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
- android:paddingLeft="4dip"
- android:paddingRight="4dip"
- android:minHeight="56dip"
- android:scaleType="center"
+ android:padding="@dimen/action_bar_icon_vertical_padding"
+ android:scaleType="fitCenter"
+ android:adjustViewBounds="true"
android:background="@null"
android:focusable="false" />
<Button android:id="@+id/textButton"
@@ -46,7 +45,6 @@
style="?attr/buttonStyleSmall"
android:textColor="?attr/actionMenuTextColor"
android:background="@null"
- android:paddingLeft="4dip"
- android:paddingRight="4dip"
+ android:padding="4dip"
android:focusable="false" />
</com.android.internal.view.menu.ActionMenuItemView>
diff --git a/core/res/res/layout/action_mode_close_item.xml b/core/res/res/layout/action_mode_close_item.xml
index 7badbac5349e..2a4d8e0513eb 100644
--- a/core/res/res/layout/action_mode_close_item.xml
+++ b/core/res/res/layout/action_mode_close_item.xml
@@ -19,20 +19,12 @@
android:background="@drawable/btn_cab_done"
android:focusable="true"
android:clickable="true"
- android:paddingLeft="16dip"
+ android:paddingLeft="8dip"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <ImageView android:layout_width="48dip"
+ <ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:scaleType="center"
+ android:scaleType="fitCenter"
android:src="@drawable/ic_cab_close_holo" />
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginLeft="8dip"
- android:layout_marginRight="16dip"
- android:textAppearance="@android:style/TextAppearance.Holo.Medium"
- android:textColor="@android:color/white"
- android:text="@string/action_mode_done" />
</LinearLayout>
diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml
index 058daa8efbe7..8def578ef357 100644
--- a/core/res/res/values-land/dimens.xml
+++ b/core/res/res/values-land/dimens.xml
@@ -28,4 +28,8 @@
<dimen name="preference_screen_side_margin">96dp</dimen>
<dimen name="preference_screen_side_margin_negative">-100dp</dimen>
<dimen name="preference_widget_width">72dp</dimen>
+
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">40dip</dimen>
+
</resources>
diff --git a/core/res/res/values-large/dimens.xml b/core/res/res/values-large/dimens.xml
index cd1847faaaf2..5355847cb223 100644
--- a/core/res/res/values-large/dimens.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -22,4 +22,10 @@
<!-- Preference UI dimensions for larger screens. -->
<dimen name="preference_widget_width">56dp</dimen>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">5</integer>
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">56dip</dimen>
</resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-port/dimens.xml
new file mode 100644
index 000000000000..bf0a3426aff7
--- /dev/null
+++ b/core/res/res/values-port/dimens.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">2</integer>
+</resources>
diff --git a/core/res/res/values-w480dp/bools.xml b/core/res/res/values-w480dp/bools.xml
new file mode 100644
index 000000000000..ea7eeb58c7d7
--- /dev/null
+++ b/core/res/res/values-w480dp/bools.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+<resources>
+ <bool name="allow_action_menu_item_text_with_icon">true</bool>
+</resources>
diff --git a/core/res/res/values/bools.xml b/core/res/res/values/bools.xml
new file mode 100644
index 000000000000..c7dcb515cd09
--- /dev/null
+++ b/core/res/res/values/bools.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+<resources>
+ <bool name="allow_action_menu_item_text_with_icon">false</bool>
+</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index fc4272d89147..a91c1e05acb7 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -101,10 +101,6 @@
for backward compatibility with apps that require external storage. -->
<bool name="config_emulateExternalStorage">false</bool>
- <!-- Set to true if external storage is case sensitive.
- Typically external storage is FAT, which is case insensitive. -->
- <bool name="config_caseSensitiveExternalStorage">false</bool>
-
<!-- A product with no SD card == not removable. -->
<bool name="config_externalStorageRemovable" product="nosdcard">false</bool>
<!-- Configures whether the primary external storage device is
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index da1c1577d2c1..a1511b3cb6ee 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -28,7 +28,7 @@
<!-- The maximum number of action buttons that should be permitted within
an action bar/action mode. This will be used to determine how many
showAsAction="ifRoom" items can fit. "always" items can override this. -->
- <integer name="max_action_buttons">5</integer>
+ <integer name="max_action_buttons">3</integer>
<dimen name="toast_y_offset">64dip</dimen>
<!-- Height of the status bar -->
<dimen name="status_bar_height">25dip</dimen>
@@ -79,4 +79,9 @@
<!-- Minimum width of the search view text entry area. -->
<dimen name="search_view_text_min_width">160dip</dimen>
+
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">48dip</dimen>
+ <!-- Vertical padding around action bar icons. -->
+ <dimen name="action_bar_icon_vertical_padding">4dip</dimen>
</resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index b9fd6a5478a6..be7b42fa61fc 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -276,7 +276,7 @@
<item name="actionModeStyle">@style/Widget.ActionMode</item>
<item name="actionModeCloseButtonStyle">@style/Widget.ActionButton.CloseMode</item>
<item name="actionBarStyle">@android:style/Widget.ActionBar</item>
- <item name="actionBarSize">56dip</item>
+ <item name="actionBarSize">@dimen/action_bar_default_height</item>
<item name="actionModePopupWindowStyle">?android:attr/popupWindowStyle</item>
<item name="actionMenuTextAppearance">?android:attr/textAppearanceMedium</item>
<item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
@@ -1009,7 +1009,7 @@
<item name="actionModeStyle">@style/Widget.Holo.ActionMode</item>
<item name="actionModeCloseButtonStyle">@style/Widget.Holo.ActionButton.CloseMode</item>
<item name="actionBarStyle">@android:style/Widget.Holo.ActionBar</item>
- <item name="actionBarSize">56dip</item>
+ <item name="actionBarSize">@dimen/action_bar_default_height</item>
<item name="actionModePopupWindowStyle">@android:style/Widget.Holo.PopupWindow.ActionMode</item>
<item name="actionModeCutDrawable">@android:drawable/ic_menu_cut_holo_dark</item>
@@ -1294,7 +1294,7 @@
<item name="actionModeStyle">@style/Widget.Holo.Light.ActionMode</item>
<item name="actionModeCloseButtonStyle">@style/Widget.Holo.Light.ActionButton.CloseMode</item>
<item name="actionBarStyle">@android:style/Widget.Holo.Light.ActionBar</item>
- <item name="actionBarSize">56dip</item>
+ <item name="actionBarSize">@dimen/action_bar_default_height</item>
<item name="actionModePopupWindowStyle">@android:style/Widget.Holo.Light.PopupWindow.ActionMode</item>
<item name="actionModeCutDrawable">@android:drawable/ic_menu_cut_holo_light</item>
diff --git a/docs/html/sdk/android-3.0.jd b/docs/html/sdk/android-3.0.jd
index f88c3a6e6192..a81be20afcfa 100644
--- a/docs/html/sdk/android-3.0.jd
+++ b/docs/html/sdk/android-3.0.jd
@@ -311,7 +311,7 @@ app widget looks like and is shown to the user from the widget picker. If this f
supplied, the app widget's icon is used for the preview.</p>
<p>To help create a preview image for your app widget (to specify in the {@link
-android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} field), the Android emulator includes an
+android.appwidget.AppWidgetProviderInfo#previewImage} field), the Android emulator includes an
application called "Widget Preview." To create a preview image, launch this application, select the
app widget for your application and set it up how you'd like your preview image to appear, then save
it and place it in your application's drawable resources.</p>
diff --git a/graphics/java/android/graphics/Point.aidl b/graphics/java/android/graphics/Point.aidl
new file mode 100644
index 000000000000..0e6b2b9098d7
--- /dev/null
+++ b/graphics/java/android/graphics/Point.aidl
@@ -0,0 +1,18 @@
+/* Copyright 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.graphics;
+
+parcelable Point;
diff --git a/graphics/java/android/graphics/Point.java b/graphics/java/android/graphics/Point.java
index c351444f8a82..338e880abaf3 100644
--- a/graphics/java/android/graphics/Point.java
+++ b/graphics/java/android/graphics/Point.java
@@ -16,11 +16,14 @@
package android.graphics;
+import android.os.Parcel;
+import android.os.Parcelable;
+
/**
* Point holds two integer coordinates
*/
-public class Point {
+public class Point implements Parcelable {
public int x;
public int y;
@@ -82,4 +85,52 @@ public class Point {
@Override public String toString() {
return "Point(" + x + ", " + y+ ")";
}
+
+ /**
+ * Parcelable interface methods
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Write this point to the specified parcel. To restore a point from
+ * a parcel, use readFromParcel()
+ * @param out The parcel to write the point's coordinates into
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(x);
+ out.writeInt(y);
+ }
+
+ public static final Parcelable.Creator<Point> CREATOR = new Parcelable.Creator<Point>() {
+ /**
+ * Return a new point from the data in the specified parcel.
+ */
+ public Point createFromParcel(Parcel in) {
+ Point r = new Point();
+ r.readFromParcel(in);
+ return r;
+ }
+
+ /**
+ * Return an array of rectangles of the specified size.
+ */
+ public Point[] newArray(int size) {
+ return new Point[size];
+ }
+ };
+
+ /**
+ * Set the point's coordinates from the data stored in the specified
+ * parcel. To write a point to a parcel, call writeToParcel().
+ *
+ * @param in The parcel to read the point's coordinates from
+ */
+ public void readFromParcel(Parcel in) {
+ x = in.readInt();
+ y = in.readInt();
+ }
}
diff --git a/graphics/java/android/graphics/PointF.aidl b/graphics/java/android/graphics/PointF.aidl
new file mode 100644
index 000000000000..ad72acd1b681
--- /dev/null
+++ b/graphics/java/android/graphics/PointF.aidl
@@ -0,0 +1,18 @@
+/* Copyright 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.graphics;
+
+parcelable PointF;
diff --git a/graphics/java/android/graphics/PointF.java b/graphics/java/android/graphics/PointF.java
index 0f045a1fede4..e00271f2e9a2 100644
--- a/graphics/java/android/graphics/PointF.java
+++ b/graphics/java/android/graphics/PointF.java
@@ -16,13 +16,15 @@
package android.graphics;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.util.FloatMath;
/**
* PointF holds two float coordinates
*/
-public class PointF {
+public class PointF implements Parcelable {
public float x;
public float y;
@@ -84,5 +86,52 @@ public class PointF {
public static float length(float x, float y) {
return FloatMath.sqrt(x * x + y * y);
}
-}
+ /**
+ * Parcelable interface methods
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Write this point to the specified parcel. To restore a point from
+ * a parcel, use readFromParcel()
+ * @param out The parcel to write the point's coordinates into
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeFloat(x);
+ out.writeFloat(y);
+ }
+
+ public static final Parcelable.Creator<PointF> CREATOR = new Parcelable.Creator<PointF>() {
+ /**
+ * Return a new point from the data in the specified parcel.
+ */
+ public PointF createFromParcel(Parcel in) {
+ PointF r = new PointF();
+ r.readFromParcel(in);
+ return r;
+ }
+
+ /**
+ * Return an array of rectangles of the specified size.
+ */
+ public PointF[] newArray(int size) {
+ return new PointF[size];
+ }
+ };
+
+ /**
+ * Set the point's coordinates from the data stored in the specified
+ * parcel. To write a point to a parcel, call writeToParcel().
+ *
+ * @param in The parcel to read the point's coordinates from
+ */
+ public void readFromParcel(Parcel in) {
+ x = in.readFloat();
+ y = in.readFloat();
+ }
+}
diff --git a/include/surfaceflinger/ISurfaceComposerClient.h b/include/surfaceflinger/ISurfaceComposerClient.h
index a1e9e0488492..46b1bb7e9fe1 100644
--- a/include/surfaceflinger/ISurfaceComposerClient.h
+++ b/include/surfaceflinger/ISurfaceComposerClient.h
@@ -64,7 +64,6 @@ public:
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual sp<ISurface> createSurface( surface_data_t* data,
- int pid,
const String8& name,
DisplayID display,
uint32_t w,
diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h
index 25b2ebf5a77a..c61a5bff2a12 100644
--- a/include/surfaceflinger/SurfaceComposerClient.h
+++ b/include/surfaceflinger/SurfaceComposerClient.h
@@ -79,7 +79,6 @@ public:
//! Create a surface
sp<SurfaceControl> createSurface(
- int pid, // pid of the process the surface is for
const String8& name,// name of the surface
DisplayID display, // Display to create this surface on
uint32_t w, // width in pixel
@@ -89,7 +88,6 @@ public:
);
sp<SurfaceControl> createSurface(
- int pid, // pid of the process the surface is for
DisplayID display, // Display to create this surface on
uint32_t w, // width in pixel
uint32_t h, // height in pixel
diff --git a/keystore/java/android/security/IKeyChainService.aidl b/keystore/java/android/security/IKeyChainService.aidl
new file mode 100644
index 000000000000..64f5a481ab58
--- /dev/null
+++ b/keystore/java/android/security/IKeyChainService.aidl
@@ -0,0 +1,31 @@
+/*
+ * 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.security;
+
+import android.os.Bundle;
+
+/**
+ * Caller is required to ensure that {@link KeyStore#unlock
+ * KeyStore.unlock} was successful.
+ *
+ * @hide
+ */
+interface IKeyChainService {
+ byte[] getPrivate(String alias, String authToken);
+ byte[] getCertificate(String alias, String authToken);
+ byte[] getCaCertificate(String alias, String authToken);
+ String findIssuer(in Bundle cert);
+}
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
new file mode 100644
index 000000000000..69847bf0eba3
--- /dev/null
+++ b/keystore/java/android/security/KeyChain.java
@@ -0,0 +1,372 @@
+/*
+ * 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.security;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.util.Log;
+import dalvik.system.CloseGuard;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters;
+import org.apache.harmony.xnet.provider.jsse.SSLParametersImpl;
+
+/**
+ * @hide
+ */
+public final class KeyChain {
+
+ private static final String TAG = "KeyChain";
+
+ /**
+ * @hide Also used by KeyChainService implementation
+ */
+ public static final String ACCOUNT_TYPE = "com.android.keychain";
+
+ /**
+ * @hide Also used by KeyChainService implementation
+ */
+ // TODO This non-localized CA string to be removed when CAs moved out of keystore
+ public static final String CA_SUFFIX = " CA";
+
+ public static final String KEY_INTENT = "intent";
+
+ /**
+ * Intentionally not public to leave open the future possibility
+ * of hardware based keys. Callers should use {@link #toPrivateKey
+ * toPrivateKey} in order to convert a bundle to a {@code
+ * PrivateKey}
+ */
+ private static final String KEY_PKCS8 = "pkcs8";
+
+ /**
+ * Intentionally not public to leave open the future possibility
+ * of hardware based certs. Callers should use {@link
+ * #toCertificate toCertificate} in order to convert a bundle to a
+ * {@code PrivateKey}
+ */
+ private static final String KEY_X509 = "x509";
+
+ /**
+ * Returns an {@code Intent} for use with {@link
+ * android.app.Activity#startActivityForResult
+ * startActivityForResult}. The result will be returned via {@link
+ * android.app.Activity#onActivityResult onActivityResult} with
+ * {@link android.app.Activity#RESULT_OK RESULT_OK} and the alias
+ * in the returned {@code Intent}'s extra data with key {@link
+ * android.content.Intent#EXTRA_TEXT Intent.EXTRA_TEXT}.
+ */
+ public static Intent chooseAlias() {
+ return new Intent("com.android.keychain.CHOOSER");
+ }
+
+ /**
+ * Returns a new {@code KeyChain} instance. When the caller is
+ * done using the {@code KeyChain}, it must be closed with {@link
+ * #close()} or resource leaks will occur.
+ */
+ public static KeyChain getInstance(Context context) throws InterruptedException {
+ return new KeyChain(context);
+ }
+
+ private final AccountManager mAccountManager;
+
+ private final Object mServiceLock = new Object();
+ private IKeyChainService mService;
+ private boolean mIsBound;
+
+ private Account mAccount;
+
+ private ServiceConnection mServiceConnection = new ServiceConnection() {
+ @Override public void onServiceConnected(ComponentName name, IBinder service) {
+ synchronized (mServiceLock) {
+ mService = IKeyChainService.Stub.asInterface(service);
+ mServiceLock.notifyAll();
+
+ // Account is created if necessary during binding of the IKeyChainService
+ mAccount = mAccountManager.getAccountsByType(ACCOUNT_TYPE)[0];
+ }
+ }
+
+ @Override public void onServiceDisconnected(ComponentName name) {
+ synchronized (mServiceLock) {
+ mService = null;
+ }
+ }
+ };
+
+ private final Context mContext;
+
+ private final CloseGuard mGuard = CloseGuard.get();
+
+ private KeyChain(Context context) throws InterruptedException {
+ if (context == null) {
+ throw new NullPointerException("context == null");
+ }
+ mContext = context;
+ ensureNotOnMainThread();
+ mAccountManager = AccountManager.get(mContext);
+ mIsBound = mContext.bindService(new Intent(IKeyChainService.class.getName()),
+ mServiceConnection,
+ Context.BIND_AUTO_CREATE);
+ if (!mIsBound) {
+ throw new AssertionError();
+ }
+ synchronized (mServiceLock) {
+ // there is a race between binding on this thread and the
+ // callback on the main thread. wait until binding is done
+ // to be sure we have the mAccount initialized.
+ if (mService == null) {
+ mServiceLock.wait();
+ }
+ }
+ mGuard.open("close");
+ }
+
+ /**
+ * {@code Bundle} will contain {@link #KEY_INTENT} if user needs
+ * to confirm application access to requested key. In the alias
+ * does not exist or there is an error, null is
+ * returned. Otherwise the {@code Bundle} contains information
+ * representing the private key which can be interpreted with
+ * {@link #toPrivateKey toPrivateKey}.
+ *
+ * non-null alias
+ */
+ public Bundle getPrivate(String alias) {
+ return get(alias, Credentials.USER_PRIVATE_KEY);
+ }
+
+ public Bundle getCertificate(String alias) {
+ return get(alias, Credentials.USER_CERTIFICATE);
+ }
+
+ public Bundle getCaCertificate(String alias) {
+ return get(alias, Credentials.CA_CERTIFICATE);
+ }
+
+ private Bundle get(String alias, String type) {
+ if (alias == null) {
+ throw new NullPointerException("alias == null");
+ }
+ ensureNotOnMainThread();
+
+ String authAlias = (type.equals(Credentials.CA_CERTIFICATE)) ? (alias + CA_SUFFIX) : alias;
+ AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount,
+ authAlias,
+ false,
+ null,
+ null);
+ Bundle bundle;
+ try {
+ bundle = future.getResult();
+ } catch (OperationCanceledException e) {
+ throw new AssertionError(e);
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ } catch (AuthenticatorException e) {
+ throw new AssertionError(e);
+ }
+ Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
+ if (intent != null) {
+ Bundle result = new Bundle();
+ // we don't want this Eclair compatability flag,
+ // it will prevent onActivityResult from being called
+ intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
+ result.putParcelable(KEY_INTENT, intent);
+ return result;
+ }
+ String authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
+ if (authToken == null) {
+ throw new AssertionError("Invalid authtoken");
+ }
+
+ byte[] bytes;
+ try {
+ if (type.equals(Credentials.USER_PRIVATE_KEY)) {
+ bytes = mService.getPrivate(alias, authToken);
+ } else if (type.equals(Credentials.USER_CERTIFICATE)) {
+ bytes = mService.getCertificate(alias, authToken);
+ } else if (type.equals(Credentials.CA_CERTIFICATE)) {
+ bytes = mService.getCaCertificate(alias, authToken);
+ } else {
+ throw new AssertionError();
+ }
+ } catch (RemoteException e) {
+ throw new AssertionError(e);
+ }
+ if (bytes == null) {
+ throw new AssertionError();
+ }
+ Bundle result = new Bundle();
+ if (type.equals(Credentials.USER_PRIVATE_KEY)) {
+ result.putByteArray(KEY_PKCS8, bytes);
+ } else if (type.equals(Credentials.USER_CERTIFICATE)) {
+ result.putByteArray(KEY_X509, bytes);
+ } else if (type.equals(Credentials.CA_CERTIFICATE)) {
+ result.putByteArray(KEY_X509, bytes);
+ } else {
+ throw new AssertionError();
+ }
+ return result;
+ }
+
+ public static PrivateKey toPrivateKey(Bundle bundle) {
+ byte[] bytes = bundle.getByteArray(KEY_PKCS8);
+ if (bytes == null) {
+ throw new IllegalArgumentException("not a private key bundle");
+ }
+ try {
+ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+ return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(bytes));
+ } catch (NoSuchAlgorithmException e) {
+ throw new AssertionError(e);
+ } catch (InvalidKeySpecException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ public static Bundle fromPrivateKey(PrivateKey privateKey) {
+ Bundle bundle = new Bundle();
+ String format = privateKey.getFormat();
+ if (!format.equals("PKCS#8")) {
+ throw new IllegalArgumentException("Unsupported private key format " + format);
+ }
+ bundle.putByteArray(KEY_PKCS8, privateKey.getEncoded());
+ return bundle;
+ }
+
+ public static X509Certificate toCertificate(Bundle bundle) {
+ byte[] bytes = bundle.getByteArray(KEY_X509);
+ if (bytes == null) {
+ throw new IllegalArgumentException("not a certificate bundle");
+ }
+ try {
+ CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+ Certificate cert = certFactory.generateCertificate(new ByteArrayInputStream(bytes));
+ return (X509Certificate) cert;
+ } catch (CertificateException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ public static Bundle fromCertificate(Certificate cert) {
+ Bundle bundle = new Bundle();
+ String type = cert.getType();
+ if (!type.equals("X.509")) {
+ throw new IllegalArgumentException("Unsupported certificate type " + type);
+ }
+ try {
+ bundle.putByteArray(KEY_X509, cert.getEncoded());
+ } catch (CertificateEncodingException e) {
+ throw new AssertionError(e);
+ }
+ return bundle;
+ }
+
+ private void ensureNotOnMainThread() {
+ Looper looper = Looper.myLooper();
+ if (looper != null && looper == mContext.getMainLooper()) {
+ throw new IllegalStateException(
+ "calling this from your main thread can lead to deadlock");
+ }
+ }
+
+ public Bundle findIssuer(X509Certificate cert) {
+ if (cert == null) {
+ throw new NullPointerException("cert == null");
+ }
+ ensureNotOnMainThread();
+
+ // check and see if the issuer is already known to the default IndexedPKIXParameters
+ IndexedPKIXParameters index = SSLParametersImpl.getDefaultIndexedPKIXParameters();
+ try {
+ TrustAnchor anchor = index.findTrustAnchor(cert);
+ if (anchor != null && anchor.getTrustedCert() != null) {
+ X509Certificate ca = anchor.getTrustedCert();
+ return fromCertificate(ca);
+ }
+ } catch (CertPathValidatorException ignored) {
+ }
+
+ // otherwise, it might be a user installed CA in the keystore
+ String alias;
+ try {
+ alias = mService.findIssuer(fromCertificate(cert));
+ } catch (RemoteException e) {
+ throw new AssertionError(e);
+ }
+ if (alias == null) {
+ Log.w(TAG, "Lookup failed for issuer");
+ return null;
+ }
+
+ Bundle bundle = get(alias, Credentials.CA_CERTIFICATE);
+ Intent intent = bundle.getParcelable(KEY_INTENT);
+ if (intent != null) {
+ // permission still required
+ return bundle;
+ }
+ // add the found CA to the index for next time
+ X509Certificate ca = toCertificate(bundle);
+ index.index(new TrustAnchor(ca, null));
+ return bundle;
+ }
+
+ public void close() {
+ if (mIsBound) {
+ mContext.unbindService(mServiceConnection);
+ mIsBound = false;
+ mGuard.close();
+ }
+ }
+
+ protected void finalize() throws Throwable {
+ // note we don't close, we just warn.
+ // shouldn't be doing I/O in a finalizer,
+ // which the unbind would cause.
+ try {
+ if (mGuard != null) {
+ mGuard.warnIfOpen();
+ }
+ } finally {
+ super.finalize();
+ }
+ }
+}
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index 7730eb1fa91b..ea38e08a555f 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -83,7 +83,6 @@ public:
}
virtual sp<ISurface> createSurface( surface_data_t* params,
- int pid,
const String8& name,
DisplayID display,
uint32_t w,
@@ -93,7 +92,6 @@ public:
{
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
- data.writeInt32(pid);
data.writeString8(name);
data.writeInt32(display);
data.writeInt32(w);
@@ -172,14 +170,13 @@ status_t BnSurfaceComposerClient::onTransact(
case CREATE_SURFACE: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
surface_data_t params;
- int32_t pid = data.readInt32();
String8 name = data.readString8();
DisplayID display = data.readInt32();
uint32_t w = data.readInt32();
uint32_t h = data.readInt32();
PixelFormat format = data.readInt32();
uint32_t flags = data.readInt32();
- sp<ISurface> s = createSurface(&params, pid, name, display, w, h,
+ sp<ISurface> s = createSurface(&params, name, display, w, h,
format, flags);
params.writeToParcel(reply);
reply->writeStrongBinder(s->asBinder());
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index d3367246a119..a1ff2c1e2f5d 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -273,7 +273,6 @@ ssize_t SurfaceComposerClient::getNumberOfDisplays()
}
sp<SurfaceControl> SurfaceComposerClient::createSurface(
- int pid,
DisplayID display,
uint32_t w,
uint32_t h,
@@ -286,12 +285,11 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
snprintf(buffer, SIZE, "<pid_%d>", getpid());
name.append(buffer);
- return SurfaceComposerClient::createSurface(pid, name, display,
+ return SurfaceComposerClient::createSurface(name, display,
w, h, format, flags);
}
sp<SurfaceControl> SurfaceComposerClient::createSurface(
- int pid,
const String8& name,
DisplayID display,
uint32_t w,
@@ -302,7 +300,7 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
sp<SurfaceControl> result;
if (mStatus == NO_ERROR) {
ISurfaceComposerClient::surface_data_t data;
- sp<ISurface> surface = mClient->createSurface(&data, pid, name,
+ sp<ISurface> surface = mClient->createSurface(&data, name,
display, w, h, format, flags);
if (surface != 0) {
result = new SurfaceControl(this, surface, data, w, h, format, flags);
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp
index 2c6840b911e6..8120864f1c51 100644
--- a/libs/rs/driver/rsdBcc.cpp
+++ b/libs/rs/driver/rsdBcc.cpp
@@ -56,8 +56,9 @@ struct DrvScript {
};
+
static Script * setTLS(Script *sc) {
- ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey);
+ ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey);
rsAssert(tls);
Script *old = tls->mScript;
tls->mScript = sc;
@@ -133,12 +134,13 @@ bool rsdScriptInit(const Context *rsc,
uint32_t flags) {
//LOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir, bitcode, bitcodeSize, flags, lookupFunc);
+ pthread_mutex_lock(&rsdgInitMutex);
char *cachePath = NULL;
uint32_t objectSlotCount = 0;
DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
if (drv == NULL) {
- return false;
+ goto error;
}
script->mHal.drv = drv;
@@ -159,20 +161,20 @@ bool rsdScriptInit(const Context *rsc,
(char const *)drv->mScriptText,
drv->mScriptTextLength, 0) != 0) {
LOGE("bcc: FAILS to read bitcode");
- return NULL;
+ goto error;
}
#if 1
if (bccLinkFile(drv->mBccScript, "/system/lib/libclcore.bc", 0) != 0) {
LOGE("bcc: FAILS to link bitcode");
- return NULL;
+ goto error;
}
#endif
cachePath = genCacheFileName(cacheDir, resName, ".oBCC");
if (bccPrepareExecutable(drv->mBccScript, cachePath, 0) != 0) {
LOGE("bcc: FAILS to prepare executable");
- return NULL;
+ goto error;
}
free(cachePath);
@@ -234,10 +236,12 @@ bool rsdScriptInit(const Context *rsc,
script->mHal.info.root = drv->mRoot;
+ pthread_mutex_unlock(&rsdgInitMutex);
return true;
error:
+ pthread_mutex_unlock(&rsdgInitMutex);
free(drv);
return false;
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
index c01e5ab5df09..5b80439974cb 100644
--- a/libs/rs/driver/rsdCore.cpp
+++ b/libs/rs/driver/rsdCore.cpp
@@ -73,6 +73,9 @@ static RsdHalFunctions FunctionTable = {
};
+pthread_key_t rsdgThreadTLSKey = 0;
+uint32_t rsdgThreadTLSKeyCount = 0;
+pthread_mutex_t rsdgInitMutex = PTHREAD_MUTEX_INITIALIZER;
static void * HelperThreadProc(void *vrsc) {
@@ -87,6 +90,11 @@ static void * HelperThreadProc(void *vrsc) {
dc->mWorkers.mLaunchSignals[idx].init();
dc->mWorkers.mNativeThreadId[idx] = gettid();
+ int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
+ if (status) {
+ LOGE("pthread_setspecific %i", status);
+ }
+
#if 0
typedef struct {uint64_t bits[1024 / 64]; } cpu_set_t;
cpu_set_t cpuset;
@@ -97,11 +105,6 @@ static void * HelperThreadProc(void *vrsc) {
LOGE("SETAFFINITY ret = %i %s", ret, EGLUtils::strerror(ret));
#endif
- int status = pthread_setspecific(rsc->gThreadTLSKey, rsc->mTlsStruct);
- if (status) {
- LOGE("pthread_setspecific %i", status);
- }
-
while (!dc->mExit) {
dc->mWorkers.mLaunchSignals[idx].wait();
if (dc->mWorkers.mLaunchCallback) {
@@ -139,6 +142,25 @@ bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
}
rsc->mHal.drv = dc;
+ pthread_mutex_lock(&rsdgInitMutex);
+ if (!rsdgThreadTLSKeyCount) {
+ int status = pthread_key_create(&rsdgThreadTLSKey, NULL);
+ if (status) {
+ LOGE("Failed to init thread tls key.");
+ pthread_mutex_unlock(&rsdgInitMutex);
+ return false;
+ }
+ }
+ rsdgThreadTLSKeyCount++;
+ pthread_mutex_unlock(&rsdgInitMutex);
+
+ dc->mTlsStruct.mContext = rsc;
+ dc->mTlsStruct.mScript = NULL;
+ int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
+ if (status) {
+ LOGE("pthread_setspecific %i", status);
+ }
+
int cpu = sysconf(_SC_NPROCESSORS_ONLN);
LOGV("RS Launching thread(s), reported CPU count %i", cpu);
@@ -155,7 +177,6 @@ bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
android_atomic_release_store(0, &dc->mWorkers.mLaunchCount);
- int status;
pthread_attr_t threadAttr;
status = pthread_attr_init(&threadAttr);
if (status) {
@@ -203,6 +224,15 @@ void Shutdown(Context *rsc) {
status = pthread_join(dc->mWorkers.mThreadId[ct], &res);
}
rsAssert(android_atomic_acquire_load(&dc->mWorkers.mRunningCount) == 0);
+
+ // Global structure cleanup.
+ pthread_mutex_lock(&rsdgInitMutex);
+ --rsdgThreadTLSKeyCount;
+ if (!rsdgThreadTLSKeyCount) {
+ pthread_key_delete(rsdgThreadTLSKey);
+ }
+ pthread_mutex_unlock(&rsdgInitMutex);
+
}
diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h
index c8df57535d1f..422bb1b07dc2 100644
--- a/libs/rs/driver/rsdCore.h
+++ b/libs/rs/driver/rsdCore.h
@@ -34,6 +34,11 @@ typedef struct RsdSymbolTableRec {
bool threadable;
} RsdSymbolTable;
+typedef struct ScriptTLSStructRec {
+ android::renderscript::Context * mContext;
+ android::renderscript::Script * mScript;
+} ScriptTLSStruct;
+
typedef struct RsdHalRec {
uint32_t version_major;
uint32_t version_minor;
@@ -53,9 +58,14 @@ typedef struct RsdHalRec {
Workers mWorkers;
bool mExit;
+ ScriptTLSStruct mTlsStruct;
+
RsdGL gl;
} RsdHal;
+extern pthread_key_t rsdgThreadTLSKey;
+extern uint32_t rsdgThreadTLSKeyCount;
+extern pthread_mutex_t rsdgInitMutex;
void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
diff --git a/libs/rs/driver/rsdRuntimeStubs.cpp b/libs/rs/driver/rsdRuntimeStubs.cpp
index e384713b94e6..b70a1232ef3d 100644
--- a/libs/rs/driver/rsdRuntimeStubs.cpp
+++ b/libs/rs/driver/rsdRuntimeStubs.cpp
@@ -32,7 +32,7 @@ using namespace android;
using namespace android::renderscript;
#define GET_TLS() ScriptTLSStruct * tls = \
- (ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
+ (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
Context * rsc = tls->mContext; \
ScriptC * sc = (ScriptC *) tls->mScript
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 0f61789b4af7..20fa3672c03f 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -39,13 +39,9 @@
using namespace android;
using namespace android::renderscript;
-pthread_key_t Context::gThreadTLSKey = 0;
-uint32_t Context::gThreadTLSKeyCount = 0;
pthread_mutex_t Context::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t Context::gLibMutex = PTHREAD_MUTEX_INITIALIZER;
-
-
bool Context::initGLThread() {
pthread_mutex_lock(&gInitMutex);
LOGV("initGLThread start %p", this);
@@ -263,94 +259,86 @@ void Context::displayDebugStats() {
}
void * Context::threadProc(void *vrsc) {
- Context *rsc = static_cast<Context *>(vrsc);
- rsc->mNativeThreadId = gettid();
-
- setpriority(PRIO_PROCESS, rsc->mNativeThreadId, ANDROID_PRIORITY_DISPLAY);
- rsc->mThreadPriority = ANDROID_PRIORITY_DISPLAY;
-
- rsc->props.mLogTimes = getProp("debug.rs.profile");
- rsc->props.mLogScripts = getProp("debug.rs.script");
- rsc->props.mLogObjects = getProp("debug.rs.object");
- rsc->props.mLogShaders = getProp("debug.rs.shader");
- rsc->props.mLogShadersAttr = getProp("debug.rs.shader.attributes");
- rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms");
- rsc->props.mLogVisual = getProp("debug.rs.visual");
-
- rsc->mTlsStruct = new ScriptTLSStruct;
- if (!rsc->mTlsStruct) {
- LOGE("Error allocating tls storage");
- rsc->setError(RS_ERROR_OUT_OF_MEMORY, "Failed allocation for TLS");
- return NULL;
- }
- rsc->mTlsStruct->mContext = rsc;
- rsc->mTlsStruct->mScript = NULL;
- int status = pthread_setspecific(rsc->gThreadTLSKey, rsc->mTlsStruct);
- if (status) {
- LOGE("pthread_setspecific %i", status);
- }
-
- if (!rsc->initGLThread()) {
- rsc->setError(RS_ERROR_OUT_OF_MEMORY, "Failed initializing GL");
- return NULL;
- }
-
- if (rsc->mIsGraphicsContext) {
- rsc->mStateRaster.init(rsc);
- rsc->setProgramRaster(NULL);
- rsc->mStateVertex.init(rsc);
- rsc->setProgramVertex(NULL);
- rsc->mStateFragment.init(rsc);
- rsc->setProgramFragment(NULL);
- rsc->mStateFragmentStore.init(rsc);
- rsc->setProgramStore(NULL);
- rsc->mStateFont.init(rsc);
- rsc->setFont(NULL);
- rsc->mStateVertexArray.init(rsc);
- }
-
- rsc->mRunning = true;
- bool mDraw = true;
- while (!rsc->mExit) {
- mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
- mDraw &= (rsc->mRootScript.get() != NULL);
- mDraw &= (rsc->mWndSurface != NULL);
-
- uint32_t targetTime = 0;
- if (mDraw && rsc->mIsGraphicsContext) {
- targetTime = rsc->runRootScript();
-
- if (rsc->props.mLogVisual) {
- rsc->displayDebugStats();
- }
-
- mDraw = targetTime && !rsc->mPaused;
- rsc->timerSet(RS_TIMER_CLEAR_SWAP);
- rsc->mHal.funcs.swap(rsc);
- rsc->timerFrame();
- rsc->timerSet(RS_TIMER_INTERNAL);
- rsc->timerPrint();
- rsc->timerReset();
- }
- if (targetTime > 1) {
- int32_t t = (targetTime - (int32_t)(rsc->mTimeMSLastScript + rsc->mTimeMSLastSwap)) * 1000;
- if (t > 0) {
- usleep(t);
- }
- }
- }
-
- LOGV("%p, RS Thread exiting", rsc);
-
- if (rsc->mIsGraphicsContext) {
- pthread_mutex_lock(&gInitMutex);
- rsc->deinitEGL();
- pthread_mutex_unlock(&gInitMutex);
- }
- delete rsc->mTlsStruct;
-
- LOGV("%p, RS Thread exited", rsc);
- return NULL;
+ Context *rsc = static_cast<Context *>(vrsc);
+ rsc->mNativeThreadId = gettid();
+
+ setpriority(PRIO_PROCESS, rsc->mNativeThreadId, ANDROID_PRIORITY_DISPLAY);
+ rsc->mThreadPriority = ANDROID_PRIORITY_DISPLAY;
+
+ rsc->props.mLogTimes = getProp("debug.rs.profile");
+ rsc->props.mLogScripts = getProp("debug.rs.script");
+ rsc->props.mLogObjects = getProp("debug.rs.object");
+ rsc->props.mLogShaders = getProp("debug.rs.shader");
+ rsc->props.mLogShadersAttr = getProp("debug.rs.shader.attributes");
+ rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms");
+ rsc->props.mLogVisual = getProp("debug.rs.visual");
+
+ if (!rsdHalInit(rsc, 0, 0)) {
+ LOGE("Hal init failed");
+ return NULL;
+ }
+ rsc->mHal.funcs.setPriority(rsc, rsc->mThreadPriority);
+
+ if (!rsc->initGLThread()) {
+ rsc->setError(RS_ERROR_OUT_OF_MEMORY, "Failed initializing GL");
+ return NULL;
+ }
+
+ if (rsc->mIsGraphicsContext) {
+ rsc->mStateRaster.init(rsc);
+ rsc->setProgramRaster(NULL);
+ rsc->mStateVertex.init(rsc);
+ rsc->setProgramVertex(NULL);
+ rsc->mStateFragment.init(rsc);
+ rsc->setProgramFragment(NULL);
+ rsc->mStateFragmentStore.init(rsc);
+ rsc->setProgramStore(NULL);
+ rsc->mStateFont.init(rsc);
+ rsc->setFont(NULL);
+ rsc->mStateVertexArray.init(rsc);
+ }
+
+ rsc->mRunning = true;
+ bool mDraw = true;
+ while (!rsc->mExit) {
+ mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
+ mDraw &= (rsc->mRootScript.get() != NULL);
+ mDraw &= (rsc->mWndSurface != NULL);
+
+ uint32_t targetTime = 0;
+ if (mDraw && rsc->mIsGraphicsContext) {
+ targetTime = rsc->runRootScript();
+
+ if (rsc->props.mLogVisual) {
+ rsc->displayDebugStats();
+ }
+
+ mDraw = targetTime && !rsc->mPaused;
+ rsc->timerSet(RS_TIMER_CLEAR_SWAP);
+ rsc->mHal.funcs.swap(rsc);
+ rsc->timerFrame();
+ rsc->timerSet(RS_TIMER_INTERNAL);
+ rsc->timerPrint();
+ rsc->timerReset();
+ }
+ if (targetTime > 1) {
+ int32_t t = (targetTime - (int32_t)(rsc->mTimeMSLastScript + rsc->mTimeMSLastSwap)) * 1000;
+ if (t > 0) {
+ usleep(t);
+ }
+ }
+ }
+
+ LOGV("%p, RS Thread exiting", rsc);
+
+ if (rsc->mIsGraphicsContext) {
+ pthread_mutex_lock(&gInitMutex);
+ rsc->deinitEGL();
+ pthread_mutex_unlock(&gInitMutex);
+ }
+
+ LOGV("%p, RS Thread exited", rsc);
+ return NULL;
}
void Context::destroyWorkerThreadResources() {
@@ -429,16 +417,6 @@ bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
int status;
pthread_attr_t threadAttr;
- if (!gThreadTLSKeyCount) {
- status = pthread_key_create(&gThreadTLSKey, NULL);
- if (status) {
- LOGE("Failed to init thread tls key.");
- pthread_mutex_unlock(&gInitMutex);
- return false;
- }
- }
- gThreadTLSKeyCount++;
-
pthread_mutex_unlock(&gInitMutex);
// Global init done at this point.
@@ -454,12 +432,6 @@ bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
timerInit();
timerSet(RS_TIMER_INTERNAL);
- if (!rsdHalInit(this, 0, 0)) {
- LOGE("Hal init failed");
- return false;
- }
- mHal.funcs.setPriority(this, mThreadPriority);
-
status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
if (status) {
LOGE("Failed to start rs context thread.");
@@ -499,10 +471,6 @@ Context::~Context() {
pthread_mutex_lock(&gInitMutex);
if (mDev) {
mDev->removeContext(this);
- --gThreadTLSKeyCount;
- if (!gThreadTLSKeyCount) {
- pthread_key_delete(gThreadTLSKey);
- }
mDev = NULL;
}
pthread_mutex_unlock(&gInitMutex);
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 0a0f3e016eeb..df85a6bc9283 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -84,9 +84,6 @@ public:
static Context * createContext(Device *, const RsSurfaceConfig *sc);
~Context();
- static pthread_key_t gThreadTLSKey;
- static uint32_t gThreadTLSKeyCount;
- static uint32_t gGLContextCount;
static pthread_mutex_t gInitMutex;
// Library mutex (for providing thread-safe calls from the runtime)
static pthread_mutex_t gLibMutex;
@@ -105,7 +102,6 @@ public:
Context *mRsc;
};
- ScriptTLSStruct *mTlsStruct;
RsSurfaceConfig mUserSurfaceConfig;
ElementState mStateElement;
diff --git a/libs/rs/rs_hal.h b/libs/rs/rs_hal.h
index 90abd85531ee..4283d4a6ae00 100644
--- a/libs/rs/rs_hal.h
+++ b/libs/rs/rs_hal.h
@@ -35,12 +35,6 @@ class ProgramRaster;
typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
-typedef struct ScriptTLSStructRec {
- Context * mContext;
- Script * mScript;
-} ScriptTLSStruct;
-
-
/**
* Script management functions
*/
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 51e715d0664c..a7ac9edf7608 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -1176,8 +1176,7 @@ public class MediaScanner
mGenresUri = Genres.getContentUri(volumeName);
mPlaylistsUri = Playlists.getContentUri(volumeName);
- mCaseInsensitivePaths = !mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_caseSensitiveExternalStorage);
+ mCaseInsensitivePaths = true;
if (!Process.supportsProcesses()) {
// Simulator uses host file system, so it should be case sensitive.
mCaseInsensitivePaths = false;
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index b900671c22fc..c9e0f6ffb1c6 100644
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -616,8 +616,8 @@ public class MtpDatabase {
// use screen size as max image size
Display display = ((WindowManager)mContext.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
- int width = display.getWidth();
- int height = display.getHeight();
+ int width = display.getMaximumSizeDimension();
+ int height = display.getMaximumSizeDimension();
String imageSize = Integer.toString(width) + "x" + Integer.toString(height);
imageSize.getChars(0, imageSize.length(), outStringValue, 0);
outStringValue[imageSize.length()] = 0;
diff --git a/media/jni/mediaeditor/VideoBrowserInternal.h b/media/jni/mediaeditor/VideoBrowserInternal.h
index ed63129ca3cd..3cfb6b9270c1 100755
--- a/media/jni/mediaeditor/VideoBrowserInternal.h
+++ b/media/jni/mediaeditor/VideoBrowserInternal.h
@@ -67,7 +67,7 @@
{ \
if (M4OSA_NULL != p) \
{ \
- M4OSA_free((M4OSA_MemAddr32)p) ; \
+ free(p) ; \
p = M4OSA_NULL ; \
} \
}
diff --git a/media/jni/mediaeditor/VideoBrowserMain.c b/media/jni/mediaeditor/VideoBrowserMain.c
index cddab601a57c..6ef688d1f2ff 100755
--- a/media/jni/mediaeditor/VideoBrowserMain.c
+++ b/media/jni/mediaeditor/VideoBrowserMain.c
@@ -73,7 +73,7 @@ M4OSA_ERR videoBrowserSetWindow(
if (pC->m_frameColorType == VideoBrowser_kGB565) {
pC->m_outputPlane[0].u_stride = pC->m_outputPlane[0].u_width << 1;
- pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)M4OSA_malloc(
+ pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
pC->m_outputPlane[0].u_stride * pC->m_outputPlane[0].u_height,
VIDEOBROWSER, (M4OSA_Char *)"output plane");
@@ -154,7 +154,7 @@ M4OSA_ERR videoBrowserCreate(
CHECK_PTR(videoBrowserCreate, pURL, err, M4ERR_PARAMETER);
/*--- Create context ---*/
- pContext = (VideoBrowserContext*)M4OSA_malloc(
+ pContext = (VideoBrowserContext*)M4OSA_32bitAlignedMalloc(
sizeof(VideoBrowserContext),
VIDEOBROWSER, (M4OSA_Char*)"Video browser context");
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index ea73e117bafe..5696433614fe 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -28,7 +28,6 @@ extern "C" {
#include <M4OSA_FileWriter.h>
#include <M4OSA_Memory.h>
#include <M4OSA_Debug.h>
-#include <M4OSA_String.h>
#include <M4OSA_Thread.h>
#include <M4VSS3GPP_API.h>
#include <M4xVSS_API.h>
@@ -2465,7 +2464,7 @@ videoEditClasses_getEffectSettings(
if (pSettings->xVSS.pFramingFilePath != M4OSA_NULL)
{
pSettings->xVSS.pFramingBuffer =
- (M4VIFI_ImagePlane *)M4OSA_malloc(sizeof(M4VIFI_ImagePlane),
+ (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),
0x00,(M4OSA_Char *)"framing buffer");
}
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index b79229539eeb..c95a0c25c13a 100755
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -41,15 +41,12 @@ extern "C" {
#include <M4OSA_FileCommon.h>
#include <M4OSA_FileReader.h>
#include <M4OSA_FileWriter.h>
-#include <M4OSA_FileExtra.h>
#include <M4OSA_Memory.h>
-#include <M4OSA_String.h>
#include <M4OSA_Thread.h>
#include <M4xVSS_API.h>
#include <M4VSS3GPP_ErrorCodes.h>
#include <M4MCS_API.h>
#include <M4MCS_ErrorCodes.h>
-#include <M4MDP_API.h>
#include <M4READER_Common.h>
#include <M4WRITER_common.h>
};
@@ -416,7 +413,7 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
LOGV("MSG_TYPE_OVERLAY_UPDATE");
if (pContext->mOverlayFileName != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+ free(pContext->mOverlayFileName);
pContext->mOverlayFileName = NULL;
}
@@ -424,7 +421,7 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
strlen((const char*)pContext->pEditSettings->Effects[overlayEffectIndex].xVSS.pFramingFilePath);
pContext->mOverlayFileName =
- (char*)M4OSA_malloc(overlayFileNameLen+1,
+ (char*)M4OSA_32bitAlignedMalloc(overlayFileNameLen+1,
M4VS, (M4OSA_Char*)"videoEdito JNI overlayFile");
if (pContext->mOverlayFileName != NULL) {
strncpy (pContext->mOverlayFileName,
@@ -454,7 +451,7 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
case MSG_TYPE_OVERLAY_CLEAR:
isSendProgress = false;
if (pContext->mOverlayFileName != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+ free(pContext->mOverlayFileName);
pContext->mOverlayFileName = NULL;
}
@@ -504,7 +501,7 @@ static int videoEditor_stopPreview(JNIEnv* pEnv,
lastProgressTimeMs = pContext->mPreviewController->stopPreview();
if (pContext->mOverlayFileName != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+ free(pContext->mOverlayFileName);
pContext->mOverlayFileName = NULL;
}
@@ -750,7 +747,7 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
framesizeYuv = width * height * 1.5;
- pixelArray = (M4VIFI_UInt8 *)M4OSA_malloc(framesizeYuv, M4VS,
+ pixelArray = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(framesizeYuv, M4VS,
(M4OSA_Char*)"videoEditor pixelArray");
if (pixelArray == M4OSA_NULL) {
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR",
@@ -768,7 +765,7 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
ClipProperties.uiVideoHeight,
&tnTimeMs);
if (result != M4NO_ERROR) {
- M4OSA_free((M4OSA_MemAddr32)pixelArray);
+ free(pixelArray);
ThumbnailClose(tnContext);
return -1;
}
@@ -792,12 +789,12 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
/**
* Allocate output YUV planes
*/
- yuvPlane = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS,
+ yuvPlane = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS,
(M4OSA_Char*)"videoEditor_renderPreviewFrame Output plane YUV");
if (yuvPlane == M4OSA_NULL) {
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR",
"videoEditor_renderPreviewFrame() malloc error for yuv plane");
- M4OSA_free((M4OSA_MemAddr32)pixelArray);
+ free(pixelArray);
pMessage = videoEditJava_getErrorName(M4ERR_ALLOC);
jniThrowException(pEnv, "java/lang/RuntimeException", pMessage);
return -1;
@@ -902,10 +899,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
if (pContext->pEditSettings->pClipList[iCurrentClipIndex]->FileType ==\
/*M4VIDEOEDITING_kFileType_JPG */ M4VIDEOEDITING_kFileType_ARGB8888) {
- M4OSA_free((M4OSA_MemAddr32)frameStr.pBuffer);
+ free(frameStr.pBuffer);
} else {
- M4OSA_free((M4OSA_MemAddr32)yuvPlane[0].pac_data);
- M4OSA_free((M4OSA_MemAddr32)yuvPlane);
+ free(yuvPlane[0].pac_data);
+ free(yuvPlane);
}
return tnTimeMs;
}
@@ -981,7 +978,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
framesizeYuv = ((frameWidth)*(frameHeight)*1.5);
- pixelArray = (M4VIFI_UInt8 *)M4OSA_malloc(framesizeYuv, M4VS,\
+ pixelArray = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(framesizeYuv, M4VS,\
(M4OSA_Char*)"videoEditor pixelArray");
if (pixelArray == M4OSA_NULL) {
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR",
@@ -996,7 +993,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
frameWidth,
frameHeight, &timeMs);
if (result != M4NO_ERROR) {
- M4OSA_free((M4OSA_MemAddr32)pixelArray);
+ free(pixelArray);
ThumbnailClose(tnContext);
return fromMs;
}
@@ -1066,7 +1063,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
(M4NO_ERROR != result), result);
/* free the pixelArray and yuvPlane[0].pac_data */
- M4OSA_free((M4OSA_MemAddr32)yuvPlane[0].pac_data);
+ free(yuvPlane[0].pac_data);
ThumbnailClose(tnContext);
@@ -1148,7 +1145,7 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", "M4MCS_init()");
- pOutputParams = (M4MCS_OutputParams *)M4OSA_malloc(
+ pOutputParams = (M4MCS_OutputParams *)M4OSA_32bitAlignedMalloc(
sizeof(M4MCS_OutputParams),0x00,
(M4OSA_Char *)"M4MCS_OutputParams");
videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
@@ -1158,14 +1155,14 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
return M4ERR_ALLOC;
}
- pEncodingParams = (M4MCS_EncodingParams *)M4OSA_malloc(
+ pEncodingParams = (M4MCS_EncodingParams *)M4OSA_32bitAlignedMalloc(
sizeof(M4MCS_EncodingParams),0x00,
(M4OSA_Char *)"M4MCS_EncodingParams");
videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
(M4OSA_NULL == pEncodingParams),
"not initialized");
if (needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return M4ERR_ALLOC;
}
@@ -1179,15 +1176,15 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
(M4OSA_NULL == mcsContext),
"not initialized");
if(needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
// generate the path for temp 3gp output file
- pTemp3gpFilePath = (M4OSA_Char*) M4OSA_malloc (
+ pTemp3gpFilePath = (M4OSA_Char*) M4OSA_32bitAlignedMalloc (
(strlen((const char*)pContext->initParams.pTempPath)
+ strlen((const char*)TEMP_MCS_OUT_FILE_PATH)) + 1 /* for null termination */ , 0x0,
(M4OSA_Char*)"Malloc for temp 3gp file");
@@ -1204,9 +1201,9 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
}
else {
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return M4ERR_ALLOC;
}
@@ -1231,12 +1228,12 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
(M4NO_ERROR != result), result);
if(needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
pTemp3gpFilePath = M4OSA_NULL;
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
@@ -1281,12 +1278,12 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
(M4NO_ERROR != result), result);
if (needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
pTemp3gpFilePath = M4OSA_NULL;
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
@@ -1311,12 +1308,12 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
(M4NO_ERROR != result), result);
if (needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
pTemp3gpFilePath = M4OSA_NULL;
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
@@ -1327,12 +1324,12 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
(M4NO_ERROR != result), result);
if (needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
pTemp3gpFilePath = M4OSA_NULL;
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
@@ -1379,12 +1376,12 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
(M4MCS_WAR_TRANSCODING_DONE != result), result);
if (needToBeLoaded == false) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
pTemp3gpFilePath = M4OSA_NULL;
M4MCS_abort(mcsContext);
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
pOutputParams = M4OSA_NULL;
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
pEncodingParams = M4OSA_NULL;
return result;
}
@@ -1399,13 +1396,13 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", "videoEditor_generateAudio() EXIT ");
if (pTemp3gpFilePath != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pTemp3gpFilePath);
+ free(pTemp3gpFilePath);
}
if (pOutputParams != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pOutputParams);
+ free(pOutputParams);
}
if(pEncodingParams != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pEncodingParams);
+ free(pEncodingParams);
}
return result;
}
@@ -1420,7 +1417,7 @@ static int removeAlphafromRGB8888 (
LOGV("removeAlphafromRGB8888: width %d", pFramingCtx->width);
- M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_malloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");
+ M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_32bitAlignedMalloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");
if (pTmpData == M4OSA_NULL) {
LOGE("Failed to allocate memory for Image clip");
return M4ERR_ALLOC;
@@ -1433,7 +1430,7 @@ static int removeAlphafromRGB8888 (
if ((lerr != M4NO_ERROR) || (lImageFileFp == M4OSA_NULL))
{
LOGE("removeAlphafromRGB8888: Can not open the file ");
- M4OSA_free((M4OSA_MemAddr32)pTmpData);
+ free(pTmpData);
return M4ERR_FILE_NOT_FOUND;
}
@@ -1443,22 +1440,22 @@ static int removeAlphafromRGB8888 (
{
LOGE("removeAlphafromRGB8888: can not read the data ");
M4OSA_fileReadClose(lImageFileFp);
- M4OSA_free((M4OSA_MemAddr32)pTmpData);
+ free(pTmpData);
return lerr;
}
M4OSA_fileReadClose(lImageFileFp);
M4OSA_UInt32 frameSize = (pFramingCtx->width * pFramingCtx->height * 3); //Size of RGB 888 data.
- pFramingCtx->FramingRgb = (M4VIFI_ImagePlane*)M4OSA_malloc(
+ pFramingCtx->FramingRgb = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(
sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"Image clip RGB888 data");
- pFramingCtx->FramingRgb->pac_data = (M4VIFI_UInt8*)M4OSA_malloc(
+ pFramingCtx->FramingRgb->pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(
frameSize, M4VS, (M4OSA_Char*)"Image clip RGB888 data");
if (pFramingCtx->FramingRgb == M4OSA_NULL)
{
LOGE("Failed to allocate memory for Image clip");
- M4OSA_free((M4OSA_MemAddr32)pTmpData);
+ free(pTmpData);
return M4ERR_ALLOC;
}
@@ -1468,7 +1465,7 @@ static int removeAlphafromRGB8888 (
pFramingCtx->FramingRgb->pac_data[j] = pTmpData[i];
j++;
}
- M4OSA_free((M4OSA_MemAddr32)pTmpData);
+ free(pTmpData);
return M4NO_ERROR;
}
@@ -1566,7 +1563,7 @@ videoEditor_populateSettings(
{
if (pContext->pEditSettings->Effects[j].xVSS.pFramingFilePath != M4OSA_NULL) {
if (pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->pEditSettings->\
+ free(pContext->pEditSettings->\
Effects[j].xVSS.pFramingBuffer);
pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer = M4OSA_NULL;
}
@@ -1613,7 +1610,7 @@ videoEditor_populateSettings(
if (pContext->pEditSettings->nbEffects > 0)
{
pOverlayIndex
- = (int*) M4OSA_malloc(pContext->pEditSettings->nbEffects * sizeof(int), 0,
+ = (int*) M4OSA_32bitAlignedMalloc(pContext->pEditSettings->nbEffects * sizeof(int), 0,
(M4OSA_Char*)"pOverlayIndex");
if (pOverlayIndex == M4OSA_NULL) {
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
@@ -1633,7 +1630,7 @@ videoEditor_populateSettings(
M4xVSS_FramingStruct *aFramingCtx = M4OSA_NULL;
aFramingCtx
- = (M4xVSS_FramingStruct*)M4OSA_malloc(sizeof(M4xVSS_FramingStruct), M4VS,
+ = (M4xVSS_FramingStruct*)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct), M4VS,
(M4OSA_Char*)"M4xVSS_internalDecodeGIF: Context of the framing effect");
if (aFramingCtx == M4OSA_NULL)
{
@@ -1671,7 +1668,7 @@ videoEditor_populateSettings(
if (needToBeLoaded == false) {
M4OSA_TRACE1_1("M4xVSS_internalConvertARGB888toYUV420_FrammingEffect returned 0x%x", result);
if (aFramingCtx != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx);
+ free(aFramingCtx);
aFramingCtx = M4OSA_NULL;
}
goto videoEditor_populateSettings_cleanup;
@@ -1699,7 +1696,7 @@ videoEditor_populateSettings(
//for RGB565
pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_topleft = 0;
pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->pac_data =
- (M4VIFI_UInt8 *)M4OSA_malloc(width*height*2,
+ (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(width*height*2,
0x00,(M4OSA_Char *)"pac_data buffer");
if (pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->pac_data == M4OSA_NULL) {
@@ -1720,31 +1717,31 @@ videoEditor_populateSettings(
if (aFramingCtx->FramingYuv != M4OSA_NULL )
{
if (aFramingCtx->FramingYuv[0].pac_data != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingYuv[0].pac_data);
+ free(aFramingCtx->FramingYuv[0].pac_data);
aFramingCtx->FramingYuv[0].pac_data = M4OSA_NULL;
}
if (aFramingCtx->FramingYuv[1].pac_data != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingYuv[1].pac_data);
+ free(aFramingCtx->FramingYuv[1].pac_data);
aFramingCtx->FramingYuv[1].pac_data = M4OSA_NULL;
}
if (aFramingCtx->FramingYuv[2].pac_data != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingYuv[2].pac_data);
+ free(aFramingCtx->FramingYuv[2].pac_data);
aFramingCtx->FramingYuv[2].pac_data = M4OSA_NULL;
}
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingYuv);
+ free(aFramingCtx->FramingYuv);
aFramingCtx->FramingYuv = M4OSA_NULL;
}
if (aFramingCtx->FramingRgb->pac_data != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingRgb->pac_data);
+ free(aFramingCtx->FramingRgb->pac_data);
aFramingCtx->FramingRgb->pac_data = M4OSA_NULL;
}
if (aFramingCtx->FramingRgb != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx->FramingRgb);
+ free(aFramingCtx->FramingRgb);
aFramingCtx->FramingRgb = M4OSA_NULL;
}
if (aFramingCtx != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)aFramingCtx);
+ free(aFramingCtx);
aFramingCtx = M4OSA_NULL;
}
nbOverlays++;
@@ -1775,11 +1772,11 @@ videoEditor_populateSettings(
/* free previous allocations , if any */
if (pContext->mAudioSettings != M4OSA_NULL) {
if (pContext->mAudioSettings->pFile != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pFile);
+ free(pContext->mAudioSettings->pFile);
pContext->mAudioSettings->pFile = M4OSA_NULL;
}
if (pContext->mAudioSettings->pPCMFilePath != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pPCMFilePath);
+ free(pContext->mAudioSettings->pPCMFilePath);
pContext->mAudioSettings->pPCMFilePath = M4OSA_NULL;
}
}
@@ -1850,7 +1847,7 @@ videoEditor_populateSettings(
strPath = (jstring)pEnv->GetObjectField(audioSettingObject,fid);
pTempChar = (M4OSA_Char*)pEnv->GetStringUTFChars(strPath, M4OSA_NULL);
if (pTempChar != NULL) {
- pContext->mAudioSettings->pFile = (M4OSA_Char*) M4OSA_malloc(
+ pContext->mAudioSettings->pFile = (M4OSA_Char*) M4OSA_32bitAlignedMalloc(
(M4OSA_UInt32)(strlen((const char*)pTempChar))+1 /* +1 for NULL termination */, 0,
(M4OSA_Char*)"strPath allocation " );
if (pContext->mAudioSettings->pFile != M4OSA_NULL) {
@@ -1875,7 +1872,7 @@ videoEditor_populateSettings(
strPCMPath = (jstring)pEnv->GetObjectField(audioSettingObject,fid);
pTempChar = (M4OSA_Char*)pEnv->GetStringUTFChars(strPCMPath, M4OSA_NULL);
if (pTempChar != NULL) {
- pContext->mAudioSettings->pPCMFilePath = (M4OSA_Char*) M4OSA_malloc(
+ pContext->mAudioSettings->pPCMFilePath = (M4OSA_Char*) M4OSA_32bitAlignedMalloc(
(M4OSA_UInt32)(strlen((const char*)pTempChar))+1 /* +1 for NULL termination */, 0,
(M4OSA_Char*)"strPCMPath allocation " );
if (pContext->mAudioSettings->pPCMFilePath != M4OSA_NULL) {
@@ -1986,7 +1983,7 @@ videoEditor_populateSettings_cleanup:
{
if (pContext->pEditSettings->Effects[pOverlayIndex[j]].xVSS.pFramingBuffer->pac_data != \
M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->pEditSettings->\
+ free(pContext->pEditSettings->\
Effects[pOverlayIndex[j]].xVSS.pFramingBuffer->pac_data);
pContext->pEditSettings->\
Effects[pOverlayIndex[j]].xVSS.pFramingBuffer->pac_data = M4OSA_NULL;
@@ -1999,7 +1996,7 @@ videoEditor_populateSettings_cleanup:
{
if (pContext->pEditSettings->Effects[j].xVSS.pFramingFilePath != M4OSA_NULL) {
if (pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer != M4OSA_NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->pEditSettings->\
+ free(pContext->pEditSettings->\
Effects[j].xVSS.pFramingBuffer);
pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer = M4OSA_NULL;
}
@@ -2009,7 +2006,7 @@ videoEditor_populateSettings_cleanup:
if (pOverlayIndex != M4OSA_NULL)
{
- M4OSA_free((M4OSA_MemAddr32)pOverlayIndex);
+ free(pOverlayIndex);
pOverlayIndex = M4OSA_NULL;
}
return;
@@ -2498,7 +2495,7 @@ videoEditor_init(
(M4OSA_Char *)videoEditJava_getString(&initialized, pEnv, tempPath,
NULL, M4OSA_NULL);
pContext->initParams.pTempPath = (M4OSA_Char *)
- M4OSA_malloc(strlen((const char *)tmpString) + 1, 0x0,
+ M4OSA_32bitAlignedMalloc(strlen((const char *)tmpString) + 1, 0x0,
(M4OSA_Char *)"tempPath");
//initialize the first char. so that strcat works.
M4OSA_Char *ptmpChar = (M4OSA_Char*)pContext->initParams.pTempPath;
@@ -2506,7 +2503,7 @@ videoEditor_init(
strncat((char *)pContext->initParams.pTempPath, (const char *)tmpString,
(size_t)strlen((const char *)tmpString));
strncat((char *)pContext->initParams.pTempPath, (const char *)"/", (size_t)1);
- M4OSA_free((M4OSA_MemAddr32)tmpString);
+ free(tmpString);
pContext->mIsUpdateOverlay = false;
pContext->mOverlayFileName = NULL;
}
@@ -2564,7 +2561,7 @@ videoEditor_init(
"not initialized");
pContext->mAudioSettings =
(M4xVSS_AudioMixingSettings *)
- M4OSA_malloc(sizeof(M4xVSS_AudioMixingSettings),0x0,
+ M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_AudioMixingSettings),0x0,
(M4OSA_Char *)"mAudioSettings");
videoEditJava_checkAndThrowIllegalStateException(&initialized, pEnv,
(M4OSA_NULL == pContext->mAudioSettings),
@@ -3066,15 +3063,15 @@ videoEditor_release(
if(pContext->mAudioSettings != M4OSA_NULL)
{
if (pContext->mAudioSettings->pFile != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pFile);
+ free(pContext->mAudioSettings->pFile);
pContext->mAudioSettings->pFile = M4OSA_NULL;
}
if (pContext->mAudioSettings->pPCMFilePath != NULL) {
- M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings->pPCMFilePath);
+ free(pContext->mAudioSettings->pPCMFilePath);
pContext->mAudioSettings->pPCMFilePath = M4OSA_NULL;
}
- M4OSA_free((M4OSA_MemAddr32)pContext->mAudioSettings);
+ free(pContext->mAudioSettings);
pContext->mAudioSettings = M4OSA_NULL;
}
videoEditor_freeContext(pEnv, &pContext);
@@ -3252,7 +3249,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL,
*******************************************************************************/
samplesCountInBytes = (samplesPerValue * sizeof(M4OSA_UInt16) * channels);
- bufferIn.m_dataAddress = (M4OSA_UInt8*)M4OSA_malloc(samplesCountInBytes*sizeof(M4OSA_UInt16), 0,
+ bufferIn.m_dataAddress = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(samplesCountInBytes*sizeof(M4OSA_UInt16), 0,
(M4OSA_Char*)"AudioGraph" );
if ( bufferIn.m_dataAddress != M4OSA_NULL) {
bufferIn.m_bufferSize = samplesCountInBytes*sizeof(M4OSA_UInt16);
@@ -3380,7 +3377,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL,
/******************************************************************************
CLOSE AND FREE ALLOCATIONS
*******************************************************************************/
- M4OSA_free((M4OSA_MemAddr32)bufferIn.m_dataAddress);
+ free(bufferIn.m_dataAddress);
M4OSA_fileReadClose(inputFileHandle);
M4OSA_fileWriteClose(outFileHandle);
/* final finish callback */
diff --git a/media/jni/mediaeditor/VideoEditorOsal.cpp b/media/jni/mediaeditor/VideoEditorOsal.cpp
index 339c0d168261..53e7de176ae4 100755
--- a/media/jni/mediaeditor/VideoEditorOsal.cpp
+++ b/media/jni/mediaeditor/VideoEditorOsal.cpp
@@ -25,7 +25,6 @@ extern "C" {
#include <M4OSA_FileReader.h>
#include <M4OSA_FileWriter.h>
#include <M4OSA_Memory.h>
-#include <M4OSA_String.h>
#include <M4OSA_Thread.h>
#include <M4xVSS_API.h>
#include <M4VSS3GPP_ErrorCodes.h>
@@ -82,14 +81,6 @@ static const VideoEdit_Osal_Result gkRESULTS[] =
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_BAD_MODE_ACCESS ),
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_INVALID_POSITION ),
- // M4OSA_String.h
- VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_BAD_STRING ),
- VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_CONV_FAILED ),
- VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_OVERFLOW ),
- VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_BAD_ARGS ),
- VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_STR_OVERFLOW ),
- VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_STR_NOT_FOUND ),
-
// M4OSA_Thread.h
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_THREAD_NOT_STARTED ),
@@ -276,7 +267,7 @@ videoEditOsal_alloc(
if (*pResult)
{
// Allocate memory for the settings.
- pData = (M4VSS3GPP_EditSettings*)M4OSA_malloc(size, 0, (M4OSA_Char*)pDescription);
+ pData = (M4VSS3GPP_EditSettings*)M4OSA_32bitAlignedMalloc(size, 0, (M4OSA_Char*)pDescription);
if (M4OSA_NULL != pData)
{
// Reset the allocated memory.
@@ -314,10 +305,10 @@ videoEditOsal_free(
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_OSAL", "videoEditOsal_free()");
// Log the API call.
- VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR_OSAL", "M4OSA_free()");
+ VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR_OSAL", "free");
// Free the memory.
- M4OSA_free((M4OSA_MemAddr32)pData);
+ free(pData);
#ifdef OSAL_MEM_LEAK_DEBUG
// Update the allocated block count.
gAllocatedBlockCount--;
diff --git a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
index 39221f3071ef..9de720768c40 100755
--- a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
@@ -34,13 +34,11 @@ extern "C" {
#include <M4OSA_FileReader.h>
#include <M4OSA_FileWriter.h>
#include <M4OSA_Memory.h>
-#include <M4OSA_String.h>
#include <M4OSA_Thread.h>
#include <M4VSS3GPP_API.h>
#include <M4VSS3GPP_ErrorCodes.h>
#include <M4MCS_API.h>
#include <M4MCS_ErrorCodes.h>
-#include <M4MDP_API.h>
#include <M4READER_Common.h>
#include <M4WRITER_common.h>
#include <M4DECODER_Common.h>
diff --git a/media/jni/mediaeditor/VideoEditorThumbnailMain.cpp b/media/jni/mediaeditor/VideoEditorThumbnailMain.cpp
index 461bdd0ab41e..fe3734f3c839 100755
--- a/media/jni/mediaeditor/VideoEditorThumbnailMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorThumbnailMain.cpp
@@ -165,7 +165,7 @@ M4OSA_ERR ThumbnailOpen(M4OSA_Context *pPContext,
CHECK_PTR(ThumbnailOpen, pString, err, M4ERR_BAD_CONTEXT);
/*--- Create context ---*/
- pContext = (ThumbnailContext*)M4OSA_malloc(sizeof(ThumbnailContext), VIDEOBROWSER,
+ pContext = (ThumbnailContext*)M4OSA_32bitAlignedMalloc(sizeof(ThumbnailContext), VIDEOBROWSER,
(M4OSA_Char*)"Thumbnail context") ;
M4OSA_TRACE3_1("context value is = %d",pContext);
CHECK_PTR(ThumbnailOpen, pContext, err, M4ERR_ALLOC);
@@ -211,7 +211,7 @@ ThumbnailOpen_cleanUp:
{
videoBrowserCleanUp(pContext->m_pVideoBrowser) ;
}
- M4OSA_free((M4OSA_MemAddr32)pContext) ;
+ free(pContext) ;
}
return err;
}
@@ -320,7 +320,7 @@ void ThumbnailClose(const M4OSA_Context pContext)
{
videoBrowserCleanUp(pC->m_pVideoBrowser);
}
- M4OSA_free((M4OSA_MemAddr32)pC);
+ free(pC);
}
ThumbnailClose_cleanUp:
diff --git a/opengl/java/android/opengl/Matrix.java b/opengl/java/android/opengl/Matrix.java
index b9fd4ab55713..6d80bc60c94a 100644
--- a/opengl/java/android/opengl/Matrix.java
+++ b/opengl/java/android/opengl/Matrix.java
@@ -16,8 +16,6 @@
package android.opengl;
-import javax.microedition.khronos.opengles.GL10;
-
/**
* Matrix math utilities. These methods operate on OpenGL ES format
* matrices and vectors stored in float arrays.
@@ -332,6 +330,43 @@ public class Matrix {
}
/**
+ * Define a projection matrix in terms of a field of view angle, an
+ * aspect ratio, and z clip planes
+ * @param m the float array that holds the perspective matrix
+ * @param offset the offset into float array m where the perspective
+ * matrix data is written
+ * @param fovy field of view in y direction, in degrees
+ * @param aspect width to height aspect ratio of the viewport
+ * @param zNear
+ * @param zFar
+ */
+ public static void perspectiveM(float[] m, int offset,
+ float fovy, float aspect, float zNear, float zFar) {
+ float f = 1.0f / (float) Math.tan(fovy * (Math.PI / 360.0));
+ float rangeReciprocal = 1.0f / (zNear - zFar);
+
+ m[offset + 0] = f / aspect;
+ m[offset + 1] = 0.0f;
+ m[offset + 2] = 0.0f;
+ m[offset + 3] = 0.0f;
+
+ m[offset + 4] = 0.0f;
+ m[offset + 5] = f;
+ m[offset + 6] = 0.0f;
+ m[offset + 7] = 0.0f;
+
+ m[offset + 8] = 0.0f;
+ m[offset + 9] = 0.0f;
+ m[offset + 10] = (zFar + zNear) * rangeReciprocal;
+ m[offset + 11] = -1.0f;
+
+ m[offset + 12] = 0.0f;
+ m[offset + 13] = 0.0f;
+ m[offset + 14] = 2.0f * zFar * zNear * rangeReciprocal;
+ m[offset + 15] = 0.0f;
+ }
+
+ /**
* Computes the length of a vector
*
* @param x x coordinate of a vector
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 196994511baa..a37ccc7d0a7e 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -35,7 +35,6 @@ import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Binder;
-import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.LocalPowerManager;
@@ -56,11 +55,9 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.view.BaseInputHandler;
import com.android.internal.widget.PointerLocationView;
-import android.telephony.TelephonyManager;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
-import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.IWindowManager;
@@ -348,10 +345,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.)
int mIncallPowerBehavior;
- int mLandscapeRotation = -1; // default landscape rotation
- int mSeascapeRotation = -1; // "other" landscape rotation, 180 degrees from mLandscapeRotation
- int mPortraitRotation = -1; // default portrait rotation
- int mUpsideDownRotation = -1; // "other" portrait rotation
+ int mLandscapeRotation = 0; // default landscape rotation
+ int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation
+ int mPortraitRotation = 0; // default portrait rotation
+ int mUpsideDownRotation = 0; // "other" portrait rotation
// Nothing to see here, move along...
int mFancyRotationAnimation;
@@ -742,6 +739,32 @@ public class PhoneWindowManager implements WindowManagerPolicy {
initializeHdmiState();
}
+ public void setInitialDisplaySize(int width, int height) {
+ if (width > height) {
+ mLandscapeRotation = Surface.ROTATION_0;
+ mSeascapeRotation = Surface.ROTATION_180;
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_reverseDefaultRotation)) {
+ mPortraitRotation = Surface.ROTATION_90;
+ mUpsideDownRotation = Surface.ROTATION_270;
+ } else {
+ mPortraitRotation = Surface.ROTATION_270;
+ mUpsideDownRotation = Surface.ROTATION_90;
+ }
+ } else {
+ mPortraitRotation = Surface.ROTATION_0;
+ mUpsideDownRotation = Surface.ROTATION_180;
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_reverseDefaultRotation)) {
+ mLandscapeRotation = Surface.ROTATION_270;
+ mSeascapeRotation = Surface.ROTATION_90;
+ } else {
+ mLandscapeRotation = Surface.ROTATION_90;
+ mSeascapeRotation = Surface.ROTATION_270;
+ }
+ }
+ }
+
public void updateSettings() {
ContentResolver resolver = mContext.getContentResolver();
boolean updateRotation = false;
@@ -2528,7 +2551,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
}
-
+
public int rotationForOrientationLw(int orientation, int lastRotation,
boolean displayEnabled) {
@@ -2541,35 +2564,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
);
}
- if (mPortraitRotation < 0) {
- // Initialize the rotation angles for each orientation once.
- Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- if (d.getWidth() > d.getHeight()) {
- mLandscapeRotation = Surface.ROTATION_0;
- mSeascapeRotation = Surface.ROTATION_180;
- if (mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_reverseDefaultRotation)) {
- mPortraitRotation = Surface.ROTATION_90;
- mUpsideDownRotation = Surface.ROTATION_270;
- } else {
- mPortraitRotation = Surface.ROTATION_270;
- mUpsideDownRotation = Surface.ROTATION_90;
- }
- } else {
- mPortraitRotation = Surface.ROTATION_0;
- mUpsideDownRotation = Surface.ROTATION_180;
- if (mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_reverseDefaultRotation)) {
- mLandscapeRotation = Surface.ROTATION_270;
- mSeascapeRotation = Surface.ROTATION_90;
- } else {
- mLandscapeRotation = Surface.ROTATION_90;
- mSeascapeRotation = Surface.ROTATION_270;
- }
- }
- }
-
synchronized (mLock) {
switch (orientation) {
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
@@ -2621,6 +2615,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
+ public int getLockedRotationLw() {
+ synchronized (mLock) {
+ if (false) {
+ // Not yet working.
+ if (mHdmiPlugged) {
+ return Surface.ROTATION_0;
+ } else if (mLidOpen == LID_OPEN) {
+ return mLidOpenRotation;
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
+ return mCarDockRotation;
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
+ return mDeskDockRotation;
+ } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
+ return mUserRotation;
+ }
+ }
+ return -1;
+ }
+ }
+
private int getCurrentLandscapeRotation(int lastRotation) {
// if the user has locked rotation, we ignore the sensor
if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
diff --git a/services/input/SpriteController.cpp b/services/input/SpriteController.cpp
index 2fd1f0ab2715..08cc75e631eb 100644
--- a/services/input/SpriteController.cpp
+++ b/services/input/SpriteController.cpp
@@ -376,7 +376,7 @@ sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height
ensureSurfaceComposerClient();
sp<SurfaceControl> surfaceControl = mSurfaceComposerClient->createSurface(
- getpid(), String8("Sprite"), 0, width, height, PIXEL_FORMAT_RGBA_8888);
+ String8("Sprite"), 0, width, height, PIXEL_FORMAT_RGBA_8888);
if (surfaceControl == NULL || !surfaceControl->isValid()
|| !surfaceControl->getSurface()->isValid()) {
LOGE("Error creating sprite surface.");
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index b1a6a9a5a42c..c129b9742f59 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -49,6 +49,7 @@ import android.service.wallpaper.IWallpaperService;
import android.service.wallpaper.WallpaperService;
import android.util.Slog;
import android.util.Xml;
+import android.view.Display;
import android.view.IWindowManager;
import android.view.WindowManager;
@@ -726,6 +727,17 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
mHeight = -1;
mName = "";
}
+
+ // We always want to have some reasonable width hint.
+ WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
+ Display d = wm.getDefaultDisplay();
+ int baseSize = d.getMaximumSizeDimension();
+ if (mWidth < baseSize) {
+ mWidth = baseSize;
+ }
+ if (mHeight < baseSize) {
+ mHeight = baseSize;
+ }
}
// Called by SystemBackupAgent after files are restored to disk.
diff --git a/services/java/com/android/server/wm/DimSurface.java b/services/java/com/android/server/wm/DimSurface.java
index 084ac6f18881..220c7fb1c7f2 100644
--- a/services/java/com/android/server/wm/DimSurface.java
+++ b/services/java/com/android/server/wm/DimSurface.java
@@ -89,7 +89,7 @@ class DimSurface {
public void printTo(String prefix, PrintWriter pw) {
pw.print(prefix); pw.print("mDimSurface="); pw.println(mDimSurface);
pw.print(prefix); pw.print("mDimShown="); pw.print(mDimShown);
- pw.print(" mLayer="); pw.println(mLayer);
+ pw.print(" mLayer="); pw.print(mLayer);
pw.print(" mDimColor=0x"); pw.println(Integer.toHexString(mDimColor));
pw.print(prefix); pw.print("mLastDimWidth="); pw.print(mLastDimWidth);
pw.print(" mLastDimWidth="); pw.println(mLastDimWidth);
diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java
index 45a78af37af3..4f157fe168ae 100644
--- a/services/java/com/android/server/wm/InputMonitor.java
+++ b/services/java/com/android/server/wm/InputMonitor.java
@@ -132,8 +132,8 @@ final class InputMonitor {
// The drag window covers the entire display
inputWindow.frameLeft = 0;
inputWindow.frameTop = 0;
- inputWindow.frameRight = mService.mDisplay.getWidth();
- inputWindow.frameBottom = mService.mDisplay.getHeight();
+ inputWindow.frameRight = mService.mDisplay.getRealWidth();
+ inputWindow.frameBottom = mService.mDisplay.getRealHeight();
// The drag window cannot receive new touches.
inputWindow.touchableRegion.setEmpty();
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index e2874f816dc8..8b739a43b6c7 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -64,6 +64,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.BatteryStats;
@@ -392,9 +393,12 @@ public class WindowManagerService extends IWindowManager.Stub
boolean mSystemBooted = false;
int mInitialDisplayWidth = 0;
int mInitialDisplayHeight = 0;
+ int mCurDisplayWidth = 0;
+ int mCurDisplayHeight = 0;
int mRotation = 0;
int mRequestedRotation = 0;
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+ boolean mAltOrientation = false;
int mLastRotationFlags;
ArrayList<IRotationWatcher> mRotationWatchers
= new ArrayList<IRotationWatcher>();
@@ -582,7 +586,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
final Configuration mTempConfiguration = new Configuration();
- int mScreenLayout = Configuration.SCREENLAYOUT_SIZE_UNDEFINED;
// The frame use to limit the size of the app running in compatibility mode.
Rect mCompatibleScreenFrame = new Rect();
@@ -1419,8 +1422,8 @@ public class WindowManagerService extends IWindowManager.Stub
int adjustWallpaperWindowsLocked() {
int changed = 0;
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
// First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it.
@@ -1838,8 +1841,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
boolean changed = false;
@@ -1879,8 +1882,8 @@ public class WindowManagerService extends IWindowManager.Stub
void updateWallpaperVisibilityLocked() {
final boolean visible = isWallpaperVisible(mWallpaperTarget);
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
int curTokenIndex = mWallpaperTokens.size();
while (curTokenIndex > 0) {
@@ -2682,8 +2685,7 @@ public class WindowManagerService extends IWindowManager.Stub
configChanged = updateOrientationFromAppTokensLocked(false);
performLayoutAndPlaceSurfacesLocked();
if (displayed && win.mIsWallpaper) {
- updateWallpaperOffsetLocked(win, mDisplay.getWidth(),
- mDisplay.getHeight(), false);
+ updateWallpaperOffsetLocked(win, mCurDisplayWidth, mCurDisplayHeight, false);
}
if (win.mAppToken != null) {
win.mAppToken.updateReportedVisibilityLocked();
@@ -4757,8 +4759,8 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity();
- dw = mDisplay.getWidth();
- dh = mDisplay.getHeight();
+ dw = mCurDisplayWidth;
+ dh = mCurDisplayHeight;
int aboveAppLayer = mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
@@ -4952,7 +4954,52 @@ public class WindowManagerService extends IWindowManager.Stub
rotation = mPolicy.rotationForOrientationLw(mForcedAppOrientation,
mRotation, mDisplayEnabled);
if (DEBUG_ORIENTATION) Slog.v(TAG, "new rotation is set to " + rotation);
+
+ int desiredRotation = rotation;
+ int lockedRotation = mPolicy.getLockedRotationLw();
+ if (lockedRotation >= 0 && rotation != lockedRotation) {
+ // We are locked in a rotation but something is requesting
+ // a different rotation... we will either keep the locked
+ // rotation if it results in the same orientation, or have to
+ // switch into an emulated orientation mode.
+
+ // First, we know that our rotation is actually going to be
+ // the locked rotation.
+ rotation = lockedRotation;
+
+ // Now the difference between the desired and lockedRotation
+ // may mean that the orientation is different... if that is
+ // not the case, we can just make the desired rotation be the
+ // same as the new locked rotation.
+ switch (lockedRotation) {
+ case Surface.ROTATION_0:
+ if (rotation == Surface.ROTATION_180) {
+ desiredRotation = lockedRotation;
+ }
+ break;
+ case Surface.ROTATION_90:
+ if (rotation == Surface.ROTATION_270) {
+ desiredRotation = lockedRotation;
+ }
+ break;
+ case Surface.ROTATION_180:
+ if (rotation == Surface.ROTATION_0) {
+ desiredRotation = lockedRotation;
+ }
+ break;
+ case Surface.ROTATION_270:
+ if (rotation == Surface.ROTATION_90) {
+ desiredRotation = lockedRotation;
+ }
+ break;
+ }
+ }
+
changed = mDisplayEnabled && mRotation != rotation;
+ if (mAltOrientation != (rotation != desiredRotation)) {
+ changed = true;
+ mAltOrientation = rotation != desiredRotation;
+ }
if (changed) {
if (DEBUG_ORIENTATION) Slog.v(TAG,
@@ -4998,6 +5045,7 @@ public class WindowManagerService extends IWindowManager.Stub
Surface.setOrientation(0, rotation, animFlags);
}
}
+
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = mWindows.get(i);
if (w.mSurface != null) {
@@ -5438,8 +5486,32 @@ public class WindowManagerService extends IWindowManager.Stub
// Use the effective "visual" dimensions based on current rotation
final boolean rotated = (mRotation == Surface.ROTATION_90
|| mRotation == Surface.ROTATION_270);
- final int dw = rotated ? mInitialDisplayHeight : mInitialDisplayWidth;
- final int dh = rotated ? mInitialDisplayWidth : mInitialDisplayHeight;
+ final int realdw = rotated ? mInitialDisplayHeight : mInitialDisplayWidth;
+ final int realdh = rotated ? mInitialDisplayWidth : mInitialDisplayHeight;
+
+ if (mAltOrientation) {
+ mCurDisplayWidth = realdw;
+ mCurDisplayHeight = realdh;
+ if (realdw > realdh) {
+ // Turn landscape into portrait.
+ int maxw = (int)(realdh/1.3f);
+ if (maxw < realdw) {
+ mCurDisplayWidth = maxw;
+ }
+ } else {
+ // Turn portrait into landscape.
+ int maxh = (int)(realdw/1.3f);
+ if (maxh < realdh) {
+ mCurDisplayHeight = maxh;
+ }
+ }
+ } else {
+ mCurDisplayWidth = realdw;
+ mCurDisplayHeight = realdh;
+ }
+
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
int orientation = Configuration.ORIENTATION_SQUARE;
if (dw < dh) {
@@ -5450,66 +5522,69 @@ public class WindowManagerService extends IWindowManager.Stub
config.orientation = orientation;
DisplayMetrics dm = new DisplayMetrics();
- mDisplay.getMetrics(dm);
+ mDisplay.getRealMetrics(dm);
+
+ // Override display width and height with what we are computing,
+ // to be sure they remain consistent.
+ dm.widthPixels = dw;
+ dm.heightPixels = dh;
+
CompatibilityInfo.updateCompatibleScreenFrame(dm, orientation, mCompatibleScreenFrame);
config.screenWidthDp = (int)(dm.widthPixels / dm.density);
config.screenHeightDp = (int)(dm.heightPixels / dm.density);
- if (mScreenLayout == Configuration.SCREENLAYOUT_SIZE_UNDEFINED) {
- // Note we only do this once because at this point we don't
- // expect the screen to change in this way at runtime, and want
- // to avoid all of this computation for every config change.
- int longSize = dw;
- int shortSize = dh;
- if (longSize < shortSize) {
- int tmp = longSize;
- longSize = shortSize;
- shortSize = tmp;
- }
- longSize = (int)(longSize/dm.density);
- shortSize = (int)(shortSize/dm.density);
-
- // These semi-magic numbers define our compatibility modes for
- // applications with different screens. These are guarantees to
- // app developers about the space they can expect for a particular
- // configuration. DO NOT CHANGE!
- if (longSize < 470) {
- // This is shorter than an HVGA normal density screen (which
- // is 480 pixels on its long side).
- mScreenLayout = Configuration.SCREENLAYOUT_SIZE_SMALL
- | Configuration.SCREENLAYOUT_LONG_NO;
+ // Compute the screen layout size class.
+ int screenLayout;
+ int longSize = dw;
+ int shortSize = dh;
+ if (longSize < shortSize) {
+ int tmp = longSize;
+ longSize = shortSize;
+ shortSize = tmp;
+ }
+ longSize = (int)(longSize/dm.density);
+ shortSize = (int)(shortSize/dm.density);
+
+ // These semi-magic numbers define our compatibility modes for
+ // applications with different screens. These are guarantees to
+ // app developers about the space they can expect for a particular
+ // configuration. DO NOT CHANGE!
+ if (longSize < 470) {
+ // This is shorter than an HVGA normal density screen (which
+ // is 480 pixels on its long side).
+ screenLayout = Configuration.SCREENLAYOUT_SIZE_SMALL
+ | Configuration.SCREENLAYOUT_LONG_NO;
+ } else {
+ // What size is this screen screen?
+ if (longSize >= 960 && shortSize >= 720) {
+ // 1.5xVGA or larger screens at medium density are the point
+ // at which we consider it to be an extra large screen.
+ screenLayout = Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ } else if (longSize >= 640 && shortSize >= 480) {
+ // VGA or larger screens at medium density are the point
+ // at which we consider it to be a large screen.
+ screenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE;
} else {
- // What size is this screen screen?
- if (longSize >= 960 && shortSize >= 720) {
- // 1.5xVGA or larger screens at medium density are the point
- // at which we consider it to be an extra large screen.
- mScreenLayout = Configuration.SCREENLAYOUT_SIZE_XLARGE;
- } else if (longSize >= 640 && shortSize >= 480) {
- // VGA or larger screens at medium density are the point
- // at which we consider it to be a large screen.
- mScreenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE;
- } else {
- mScreenLayout = Configuration.SCREENLAYOUT_SIZE_NORMAL;
- }
-
- // If this screen is wider than normal HVGA, or taller
- // than FWVGA, then for old apps we want to run in size
- // compatibility mode.
- if (shortSize > 321 || longSize > 570) {
- mScreenLayout |= Configuration.SCREENLAYOUT_COMPAT_NEEDED;
- }
+ screenLayout = Configuration.SCREENLAYOUT_SIZE_NORMAL;
+ }
- // Is this a long screen?
- if (((longSize*3)/5) >= (shortSize-1)) {
- // Anything wider than WVGA (5:3) is considering to be long.
- mScreenLayout |= Configuration.SCREENLAYOUT_LONG_YES;
- } else {
- mScreenLayout |= Configuration.SCREENLAYOUT_LONG_NO;
- }
+ // If this screen is wider than normal HVGA, or taller
+ // than FWVGA, then for old apps we want to run in size
+ // compatibility mode.
+ if (shortSize > 321 || longSize > 570) {
+ screenLayout |= Configuration.SCREENLAYOUT_COMPAT_NEEDED;
+ }
+
+ // Is this a long screen?
+ if (((longSize*3)/5) >= (shortSize-1)) {
+ // Anything wider than WVGA (5:3) is considering to be long.
+ screenLayout |= Configuration.SCREENLAYOUT_LONG_YES;
+ } else {
+ screenLayout |= Configuration.SCREENLAYOUT_LONG_NO;
}
}
- config.screenLayout = mScreenLayout;
+ config.screenLayout = screenLayout;
// Determine whether a hard keyboard is available and enabled.
boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
@@ -5848,9 +5923,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mDisplay = wm.getDefaultDisplay();
- mInitialDisplayWidth = mDisplay.getWidth();
- mInitialDisplayHeight = mDisplay.getHeight();
- mInputManager.setDisplaySize(0, mDisplay.getRealWidth(), mDisplay.getRealHeight());
+ mInitialDisplayWidth = mCurDisplayWidth = mDisplay.getRealWidth();
+ mInitialDisplayHeight = mCurDisplayHeight = mDisplay.getRealHeight();
+ mInputManager.setDisplaySize(0, mDisplay.getRawWidth(), mDisplay.getRawHeight());
+ mPolicy.setInitialDisplaySize(mInitialDisplayWidth, mInitialDisplayHeight);
}
try {
@@ -6344,6 +6420,21 @@ public class WindowManagerService extends IWindowManager.Stub
return false;
}
+ public void getDisplaySize(Point size) {
+ synchronized(mWindowMap) {
+ size.x = mCurDisplayWidth;
+ size.y = mCurDisplayHeight;
+ }
+ }
+
+ public int getMaximumSizeDimension() {
+ synchronized(mWindowMap) {
+ // Do this based on the raw screen size, until we are smarter.
+ return mInitialDisplayWidth > mInitialDisplayHeight
+ ? mInitialDisplayWidth : mInitialDisplayHeight;
+ }
+ }
+
// -------------------------------------------------------------
// Internals
// -------------------------------------------------------------
@@ -6586,8 +6677,8 @@ public class WindowManagerService extends IWindowManager.Stub
mLayoutNeeded = false;
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
final int N = mWindows.size();
int i;
@@ -6704,8 +6795,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
final long currentTime = SystemClock.uptimeMillis();
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
int i;
@@ -8691,24 +8782,25 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(" mAppsFreezingScreen="); pw.print(mAppsFreezingScreen);
pw.print(" mWaitingForConfig="); pw.println(mWaitingForConfig);
pw.print(" mRotation="); pw.print(mRotation);
- pw.print(", mForcedAppOrientation="); pw.print(mForcedAppOrientation);
- pw.print(", mRequestedRotation="); pw.println(mRequestedRotation);
+ pw.print(" mForcedAppOrientation="); pw.print(mForcedAppOrientation);
+ pw.print(" mRequestedRotation="); pw.print(mRequestedRotation);
+ pw.print(" mAltOrientation="); pw.println(mAltOrientation);
pw.print(" mDeferredRotation="); pw.print(mDeferredRotation);
- pw.print(", mDeferredRotationAnimFlags="); pw.print(mDeferredRotationAnimFlags);
+ pw.print(", mDeferredRotationAnimFlags="); pw.println(mDeferredRotationAnimFlags);
pw.print(" mAnimationPending="); pw.print(mAnimationPending);
pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale);
pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale);
pw.print(" mNextAppTransition=0x");
pw.print(Integer.toHexString(mNextAppTransition));
- pw.print(", mAppTransitionReady="); pw.print(mAppTransitionReady);
- pw.print(", mAppTransitionRunning="); pw.print(mAppTransitionRunning);
- pw.print(", mAppTransitionTimeout="); pw.println( mAppTransitionTimeout);
+ pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady);
+ pw.print(" mAppTransitionRunning="); pw.print(mAppTransitionRunning);
+ pw.print(" mAppTransitionTimeout="); pw.println( mAppTransitionTimeout);
if (mNextAppTransitionPackage != null) {
pw.print(" mNextAppTransitionPackage=");
pw.print(mNextAppTransitionPackage);
- pw.print(", mNextAppTransitionEnter=0x");
+ pw.print(" mNextAppTransitionEnter=0x");
pw.print(Integer.toHexString(mNextAppTransitionEnter));
- pw.print(", mNextAppTransitionExit=0x");
+ pw.print(" mNextAppTransitionExit=0x");
pw.print(Integer.toHexString(mNextAppTransitionExit));
}
pw.print(" mStartingIconInTransition="); pw.print(mStartingIconInTransition);
@@ -8726,8 +8818,13 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(" mToBottomApps="); pw.println(mToBottomApps);
}
if (mDisplay != null) {
- pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth());
- pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight());
+ pw.print(" Display: init="); pw.print(mInitialDisplayWidth); pw.print("x");
+ pw.print(mInitialDisplayHeight); pw.print(" cur=");
+ pw.print(mCurDisplayWidth); pw.print("x"); pw.print(mCurDisplayHeight);
+ pw.print(" real="); pw.print(mDisplay.getRealWidth());
+ pw.print("x"); pw.print(mDisplay.getRealHeight());
+ pw.print(" raw="); pw.print(mDisplay.getRawWidth());
+ pw.print("x"); pw.println(mDisplay.getRawHeight());
} else {
pw.println(" NO DISPLAY");
}
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index f8ff5f8133b6..c05186a5e041 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -440,8 +440,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
visibleInsets.bottom = frame.bottom-visible.bottom;
if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
- mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getWidth(),
- mService.mDisplay.getHeight(), false);
+ mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getRealWidth(),
+ mService.mDisplay.getRealHeight(), false);
}
if (WindowManagerService.localLOGV) {
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2f3a144ec1f1..7506f298f2aa 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1241,8 +1241,10 @@ int SurfaceFlinger::setOrientation(DisplayID dpy,
return orientation;
}
-sp<ISurface> SurfaceFlinger::createSurface(const sp<Client>& client, int pid,
- const String8& name, ISurfaceComposerClient::surface_data_t* params,
+sp<ISurface> SurfaceFlinger::createSurface(
+ ISurfaceComposerClient::surface_data_t* params,
+ const String8& name,
+ const sp<Client>& client,
DisplayID d, uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags)
{
@@ -2414,12 +2416,12 @@ ssize_t Client::getTokenForSurface(const sp<ISurface>& sur) const {
return -1;
}
sp<ISurface> Client::createSurface(
- ISurfaceComposerClient::surface_data_t* params, int pid,
+ ISurfaceComposerClient::surface_data_t* params,
const String8& name,
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags)
{
- return mFlinger->createSurface(this, pid, name, params,
+ return mFlinger->createSurface(params, name, this,
display, w, h, format, flags);
}
status_t Client::destroySurface(SurfaceID sid) {
@@ -2523,7 +2525,7 @@ ssize_t UserClient::getTokenForSurface(const sp<ISurface>& sur) const
}
sp<ISurface> UserClient::createSurface(
- ISurfaceComposerClient::surface_data_t* params, int pid,
+ ISurfaceComposerClient::surface_data_t* params,
const String8& name,
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags) {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 8d431574ac38..1b36d1cd67be 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -75,7 +75,7 @@ private:
virtual sp<IMemoryHeap> getControlBlock() const;
virtual ssize_t getTokenForSurface(const sp<ISurface>& sur) const;
virtual sp<ISurface> createSurface(
- surface_data_t* params, int pid, const String8& name,
+ surface_data_t* params, const String8& name,
DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
uint32_t flags);
virtual status_t destroySurface(SurfaceID surfaceId);
@@ -107,7 +107,7 @@ private:
virtual sp<IMemoryHeap> getControlBlock() const;
virtual ssize_t getTokenForSurface(const sp<ISurface>& sur) const;
virtual sp<ISurface> createSurface(
- surface_data_t* params, int pid, const String8& name,
+ surface_data_t* params, const String8& name,
DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
uint32_t flags);
virtual status_t destroySurface(SurfaceID surfaceId);
@@ -232,9 +232,10 @@ private:
friend class Layer;
friend class LayerDim;
- sp<ISurface> createSurface(const sp<Client>& client,
- int pid, const String8& name,
+ sp<ISurface> createSurface(
ISurfaceComposerClient::surface_data_t* params,
+ const String8& name,
+ const sp<Client>& client,
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags);
diff --git a/test-runner/src/android/test/TouchUtils.java b/test-runner/src/android/test/TouchUtils.java
index 69c6d2d57d00..acbde0bd2e57 100644
--- a/test-runner/src/android/test/TouchUtils.java
+++ b/test-runner/src/android/test/TouchUtils.java
@@ -18,6 +18,7 @@ package android.test;
import android.app.Activity;
import android.app.Instrumentation;
+import android.graphics.Point;
import android.os.SystemClock;
import android.view.Display;
import android.view.Gravity;
@@ -53,12 +54,12 @@ public class TouchUtils {
*/
public static void dragQuarterScreenDown(InstrumentationTestCase test, Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay();
- int screenHeight = display.getHeight();
- int screenWidth = display.getWidth();
+ final Point size = new Point();
+ display.getSize(size);
- final float x = screenWidth / 2.0f;
- final float fromY = screenHeight * 0.5f;
- final float toY = screenHeight * 0.75f;
+ final float x = size.x / 2.0f;
+ final float fromY = size.y * 0.5f;
+ final float toY = size.y * 0.75f;
drag(test, x, x, fromY, toY, 4);
}
@@ -83,12 +84,12 @@ public class TouchUtils {
*/
public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay();
- int screenHeight = display.getHeight();
- int screenWidth = display.getWidth();
+ final Point size = new Point();
+ display.getSize(size);
- final float x = screenWidth / 2.0f;
- final float fromY = screenHeight * 0.5f;
- final float toY = screenHeight * 0.25f;
+ final float x = size.x / 2.0f;
+ final float fromY = size.y * 0.5f;
+ final float toY = size.y * 0.25f;
drag(test, x, x, fromY, toY, 4);
}