Example #1
0
  void updateSignalStrength() {
    // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
    // should probably used instead.

    // not loaded in some versions of the code (e.g., zaku)
    if (mSignalStrength != null) {
      int state = mPhoneStateReceiver.getServiceState().getState();
      Resources r = getResources();

      if ((ServiceState.STATE_OUT_OF_SERVICE == state) || (ServiceState.STATE_POWER_OFF == state)) {
        mSignalStrength.setSummary("0");
      }

      int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm();
      Xlog.d(TAG, "updateSignalStrength() signalDbm : " + signalDbm);
      if (-1 == signalDbm) signalDbm = 0;

      int signalAsu = mPhoneStateReceiver.getSignalStrengthLevelAsu();
      Xlog.d(TAG, "updateSignalStrength() signalAsu : " + signalAsu);
      if (-1 == signalAsu) signalAsu = 0;

      mSignalStrength.setSummary(
          String.valueOf(signalDbm)
              + " "
              + r.getString(R.string.radioInfo_display_dbm)
              + "   "
              + String.valueOf(signalAsu)
              + " "
              + r.getString(R.string.radioInfo_display_asu));
    }
  }
 @Override
 public void onSwitchChanged(Switch switchView, boolean desiredState) {
   Xlog.d(
       TAG,
       "onCheckedChanged, desiredState "
           + desiredState
           + " mUpdateStatusOnly "
           + mUpdateStatusOnly);
   // turn off card emulation, set the active mode off and clear the screen
   if (mUpdateStatusOnly) {
     return;
   }
   if (!desiredState) {
     Settings.Global.putString(
         getContentResolver(), Settings.Global.NFC_MULTISE_ACTIVE, EMULATION_OFF);
     Xlog.d(
         TAG,
         "onCheckedChanged, set  Settings.Global.NFC_MULTISE_ACTIVE  EMULATION_OFF"
             + EMULATION_OFF);
   } else {
     // set the active mode is the list first elment and add preference
     String previousMode =
         Settings.Global.getString(getContentResolver(), Settings.Global.NFC_MULTISE_PREVIOUS);
     Settings.Global.putString(
         getContentResolver(), Settings.Global.NFC_MULTISE_ACTIVE, previousMode);
     Xlog.d(TAG, "onCheckedChanged, set active mode to " + previousMode);
   }
   mSwitchBar.setEnabled(false);
 }
  private int getModemType() {
    String mt;
    if (mSimType == PhoneConstants.GEMINI_SIM_1) {
      mt = SystemProperties.get("gsm.baseband.capability");
      Xlog.i(TAG, "gsm.baseband.capability " + mt);
    } else {
      mt = SystemProperties.get("gsm.baseband.capability2");
      Xlog.i(TAG, "gsm.baseband.capability2 " + mt);
    }
    int mode = MODEM_NO3G;

    if (mt == null) {
      mode = MODEM_NO3G;
    } else {
      try {
        int mask = Integer.valueOf(mt);
        if ((mask & MODEM_MASK_TDSCDMA) == MODEM_MASK_TDSCDMA) {
          mode = MODEM_TD;
        } else if ((mask & MODEM_MASK_WCDMA) == MODEM_MASK_WCDMA) {
          mode = MODEM_FDD;
        } else {
          mode = MODEM_NO3G;
        }
      } catch (NumberFormatException e) {
        mode = MODEM_NO3G;
      }
    }
    return mode;
  }
 // When a WebView is paused, we also want to pause the video in it.
 public static void pauseAndDispatch() {
   Xlog.d(XLOGTAG, "HTML5VideoViewProxy.pauseAndDispatch()");
   Xlog.d(XLOGTAG, "stack:" + Thread.currentThread().getStackTrace());
   if (mHTML5VideoView != null) {
     mHTML5VideoView.pauseAndDispatch(mCurrentProxy);
   }
 }
Example #5
0
 /** Finalise communicate with socket server. */
 public void endClient() {
   Xlog.v(TAG, "enter endClient");
   mSendThread.interrupt();
   Xlog.v(TAG, "Queue remaining:" + mCommandQueue.size());
   closeClient();
   mCallBack = null;
 }
 @Override
 public void handleMessage(Message msg) {
   if (!EMWifi.sIsInitialed) {
     showDialog(DIALOG_WIFI_ERROR);
     return;
   }
   if (HANDLER_EVENT_RX == msg.what) {
     long[] i4Rx = new long[2];
     long i4RxCntOk = -1;
     long i4RxCntFcsErr = -1;
     long i4RxPer = -1;
     Xlog.i(TAG, "The Handle event is : HANDLER_EVENT_RX");
     try {
       i4RxPer = Long.parseLong(mTvPer.getText().toString());
     } catch (NumberFormatException e) {
       Xlog.d(TAG, "Long.parseLong NumberFormatException: " + e.getMessage());
     }
     EMWifi.getPacketRxStatus(i4Rx, 2);
     Xlog.d(TAG, "after rx test: rx ok = " + String.valueOf(i4Rx[0]));
     Xlog.d(TAG, "after rx test: fcs error = " + String.valueOf(i4Rx[1]));
     i4RxCntOk = i4Rx[0] /* - i4Init[0] */;
     i4RxCntFcsErr = i4Rx[1] /* - i4Init[1] */;
     if (i4RxCntFcsErr + i4RxCntOk != 0) {
       i4RxPer = i4RxCntFcsErr * PERCENT / (i4RxCntFcsErr + i4RxCntOk);
     }
     mTvFcs.setText(String.valueOf(i4RxCntFcsErr));
     mTvRx.setText(String.valueOf(i4RxCntOk));
     mTvPer.setText(String.valueOf(i4RxPer));
   }
   mHandler.sendEmptyMessageDelayed(HANDLER_EVENT_RX, HANDLER_RX_DELAY_TIME);
 }
  private boolean unzipInstallFile() {
    int result = -1;

    String updateZip = Util.getTempPath(this) + Util.PathName.PACKAGE_NAME;
    try {
      ZipFile updatePackage = new ZipFile(mPath);
      result = Util.unzipFileElement(updatePackage, UPDATE_PACKAGE_NAME, mUpdatePath);
      updatePackage.close();
      Xlog.d(TAG, "[unzipInstallFile], unzip install.zip to googleota folder");
    } catch (IOException e) {
      Xlog.e(TAG, "[unzipInstallFile], unzip file fail");
      e.printStackTrace();
    }

    Util.deleteFile(updateZip);

    if (result != Util.OTAresult.OTA_FILE_UNZIP_OK) {
      if (mHandler != null) {
        mHandler.sendEmptyMessage(SystemUpdateService.MSG_UNZIP_ERROR);
      }
      return false;
    }

    return true;
  }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.cds_traffic_info);

    mContext = this.getBaseContext();
    if (mContext == null) {
      Xlog.e(TAG, "Could not get Conext of this activity");
      return;
    }

    mTotalTxEdit = (TextView) findViewById(R.id.tx_info);
    mTotalRxEdit = (TextView) findViewById(R.id.rx_info);
    mTotalMobileTxEdit = (TextView) findViewById(R.id.tx_mobile_info);
    mTotalMobileRxEdit = (TextView) findViewById(R.id.rx_mobile_info);
    mWlanEdit = (TextView) findViewById(R.id.wlan_info);
    mCcmni0Edit = (TextView) findViewById(R.id.ccmni0_info);
    mCcmni1Edit = (TextView) findViewById(R.id.ccmni1_info);
    mCcmni2Edit = (TextView) findViewById(R.id.ccmni2_info);

    try {
      updateTrafficInfo();
    } catch (Exception e) {
      e.printStackTrace();
    }

    Xlog.i(TAG, "CdsTrafficStatActivity is started");
  }
  /**
   * Class constructor.
   *
   * @param audioSource the recording source. See {@link MediaRecorder.AudioSource} for recording
   *     source definitions.
   * @param sampleRateInHz the sample rate expressed in Hertz. 44100Hz is currently the only rate
   *     that is guaranteed to work on all devices, but other rates such as 22050, 16000, and 11025
   *     may work on some devices.
   * @param channelConfig describes the configuration of the audio channels. See {@link
   *     AudioFormat#CHANNEL_IN_MONO} and {@link AudioFormat#CHANNEL_IN_STEREO}. {@link
   *     AudioFormat#CHANNEL_IN_MONO} is guaranteed to work on all devices.
   * @param audioFormat the format in which the audio data is represented. See {@link
   *     AudioFormat#ENCODING_PCM_16BIT} and {@link AudioFormat#ENCODING_PCM_8BIT}
   * @param bufferSizeInBytes the total size (in bytes) of the buffer where audio data is written to
   *     during the recording. New audio data can be read from this buffer in smaller chunks than
   *     this size. See {@link #getMinBufferSize(int, int, int)} to determine the minimum required
   *     buffer size for the successful creation of an AudioRecord instance. Using values smaller
   *     than getMinBufferSize() will result in an initialization failure.
   * @throws java.lang.IllegalArgumentException
   */
  public AudioRecord(
      int audioSource,
      int sampleRateInHz,
      int channelConfig,
      int audioFormat,
      int bufferSizeInBytes)
      throws IllegalArgumentException {
    /// M: Check record permission to user for CTA. {@
    if (FeatureOption.MTK_MOBILE_MANAGEMENT) {
      Xlog.d(TAG, "AudioRecord>>>");
      IBinder binder = ServiceManager.getService(Context.MOBILE_SERVICE);
      IMobileManagerService moms = IMobileManagerService.Stub.asInterface(binder);
      int uid = Binder.getCallingUid();
      String permission = SubPermissions.RECORD_MIC;
      try {
        if (moms != null
            && (moms.checkPermission(permission, uid) != PackageManager.PERMISSION_GRANTED)) {
          Xlog.d(TAG, "AudioRecord<<<: user denied permission " + permission + " for uid " + uid);
          throw new IllegalArgumentException();
        }
      } catch (RemoteException e) {
        Xlog.e(TAG, "CheckPermission failed in prepare with RemoteException, continues record.", e);
      }
    }
    /// @}

    mRecordingState = RECORDSTATE_STOPPED;

    // remember which looper is associated with the AudioRecord instanciation
    if ((mInitializationLooper = Looper.myLooper()) == null) {
      mInitializationLooper = Looper.getMainLooper();
    }

    audioParamCheck(audioSource, sampleRateInHz, channelConfig, audioFormat);

    audioBuffSizeCheck(bufferSizeInBytes);

    // native initialization
    int[] session = new int[1];
    session[0] = 0;
    // TODO: update native initialization when information about hardware init failure
    //      due to capture device already open is available.
    int initResult =
        native_setup(
            new WeakReference<AudioRecord>(this),
            mRecordSource,
            mSampleRate,
            mChannelMask,
            mAudioFormat,
            mNativeBufferSizeInBytes,
            session);
    if (initResult != SUCCESS) {
      loge("Error code " + initResult + " when initializing native AudioRecord object.");
      return; // with mState == STATE_UNINITIALIZED
    }

    mSessionId = session[0];

    mState = STATE_INITIALIZED;
  }
Example #10
0
 void hide() {
   Xlog.i(TAG, "bottom bar hide(), showing: " + mShowing);
   if (mUseQuickControls || mUseFullScreen) {
     cancelBottomBarAnimation();
     int visibleHeight = getVisibleBottomHeight();
     float startPos = getTranslationY();
     this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
     mBottomBarAnimator =
         ObjectAnimator.ofFloat(this, "translationY", startPos, startPos + visibleHeight);
     mBottomBarAnimator.addListener(mHideBottomBarAnimatorListener);
     setupBottomBarAnimator(mBottomBarAnimator);
     mBottomBarAnimator.start();
     this.setVisibility(View.GONE);
     mShowing = false;
     return;
   } else {
     this.setVisibility(View.VISIBLE);
     cancelBottomBarAnimation();
     int visibleHeight = getVisibleBottomHeight();
     float startPos = getTranslationY();
     Xlog.i(TAG, "hide(): visibleHeight: " + visibleHeight);
     Xlog.i(TAG, "hide(): startPos: " + startPos);
     this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
     mBottomBarAnimator =
         ObjectAnimator.ofFloat(this, "translationY", startPos, startPos + visibleHeight);
     mBottomBarAnimator.addListener(mHideBottomBarAnimatorListener);
     setupBottomBarAnimator(mBottomBarAnimator);
     mBottomBarAnimator.start();
   }
   mShowing = false;
 }
Example #11
0
  private void updateState(String[] available, String[] tethered, String[] errored) {
    /// M: @{
    if (mUsbInternetSharing) {
      /// M: add for not update BT tether state
      updateBluetoothState(available, tethered, errored);
      mUsbTether.setEnabled(false);
      mBluetoothTether.setEnabled(false);
      Xlog.d(TAG, "usb internet is connected, return");
      return;
    }
    /// @}
    Xlog.d(
        TAG,
        "=======> updateState - mUsbConnected: "
            + mUsbConnected
            + ", mUsbConfigured:  "
            + mUsbConfigured
            + ", mUsbHwDisconnected: "
            + mUsbHwDisconnected
            + ", checked: "
            + mUsbTether.isChecked()
            + ", mUsbUnTetherDone: "
            + mUsbUnTetherDone
            + ", mUsbTetherDone: "
            + mUsbTetherDone
            + ", tetherfail: "
            + mUsbTetherFail
            + ", mIsPcKnowMe: "
            + mIsPcKnowMe);

    /** M: for bug solving, ALPS00331223 */
    // turn on tethering case
    if (mUsbTether.isChecked()) {
      if (mUsbConnected && mUsbConfigured && !mUsbHwDisconnected) {
        if (mUsbTetherFail || mUsbTetherDone || !mIsPcKnowMe) {
          mUsbTetherCheckEnable = true;
        }
      } else {
        mUsbTetherCheckEnable = false;
      }
    } else { // turn off tethering case or first launch case
      if (mUsbConnected && !mUsbHwDisconnected) {
        if (mUsbUnTetherDone || mUsbTetherFail) {
          mUsbTetherCheckEnable = true;
        }
      } else {
        mUsbTetherCheckEnable = false;
      }
    }

    updateUsbState(available, tethered, errored);
    updateBluetoothState(available, tethered, errored);
    /// M: @{
    if (FeatureOption.MTK_TETHERINGIPV6_SUPPORT) {
      updateIpv6Preference();
    }
    /// @}
  }
Example #12
0
  public WapPushFwkExt(Context context, int phoneId) {
    if (context == null) {
      Xlog.d(TAG, "FAIL! context is null");
      return;
    }

    mContext = context;
    mPhoneId = phoneId;
    Xlog.d(TAG, "call WapPushFwkExt constructor");
  }
 @Override
 public boolean checkPermission() {
   if (is4GDataOnly()) {
     startService();
     Xlog.d(TAG, "checkPermission result : false");
     return false;
   }
   Xlog.d(TAG, "checkPermission result : true");
   return true;
 }
  /**
   * Sets alarm on ACTION_BOOT_COMPLETED. Resets alarm on TIME_SET, TIMEZONE_CHANGED
   *
   * @param context Context
   * @param intent Intent
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Xlog.d(TAG, "AlarmInitReceiver" + action);

    if (context.getContentResolver() == null) {
      Xlog.e(TAG, "AlarmInitReceiver: FAILURE unable to get content resolver.  Alarms inactive.");
      return;
    }
    AlarmReceiverService.processBroadcastIntent(context, intent);
  }
Example #15
0
 private boolean isUMSEnabled() {
   if (mMountService == null) {
     Xlog.d(TAG, " mMountService is null, return");
     return false;
   }
   try {
     return mMountService.isUsbMassStorageEnabled();
   } catch (RemoteException e) {
     Xlog.e(TAG, "Util:RemoteException when isUsbMassStorageEnabled: " + e);
     return false;
   }
 }
Example #16
0
  /** for inheritence. */
  protected String getFillListQuery() {
    boolean isMVNO = false;
    try {
      ITelephony telephony =
          ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
      if (FeatureOption.MTK_MVNO_SUPPORT) {
        if (FeatureOption.MTK_GEMINI_SUPPORT) {
          isMVNO = telephony.isIccCardProviderAsMvnoGemini(mSimId);
        } else {
          isMVNO = telephony.isIccCardProviderAsMvno();
        }
      }
    } catch (android.os.RemoteException e) {
      Xlog.d(TAG, "RemoteException");
    }
    boolean flagImsi = false;
    boolean flagSpn = false;
    boolean flagPnn = false;
    String sqlStr = "";

    Xlog.d(TAG, "[isMVNO =" + isMVNO + "]");
    if (FeatureOption.MTK_MVNO_SUPPORT) {
      if (isMVNO) {
        if (mIMSI != null && !mIMSI.isEmpty()) {
          flagImsi = true;
          sqlStr += " imsi=\"" + mIMSI + "\"";
        }
        if (mSpn != null && !mSpn.isEmpty()) {
          flagSpn = true;
          if (flagImsi) {
            sqlStr += " or spn=\"" + mSpn + "\"";
          } else {
            sqlStr += " spn=\"" + mSpn + "\"";
          }
        }
        if (mPnn != null && !mPnn.isEmpty()) {
          flagPnn = true;
          if (flagImsi || flagSpn) {
            sqlStr += " or pnn=\"" + mPnn + "\"";
          } else {
            sqlStr += " pnn=\"" + mPnn + "\"";
          }
        }
      } else {
        sqlStr =
            "(spn is NULL or spn=\"\") and (imsi is NULL or imsi=\"\") and (pnn is NULL or pnn=\"\") ";
      }
    }
    String result = "numeric=\"" + mNumeric + "\" and ( " + sqlStr + ")";
    Xlog.e(TAG, "getFillListQuery result: " + result);
    return result;
  }
  @Override
  protected void onStop() {
    Xlog.i(TAG, "onStop");
    if (!mGoToMainEntry
        && !mDownloadInfo.getIfNeedRefresh()
        && mDownloadInfo.getActivityID() < 0
        && (MainEntry.getInstance() == null || !MainEntry.getInstance().isStarted())) {
      Xlog.v(TAG, "background, show new version notification");
      mNotifyManager.showNewVersionNotification();
    }

    super.onStop();
  }
Example #18
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mConnectivityManager =
        (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    Bundle bundle = this.getArguments();
    Xlog.d(TAG, "onCreate activity,bundle = " + bundle + ",this = " + this);

    if (bundle != null) {
      mSelectedSystemIndex = bundle.getInt(UsbSharingChoose.SYSTEM_TYPE);
    }
    Xlog.d(TAG, "index is " + mSelectedSystemIndex);
  }
  public static void setPendingMmsFailed(final Context context) {
    Xlog.d(MmsApp.TXN_TAG, "setPendingMmsFailed");
    Cursor cursor =
        PduPersister.getPduPersister(context)
            .getPendingMessages(Long.MAX_VALUE /*System.currentTimeMillis()*/);
    if (cursor != null) {
      try {
        int count = cursor.getCount();
        Xlog.d(MmsApp.TXN_TAG, "setPendingMmsFailed: Pending Message Size=" + count);

        if (count == 0) {
          return;
        }
        DefaultRetryScheme scheme = new DefaultRetryScheme(context, 100);
        ContentValues values = null;
        int columnIndex = 0;
        int columnType = 0;
        int id = 0;
        int type = 0;
        while (cursor.moveToNext()) {
          columnIndex = cursor.getColumnIndexOrThrow(PendingMessages._ID);
          id = cursor.getInt(columnIndex);

          columnType = cursor.getColumnIndexOrThrow(PendingMessages.MSG_TYPE);
          type = cursor.getInt(columnType);

          Xlog.d(MmsApp.TXN_TAG, "setPendingMmsFailed: type=" + type + "; MsgId=" + id);

          if (type == PduHeaders.MESSAGE_TYPE_SEND_REQ) {
            values = new ContentValues(2);
            values.put(PendingMessages.ERROR_TYPE, MmsSms.ERR_TYPE_GENERIC_PERMANENT);
            values.put(PendingMessages.RETRY_INDEX, scheme.getRetryLimit());
            SqliteWrapper.update(
                context,
                context.getContentResolver(),
                PendingMessages.CONTENT_URI,
                values,
                PendingMessages._ID + "=" + id,
                null);
          }
        }
      } catch (SQLiteDiskIOException e) {
        // Ignore
        Xlog.e(MmsApp.TXN_TAG, "SQLiteDiskIOException caught while set pending message failed", e);
      } finally {
        cursor.close();
      }
    } else {
      Xlog.d(MmsApp.TXN_TAG, "setPendingMmsFailed: no pending MMS.");
    }
  }
  public static void setNotificationIndUnstarted(final Context context) {
    Xlog.d(MmsApp.TXN_TAG, "setNotificationIndUnstarted");
    Cursor cursor =
        SqliteWrapper.query(
            context,
            context.getContentResolver(),
            Mms.CONTENT_URI,
            new String[] {Mms._ID, Mms.STATUS},
            Mms.MESSAGE_TYPE + "=" + PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND,
            null,
            null);
    if (cursor != null) {
      try {
        int count = cursor.getCount();
        Xlog.d(MmsApp.TXN_TAG, "setNotificationIndUnstarted: Message Size=" + count);

        if (count == 0) {
          return;
        }

        ContentValues values = null;
        int id = 0;
        int status = 0;
        while (cursor.moveToNext()) {
          id = cursor.getInt(0);
          status = cursor.getInt(1);
          Xlog.d(MmsApp.TXN_TAG, "setNotificationIndUnstarted: MsgId=" + id + "; status=" + status);

          if (DownloadManager.STATE_DOWNLOADING == (status & ~DownloadManager.DEFERRED_MASK)) {
            values = new ContentValues(1);
            values.put(Mms.STATUS, PduHeaders.STATUS_UNRECOGNIZED);
            SqliteWrapper.update(
                context,
                context.getContentResolver(),
                Mms.CONTENT_URI,
                values,
                Mms._ID + "=" + id,
                null);
          }
        }
      } catch (SQLiteDiskIOException e) {
        // Ignore
        Xlog.e(
            MmsApp.TXN_TAG, "SQLiteDiskIOException caught while set notification ind unstart", e);
      } finally {
        cursor.close();
      }
    } else {
      Xlog.d(MmsApp.TXN_TAG, "setNotificationIndUnstarted: no pending messages.");
    }
  }
  @Override
  public void onClick(View v) {
    boolean newValue = !isChecked();

    if (!newValue) {
      Xlog.d(TAG, "button.onClick return");
      return;
    }

    if (setChecked(newValue)) {
      callChangeListener(newValue);
      Xlog.d(TAG, "button.onClick");
    }
  }
Example #22
0
 private void setSpn() {
   try {
     ITelephony telephony =
         ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
     if (FeatureOption.MTK_GEMINI_SUPPORT) {
       mSpn = telephony.getSpNameInEfSpnGemini(mSimId);
     } else {
       mSpn = telephony.getSpNameInEfSpn();
     }
     Xlog.d(TAG, "spn = " + mSpn);
   } catch (android.os.RemoteException e) {
     Xlog.d(TAG, "RemoteException");
   }
 }
  public static void setPendingSmsFailed(final Context context) {
    Xlog.d(MmsApp.TXN_TAG, "setPendingSmsFailed");
    Cursor cursor =
        SqliteWrapper.query(
            context,
            context.getContentResolver(),
            Sms.CONTENT_URI,
            new String[] {Sms._ID},
            Sms.TYPE
                + "="
                + Sms.MESSAGE_TYPE_OUTBOX
                + " OR "
                + Sms.TYPE
                + "="
                + Sms.MESSAGE_TYPE_QUEUED,
            null,
            null);
    if (cursor != null) {
      try {
        int count = cursor.getCount();
        Xlog.d(MmsApp.TXN_TAG, "setPendingSmsFailed: Message Size=" + count);

        if (count == 0) {
          return;
        }

        ContentValues values = null;
        int id = 0;
        while (cursor.moveToNext()) {
          id = cursor.getInt(0);
          Xlog.d(MmsApp.TXN_TAG, "setPendingSmsFailed: MsgId=" + id);
          values = new ContentValues(1);
          values.put(Sms.TYPE, Sms.MESSAGE_TYPE_FAILED);
          SqliteWrapper.update(
              context,
              context.getContentResolver(),
              Sms.CONTENT_URI,
              values,
              Sms._ID + "=" + id,
              null);
        }
      } catch (SQLiteDiskIOException e) {
        Xlog.e(MmsApp.TXN_TAG, "SQLiteDiskIOException caught while set sms failed", e);
      } finally {
        cursor.close();
      }
    } else {
      Xlog.d(MmsApp.TXN_TAG, "setPendingSmsFailed: no pending messages.");
    }
  }
Example #24
0
  private void initSimState() {
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      Intent it = getIntent();
      mSimId = it.getIntExtra("simId", SIM_CARD_UNDEFINED);
      if (SIMInfo.getInsertedSIMCount(this) > 1) {
        SIMInfo siminfo = SIMInfo.getSIMInfoBySlot(this, mSimId);
        if (siminfo != null) {
          setTitle(siminfo.mDisplayName);
        }
      }
      Xlog.d(TAG, "GEMINI_SIM_ID_KEY = " + mSimId);
    } else {
      Xlog.w(TAG, "Not support GEMINI");
      mSimId = SIM_CARD_SINGLE;
    }
    switch (mSimId) {
      case SIM_CARD_SINGLE:
        mUri = Telephony.Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "-1");
        mDefaultApnUri = DEFAULTAPN_URI;
        mRestoreCarrierUri = PREFERAPN_URI;
        break;
      case SIM_CARD_1:
        mUri = Telephony.Carriers.SIM1Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "-1");
        mDefaultApnUri = DEFAULTAPN_URI_GEMINI_SIM1;
        mRestoreCarrierUri = PREFERAPN_URI_GEMINI_SIM1;
        break;
      case SIM_CARD_2:
        mUri = Telephony.Carriers.SIM2Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC_2, "-1");
        mDefaultApnUri = DEFAULTAPN_URI_GEMINI_SIM2;
        mRestoreCarrierUri = PREFERAPN_URI_GEMINI_SIM2;
        break;

      default:
        Xlog.i(TAG, "Incorrect sim id ");
        if (FeatureOption.MTK_GEMINI_SUPPORT) {
          Intent intent = new Intent();
          intent.setClassName("com.android.phone", "com.mediatek.settings.MultipleSimActivity");
          intent.putExtra("TARGET_CLASS", "com.android.settings.ApnSettings");
          startActivity(intent);
        }
        finish();
        break;
    }

    Xlog.d(TAG, "mNumeric " + mNumeric);
    Xlog.d(TAG, "mUri = " + mUri);
  }
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    Xlog.i(TAG, "mSelected = " + mSelected);
    Xlog.i(TAG, "mInitValue = " + mInitValue);
    if (positiveResult && mSelected >= 0 && (mSelected != mInitValue)) {

      Xlog.i(TAG, "callChangeListener");
      long value = mSimItemList.get(mSelected).mSimID;
      callChangeListener(value);
      mInitValue = mSelected;
    }
  }
  /**
   * Increases or decreases the brightness.
   *
   * @param context
   */
  private void toggleBrightness(Context context) {
    try {
      IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
      if (power != null) {
        ContentResolver cr = context.getContentResolver();
        int brightness = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
        int brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
        // Only get brightness setting if available
        if (context
            .getResources()
            .getBoolean(com.android.internal.R.bool.config_automatic_brightness_available)) {
          brightnessMode = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS_MODE);
        }

        // Rotate AUTO -> MINIMUM -> DEFAULT -> MAXIMUM
        // Technically, not a toggle...
        if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
          brightness = MINIMUM_BACKLIGHT;
          brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
        } else if (brightness < DEFAULT_BACKLIGHT) {
          brightness = DEFAULT_BACKLIGHT;
        } else if (brightness < MAXIMUM_BACKLIGHT) {
          brightness = MAXIMUM_BACKLIGHT;
        } else {
          brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
          brightness = MINIMUM_BACKLIGHT;
        }

        if (context
            .getResources()
            .getBoolean(com.android.internal.R.bool.config_automatic_brightness_available)) {
          // Set screen brightness mode (automatic or manual)
          Settings.System.putInt(
              context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, brightnessMode);
        } else {
          // Make sure we set the brightness if automatic mode isn't available
          brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
        }
        if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) {
          power.setBacklightBrightness(brightness);
          Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness);
        }
      }
    } catch (RemoteException e) {
      Xlog.d(TAG, "toggleBrightness: " + e);
    } catch (Settings.SettingNotFoundException e) {
      Xlog.d(TAG, "toggleBrightness: " + e);
    }
  }
Example #27
0
 private void setIMSI() {
   try {
     ITelephony telephony =
         ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
     if (FeatureOption.MTK_GEMINI_SUPPORT) {
       mIMSI = telephony.isOperatorMvnoForImsiGemini(mSimId);
     } else {
       mIMSI = telephony.isOperatorMvnoForImsi();
     }
     Xlog.d(TAG, "IMSI = " + mIMSI);
   } catch (android.os.RemoteException e) {
     Xlog.d(TAG, "RemoteException");
   }
   Xlog.d(TAG, "IMSI = " + mIMSI);
 }
Example #28
0
 private String getUsbMode() {
   String result = null;
   StringBuilder strBuilder = new StringBuilder();
   strBuilder.append("cat ");
   strBuilder.append(mPortFile);
   Xlog.v(TAG, "get current dramc cmd: " + strBuilder.toString());
   try {
     if (ShellExe.RESULT_SUCCESS == ShellExe.execCommand(strBuilder.toString(), true)) {
       result = ShellExe.getOutput();
     }
   } catch (IOException e) {
     Xlog.w(TAG, "get current dramc IOException: " + e.getMessage());
   }
   return result;
 }
Example #29
0
  public static synchronized IQuickSettingsPlugin getQuickSettingsPlugin(Context context) {
    if (mQuickSettingsPlugin == null) {
      mQuickSettingsPlugin =
          (IQuickSettingsPlugin)
              MPlugin.createInstance(IQuickSettingsPlugin.class.getName(), context);
      Xlog.d(TAG, "getQuickSettingsPlugin mQuickSettingsPlugin= " + mQuickSettingsPlugin);

      if (mQuickSettingsPlugin == null) {
        mQuickSettingsPlugin = new DefaultQuickSettingsPlugin(context);
        Xlog.d(
            TAG, "getQuickSettingsPlugin get DefaultQuickSettingsPlugin = " + mQuickSettingsPlugin);
      }
    }
    return mQuickSettingsPlugin;
  }
Example #30
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    addPreferencesFromResource(R.xml.apn_settings);
    getListView().setItemsCanFocus(true);

    mExt = Utils.getMiscPlugin(this);
    mRcseExt = Utils.getRcseApnPlugin(this);
    if (mRcseExt != null) {
      mRcseExt.addRcseOnlyApnStateChanged(mListener);
    } else {
      Xlog.d(TAG, "mApnPlugin is null");
    }
    initSimState();

    mMobileStateFilter = getIntentFilter();
    mReceiver = getBroadcastReceiver();
    mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    if (FeatureOption.MTK_MVNO_SUPPORT) {
      setSpn();
      setIMSI();
      setPnn();
    }
  }