diff options
18 files changed, 266 insertions, 289 deletions
diff --git a/Android.mk b/Android.mk index 570fbf8dd1c0..78d9b7b5d0d4 100644 --- a/Android.mk +++ b/Android.mk @@ -126,8 +126,6 @@ LOCAL_SRC_FILES += \ core/java/android/os/IPowerManager.aidl \ core/java/android/os/IRemoteCallback.aidl \ core/java/android/os/IVibratorService.aidl \ - core/java/android/service/urlrenderer/IUrlRendererService.aidl \ - core/java/android/service/urlrenderer/IUrlRendererCallback.aidl \ core/java/android/service/wallpaper/IWallpaperConnection.aidl \ core/java/android/service/wallpaper/IWallpaperEngine.aidl \ core/java/android/service/wallpaper/IWallpaperService.aidl \ diff --git a/core/java/android/service/urlrenderer/IUrlRendererCallback.aidl b/core/java/android/service/urlrenderer/IUrlRendererCallback.aidl deleted file mode 100644 index 004aca7aa0de..000000000000 --- a/core/java/android/service/urlrenderer/IUrlRendererCallback.aidl +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.service.urlrenderer; - -import android.os.ParcelFileDescriptor; - -/** - * {@hide} - */ -oneway interface IUrlRendererCallback { - void complete(String url, in ParcelFileDescriptor result); -} diff --git a/core/java/android/service/urlrenderer/IUrlRendererService.aidl b/core/java/android/service/urlrenderer/IUrlRendererService.aidl deleted file mode 100644 index d561fdc731f6..000000000000 --- a/core/java/android/service/urlrenderer/IUrlRendererService.aidl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.service.urlrenderer; - -import android.service.urlrenderer.IUrlRendererCallback; - -/** - * {@hide} - */ -interface IUrlRendererService { - void render(in List<String> urls, int width, int height, - IUrlRendererCallback cb); -} diff --git a/core/java/android/service/urlrenderer/UrlRenderer.java b/core/java/android/service/urlrenderer/UrlRenderer.java deleted file mode 100644 index 6057d6c84a22..000000000000 --- a/core/java/android/service/urlrenderer/UrlRenderer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.service.urlrenderer; - -import android.os.IBinder; -import android.os.ParcelFileDescriptor; -import android.os.RemoteException; - -import java.util.List; - -/** - * TODO(phanna): Document this class. - * {@hide} while developing - */ -public final class UrlRenderer { - /** - * Interface for clients to receive the result of calls to - * {@link UrlRenderer#render}. - * {@hide} while developing - */ - public interface Callback { - /** - * Calls to {@link render} will result in multiple invokations of this - * method for each url. A null result means that there was a server - * error or a problem rendering the url. - * @param url The url that has been rendered. - * @param result A ParcelFileDescriptor containing the encoded image - * data. The client is responsible for closing the stream - * to free resources. A null result indicates a failure - * to render. - */ - public void complete(String url, ParcelFileDescriptor result); - } - - private IUrlRendererService mService; - - /** - * Create a new UrlRenderer to remotely render urls. - * @param service An IBinder service usually obtained through - * {@link ServiceConnection#onServiceConnected} - */ - public UrlRenderer(IBinder service) { - mService = IUrlRendererService.Stub.asInterface(service); - } - - private static class InternalCallback extends IUrlRendererCallback.Stub { - private final Callback mCallback; - InternalCallback(Callback cb) { - mCallback = cb; - } - - public void complete(String url, ParcelFileDescriptor result) { - mCallback.complete(url, result); - } - } - - /** - * Render the list of <var>urls</var> and invoke the <var>callback</var> - * for each result. - * @param urls A List of urls to render. - * @param width The desired width of the result. - * @param height The desired height of the result. - * @param callback An instance of {@link Callback} invoked for each url. - */ - public void render(List<String> urls, int width, int height, - Callback callback) { - if (mService != null) { - try { - mService.render(urls, width, height, - new InternalCallback(callback)); - } catch (RemoteException ex) { - } - } - } -} diff --git a/core/java/android/service/urlrenderer/UrlRendererService.java b/core/java/android/service/urlrenderer/UrlRendererService.java deleted file mode 100644 index f7bf7d7aa85e..000000000000 --- a/core/java/android/service/urlrenderer/UrlRendererService.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.service.urlrenderer; - -import android.annotation.SdkConstant; -import android.annotation.SdkConstant.SdkConstantType; -import android.app.Service; -import android.os.ParcelFileDescriptor; -import android.os.RemoteException; - -import java.util.List; - -/** - * TODO(phanna): Complete documentation. - * {@hide} while developing - */ -public abstract class UrlRendererService extends Service { - /** - * The {@link Intent} that must be declared as handled by the service. - */ - @SdkConstant(SdkConstantType.SERVICE_ACTION) - public static final String SERVICE_INTERFACE = - "android.service.urlrenderer.UrlRendererService"; - - static final String TAG = "UrlRendererService"; - - private static class InternalCallback implements UrlRenderer.Callback { - private final IUrlRendererCallback mCallback; - InternalCallback(IUrlRendererCallback cb) { - mCallback = cb; - } - - public void complete(String url, ParcelFileDescriptor result) { - try { - mCallback.complete(url, result); - } catch (RemoteException ex) { - } - } - } - - private final IUrlRendererService.Stub mBinderInterface = - new IUrlRendererService.Stub() { - public void render(List<String> urls, int width, int height, - IUrlRendererCallback cb) { - processRequest(urls, width, height, - new InternalCallback(cb)); - } - }; - - /** - * Implement to return the implementation of the internal accessibility - * service interface. Subclasses should not override. - */ - @Override - public final android.os.IBinder onBind(android.content.Intent intent) { - return mBinderInterface; - } - - /** - * When all clients unbind from the service, stop the service. Subclasses - * should not override. - */ - @Override - public final boolean onUnbind(android.content.Intent intent) { - stopSelf(); - return false; - } - - /** - * Subclasses implement this function to process the given urls. When each - * url is complete, the subclass must invoke the callback with the result. - * @param urls A list of urls to render at the given dimensions. - * @param width The desired width of the result. - * @param height The desired height of the result. - * @param cb The callback to invoke when each url is complete. - */ - public abstract void processRequest(List<String> urls, int width, - int height, UrlRenderer.Callback cb); -} diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 3de79621db40..0247f6a7828a 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -103,10 +103,10 @@ public abstract class HardwareRenderer { abstract void draw(View view, View.AttachInfo attachInfo, int yOffset); /** - * Creates a new canvas that can be used to record drawing operations - * in the specified display list. + * Creates a new display list that can be used to record batches of + * drawing operations. * - * @return A new recording canvas. + * @return A new display list. */ abstract DisplayList createDisplayList(); @@ -216,9 +216,11 @@ public abstract class HardwareRenderer { /** * Return a string for the EGL error code, or the hex representation - * if an unknown error. - * @param error EGL error. - * @return Error string. + * if the error is unknown. + * + * @param error The EGL error to convert into a String. + * + * @return An error string correponding to the EGL error code. */ static String getEGLErrorString(int error) { switch (error) { @@ -446,11 +448,9 @@ public abstract class HardwareRenderer { } /** - * Defines the EGL configuration for this renderer. The default configuration - * is RGBX, no depth, no stencil. + * Defines the EGL configuration for this renderer. * * @return An {@link android.view.HardwareRenderer.GlRenderer.EglConfigChooser}. - * @param glVersion */ EglConfigChooser getConfigChooser(int glVersion) { return new ComponentSizeChooser(glVersion, 8, 8, 8, 8, 0, 0); diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index cd0ae3b02fbb..d596a7f9bb18 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -86,6 +86,15 @@ public class Surface implements Parcelable { * play back. */ public static final int PUSH_BUFFERS = 0x00000200; + /** + * Indicates that the surface must be considered opaque, even if its + * pixel format is set to translucent. This can be useful if an + * application needs full RGBA 8888 support for instance but will + * still draw every pixel opaque. + * + * @hide + */ + public static final int OPAQUE = 0x00000400; /** Creates a normal surface. This is the default */ public static final int FX_SURFACE_NORMAL = 0x00000000; @@ -269,7 +278,7 @@ public class Surface implements Parcelable { } mOrigMatrix.set(m); } - }; + } /** * Sets the display metrics used to provide canva's width/height in compatibility mode. @@ -422,16 +431,20 @@ public class Surface implements Parcelable { /* no user serviceable parts here ... */ @Override protected void finalize() throws Throwable { - if (mNativeSurface != 0 || mSurfaceControl != 0) { - if (DEBUG_RELEASE) { - Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() (" - + mNativeSurface + ", " + mSurfaceControl + ")", mCreationStack); - } else { - Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() (" - + mNativeSurface + ", " + mSurfaceControl + ")"); + try { + super.finalize(); + } finally { + if (mNativeSurface != 0 || mSurfaceControl != 0) { + if (DEBUG_RELEASE) { + Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() (" + + mNativeSurface + ", " + mSurfaceControl + ")", mCreationStack); + } else { + Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() (" + + mNativeSurface + ", " + mSurfaceControl + ")"); + } } + release(); } - release(); } private native void init(SurfaceSession s, diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java index b1fdec89f147..4ab2881f79a7 100644 --- a/core/java/android/view/VelocityTracker.java +++ b/core/java/android/view/VelocityTracker.java @@ -387,7 +387,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> { return pointer != null ? pointer.yVelocity : 0; } - private final Pointer getPointer(int id) { + private Pointer getPointer(int id) { for (Pointer pointer = mPointerListHead; pointer != null; pointer = pointer.next) { if (pointer.id == id) { return pointer; @@ -396,7 +396,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> { return null; } - private static final Pointer obtainPointer() { + private static Pointer obtainPointer() { synchronized (sPool) { if (sRecycledPointerCount != 0) { Pointer element = sRecycledPointerListHead; @@ -409,7 +409,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> { return new Pointer(); } - private static final void releasePointer(Pointer pointer) { + private static void releasePointer(Pointer pointer) { synchronized (sPool) { if (sRecycledPointerCount < POINTER_POOL_CAPACITY) { pointer.next = sRecycledPointerListHead; @@ -419,7 +419,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> { } } - private static final void releasePointerList(Pointer pointer) { + private static void releasePointerList(Pointer pointer) { if (pointer != null) { synchronized (sPool) { int count = sRecycledPointerCount; diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 7907ad2cb25f..14a049c8b68a 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -472,7 +472,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn mAttachInfo.mHardwareRenderer.destroy(true); } mAttachInfo.mHardwareRenderer = HardwareRenderer.createGlRenderer(2, translucent); - mAttachInfo.mHardwareAccelerated = true; + mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareRenderer != null; } } } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 5d68613c7b08..8c1e5f7a6b2d 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -317,6 +317,10 @@ public class WebView extends AbsoluteLayout // true means redraw the screen all-the-time. Only with AUTO_REDRAW_HACK private boolean mAutoRedraw; + // Reference to the AlertDialog displayed by InvokeListBox. + // It's used to dismiss the dialog in destroy if not done before. + private AlertDialog mListBoxDialog = null; + static final String LOGTAG = "webview"; private ZoomManager mZoomManager; @@ -1301,7 +1305,10 @@ public class WebView extends AbsoluteLayout */ public void destroy() { clearHelpers(); - + if (mListBoxDialog != null) { + mListBoxDialog.dismiss(); + mListBoxDialog = null; + } if (mWebViewCore != null) { // Set the handlers to null before destroying WebViewCore so no // more messages will be posted. @@ -7263,7 +7270,7 @@ public class WebView extends AbsoluteLayout EventHub.SINGLE_LISTBOX_CHOICE, -2, 0); }}); } - final AlertDialog dialog = b.create(); + mListBoxDialog = b.create(); listView.setAdapter(adapter); listView.setFocusableInTouchMode(true); // There is a bug (1250103) where the checks in a ListView with @@ -7285,7 +7292,8 @@ public class WebView extends AbsoluteLayout int position, long id) { mWebViewCore.sendMessage( EventHub.SINGLE_LISTBOX_CHOICE, (int)id, 0); - dialog.dismiss(); + mListBoxDialog.dismiss(); + mListBoxDialog = null; } }); if (mSelection != -1) { @@ -7297,13 +7305,14 @@ public class WebView extends AbsoluteLayout adapter.registerDataSetObserver(observer); } } - dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + mListBoxDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { mWebViewCore.sendMessage( EventHub.SINGLE_LISTBOX_CHOICE, -2, 0); + mListBoxDialog = null; } }); - dialog.show(); + mListBoxDialog.show(); } } diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java index d2e66886b5f2..79ab44890af2 100644 --- a/core/java/android/widget/Scroller.java +++ b/core/java/android/widget/Scroller.java @@ -92,7 +92,7 @@ public class Scroller { * friction. */ public final void setFriction(float friction) { - computeDeceleration(friction); + mDeceleration = computeDeceleration(friction); } private float computeDeceleration(float friction) { diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h index 653360023859..b18178128fa4 100644 --- a/include/surfaceflinger/ISurfaceComposer.h +++ b/include/surfaceflinger/ISurfaceComposer.h @@ -43,6 +43,7 @@ public: eSecure = 0x00000080, eNonPremultiplied = 0x00000100, ePushBuffers = 0x00000200, + eOpaque = 0x00000400, eFXSurfaceNormal = 0x00000000, eFXSurfaceBlur = 0x00010000, diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 57de43af0baa..cb23680f9007 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -467,19 +467,14 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, // Copy the framebuffer into the layer glBindTexture(GL_TEXTURE_2D, layer->texture); - // TODO: Workaround for b/3054204 - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom, - layer->width, layer->height, 0); - - // TODO: Waiting for b/3054204 to be fixed - // if (layer->empty) { - // glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom, - // layer->width, layer->height, 0); - // layer->empty = false; - // } else { - // glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom, - // bounds.getWidth(), bounds.getHeight()); - // } + if (layer->empty) { + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom, + layer->width, layer->height, 0); + layer->empty = false; + } else { + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom, + bounds.getWidth(), bounds.getHeight()); + } // Enqueue the buffer coordinates to clear the corresponding region later mLayers.push(new Rect(bounds)); diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index f69cb159b83b..124d5e642b22 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -71,13 +71,13 @@ void ObjectBase::setContext(Context *rsc) void ObjectBase::incUserRef() const { mUserRefCount ++; - //LOGV("ObjectBase %p inc ref %i", this, mRefCount); + //LOGV("ObjectBase %p inc ref %i", this, mUserRefCount); } void ObjectBase::incSysRef() const { mSysRefCount ++; - //LOGV("ObjectBase %p inc ref %i", this, mRefCount); + //LOGV("ObjectBase %p inc ref %i", this, mSysRefCount); } bool ObjectBase::checkDelete() const @@ -96,14 +96,14 @@ bool ObjectBase::decUserRef() const { rsAssert(mUserRefCount > 0); mUserRefCount --; - //dumpObj("decUserRef"); + //dumpLOGV("decUserRef"); return checkDelete(); } bool ObjectBase::zeroUserRef() const { mUserRefCount = 0; - //dumpObj("zeroUserRef"); + //dumpLOGV("zeroUserRef"); return checkDelete(); } @@ -111,7 +111,7 @@ bool ObjectBase::decSysRef() const { rsAssert(mSysRefCount > 0); mSysRefCount --; - //dumpObj("decSysRef"); + //dumpLOGV("decSysRef"); return checkDelete(); } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 8be980fe2cc6..92c5cc8b1b74 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -6832,10 +6832,16 @@ public class WindowManagerService extends IWindowManager.Stub mSurfaceW = w; mSurfaceH = h; try { + final boolean isHwAccelerated = (mAttrs.flags & + WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; + final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : mAttrs.format; + if (isHwAccelerated && mAttrs.format == PixelFormat.OPAQUE) { + flags |= Surface.OPAQUE; + } mSurface = new Surface( mSession.mSurfaceSession, mSession.mPid, mAttrs.getTitle().toString(), - 0, w, h, mAttrs.format, flags); + 0, w, h, format, flags); if (SHOW_TRANSACTIONS) Slog.i(TAG, " CREATE SURFACE " + mSurface + " IN SESSION " + mSession.mSurfaceSession diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index fb76720084c6..1b06843df7ee 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -171,7 +171,8 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mReqHeight = h; mSecure = (flags & ISurfaceComposer::eSecure) ? true : false; - mNeedsBlending = (info.h_alpha - info.l_alpha) > 0; + mNeedsBlending = (info.h_alpha - info.l_alpha) > 0 && + (flags & ISurfaceComposer::eOpaque) == 0; // we use the red index int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); diff --git a/telephony/mockril/src/com/android/internal/telephony/mockril/MockRilController.java b/telephony/mockril/src/com/android/internal/telephony/mockril/MockRilController.java index a5139bd829fe..0e75c72483d3 100644 --- a/telephony/mockril/src/com/android/internal/telephony/mockril/MockRilController.java +++ b/telephony/mockril/src/com/android/internal/telephony/mockril/MockRilController.java @@ -132,4 +132,86 @@ public class MockRilController { int curstate = resp.getState(); return curstate == state; } + + /** + * Start an incoming call for the given phone number + * + * @param phoneNumber is the number to show as incoming call + * @return true if the incoming call is started successfully, false if it fails. + */ + public boolean startIncomingCall(String phoneNumber) { + RilCtrlCmds.CtrlReqSetMTCall req = new RilCtrlCmds.CtrlReqSetMTCall(); + + req.setPhoneNumber(phoneNumber); + if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_MT_CALL, 0, 0, req)) { + Log.v(TAG, "send CMD_SET_MT_CALL request failed"); + return false; + } + return true; + } + + /** + * Hang up a connection remotelly for the given call fail cause + * + * @param connectionID is the connection to be hung up + * @param failCause is the call fail cause defined in ril.h + * @return true if the hangup is successful, false if it fails + */ + public boolean hangupRemote(int connectionId, int failCause) { + RilCtrlCmds.CtrlHangupConnRemote req = new RilCtrlCmds.CtrlHangupConnRemote(); + req.setConnectionId(connectionId); + req.setCallFailCause(failCause); + + if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, req)) { + Log.v(TAG, "send CTRL_CMD_HANGUP_CONN_REMOTE request failed"); + return false; + } + return true; + } + + /** + * Set call transition flag to the Mock Ril + * + * @param flag is a boolean value for the call transiton flag + * true: call transition: dialing->alert, alert->active is controlled + * false: call transition is automatically handled by Mock Ril + * @return true if the request is successful, false if it failed to set the flag + */ + public boolean setCallTransitionFlag(boolean flag) { + RilCtrlCmds.CtrlSetCallTransitionFlag req = new RilCtrlCmds.CtrlSetCallTransitionFlag(); + + req.setFlag(flag); + + if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, req)) { + Log.v(TAG, "send CTRL_CMD_SET_CALL_TRANSITION_FLAG request failed"); + return false; + } + return true; + } + + /** + * Set the dialing call to alert if the call transition flag is true + * + * @return true if the call transition is successful, false if it fails + */ + public boolean setDialCallToAlert() { + if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ALERT, 0, 0, null)) { + Log.v(TAG, "send CTRL_CMD_SET_CALL_ALERT request failed"); + return false; + } + return true; + } + + /** + * Set the alert call to active if the call transition flag is true + * + * @return true if the call transition is successful, false if it fails + */ + public boolean setAlertCallToActive() { + if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ACTIVE, 0, 0, null)) { + Log.v(TAG, "send CTRL_CMD_SET_CALL_ACTIVE request failed"); + return false; + } + return true; + } } diff --git a/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java b/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java index f0d5b31a4e72..3149ee15e00d 100644 --- a/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java +++ b/telephony/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java @@ -55,7 +55,7 @@ public class MockRilTest extends InstrumentationTestCase { } /** - * Test protobuf serialization and deserialization + * Test Case 1: Test protobuf serialization and deserialization * @throws InvalidProtocolBufferMicroException */ public void testProtobufSerDes() throws InvalidProtocolBufferMicroException { @@ -77,7 +77,7 @@ public class MockRilTest extends InstrumentationTestCase { } /** - * Test echo command works using writeMsg & readMsg + * Test case 2: Test echo command works using writeMsg & readMsg */ public void testEchoMsg() throws IOException { log("testEchoMsg E"); @@ -110,7 +110,7 @@ public class MockRilTest extends InstrumentationTestCase { } /** - * Test get as + * Test case 3: Test get as */ public void testGetAs() { log("testGetAs E"); @@ -150,6 +150,9 @@ public class MockRilTest extends InstrumentationTestCase { log("testGetAs X"); } + /** + * Test case 3: test get radio state + */ public void testGetRadioState() throws IOException { log("testGetRadioState E"); @@ -175,6 +178,9 @@ public class MockRilTest extends InstrumentationTestCase { log("testGetRadioState X"); } + /** + * Test case 5: test set radio state + */ public void testSetRadioState() throws IOException { log("testSetRadioState E"); @@ -187,6 +193,9 @@ public class MockRilTest extends InstrumentationTestCase { Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_RADIO_STATE, 0, 0, cmdrs); Msg resp = Msg.recv(mMockRilChannel); + log("get response status :" + resp.getStatus()); + log("get response for command: " + resp.getCmd()); + log("get command token: " + resp.getToken()); RilCtrlCmds.CtrlRspRadioState rsp = resp.getDataAs(RilCtrlCmds.CtrlRspRadioState.class); @@ -194,4 +203,102 @@ public class MockRilTest extends InstrumentationTestCase { log("get response for testSetRadioState: " + state); assertTrue(RilCmds.RADIOSTATE_SIM_NOT_READY == state); } + + /** + * Test case 6: test start incoming call and hangup it. + */ + public void testStartIncomingCallAndHangup() throws IOException { + log("testStartIncomingCallAndHangup"); + RilCtrlCmds.CtrlReqSetMTCall cmd = new RilCtrlCmds.CtrlReqSetMTCall(); + String incomingCall = "6502889108"; + // set the MT call + cmd.setPhoneNumber(incomingCall); + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_MT_CALL, 0, 0, cmd); + // get response + Msg resp = Msg.recv(mMockRilChannel); + log("Get response status: " + resp.getStatus()); + assertTrue("The ril is not in a proper state to set MT calls.", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + + // allow the incoming call alerting for some time + try { + Thread.sleep(5000); + } catch (InterruptedException e) {} + + // we are playing a trick to assume the current is 1 + RilCtrlCmds.CtrlHangupConnRemote hangupCmd = new RilCtrlCmds.CtrlHangupConnRemote(); + hangupCmd.setConnectionId(1); + hangupCmd.setCallFailCause(16); // normal hangup + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, hangupCmd); + + // get response + resp = Msg.recv(mMockRilChannel); + log("Get response for hangup connection: " + resp.getStatus()); + assertTrue("CTRL_CMD_HANGUP_CONN_REMOTE failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + } + + /** + * Test case 7: test set call transition flag + */ + public void testSetCallTransitionFlag() throws IOException { + log("testSetCallTransitionFlag"); + // Set flag to true: + RilCtrlCmds.CtrlSetCallTransitionFlag cmd = new RilCtrlCmds.CtrlSetCallTransitionFlag(); + cmd.setFlag(true); + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, cmd); + + Msg resp = Msg.recv(mMockRilChannel); + log("Get response status: " + resp.getStatus()); + assertTrue("Set call transition flag failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + + // add a dialing call + RilCtrlCmds.CtrlReqAddDialingCall cmdDialCall = new RilCtrlCmds.CtrlReqAddDialingCall(); + String phoneNumber = "5102345678"; + cmdDialCall.setPhoneNumber(phoneNumber); + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_ADD_DIALING_CALL, 0, 0, cmdDialCall); + resp = Msg.recv(mMockRilChannel); + log("Get response status for adding a dialing call: " + resp.getStatus()); + assertTrue("add dialing call failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + try { + Thread.sleep(5000); + } catch (InterruptedException e) {} + + // send command to force call state change + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_ALERT, 0, 0, null); + resp = Msg.recv(mMockRilChannel); + log("Get response status: " + resp.getStatus()); + assertTrue("Set call alert failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) {} + + // send command to force call state change + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_ACTIVE, 0, 0, null); + resp = Msg.recv(mMockRilChannel); + log("Get response status: " + resp.getStatus()); + assertTrue("Set call active failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + + // hangup the active all remotely + RilCtrlCmds.CtrlHangupConnRemote hangupCmd = new RilCtrlCmds.CtrlHangupConnRemote(); + hangupCmd.setConnectionId(1); + hangupCmd.setCallFailCause(16); // normal hangup + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, hangupCmd); + resp = Msg.recv(mMockRilChannel); + log("Get response for hangup connection: " + resp.getStatus()); + assertTrue("CTRL_CMD_HANGUP_CONN_REMOTE failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + + // set the flag to false + cmd.setFlag(false); + Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, cmd); + resp = Msg.recv(mMockRilChannel); + assertTrue("Set call transition flag failed", + resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); + } } |