예제 #1
0
  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;
  }
예제 #2
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;
 }
  @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;
    }
  }
예제 #4
0
 @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);
 }
  @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");
  }
 @Override
 public ImageView getIndicatorView() {
   // TODO Auto-generated method stub
   ImageView imageView;
   imageView = mBrightnessIcon.getIndicatorView();
   boolean brightnessMode = getBrightnessMode(mContext);
   if (DBG) {
     Xlog.i(TAG, "Brightnesst getIndicatorView: brightnessMode is " + brightnessMode);
   }
   if (brightnessMode) {
     imageView.setImageDrawable(null);
     return imageView;
   }
   int brightness = getBrightness(mContext);
   switch (brightness) {
     case DEFAULT_BACKLIGHT:
       imageView.setImageResource(R.drawable.zzz_light_middle);
       break;
     case MAXIMUM_BACKLIGHT:
       imageView.setImageResource(R.drawable.zzz_light_fully);
       break;
     case MINIMUM_BACKLIGHT:
       imageView.setImageResource(R.drawable.zzz_light_low);
       break;
   }
   return imageView;
 }
예제 #7
0
 private boolean isVoiceCapable() {
   TelephonyManager telephony =
       (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
   boolean bVoiceCapable = (telephony != null && telephony.isVoiceCapable());
   Xlog.i(TAG, "sIsVoiceCapable : " + bVoiceCapable);
   return bVoiceCapable;
 }
  public boolean onPreferenceChange(Preference arg0, Object arg1) {

    final String key = arg0.getKey();

    if (KEY_NETWORK_MODE_SETTING.equals(key)) {

      int oldNetworkMode =
          android.provider.Settings.Secure.getInt(
              getContentResolver(), Settings.Secure.PREFERRED_NETWORK_MODE, preferredNetworkMode);

      int newNetworkMode = Integer.valueOf((String) arg1).intValue();

      newNetworkMode = GeminiUtils.getNetworkMode(newNetworkMode);

      Settings.Secure.putInt(
          getContentResolver(), Settings.Secure.PREFERRED_NETWORK_MODE, newNetworkMode);

      if (newNetworkMode != oldNetworkMode) {

        Intent intent = new Intent(GeminiUtils.NETWORK_MODE_CHANGE_BROADCAST, null);
        intent.putExtra(GeminiUtils.OLD_NETWORK_MODE, oldNetworkMode);
        intent.putExtra(GeminiUtils.NETWORK_MODE_CHANGE_BROADCAST, newNetworkMode);
        intent.putExtra(Phone.GEMINI_SIM_ID_KEY, Phone.GEMINI_SIM_1);
        showDialog(DIALOG_NETWORK_MODE_CHANGE);
        setCancelable(false);
        getActivity().sendBroadcast(intent);
        Xlog.i(TAG, "Send broadcast of " + GeminiUtils.NETWORK_MODE_CHANGE_BROADCAST);
      }
    }
    return true;
  }
  @Override
  protected void onDestroy() {
    Xlog.i(TAG, "onDestroy");
    unregisterReceiver(mReceiver);

    sInstance = null;
    super.onDestroy();
  }
 @Override
 protected void onStart() {
   super.onStart();
   Xlog.i(TAG, "onStart");
   OtaPkgManagerActivity.stopSelf();
   mGoToMainEntry = false;
   mNotifyManager.clearNotification(NotifyManager.NOTIFY_NEW_VERSION);
 }
  protected void tearDown() throws Exception {

    if (mActivity != null) {
      mActivity.finish();
      Xlog.i(TAG, "activity finish");
    }
    super.tearDown();
  }
예제 #12
0
 public static final int i(String tag, String msg, Throwable tr) {
   int result;
   if (SR_XLOG_ENABLED) {
     result = Xlog.i(tag, msg, tr);
   } else {
     result = Log.i(tag, msg, tr);
   }
   return result;
 }
  private String getTxInfoByIface(String iface) {
    Method method = null;
    String infoTxString = "";
    String infoRxString = "";
    Long packetTxSize = (long) 0, byteTxSize = (long) 0;
    Long packetRxSize = (long) 0, byteRxSize = (long) 0;

    try {
      method = TrafficStats.class.getDeclaredMethod("getTxPackets", String.class);
      packetTxSize = (Long) method.invoke(null, iface);
      method = TrafficStats.class.getDeclaredMethod("getTxBytes", String.class);
      byteTxSize = (Long) method.invoke(null, iface);
      infoTxString =
          "TX pacekts:"
              + packetTxSize
              + " bytes:"
              + byteTxSize
              + " ("
              + byteTxSize / 1024
              + " KBytes)";

      Xlog.i(TAG, infoTxString);

      method = TrafficStats.class.getDeclaredMethod("getRxPackets", String.class);
      packetRxSize = (Long) method.invoke(null, iface);
      method = TrafficStats.class.getDeclaredMethod("getRxBytes", String.class);
      byteRxSize = (Long) method.invoke(null, iface);
      infoRxString =
          "RX pacekts:"
              + packetRxSize
              + " bytes:"
              + byteRxSize
              + " ("
              + byteRxSize / 1024
              + " KBytes)";

      Xlog.i(TAG, infoTxString);

    } catch (Exception e) {
      e.printStackTrace();
    }
    return infoTxString + "\r\n" + infoRxString;
  }
  /*
   * Test the download function when new version detected
   */
  public void testcase01_NewVersionLayout() {
    Xlog.i(TAG, "start1 ");
    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_NEWVERSION_READY).commit();
    mPreference.edit().putString(OTA_ANDR_VER, ANDROID_VER_TEST).commit();
    mPreference.edit().putString(OTA_PRE_VER, LOAD_VER_TEST).commit();
    mActivity = getActivity();

    TextView textAndroidVer = (TextView) mActivity.findViewById(R.id.textAndroidNum);

    assertTrue(textAndroidVer != null);

    Xlog.i(TAG, textAndroidVer.getText().toString());

    assertTrue(ANDROID_VER_TEST.equals(textAndroidVer.getText()));

    TextView textLoadVer = (TextView) mActivity.findViewById(R.id.textVerNum);

    assertTrue(textLoadVer != null);
  }
 /**
  * Increases or decreases the brightness.
  *
  * @param context
  */
 private void toggleTimeout(Context context) {
   try {
     ContentResolver cr = context.getContentResolver();
     int timeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
     if (DBG) {
       Xlog.i(TAG, "toggleTimeout, before is " + timeout);
     }
     if (timeout <= MINIMUM_TIMEOUT) {
       timeout = MEDIUM_TIMEOUT;
     } else if (timeout <= MEDIUM_TIMEOUT) {
       timeout = MAXIMUM_TIMEOUT;
     } else {
       timeout = MINIMUM_TIMEOUT;
     }
     Settings.System.putInt(cr, Settings.System.SCREEN_OFF_TIMEOUT, timeout);
     if (DBG) {
       Xlog.i(TAG, "toggleTimeout, after is " + timeout);
     }
   } catch (Exception e) {
     Xlog.d(TAG, "toggleTimeout: " + e);
   }
 }
  @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();
  }
예제 #17
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
  public void onBindView(View view) {

    super.onBindView(view);

    TextView textSummary = (TextView) view.findViewById(android.R.id.summary);

    if (textSummary != null) {
      textSummary.setSingleLine();
      textSummary.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    }

    Xlog.i(TAG, "summary is +" + this.getSummary());
  }
        @Override
        public void onReceive(Context context, Intent intent) {

          String action = intent.getAction();

          if (action.equals(TelephonyIntents.ACTION_SIM_INDICATOR_STATE_CHANGED)) {

            int slotId = intent.getIntExtra(TelephonyIntents.INTENT_KEY_ICC_SLOT, -1);
            int simStatus = intent.getIntExtra(TelephonyIntents.INTENT_KEY_ICC_STATE, -1);
            Xlog.i(TAG, "receive notification of  sim slot = " + slotId + " status = " + simStatus);

            if ((slotId == Phone.GEMINI_SIM_1) && (simStatus >= 0)) {
              mNetworkMode.setStatus(simStatus);
            }

          } else if (action.equals(GeminiUtils.NETWORK_MODE_CHANGE_RESPONSE)) {

            if (!intent.getBooleanExtra(GeminiUtils.NETWORK_MODE_CHANGE_RESPONSE, true)) {
              Xlog.i(TAG, "BroadcastReceiver: network mode change failed! restore the old value.");
              android.provider.Settings.Secure.putInt(
                  getContentResolver(),
                  android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
                  intent.getIntExtra(OLD_NETWORK_MODE, 0));
            } else {
              Xlog.i(TAG, "BroadcastReceiver: network mode change succeed! set the new value.");
              android.provider.Settings.Secure.putInt(
                  getContentResolver(),
                  android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
                  intent.getIntExtra(GeminiUtils.NEW_NETWORK_MODE, 0));
            }

            if (isDialogShowing(DIALOG_NETWORK_MODE_CHANGE)) {
              removeDialog(DIALOG_NETWORK_MODE_CHANGE);
            }
          }
        }
  public void testcase03_DownloadingPaused() {

    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_PAUSEDOWNLOAD).commit();
    mPreference.edit().putInt(OTA_PRE_DELTA_ID, PKG_ID_TEST).commit();
    mActivity = getActivity();

    ProgressBar dlRatioProgressBar = (ProgressBar) mActivity.findViewById(R.id.downloaingProBar);

    assertTrue(dlRatioProgressBar != null);
    assertTrue(dlRatioProgressBar.isShown());

    Xlog.i(TAG, "OTA_PRE_STATUS = " + mPreference.getInt(OTA_PRE_STATUS, -1));
    if (Util.isSdcardAvailable(mActivity) && Util.isNetWorkAvailable(mActivity, "WIFI")) {
      assertTrue(mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_PAUSEDOWNLOAD);
    }
  }
  public void testcase02_NewVersionDl() {

    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_NEWVERSION_READY).commit();
    mPreference.edit().putInt(OTA_PRE_DELTA_ID, PKG_ID_TEST).commit();
    mActivity = getActivity();

    mInst.invokeMenuActionSync(mActivity, MENU_ID_DOWNLOAD, 0);
    mInst.waitForIdleSync();

    Xlog.i(TAG, "OTA_PRE_STATUS = " + mPreference.getInt(OTA_PRE_STATUS, -1));
    if (Util.isSdcardAvailable(mActivity) && Util.isNetWorkAvailable(mActivity, "WIFI")) {
      assertTrue(
          mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_DOWNLOADING
              || mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_PAUSEDOWNLOAD);
    }
  }
        @Override
        public void handleMessage(Message msg) {
          Xlog.i(TAG, "handleMessage msg.what = " + msg.what);

          switch (msg.what) {
            case SystemUpdateService.MSG_SDCARDUNKNOWNERROR:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }

              showDialog(DIALOG_NOSDCARD);
              break;
            case SystemUpdateService.MSG_SDCARDINSUFFICENT:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }
              showDialog(DIALOG_NOENOUGHSPACE);
              break;
            case SystemUpdateService.MSG_SDCARDPACKAGEINVALIDATE:
              showDialog(DIALOG_INVALIDATEPACKAGE);
              break;
            case SystemUpdateService.MSG_UNKNOWERROR:
              showDialog(DIALOG_UNKNOWN_ERROR);
              break;
            case SystemUpdateService.MSG_UNZIP_LODING:
              showDialog(DIALOG_UNZIPPING);
              break;
            case SystemUpdateService.MSG_CKSUM_ERROR:
            case SystemUpdateService.MSG_UNZIP_ERROR:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }
              mOTADialogTitleResId = R.string.package_unzip_error;
              mOTADialogMessageResId = R.string.package_error_message_invalid;
              showDialog(DIALOG_OTARESULT);
              break;
            default:
              super.handleMessage(msg);
          }
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Xlog.i(TAG, "onCreate");

    sInstance = this;

    setContentView(R.layout.sd_package_ready);
    this.getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    updateUi(intent);
    mDownloadInfo = DownloadInfo.getInstance(getApplicationContext());
    mNotifyManager = new NotifyManager(this);
    IntentFilter filter = new IntentFilter();
    filter.addAction(Util.Action.ACTION_MEDIA_MOUNT_UPDATEUI);
    filter.addAction(Util.Action.ACTION_MEDIA_UNMOUNT_UPDATEUI);
    registerReceiver(mReceiver, filter);
    mInstallBtn = (Button) this.findViewById(R.id.btn_install);
    mInstallBtn.setOnClickListener(mInstallListener);
  }
 @Override
 public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
   Xlog.i(TAG, "positon is " + position);
   if (v != null) {
     if (!v.isEnabled()) {
       return;
     } else {
       SimItem simItem = mSimItemList.get(position);
       if ((mType == GeminiUtils.TYPE_GPRS)
           && (simItem.mIsSim)
           && (mCellConnMgr != null)
           && (simItem.mState == PhoneConstants.SIM_INDICATOR_LOCKED)) {
         mCellConnMgr.handleCellConn(simItem.mSlot, PIN1_REQUEST_CODE);
       } else {
         mSelected = position;
         onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
         getDialog().dismiss();
       }
     }
   }
 }
예제 #25
0
 void show() {
   // Xlog.i(TAG, "bottom bar show(), showing: " + mShowing + "IME: " + mIMEShow);
   cancelBottomBarAnimation();
   if (mUseQuickControls || mUseFullScreen) {
     this.setVisibility(View.GONE);
     mShowing = false;
     return;
   } else if (!mShowing /* && !mIMEShow*/) {
     this.setVisibility(View.VISIBLE);
     int visibleHeight = getVisibleBottomHeight();
     float startPos = getTranslationY();
     Xlog.i(
         TAG,
         "bottombar show(): visibleHeight: " + visibleHeight + " show(): startPos: " + startPos);
     this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
     mBottomBarAnimator =
         ObjectAnimator.ofFloat(this, "translationY", startPos, startPos - visibleHeight);
     setupBottomBarAnimator(mBottomBarAnimator);
     mBottomBarAnimator.start();
     mShowing = true;
   }
 }
예제 #26
0
  private void initMediaDuration(Uri uri) throws MmsException {
    if (uri == null) {
      throw new IllegalArgumentException("Uri may not be null.");
    }

    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    int duration = 0;
    try {
      retriever.setDataSource(mContext, uri);
      String dur = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
      if (dur != null) {
        duration = Integer.parseInt(dur);
      }
      mDuration = duration;
      Xlog.i(TAG, "Got audio duration:" + duration);
    } catch (Exception ex) {
      Xlog.e(TAG, "MediaMetadataRetriever failed to get duration for " + uri.getPath(), ex);
      throw new MmsException(ex);
    } finally {
      retriever.release();
    }
  }
예제 #27
0
 public static void startSimEditor(SettingsPreferenceFragment fragment, Bundle extras) {
   Activity activity = fragment.getActivity();
   if (activity.getIntent().getBooleanExtra(EXTRA_IS_OOBE, false)) {
     Intent intent = new Intent(activity, SetupWizardForOobe.class);
     intent.putExtra(EXTRA_IS_OOBE, true);
     intent.putExtra(EXTRA_OOBE_SETTINGS, ID_SIM_INFO_EDITOR);
     intent.putExtra(
         OOBE_BASIC_STEP_TOTAL, activity.getIntent().getIntExtra(OOBE_BASIC_STEP_TOTAL, 1));
     intent.putExtra(
         OOBE_BASIC_STEP_INDEX, activity.getIntent().getIntExtra(OOBE_BASIC_STEP_INDEX, 0));
     intent.putExtras(extras);
     activity.startActivity(intent);
     activity.overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out);
   } else {
     fragment.startFragment(
         fragment,
         SimInfoEditor.class.getCanonicalName(),
         -1,
         extras,
         R.string.gemini_sim_info_title);
     Xlog.i(TAG, "startFragment " + SimInfoEditor.class.getCanonicalName());
   }
 }
 /**
  * Gets state of brightness.
  *
  * @param context
  * @return true if more than moderately bright.
  */
 public static int getBrightness(Context context) {
   if (DBG) {
     Xlog.i(TAG, "getBrightness called.");
   }
   try {
     IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
     if (power != null) {
       int brightness =
           Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
       if (brightness <= MINIMUM_BACKLIGHT) {
         brightness = MINIMUM_BACKLIGHT;
       } else if (brightness <= DEFAULT_BACKLIGHT) {
         brightness = DEFAULT_BACKLIGHT;
       } else {
         brightness = MAXIMUM_BACKLIGHT;
       }
       return brightness;
     }
   } catch (Exception e) {
     Xlog.d(TAG, "getBrightness: " + e);
   }
   return DEFAULT_BACKLIGHT;
 }
예제 #29
0
  private void fillList(int simId) {
    String where = getFillListQuery();
    Xlog.e(TAG, "fillList where: " + where);

    if (mUri == null) {
      Xlog.e(TAG, "fillList, mUri null !");
      finish();
      return;
    }
    Cursor cursor =
        getContentResolver()
            .query(
                mUri, new String[] {"_id", "name", "apn", "type", "sourcetype"}, where, null, null);

    PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
    apnList.removeAll();

    ArrayList<Preference> mmsApnList = new ArrayList<Preference>();

    boolean keySetChecked = false;

    mSelectedKey = getSelectedApnKey();
    Xlog.d(TAG, "fillList : mSelectedKey = " + mSelectedKey);

    cursor.moveToFirst();

    while (!cursor.isAfterLast()) {
      String type = cursor.getString(TYPES_INDEX);

      if (mIsTetherApn && !TETHER_TYPE.equals(type)) {
        cursor.moveToNext();
        continue;
      }

      String name = cursor.getString(NAME_INDEX);
      String apn = cursor.getString(APN_INDEX);
      String key = cursor.getString(ID_INDEX);

      int sourcetype = cursor.getInt(SOURCE_TYPE_INDEX);

      if ("cmmail".equals(apn) && sourcetype == 0) {
        cursor.moveToNext();
        continue;
      }
      if (RCSE_TYPE.equals(type) && mRcseExt != null) {
        if (!mRcseExt.isRcseOnlyApnEnabled()) {
          cursor.moveToNext();
          Xlog.d(TAG, "Vodafone not matched");
          continue;
        } else {
          Xlog.d(TAG, "Vodafone matched");
        }
      }

      ApnPreference pref = new ApnPreference(this);

      pref.setSimId(simId); // set pre sim id info to the ApnEditor
      pref.setKey(key);
      pref.setTitle(name);
      pref.setSummary(apn);
      pref.setPersistent(false);
      pref.setSourceType(sourcetype);
      pref.setOnPreferenceChangeListener(this);

      boolean isEditable = mExt.isAllowEditPresetApn(type, apn, mNumeric);
      pref.setApnEditable((sourcetype != 0) || isEditable);

      // All tether apn will be selectable for otthers , mms will not be selectable.
      boolean selectable = true;
      if (TETHER_TYPE.equals(type)) {
        selectable = mIsTetherApn;
      } else {
        selectable = !"mms".equals(type);
      }
      pref.setSelectable(selectable);

      if (selectable) {
        if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
          pref.setChecked();
          keySetChecked = true;
          Xlog.d(TAG, "apn key: " + key + " set.");
        }
        apnList.addPreference(pref);
        Xlog.i(TAG, "key:  " + key + " added!");
      } else {
        mmsApnList.add(pref);
      }
      cursor.moveToNext();
    }
    cursor.close();

    mSelectableApnCount = apnList.getPreferenceCount();
    // if no key selected, choose the 1st one.
    if (!keySetChecked && mSelectableApnCount > 0) {
      int[] sourceTypeArray = new int[mSelectableApnCount];
      for (int i = 0; i < mSelectableApnCount; i++) {
        sourceTypeArray[i] = ((ApnPreference) apnList.getPreference(i)).getSourceType();
      }
      ApnPreference apnPref =
          (ApnPreference) mExt.getApnPref(apnList, mSelectableApnCount, sourceTypeArray);
      if (apnPref != null) {
        setSelectedApnKey(apnPref.getKey());
        apnPref.setChecked();
        Xlog.i(TAG, "Key does not match.Set key: " + apnPref.getKey() + ".");
      }
    }

    if (!mIsTetherApn) {
      for (Preference preference : mmsApnList) {
        apnList.addPreference(preference);
      }
    }
    getPreferenceScreen().setEnabled(getScreenEnableState());
  }
예제 #30
0
  public void initModelFromFileUri(Uri uri) throws MmsException {
    String path = uri.getPath();
    mSrc = path.substring(path.lastIndexOf('/') + 1);
    Xlog.i(TAG, "AudioModel mSrc: " + mSrc);
    if (mSrc.startsWith(".") && mSrc.length() > 1) {
      mSrc = mSrc.substring(1);
    }

    // Some MMSCs appear to have problems with filenames
    // containing a space.  So just replace them with
    // underscores in the name, which is typically not
    // visible to the user anyway.
    mSrc = mSrc.replace(' ', '_');
    // mUri = uri;

    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    String extension = MimeTypeMap.getFileExtensionFromUrl(path).toLowerCase();
    if (TextUtils.isEmpty(extension)) {
      // getMimeTypeFromExtension() doesn't handle spaces in filenames nor can it handle
      // urlEncoded strings. Let's try one last time at finding the extension.
      int dotPos = path.lastIndexOf('.');
      if (0 <= dotPos) {
        extension = path.substring(dotPos + 1);
        extension = extension.toLowerCase();
      }
    }
    Xlog.i(TAG, "AudioModel extension: " + extension);
    mContentType = mimeTypeMap.getMimeTypeFromExtension(extension);
    if (mContentType == null) {
      // set default content type to "application/octet-stream"
      mContentType = "application/octet-stream";
      if (extension != null && extension.equals("dcf")) {
        DrmManagerClient drmManager = new DrmManagerClient(mContext);
        mContentType = drmManager.getOriginalMimeType(path);
      }
    }
    Xlog.i(TAG, "AudioModel got mContentType: " + mContentType);
    if (mContentType != null && mContentType.startsWith("video/")) {
      String temp = mContentType.substring(mContentType.lastIndexOf('/') + 1);
      mContentType = "audio/";
      mContentType += temp;
    }
    Xlog.i(TAG, "AudioModel mContentType: " + mContentType);
    // initMediaDuration

    if (path != null) {
      Xlog.i(TAG, "Audio Path: " + path);
      ContentResolver cr = mContext.getContentResolver();
      Cursor c =
          cr.query(
              MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
              new String[] {MediaStore.MediaColumns._ID},
              MediaStore.MediaColumns.DATA + "=?",
              new String[] {path},
              null);
      if (c != null) {
        try {
          if (c.moveToFirst()) {
            Uri audioUri =
                Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, c.getString(0));
            Xlog.i(TAG, "Get audio id in MediaStore:" + c.getString(0));
            initMediaDuration(audioUri);
          } else {
            Xlog.i(TAG, "MediaStore has not this audio");
          }
        } finally {
          c.close();
        }
      } else {
        throw new MmsException("Bad URI: " + uri);
      }
    }
  }