Merge "resolved conflicts for merge of ec348b49 to honeycomb-plus-aosp" into honeycomb-plus-aosp
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f91ae9f..fa99eae 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -7144,6 +7144,16 @@
setContentScrollTo(msg.arg1, msg.arg2);
break;
case SCROLL_TO_MSG_ID:
+ if (((Boolean) msg.obj).booleanValue()) {
+ // This scroll is intended to bring the textfield into
+ // view, but is only necessary if the IME is showing
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm == null || !imm.isAcceptingText()
+ || (!imm.isActive(WebView.this) && (!inEditingMode()
+ || !imm.isActive(mWebTextView)))) {
+ break;
+ }
+ }
if (setContentScrollTo(msg.arg1, msg.arg2)) {
// if we can't scroll to the exact position due to pin,
// send a message to WebCore to re-scroll when we get a
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index f4ee911..b410699 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2124,7 +2124,7 @@
}
// called by JNI
- private void contentScrollTo(int x, int y) {
+ private void contentScrollTo(int x, int y, boolean onlyIfImeIsShowing) {
if (!mBrowserFrame.firstLayoutDone()) {
/*
* WebKit restore state will be called before didFirstLayout(),
@@ -2137,7 +2137,8 @@
}
if (mWebView != null) {
Message msg = Message.obtain(mWebView.mPrivateHandler,
- WebView.SCROLL_TO_MSG_ID, x, y);
+ WebView.SCROLL_TO_MSG_ID, x, y,
+ Boolean.valueOf(onlyIfImeIsShowing));
if (mDrawIsScheduled) {
mEventHub.sendMessage(Message.obtain(null,
EventHub.MESSAGE_RELAY, msg));
diff --git a/docs/html/guide/developing/building/index.jd b/docs/html/guide/developing/building/index.jd
index b001ebc..25a6e23 100644
--- a/docs/html/guide/developing/building/index.jd
+++ b/docs/html/guide/developing/building/index.jd
@@ -37,7 +37,7 @@
<p>The following diagram depicts the components involved in building and running an application:</p>
- <img src="/images/build-simplified.png" />
+ <img src="{@docRoot}images/build-simplified.png" />
<h2 id="detailed-build">A Detailed Look at the Build Process</h2>
@@ -49,7 +49,7 @@
tools and processes are masked from you. The following diagram depicts the different tools and
processes that are involved in a build:</p>
- <p><img src="/images/build.png" /></p>
+ <p><img src="{@docRoot}images/build.png" /></p>
<p>The general process for a typical build is outlined below:</p>
diff --git a/docs/html/guide/developing/debugging/debugging-tracing.jd b/docs/html/guide/developing/debugging/debugging-tracing.jd
index dcc889d..0401966 100644
--- a/docs/html/guide/developing/debugging/debugging-tracing.jd
+++ b/docs/html/guide/developing/debugging/debugging-tracing.jd
@@ -67,7 +67,7 @@
selected method. The method in this case is <code>LoadListener.nativeFinished()</code> and it was selected in
the profile view.</p>
- <img src="/images/traceview_timeline.png"
+ <img src="{@docRoot}images/traceview_timeline.png"
alt="Traceview timeline panel"
width="893"
height="284" />
@@ -87,7 +87,7 @@
<code>LoadListener.nativeFinished();</code> looking at the timeline panel shows that one of those calls took
an unusually long time.</p>
- <img src="/images/traceview_profile.png"
+ <img src="{@docRoot}images/traceview_profile.png"
alt="Traceview profile panel."
width="892"
height="630" />
diff --git a/docs/html/guide/developing/debugging/index.jd b/docs/html/guide/developing/debugging/index.jd
index f9202ce..1f1a4ca 100644
--- a/docs/html/guide/developing/debugging/index.jd
+++ b/docs/html/guide/developing/debugging/index.jd
@@ -62,7 +62,7 @@
<p>Figure 1 shows how the various debugging tools work together in a typical
debugging environment.</p>
- <img src="/images/debugging.png"
+ <img src="{@docRoot}images/debugging.png"
alt="Debugging workflow" />
<p class="img-caption><strong>Figure 1. </strong> Debugging Workflow</p>
diff --git a/docs/html/guide/developing/devices/emulator.jd b/docs/html/guide/developing/devices/emulator.jd
index a3cd5c5..53c1407 100644
--- a/docs/html/guide/developing/devices/emulator.jd
+++ b/docs/html/guide/developing/devices/emulator.jd
@@ -33,7 +33,7 @@
</div>
</div>
-<img src="/images/emulator-wvga800l.png" alt="Image of the Android Emulator"
+<img src="{@docRoot}images/emulator-wvga800l.png" alt="Image of the Android Emulator"
width="367" height="349" style="margin-left:2em;float:right;"/>
<p>The Android SDK includes a virtual mobile device emulator
that runs on your computer. The emulator lets you prototype, develop, and test
diff --git a/docs/html/guide/developing/projects/index.jd b/docs/html/guide/developing/projects/index.jd
index 45fd5a1..609a71a 100644
--- a/docs/html/guide/developing/projects/index.jd
+++ b/docs/html/guide/developing/projects/index.jd
@@ -471,7 +471,7 @@
<code>MyLibrary/src</code>. Eclipse shows an error on one of them because they
are duplicate links to a single class.</p>
-<img src="/images/developing/lib-migration-0.png" alt="">
+<img src="{@docRoot}images/developing/lib-migration-0.png" alt="">
<p class="img-caption"><strong>Figure 1.</strong> Library project migration error</p>
<p>To fix the error, remove the linked folder that <em>does not</em> contain the
<code>_src</code> suffix. </p>
@@ -481,14 +481,14 @@
<code>MyLibrary</code> folder) and choose <strong>Build Path</strong> >
<strong>Remove from Build Path</strong>, as shown in figure 2.</li>
-<img src="/images/developing/lib-migration-1.png" style="height:600px"
+<img src="{@docRoot}images/developing/lib-migration-1.png" style="height:600px"
alt="">
<p class="img-caption"><strong>Figure 2.</strong> Remove from Build Path menu item</p>
<li>Next, when asked about unlinking the folder from the project, select
<strong>Yes</strong>, as shown in figure 3.</li>
-<img src="/images/developing/lib-migration-2.png" alt="">
+<img src="{@docRoot}images/developing/lib-migration-2.png" alt="">
<p class="img-caption"><strong>Figure 3.</strong> Unlink folder confirmation window</p>
</ol>
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 10ce347..cf0593c 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -466,38 +466,37 @@
<li><a href="<?cs var:toroot ?>guide/developing/tools/logcat.html">logcat</a></li>
<li><a href="<?cs var:toroot ?>guide/developing/tools/mksdcard.html">mksdcard</a></li>
- <li><a href="/guide/developing/tools/monkey.html">Monkey</a></li>
+ <li><a href="<?cs var:toroot ?>guide/developing/tools/monkey.html">Monkey</a></li>
<li class="toggle-list">
<div>
- <a href="/guide/developing/tools/monkeyrunner_concepts.html">
+ <a href="<?cs var:toroot ?>guide/developing/tools/monkeyrunner_concepts.html">
<span class="en">monkeyrunner</span>
</a>
</div>
<ul>
<li>
- <a href="/guide/developing/tools/MonkeyDevice.html">
+ <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyDevice.html">
<span class="en">MonkeyDevice</span>
</a>
</li>
<li>
- <a href="/guide/developing/tools/MonkeyImage.html">
+ <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyImage.html">
<span class="en">MonkeyImage</span>
</a>
</li>
<li>
- <a href="/guide/developing/tools/MonkeyRunner.html">
+ <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyRunner.html">
<span class="en">MonkeyRunner</span>
</a>
</li>
</ul>
</li>
- <li><a href="<?cs var:toroot ?>guide/developing/tools/proguard.html">ProGuard</a>
-<span class="new">new!</span></li>
+ <li><a href="<?cs var:toroot ?>guide/developing/tools/proguard.html">ProGuard</a></li>
<li><a href="<?cs var:toroot ?>guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
- <li><a href="<?cs var:toroot ?>guide/developing/tools/traceview.html" >Traceview</a></li>
- <li><a href="<?cs var:toroot ?>guide/developing/tools/zipalign.html" >zipalign</a></li>
- </ul>
- </li>
+ <li><a href="<?cs var:toroot ?>guide/developing/tools/traceview.html">Traceview</a></li>
+ <li><a href="<?cs var:toroot ?>guide/developing/tools/zipalign.html">zipalign</a></li>
+ </ul>
+ </li>
</ul>
</li>
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 77d37f1..168310c 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -72,6 +72,12 @@
virtual status_t setCrop(const Rect& reg) = 0;
virtual status_t setTransform(uint32_t transform) = 0;
+
+ // getAllocator retrieves the binder object that must be referenced as long
+ // as the GraphicBuffers dequeued from this ISurfaceTexture are referenced.
+ // Holding this binder reference prevents SurfaceFlinger from freeing the
+ // buffers before the client is done with them.
+ virtual sp<IBinder> getAllocator() = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 79c33f5..31615d0 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -101,6 +101,12 @@
// when a new frame becomes available.
void setFrameAvailableListener(const sp<FrameAvailableListener>& l);
+ // getAllocator retrieves the binder object that must be referenced as long
+ // as the GraphicBuffers dequeued from this SurfaceTexture are referenced.
+ // Holding this binder reference prevents SurfaceFlinger from freeing the
+ // buffers before the client is done with them.
+ sp<IBinder> getAllocator();
+
private:
// freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index dd1d490..ff2251d 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -83,6 +83,10 @@
// interactions with the server using this interface.
sp<ISurfaceTexture> mSurfaceTexture;
+ // mAllocator is the binder object that is referenced to prevent the
+ // dequeued buffers from being freed prematurely.
+ sp<IBinder> mAllocator;
+
// mSlots stores the buffers that have been allocated for each buffer slot.
// It is initialized to null pointers, and gets filled in with the result of
// ISurfaceTexture::requestBuffer when the client dequeues a buffer from a
diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/ISurfaceTexture.cpp
index 90bca3c..d661fd5 100644
--- a/libs/gui/ISurfaceTexture.cpp
+++ b/libs/gui/ISurfaceTexture.cpp
@@ -38,6 +38,7 @@
CANCEL_BUFFER,
SET_CROP,
SET_TRANSFORM,
+ GET_ALLOCATOR,
};
@@ -123,6 +124,13 @@
status_t result = reply.readInt32();
return result;
}
+
+ virtual sp<IBinder> getAllocator() {
+ Parcel data, reply;
+ data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
+ remote()->transact(GET_ALLOCATOR, data, &reply);
+ return reply.readStrongBinder();
+ }
};
IMPLEMENT_META_INTERFACE(SurfaceTexture, "android.gui.SurfaceTexture");
@@ -195,6 +203,12 @@
reply->writeInt32(result);
return NO_ERROR;
} break;
+ case GET_ALLOCATOR: {
+ CHECK_INTERFACE(ISurfaceTexture, data, reply);
+ sp<IBinder> result = getAllocator();
+ reply->writeStrongBinder(result);
+ return NO_ERROR;
+ } break;
}
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 1dadd53..3c4b565 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -304,6 +304,11 @@
mFrameAvailableListener = l;
}
+sp<IBinder> SurfaceTexture::getAllocator() {
+ LOGV("SurfaceTexture::getAllocator");
+ return mGraphicBufferAlloc->asBinder();
+}
+
void SurfaceTexture::freeAllBuffers() {
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
mSlots[i].mGraphicBuffer = 0;
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 50cbdb8..ee14ac9 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -25,8 +25,8 @@
SurfaceTextureClient::SurfaceTextureClient(
const sp<ISurfaceTexture>& surfaceTexture):
- mSurfaceTexture(surfaceTexture), mReqWidth(1), mReqHeight(1),
- mReqFormat(DEFAULT_FORMAT), mReqUsage(0), mMutex() {
+ mSurfaceTexture(surfaceTexture), mAllocator(0), mReqWidth(1),
+ mReqHeight(1), mReqFormat(DEFAULT_FORMAT), mReqUsage(0), mMutex() {
// Initialize the ANativeWindow function pointers.
ANativeWindow::setSwapInterval = setSwapInterval;
ANativeWindow::dequeueBuffer = dequeueBuffer;
@@ -35,6 +35,9 @@
ANativeWindow::queueBuffer = queueBuffer;
ANativeWindow::query = query;
ANativeWindow::perform = perform;
+
+ // Get a reference to the allocator.
+ mAllocator = mSurfaceTexture->getAllocator();
}
int SurfaceTextureClient::setSwapInterval(ANativeWindow* window, int interval) {
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index b9105cb..297c4df 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -3058,6 +3059,8 @@
Log.e(TAG, "Runtime exception in nativeStartPreview");
throw ex;
}
+ } else {
+ throw new IllegalStateException("generatePreview is in progress");
}
}
@@ -3085,7 +3088,10 @@
long renderPreviewFrame(Surface surface, long time, int surfaceWidth,
int surfaceHeight, VideoEditor.OverlayData overlayData) {
if (mInvalidatePreviewArray) {
- throw new RuntimeException("Call generate preview first");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Call generate preview first");
+ }
+ throw new IllegalStateException("Call generate preview first");
}
long timeMs = 0;
@@ -3913,6 +3919,27 @@
}
/**
+ * Tries to grab the semaphore with a specified time out which arbitrates access to the editor
+ *
+ * @param timeoutMs time out in ms.
+ *
+ * @return true if the semaphore is acquired, false otherwise
+ * @throws InterruptedException
+ */
+ boolean lock(long timeoutMs) throws InterruptedException {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "lock: grabbing semaphore with timeout " + timeoutMs, new Throwable());
+ }
+
+ boolean acquireSem = mLock.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "lock: grabbed semaphore status " + acquireSem);
+ }
+
+ return acquireSem;
+ }
+
+ /**
* Release the semaphore which arbitrates access to the editor
*/
void unlock() {
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index 7608c05..27ab799 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -112,6 +112,7 @@
private static final String ATTR_OVERLAY_RESIZED_RGB_FRAME_WIDTH = "resized_RGBframe_width";
private static final String ATTR_OVERLAY_RESIZED_RGB_FRAME_HEIGHT = "resized_RGBframe_height";
+ private static final int ENGINE_ACCESS_MAX_TIMEOUT_MS = 500;
/*
* Instance variables
*/
@@ -852,8 +853,10 @@
boolean semAcquireDone = false;
try {
- mMANativeHelper.lock();
- semAcquireDone = true;
+ semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
+ if (semAcquireDone == false) {
+ throw new IllegalStateException("Timeout waiting for semaphore");
+ }
if (mMediaItems.size() > 0) {
final Rect frame = surfaceHolder.getSurfaceFrame();
@@ -862,8 +865,9 @@
} else {
result = 0;
}
- } catch (InterruptedException ex) {
- Log.e(TAG, "Sem acquire NOT successful in renderPreviewFrame");
+ } catch (InterruptedException ex) {
+ Log.w(TAG, "The thread was interrupted", new Throwable());
+ throw new IllegalStateException("The thread was interrupted");
} finally {
if (semAcquireDone) {
mMANativeHelper.unlock();
@@ -1582,8 +1586,10 @@
boolean semAcquireDone = false;
try{
- mMANativeHelper.lock();
- semAcquireDone = true;
+ semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
+ if (semAcquireDone == false) {
+ throw new IllegalStateException("Timeout waiting for semaphore");
+ }
if (mMediaItems.size() > 0) {
mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions,
@@ -1595,17 +1601,9 @@
/**
* release on complete by calling stopPreview
*/
- } catch (InterruptedException ex) {
- Log.e(TAG, "Sem acquire NOT successful in startPreview");
- } catch (IllegalArgumentException ex) {
- Log.e(TAG, "Illegal Argument exception in do preview");
- throw ex;
- } catch (IllegalStateException ex) {
- Log.e(TAG, "Illegal State exception in do preview");
- throw ex;
- } catch (RuntimeException ex) {
- Log.e(TAG, "Runtime exception in do preview");
- throw ex;
+ } catch (InterruptedException ex) {
+ Log.w(TAG, "The thread was interrupted", new Throwable());
+ throw new IllegalStateException("The thread was interrupted");
} finally {
if (semAcquireDone) {
mMANativeHelper.unlock();
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
index 0746562..93d89a7 100644
--- a/telephony/java/android/telephony/SmsMessage.java
+++ b/telephony/java/android/telephony/SmsMessage.java
@@ -124,7 +124,7 @@
*/
public static SmsMessage createFromPdu(byte[] pdu) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
@@ -146,7 +146,7 @@
*/
public static SmsMessage newFromCMT(String[] lines){
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMT(lines);
@@ -160,7 +160,7 @@
/** @hide */
protected static SmsMessage newFromCMTI(String line) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMTI(line);
@@ -174,7 +174,7 @@
/** @hide */
public static SmsMessage newFromCDS(String line) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCDS(line);
@@ -188,7 +188,7 @@
/** @hide */
public static SmsMessage newFromParcel(Parcel p) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromParcel(p);
@@ -211,7 +211,7 @@
*/
public static SmsMessage createFromEfRecord(int index, byte[] data) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord(
@@ -229,7 +229,7 @@
* length in bytes (not hex chars) less the SMSC header
*/
public static int getTPLayerLengthForPDU(String pdu) {
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
@@ -265,7 +265,7 @@
* class).
*/
public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) {
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ?
com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly) :
com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly);
@@ -288,7 +288,7 @@
* @hide
*/
public static ArrayList<String> fragmentText(String text) {
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ?
com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false) :
com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false);
@@ -385,7 +385,7 @@
String destinationAddress, String message,
boolean statusReportRequested, byte[] header) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -410,7 +410,7 @@
public static SubmitPdu getSubmitPdu(String scAddress,
String destinationAddress, String message, boolean statusReportRequested) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -439,7 +439,7 @@
String destinationAddress, short destinationPort, byte[] data,
boolean statusReportRequested) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -708,7 +708,7 @@
* @hide
*/
private static final SmsMessageBase getSmsFacility(){
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
return new com.android.internal.telephony.cdma.SmsMessage();
} else {
diff --git a/telephony/java/android/telephony/gsm/SmsMessage.java b/telephony/java/android/telephony/gsm/SmsMessage.java
index 0c63c37..6880175 100644
--- a/telephony/java/android/telephony/gsm/SmsMessage.java
+++ b/telephony/java/android/telephony/gsm/SmsMessage.java
@@ -154,7 +154,7 @@
@Deprecated
public static SmsMessage createFromPdu(byte[] pdu) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
@@ -177,7 +177,7 @@
@Deprecated
public static SmsMessage newFromCMT(String[] lines){
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMT(lines);
@@ -193,7 +193,7 @@
@Deprecated
protected static SmsMessage newFromCMTI(String line) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCMTI(line);
@@ -209,7 +209,7 @@
@Deprecated
public static SmsMessage newFromCDS(String line) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromCDS(line);
@@ -225,7 +225,7 @@
@Deprecated
public static SmsMessage newFromParcel(Parcel p) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.newFromParcel(p);
@@ -250,7 +250,7 @@
@Deprecated
public static SmsMessage createFromEfRecord(int index, byte[] data) {
SmsMessageBase wrappedMessage;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord(
@@ -270,7 +270,7 @@
*/
@Deprecated
public static int getTPLayerLengthForPDU(String pdu) {
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
@@ -367,7 +367,7 @@
String destinationAddress, String message,
boolean statusReportRequested, byte[] header) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -394,7 +394,7 @@
public static SubmitPdu getSubmitPdu(String scAddress,
String destinationAddress, String message, boolean statusReportRequested) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -425,7 +425,7 @@
String destinationAddress, short destinationPort, byte[] data,
boolean statusReportRequested) {
SubmitPduBase spb;
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
@@ -739,7 +739,7 @@
* @deprecated Use android.telephony.SmsMessage.
*/
private static final SmsMessageBase getSmsFacility(){
- int activePhone = TelephonyManager.getDefault().getPhoneType();
+ int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
if (PHONE_TYPE_CDMA == activePhone) {
return new com.android.internal.telephony.cdma.SmsMessage();
} else {
diff --git a/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java b/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java
new file mode 100644
index 0000000..03f3980
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java
@@ -0,0 +1,62 @@
+/*
+ * 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.content.res;
+
+import com.android.layoutlib.bridge.impl.RenderSessionImpl;
+
+import android.content.res.Resources.NotFoundException;
+import android.content.res.Resources.Theme;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+
+/**
+ * Delegate used to provide new implementation of a select few methods of {@link Theme}
+ *
+ * Through the layoutlib_create tool, the original methods of Theme have been replaced
+ * by calls to methods of the same name in this delegate class.
+ *
+ */
+public class Resources_Theme_Delegate {
+
+ /*package*/ static TypedArray obtainStyledAttributes(
+ Resources thisResources, Theme thisTheme,
+ int[] attrs) {
+ return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(attrs);
+ }
+
+ /*package*/ static TypedArray obtainStyledAttributes(
+ Resources thisResources, Theme thisTheme,
+ int resid, int[] attrs)
+ throws NotFoundException {
+ return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(resid, attrs);
+ }
+
+ /*package*/ static TypedArray obtainStyledAttributes(
+ Resources thisResources, Theme thisTheme,
+ AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
+ return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(
+ set, attrs, defStyleAttr, defStyleRes);
+ }
+
+ /*package*/ static boolean resolveAttribute(
+ Resources thisResources, Theme thisTheme,
+ int resid, TypedValue outValue,
+ boolean resolveRefs) {
+ return RenderSessionImpl.getCurrentContext().resolveThemeAttribute(
+ resid, outValue, resolveRefs);
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 037ad23..4220ddd 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -56,6 +56,7 @@
import android.os.Looper;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@@ -77,7 +78,6 @@
public final class BridgeContext extends Activity {
private Resources mSystemResources;
- private Theme mTheme;
private final HashMap<View, Object> mViewKeyMap = new HashMap<View, Object>();
private final Object mProjectKey;
private final DisplayMetrics mMetrics;
@@ -87,7 +87,7 @@
private final Map<Object, Map<String, String>> mDefaultPropMaps =
new IdentityHashMap<Object, Map<String,String>>();
- // maps for dynamically generated id representing style objects (IStyleResourceValue)
+ // maps for dynamically generated id representing style objects (StyleResourceValue)
private Map<Integer, StyleResourceValue> mDynamicIdToStyleMap;
private Map<StyleResourceValue, Integer> mStyleToDynamicIdMap;
private int mDynamicIdGenerator = 0x01030000; // Base id for framework R.style
@@ -222,6 +222,50 @@
return mParserStack.get(mParserStack.size() - 2);
}
+ public boolean resolveThemeAttribute(int resid, TypedValue outValue, boolean resolveRefs) {
+ Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(resid);
+ if (resourceInfo == null) {
+ resourceInfo = mProjectCallback.resolveResourceId(resid);
+ }
+
+ if (resourceInfo == null) {
+ return false;
+ }
+
+ ResourceValue value = mRenderResources.findItemInTheme(resourceInfo.getSecond());
+ if (resolveRefs) {
+ value = mRenderResources.resolveResValue(value);
+ }
+
+ // check if this is a style resource
+ if (value instanceof StyleResourceValue) {
+ // get the id that will represent this style.
+ outValue.resourceId = getDynamicIdByStyle((StyleResourceValue)value);
+ return true;
+ }
+
+
+ int a;
+ // if this is a framework value.
+ if (value.isFramework()) {
+ // look for idName in the android R classes.
+ // use 0 a default res value as it's not a valid id value.
+ a = getFrameworkResourceValue(value.getResourceType(), value.getName(), 0 /*defValue*/);
+ } else {
+ // look for idName in the project R class.
+ // use 0 a default res value as it's not a valid id value.
+ a = getProjectResourceValue(value.getResourceType(), value.getName(), 0 /*defValue*/);
+ }
+
+ if (a != 0) {
+ outValue.resourceId = a;
+ return true;
+ }
+
+ return false;
+ }
+
+
// ------------- Activity Methods
@Override
@@ -275,7 +319,7 @@
@Override
public final TypedArray obtainStyledAttributes(int resid, int[] attrs)
throws Resources.NotFoundException {
- // get the IStyleResourceValue based on the resId;
+ // get the StyleResourceValue based on the resId;
StyleResourceValue style = getStyleByDynamicId(resid);
if (style == null) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index d816d18..fa04697 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -334,7 +334,10 @@
Bridge.setLog(null);
mContext.getRenderResources().setFrameworkResourceIdProvider(null);
mContext.getRenderResources().setLogger(null);
+ }
+ public static BridgeContext getCurrentContext() {
+ return sCurrentContext;
}
/**
diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
new file mode 100644
index 0000000..ab01a394
--- /dev/null
+++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
@@ -0,0 +1,163 @@
+/*
+ * 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 libcore.icu;
+
+import java.util.Locale;
+
+/**
+ * Delegate implementing the native methods of libcore.icu.ICU
+ *
+ * Through the layoutlib_create tool, the original native methods of ICU have been replaced
+ * by calls to methods of the same name in this delegate class.
+ *
+ */
+public class ICU_Delegate {
+
+ /*package*/ static String toLowerCase(String s, String localeName) {
+ return s.toLowerCase();
+ }
+
+ /*package*/ static String toUpperCase(String s, String localeName) {
+ return s.toUpperCase();
+ }
+
+ // --- Native methods accessing ICU's database.
+
+ /*package*/ static String[] getAvailableBreakIteratorLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String[] getAvailableCalendarLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String[] getAvailableCollatorLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String[] getAvailableDateFormatLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String[] getAvailableLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String[] getAvailableNumberFormatLocalesNative() {
+ return new String[0];
+ }
+
+ /*package*/ static String getCurrencyCodeNative(String locale) {
+ return "";
+ }
+
+ /*package*/ static int getCurrencyFractionDigitsNative(String currencyCode) {
+ return 0;
+ }
+
+ /*package*/ static String getCurrencySymbolNative(String locale, String currencyCode) {
+ return "";
+ }
+
+ /*package*/ static String getDisplayCountryNative(String countryCode, String locale) {
+ return "";
+ }
+
+ /*package*/ static String getDisplayLanguageNative(String languageCode, String locale) {
+ return "";
+ }
+
+ /*package*/ static String getDisplayVariantNative(String variantCode, String locale) {
+ return "";
+ }
+
+ /*package*/ static String getISO3CountryNative(String locale) {
+ return "";
+ }
+
+ /*package*/ static String getISO3LanguageNative(String locale) {
+ return "";
+ }
+
+ /*package*/ static String[] getISOLanguagesNative() {
+ return Locale.getISOLanguages();
+ }
+
+ /*package*/ static String[] getISOCountriesNative() {
+ return Locale.getISOCountries();
+ }
+
+ /*package*/ static boolean initLocaleDataImpl(String locale, LocaleData result) {
+
+ // Used by Calendar.
+ result.firstDayOfWeek = Integer.valueOf(1);
+ result.minimalDaysInFirstWeek = Integer.valueOf(1);
+
+ // Used by DateFormatSymbols.
+ result.amPm = new String[] { "AM", "PM" };
+ result.eras = new String[] { "BC", "AD" };
+
+ result.longMonthNames = new String[] { "January", "February", "March", "April", "May",
+ "June", "July", "August", "September", "October", "November", "December" };
+ result.shortMonthNames = new String[] { "Jan", "Feb", "Mar", "Apr", "May",
+ "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+ result.longStandAloneMonthNames = result.longMonthNames;
+ result.shortStandAloneMonthNames = result.shortMonthNames;
+
+ result.longWeekdayNames = new String[] {
+ "Monday" ,"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
+ result.shortWeekdayNames = new String[] {
+ "Mon" ,"Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
+ result.longStandAloneWeekdayNames = result.longWeekdayNames;
+ result.shortStandAloneWeekdayNames = result.shortWeekdayNames;
+
+ result.fullTimeFormat = "";
+ result.longTimeFormat = "";
+ result.mediumTimeFormat = "";
+ result.shortTimeFormat = "";
+
+ result.fullDateFormat = "";
+ result.longDateFormat = "";
+ result.mediumDateFormat = "";
+ result.shortDateFormat = "";
+
+ // Used by DecimalFormatSymbols.
+ result.zeroDigit = '0';
+ result.digit = '0';
+ result.decimalSeparator = '.';
+ result.groupingSeparator = ',';
+ result.patternSeparator = ' ';
+ result.percent = '%';
+ result.perMill = '\u2030';
+ result.monetarySeparator = ' ';
+ result.minusSign = '-';
+ result.exponentSeparator = "e";
+ result.infinity = "\u221E";
+ result.NaN = "NaN";
+ // Also used by Currency.
+ result.currencySymbol = "$";
+ result.internationalCurrencySymbol = "USD";
+
+ // Used by DecimalFormat and NumberFormat.
+ result.numberPattern = "%f";
+ result.integerPattern = "%d";
+ result.currencyPattern = "%s";
+ result.percentPattern = "%f";
+
+ return true;
+ }
+}
diff --git a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java
index 0ff1925..a4140e3 100644
--- a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java
+++ b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java
@@ -56,8 +56,9 @@
// extract the class name
String className = methodName.substring(0, methodName.indexOf('#'));
+ String targetClassName = className.replace('$', '_') + "_Delegate";
- loadAndCompareClasses(className, className + "_Delegate");
+ loadAndCompareClasses(className, targetClassName);
}
}
@@ -98,6 +99,16 @@
parameters = newParameters;
}
+ // if the original class is an inner class that's not static, then
+ // we add this on the enclosing class at the beginning
+ if (originalClass.getEnclosingClass() != null &&
+ (originalClass.getModifiers() & Modifier.STATIC) == 0) {
+ Class<?>[] newParameters = new Class<?>[parameters.length + 1];
+ newParameters[0] = originalClass.getEnclosingClass();
+ System.arraycopy(parameters, 0, newParameters, 1, parameters.length);
+ parameters = newParameters;
+ }
+
try {
// try to load the method with the given parameter types.
Method delegateMethod = delegateClass.getDeclaredMethod(originalMethod.getName(),
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 55e9e48..291f076d 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -95,13 +95,14 @@
*/
private final static String[] DELEGATE_METHODS = new String[] {
"android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
+ "android.content.res.Resources$Theme#obtainStyledAttributes",
+ "android.content.res.Resources$Theme#resolveAttribute",
"android.os.Handler#sendMessageAtTime",
"android.os.Build#getString",
"android.view.LayoutInflater#rInflate",
"android.view.View#isInEditMode",
"com.android.internal.util.XmlUtils#convertValueToInt",
// TODO: comment out once DelegateClass is working
- // "android.content.res.Resources$Theme#obtainStyledAttributes",
};
/**
@@ -147,6 +148,7 @@
"android.graphics.Xfermode",
"android.os.SystemClock",
"android.util.FloatMath",
+ "libcore.icu.ICU",
};
/**
@@ -154,8 +156,6 @@
* "package.package.OuterClass$InnerClass#MethodName".
*/
private final static String[] OVERRIDDEN_METHODS = new String[] {
- // TODO: remove once DelegateClass is working
- "android.content.res.Resources$Theme#obtainStyledAttributes",
};
/**