diff options
9 files changed, 125 insertions, 34 deletions
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp index ffcd1a0c0ab6..de2d8c48b662 100644 --- a/core/jni/android/graphics/SurfaceTexture.cpp +++ b/core/jni/android/graphics/SurfaceTexture.cpp @@ -212,10 +212,10 @@ static void SurfaceTexture_setDefaultBufferSize(      surfaceTexture->setDefaultBufferSize(width, height);  } -static void SurfaceTexture_updateTexImage(JNIEnv* env, jobject thiz) +static jint SurfaceTexture_updateTexImage(JNIEnv* env, jobject thiz)  {      sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); -    surfaceTexture->updateTexImage(); +    return surfaceTexture->updateTexImage();  }  static void SurfaceTexture_getTransformMatrix(JNIEnv* env, jobject thiz, @@ -246,7 +246,7 @@ static JNINativeMethod gSurfaceTextureMethods[] = {      {"nativeInit",               "(ILjava/lang/Object;Z)V", (void*)SurfaceTexture_init },      {"nativeFinalize",           "()V",   (void*)SurfaceTexture_finalize },      {"nativeSetDefaultBufferSize", "(II)V", (void*)SurfaceTexture_setDefaultBufferSize }, -    {"nativeUpdateTexImage",     "()V",   (void*)SurfaceTexture_updateTexImage }, +    {"nativeUpdateTexImage",     "()I",   (void*)SurfaceTexture_updateTexImage },      {"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix },      {"nativeGetTimestamp",       "()J",   (void*)SurfaceTexture_getTimestamp },      {"nativeRelease",            "()V",   (void*)SurfaceTexture_release }, diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 9b8be854e325..c8ba26a336a7 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?>  <!--  /* //device/apps/common/assets/res/any/strings.xml  ** @@ -3365,4 +3365,13 @@      <!-- Delimeter used between each item in a textual list; for example "Alpha, Beta". [CHAR LIMIT=3] -->      <string name="list_delimeter">", "</string> +    <!-- STK sending DTMF, SMS, USSD, SS --> +    <string name="sending">Sending...</string> + +    <!-- STK launch Browser --> +    <string name="launchBrowserDefault">Launch Browser?</string> + +    <!-- STK setup Call --> +    <string name="SetupCallDefault">Accept Call?</string> +  </resources> diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 29fab11603a4..0521e6985eb1 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -17,6 +17,7 @@  package android.graphics;  import java.lang.ref.WeakReference; +  import android.os.Handler;  import android.os.Looper;  import android.os.Message; @@ -141,6 +142,12 @@ public class SurfaceTexture {       * android.view.Surface#lockCanvas} is called.  For OpenGL ES, the EGLSurface should be       * destroyed (via eglDestroySurface), made not-current (via eglMakeCurrent), and then recreated       * (via eglCreateWindowSurface) to ensure that the new default size has taken effect. +     *  +     * The width and height parameters must be no greater than the minimum of +     * GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see  +     * {@link javax.microedition.khronos.opengles.GL10#glGetIntegerv glGetIntegerv}). +     * An error due to invalid dimensions might not be reported until +     * updateTexImage() is called.       */      public void setDefaultBufferSize(int width, int height) {          nativeSetDefaultBufferSize(width, height); @@ -152,7 +159,10 @@ public class SurfaceTexture {       * implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target.       */      public void updateTexImage() { -        nativeUpdateTexImage(); +        int err = nativeUpdateTexImage();  +        if (err != 0) { +            throw new RuntimeException("Error during updateTexImage (see logs)"); +        }      }      /** @@ -258,7 +268,7 @@ public class SurfaceTexture {      private native void nativeGetTransformMatrix(float[] mtx);      private native long nativeGetTimestamp();      private native void nativeSetDefaultBufferSize(int width, int height); -    private native void nativeUpdateTexImage(); +    private native int nativeUpdateTexImage();      private native int nativeGetQueuedCount();      private native void nativeRelease(); diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index e2d6179ef046..d7dd4d6cb41e 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -79,7 +79,11 @@ public:      // pointed to by the buf argument and a status of OK is returned.  If no      // slot is available then a status of -EBUSY is returned and buf is      // unmodified. -    virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, +    // The width and height parameters must be no greater than the minimum of +    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). +    // An error due to invalid dimensions might not be reported until +    // updateTexImage() is called. +    virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height,              uint32_t format, uint32_t usage);      // queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a @@ -176,7 +180,11 @@ public:      // requestBuffers when a with and height of zero is requested.      // A call to setDefaultBufferSize() may trigger requestBuffers() to      // be called from the client. -    status_t setDefaultBufferSize(uint32_t w, uint32_t h); +    // The width and height parameters must be no greater than the minimum of +    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). +    // An error due to invalid dimensions might not be reported until +    // updateTexImage() is called. +    status_t setDefaultBufferSize(uint32_t width, uint32_t height);      // getCurrentBuffer returns the buffer associated with the current image.      sp<GraphicBuffer> getCurrentBuffer() const; diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp index 5daafd5581aa..93ebfb99ff6f 100644 --- a/libs/gui/tests/SurfaceTexture_test.cpp +++ b/libs/gui/tests/SurfaceTexture_test.cpp @@ -1520,4 +1520,36 @@ TEST_F(SurfaceTextureGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {      EXPECT_EQ(1, buffers[2]->getStrongCount());  } +TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) { +    int texHeight = 16; +    ANativeWindowBuffer* anb; + +    GLint maxTextureSize; +    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + +    // make sure it works with small textures +    mST->setDefaultBufferSize(16, texHeight); +    EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); +    EXPECT_EQ(16, anb->width); +    EXPECT_EQ(texHeight, anb->height); +    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); +    EXPECT_EQ(NO_ERROR, mST->updateTexImage()); + +    // make sure it works with GL_MAX_TEXTURE_SIZE +    mST->setDefaultBufferSize(maxTextureSize, texHeight); +    EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); +    EXPECT_EQ(maxTextureSize, anb->width); +    EXPECT_EQ(texHeight, anb->height); +    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); +    EXPECT_EQ(NO_ERROR, mST->updateTexImage()); + +    // make sure it fails with GL_MAX_TEXTURE_SIZE+1 +    mST->setDefaultBufferSize(maxTextureSize+1, texHeight); +    EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); +    EXPECT_EQ(maxTextureSize+1, anb->width); +    EXPECT_EQ(texHeight, anb->height); +    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); +    ASSERT_NE(NO_ERROR, mST->updateTexImage()); +} +  } // namespace android diff --git a/telephony/java/com/android/internal/telephony/cat/CatService.java b/telephony/java/com/android/internal/telephony/cat/CatService.java index 542026498eaa..5a994f3de061 100644 --- a/telephony/java/com/android/internal/telephony/cat/CatService.java +++ b/telephony/java/com/android/internal/telephony/cat/CatService.java @@ -94,6 +94,8 @@ public class CatService extends Handler implements AppInterface {      private static final int DEV_ID_TERMINAL    = 0x82;      private static final int DEV_ID_NETWORK     = 0x83; +    static final String STK_DEFAULT = "Defualt Message"; +      /* Intentionally private for singleton */      private CatService(CommandsInterface ci, IccRecords ir, Context context,              IccFileHandler fh, IccCard ic) { @@ -157,7 +159,15 @@ public class CatService extends Handler implements AppInterface {              }              break;          case MSG_ID_PROACTIVE_COMMAND: -            cmdParams = (CommandParams) rilMsg.mData; +            try { +                cmdParams = (CommandParams) rilMsg.mData; +            } catch (ClassCastException e) { +                // for error handling : cast exception +                CatLog.d(this, "Fail to parse proactive command"); +                sendTerminalResponse(mCurrntCmd.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD, +                                     false, 0x00, null); +                break; +            }              if (cmdParams != null) {                  if (rilMsg.mResCode == ResultCode.OK) {                      handleProactiveCommand(cmdParams); @@ -194,6 +204,7 @@ public class CatService extends Handler implements AppInterface {      private void handleProactiveCommand(CommandParams cmdParams) {          CatLog.d(this, cmdParams.getCommandType().name()); +        CharSequence message;          CatCmdMessage cmdMsg = new CatCmdMessage(cmdParams);          switch (cmdParams.getCommandType()) {              case SET_UP_MENU: @@ -224,26 +235,44 @@ public class CatService extends Handler implements AppInterface {                      case CommandParamsFactory.DTTZ_SETTING:                          resp = new DTTZResponseData(null);                          sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, resp); -                        break; +                        return;                      case CommandParamsFactory.LANGUAGE_SETTING:                          resp = new LanguageResponseData(Locale.getDefault().getLanguage());                          sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, resp); -                        break; +                        return;                      default:                          sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, null);                          return;                  }              case LAUNCH_BROWSER: +                if ((((LaunchBrowserParams) cmdParams).confirmMsg.text != null) +                        && (((LaunchBrowserParams) cmdParams).confirmMsg.text.equals(STK_DEFAULT))) { +                    message = mContext.getText(com.android.internal.R.string.launchBrowserDefault); +                    ((LaunchBrowserParams) cmdParams).confirmMsg.text = message.toString(); +                } +                break;              case SELECT_ITEM:              case GET_INPUT:              case GET_INKEY: +                break;              case SEND_DTMF:              case SEND_SMS:              case SEND_SS:              case SEND_USSD: +                if ((((DisplayTextParams)cmdParams).textMsg.text != null) +                        && (((DisplayTextParams)cmdParams).textMsg.text.equals(STK_DEFAULT))) { +                    message = mContext.getText(com.android.internal.R.string.sending); +                    ((DisplayTextParams)cmdParams).textMsg.text = message.toString(); +                } +                break;              case PLAY_TONE: +                break;              case SET_UP_CALL: -                // nothing to do on telephony! +                if ((((CallSetupParams) cmdParams).confirmMsg.text != null) +                        && (((CallSetupParams) cmdParams).confirmMsg.text.equals(STK_DEFAULT))) { +                    message = mContext.getText(com.android.internal.R.string.SetupCallDefault); +                    ((CallSetupParams) cmdParams).confirmMsg.text = message.toString(); +                }                  break;              default:                  CatLog.d(this, "Unsupported command"); diff --git a/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java b/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java index 686fe4646542..e7fca5a8b936 100644 --- a/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java +++ b/telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java @@ -403,6 +403,7 @@ class CommandParamsFactory extends Handler {          input.ucs2 = (cmdDet.commandQualifier & 0x02) != 0;          input.yesNo = (cmdDet.commandQualifier & 0x04) != 0;          input.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0; +        input.echo = true;          mCmdParams = new GetInputParams(cmdDet, input); @@ -625,11 +626,7 @@ class CommandParamsFactory extends Handler {          ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID,                  ctlvs); -        if (ctlv != null) { -            textMsg.text = ValueParser.retrieveAlphaId(ctlv); -        } else { -            throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING); -        } +        textMsg.text = ValueParser.retrieveAlphaId(ctlv);          ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);          if (ctlv != null) { @@ -714,9 +711,8 @@ class CommandParamsFactory extends Handler {          // parse alpha identifier.          ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs); -        if (ctlv != null) { -            confirmMsg.text = ValueParser.retrieveAlphaId(ctlv); -        } +        confirmMsg.text = ValueParser.retrieveAlphaId(ctlv); +          // parse icon identifier          ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);          if (ctlv != null) { @@ -841,9 +837,7 @@ class CommandParamsFactory extends Handler {          // get confirmation message string.          ctlv = searchForNextTag(ComprehensionTlvTag.ALPHA_ID, iter); -        if (ctlv != null) { -            confirmMsg.text = ValueParser.retrieveAlphaId(ctlv); -        } +        confirmMsg.text = ValueParser.retrieveAlphaId(ctlv);          ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);          if (ctlv != null) { diff --git a/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java b/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java index e5a2d31e5562..ab26d13a5931 100644 --- a/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java +++ b/telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java @@ -94,6 +94,7 @@ class ComprehensionTlv {                  startIndex = ctlv.mValueIndex + ctlv.mLength;              } else {                  CatLog.d(LOG_TAG, "decodeMany: ctlv is null, stop decoding"); +                items.clear();                  break;              }          } @@ -123,7 +124,10 @@ class ComprehensionTlv {              case 0:              case 0xff:              case 0x80: -                throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD); +                // for error handling +                // these one make exception while decoding the abnormal command. +                // (in case of Ghana MTN simcard , JDI simcard) +                return null;              case 0x7f: // tag is in three-byte format                  tag = ((data[curIndex] & 0xff) << 8) diff --git a/telephony/java/com/android/internal/telephony/cat/ValueParser.java b/telephony/java/com/android/internal/telephony/cat/ValueParser.java index 34e48112f4d8..584d96cb522f 100644 --- a/telephony/java/com/android/internal/telephony/cat/ValueParser.java +++ b/telephony/java/com/android/internal/telephony/cat/ValueParser.java @@ -273,18 +273,23 @@ abstract class ValueParser {       */      static String retrieveAlphaId(ComprehensionTlv ctlv) throws ResultException { -        byte[] rawValue = ctlv.getRawValue(); -        int valueIndex = ctlv.getValueIndex(); -        int length = ctlv.getLength(); -        if (length != 0) { -            try { -                return IccUtils.adnStringFieldToString(rawValue, valueIndex, -                        length); -            } catch (IndexOutOfBoundsException e) { -                throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD); +        if (ctlv != null) { +            byte[] rawValue = ctlv.getRawValue(); +            int valueIndex = ctlv.getValueIndex(); +            int length = ctlv.getLength(); +            if (length != 0) { +                try { +                    return IccUtils.adnStringFieldToString(rawValue, valueIndex, +                            length); +                } catch (IndexOutOfBoundsException e) { +                    throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD); +                } +            } else { +                return CatService.STK_DEFAULT;              } +        } else { +            return CatService.STK_DEFAULT;          } -        return null;      }      /**  |