public static ComponentName getErrorReportReceiver(
      Context context, String packageName, int appFlags) {
    // check if error reporting is enabled in secure settings
    int enabled =
        Settings.Secure.getInt(
            context.getContentResolver(), Settings.Secure.SEND_ACTION_APP_ERROR, 0);
    if (enabled == 0) {
      return null;
    }

    PackageManager pm = context.getPackageManager();

    // look for receiver in the installer package
    String candidate = pm.getInstallerPackageName(packageName);
    ComponentName result = getErrorReportReceiver(pm, packageName, candidate);
    if (result != null) {
      return result;
    }

    // if the error app is on the system image, look for system apps
    // error receiver
    if ((appFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
      candidate = SystemProperties.get(SYSTEM_APPS_ERROR_RECEIVER_PROPERTY);
      result = getErrorReportReceiver(pm, packageName, candidate);
      if (result != null) {
        return result;
      }
    }

    // if there is a default receiver, try that
    candidate = SystemProperties.get(DEFAULT_ERROR_RECEIVER_PROPERTY);
    return getErrorReportReceiver(pm, packageName, candidate);
  }
    private void setEnabledFunctions(String functions, boolean makeDefault) {

      // Do not update persystent.sys.usb.config if the device is booted up
      // with OEM specific mode.
      if (functions != null && makeDefault && !needsOemUsbOverride()) {

        if (mAdbEnabled) {
          functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
        } else {
          functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);
        }
        if (!mDefaultFunctions.equals(functions)) {
          if (!setUsbConfig("none")) {
            Slog.e(TAG, "Failed to disable USB");
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
            return;
          }
          // setting this property will also change the current USB state
          // via a property trigger
          SystemProperties.set("persist.sys.usb.config", functions);
          if (waitForState(functions)) {
            mCurrentFunctions = functions;
            mDefaultFunctions = functions;
          } else {
            Slog.e(TAG, "Failed to switch persistent USB config to " + functions);
            // revert to previous configuration if we fail
            SystemProperties.set("persist.sys.usb.config", mDefaultFunctions);
          }
        }
      } else {
        if (functions == null) {
          functions = mDefaultFunctions;
        }

        // Override with bootmode specific usb mode if needed
        functions = processOemUsbOverride(functions);

        if (mAdbEnabled) {
          functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
        } else {
          functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);
        }
        if (!mCurrentFunctions.equals(functions)) {
          if (!setUsbConfig("none")) {
            Slog.e(TAG, "Failed to disable USB");
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
            return;
          }
          if (setUsbConfig(functions)) {
            mCurrentFunctions = functions;
          } else {
            Slog.e(TAG, "Failed to switch USB config to " + functions);
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
          }
        }
      }
    }
  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;
  }
 // Returns the current state of the system property that controls
 // strictmode flashes.  One of:
 //    0: not explicitly set one way or another
 //    1: on
 //    2: off
 private int currentStrictModeActiveIndex() {
   if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) {
     return 0;
   }
   boolean enabled = SystemProperties.getBoolean(StrictMode.VISUAL_PROPERTY, false);
   return enabled ? 1 : 2;
 }
 @SmallTest
 public void testStressMemoryPropertyConsistency() throws Exception {
   for (int i = 0; i < 100; ++i) {
     SystemProperties.set(KEY, Long.toString(i));
     long ret = SystemProperties.getLong(KEY, -1);
     assertEquals(i, ret);
   }
 }
Exemple #6
0
 /**
  * Whether the SVLTE AP-IRAT Support.
  *
  * @return true if ap-irat support.
  */
 public static final boolean isApIratSupport() {
   if (SystemProperties.get("ro.mtk_svlte_support").equals("1")
       && !SystemProperties.get("ro.c2k.md.irat.support").equals("1")) {
     return true;
   } else {
     return false;
   }
 }
  public DisplayManagerService(Context context, Handler mainHandler, Handler uiHandler) {
    mContext = context;
    mHeadless = SystemProperties.get(SYSTEM_HEADLESS).equals("1");

    mHandler = new DisplayManagerHandler(mainHandler.getLooper());
    mUiHandler = uiHandler;
    mDisplayAdapterListener = new DisplayAdapterListener();
    mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false);

    mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER);
  }
  /**
   * Enable the keyguard if the settings are appropriate. Return true if all work that will happen
   * is done; returns false if the caller can wait for the keyguard to be shown.
   */
  private void doKeyguardLocked() {
    boolean bEnableKeyguard = SystemProperties.getBoolean("keyguard.enable", true);
    if (!bEnableKeyguard) return;

    // if another app is disabling us, don't show
    if (!mExternallyEnabled) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");

      // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes
      // for an occasional ugly flicker in this situation:
      // 1) receive a call with the screen on (no keyguard) or make a call
      // 2) screen times out
      // 3) user hits key to turn screen back on
      // instead, we reenable the keyguard when we know the screen is off and the call
      // ends (see the broadcast receiver below)
      // TODO: clean this up when we have better support at the window manager level
      // for apps that wish to be on top of the keyguard
      return;
    }

    // if the keyguard is already showing, don't bother
    if (mKeyguardViewManager.isShowing()) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
      return;
    }

    // if the setup wizard hasn't run yet, don't show
    final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", false);
    final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();
    final IccCard.State state = mUpdateMonitor.getSimState();
    final boolean lockedOrMissing =
        state.isPinLocked()
            || ((state == IccCard.State.ABSENT || state == IccCard.State.PERM_DISABLED)
                && requireSim);

    if (!lockedOrMissing && !provisioned) {
      if (DEBUG)
        Log.d(
            TAG,
            "doKeyguard: not showing because device isn't provisioned"
                + " and the sim is not locked or missing");
      return;
    }

    if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
      return;
    }

    if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
    showLocked();
  }
  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);
  }
  /**
   * Some dial strings in GSM are defined to do non-call setup things, such as modify or query
   * supplementary service settings (eg, call forwarding). These are generally referred to as "MMI
   * codes". We look to see if the dial string contains a valid MMI code (potentially with a dial
   * string at the end as well) and return info here.
   *
   * <p>If the dial string contains no MMI code, we return an instance with only "dialingNumber" set
   *
   * <p>Please see flow chart in TS 22.030 6.5.3.2
   */
  static GsmMmiCode newFromDialString(String dialString, GSMPhone phone, UiccCardApplication app) {
    Matcher m;
    GsmMmiCode ret = null;

    if (SystemProperties.getBoolean("ro.config.multimode_cdma", false)) {
      m = sPatternSuppServiceGlobalDev.matcher(dialString);
      if (m.matches()) {
        ret = new GsmMmiCode(phone, app);
        ret.action = makeEmptyNull(m.group(MATCH_GROUP_ACTION));
        String DialCode = makeEmptyNull(m.group(MATCH_GROUP_SERVICE_CODE));
        if (DialCode.equals(SC_GLOBALDEV_VM)) {
          ret.sc = SC_GLOBALDEV_VM;
          ret.dialingNumber = "+1" + phone.getMdn();
          return ret;
        } else if (DialCode.equals(SC_GLOBALDEV_CS)) {
          ret.sc = SC_GLOBALDEV_CS;
          ret.dialingNumber = GLOBALDEV_CS;
          return ret;
        } else if (DialCode.length() >= 3 && DialCode.startsWith(SC_GLOBALDEV_CLIR_INVK)) {
          // Dial "#31#PhoneNum" to invoke CLIR temporarily
          dialString = ACTION_DEACTIVATE + SC_CLIR + ACTION_DEACTIVATE + DialCode.substring(2);
        } else if (DialCode.length() >= 3 && DialCode.startsWith(SC_GLOBALDEV_CLIR_SUPP)) {
          // Dial "*31#PhoneNum" to suppress CLIR temporarily
          dialString = ACTION_ACTIVATE + SC_CLIR + ACTION_DEACTIVATE + DialCode.substring(2);
        }
      }
    }

    m = sPatternSuppService.matcher(dialString);

    // Is this formatted like a standard supplementary service code?
    if (m.matches()) {
      ret = new GsmMmiCode(phone, app);
      ret.poundString = makeEmptyNull(m.group(MATCH_GROUP_POUND_STRING));
      ret.action = makeEmptyNull(m.group(MATCH_GROUP_ACTION));
      ret.sc = makeEmptyNull(m.group(MATCH_GROUP_SERVICE_CODE));
      ret.sia = makeEmptyNull(m.group(MATCH_GROUP_SIA));
      ret.sib = makeEmptyNull(m.group(MATCH_GROUP_SIB));
      ret.sic = makeEmptyNull(m.group(MATCH_GROUP_SIC));
      ret.pwd = makeEmptyNull(m.group(MATCH_GROUP_PWD_CONFIRM));
      ret.dialingNumber = makeEmptyNull(m.group(MATCH_GROUP_DIALING_NUMBER));

    } else if (dialString.endsWith("#")) {
      // TS 22.030 sec 6.5.3.2
      // "Entry of any characters defined in the 3GPP TS 23.038 [8] Default Alphabet
      // (up to the maximum defined in 3GPP TS 24.080 [10]), followed by #SEND".

      ret = new GsmMmiCode(phone, app);
      ret.poundString = dialString;
    } else if (isTwoDigitShortCode(phone.getContext(), dialString)) {
      // Is a country-specific exception to short codes as defined in TS 22.030, 6.5.3.2
      ret = null;
    } else if (isShortCode(dialString, phone)) {
      // this may be a short code, as defined in TS 22.030, 6.5.3.2
      ret = new GsmMmiCode(phone, app);
      ret.dialingNumber = dialString;
    }

    return ret;
  }
 /**
  * while receiving one sms, check the sms count to see whether it reaches the max count.
  *
  * @param threadId
  * @param context
  * @param flag indicate the operator (increase/decrease)
  * @return true if the count is less than the max size, otherwise false.
  */
 public void isFull(Long threadId, Context context, int flag) {
   try {
     ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
     if (phone != null) {
       if (phone.isTestIccCard()
           || (Integer.parseInt(SystemProperties.get("gsm.gcf.testmode", "0")) == 2)) {
         Log.d(TAG, "Now using test icc card...");
         if (flag == OP_FLAG_INCREASE) {
           if (get(threadId, context) >= THREAD_MAX_SIZE) {
             Log.d(TAG, "Storage is full. send notification...");
             SmsManager.getDefault().setSmsMemoryStatus(false);
           }
         } else if (flag == OP_FLAG_DECREASE) {
           if (get(threadId, context) < THREAD_MAX_SIZE) {
             Log.d(TAG, "Storage is available. send notification...");
             SmsManager.getDefault().setSmsMemoryStatus(true);
           }
         }
       }
     } else {
       Log.d(TAG, "Telephony service is not available!");
     }
   } catch (Exception ex) {
     Log.e(TAG, " " + ex.getMessage());
   }
 }
  private void handleNitzTimeReceived(Parcel p) {
    String nitz = (String) responseString(p);
    // if (RILJ_LOGD) unsljLogRet(RIL_UNSOL_NITZ_TIME_RECEIVED, nitz);

    // has bonus long containing milliseconds since boot that the NITZ
    // time was received
    long nitzReceiveTime = p.readLong();

    Object[] result = new Object[2];

    String fixedNitz = nitz;
    String[] nitzParts = nitz.split(",");
    if (nitzParts.length == 4) {
      // 0=date, 1=time+zone, 2=dst, 3=garbage that confuses GsmServiceStateTracker (so remove it)
      fixedNitz = nitzParts[0] + "," + nitzParts[1] + "," + nitzParts[2] + ",";
    }

    result[0] = fixedNitz;
    result[1] = Long.valueOf(nitzReceiveTime);

    boolean ignoreNitz =
        SystemProperties.getBoolean(TelephonyProperties.PROPERTY_IGNORE_NITZ, false);

    if (ignoreNitz) {
      if (RILJ_LOGD) riljLog("ignoring UNSOL_NITZ_TIME_RECEIVED");
    } else {
      if (mNITZTimeRegistrant != null) {
        mNITZTimeRegistrant.notifyRegistrant(new AsyncResult(null, result, null));
      } else {
        // in case NITZ time registrant isnt registered yet
        mLastNITZTimeInfo = result;
      }
    }
  }
 @Override
 @ServiceThreadOnly
 protected int getPreferredAddress() {
   assertRunOnServiceThread();
   return SystemProperties.getInt(
       Constants.PROPERTY_PREFERRED_ADDRESS_PLAYBACK, Constants.ADDR_UNREGISTERED);
 }
 private void getIpoLedStatus() {
   if ("1".equals(SystemProperties.get("sys.ipo.ledon"))) {
     ipo_led_on = true;
   } else if ("0".equals(SystemProperties.get("sys.ipo.ledon"))) {
     ipo_led_off = true;
   }
   if (DEBUG) {
     Slog.d(
         TAG,
         ">>>>>>>getIpoLedStatus ipo_led_on = "
             + ipo_led_on
             + ",  ipo_led_off = "
             + ipo_led_off
             + "<<<<<<<");
   }
 }
  private static void initRndisAddress() {
    // configure RNDIS ethernet address based on our serial number using the same algorithm
    // we had been previously using in kernel board files
    final int ETH_ALEN = 6;
    int address[] = new int[ETH_ALEN];
    // first byte is 0x02 to signify a locally administered address
    address[0] = 0x02;

    String serial = SystemProperties.get("ro.serialno", "1234567890ABCDEF");
    int serialLength = serial.length();
    // XOR the USB serial across the remaining 5 bytes
    for (int i = 0; i < serialLength; i++) {
      address[i % (ETH_ALEN - 1) + 1] ^= (int) serial.charAt(i);
    }
    String addrString =
        String.format(
            Locale.US,
            "%02X:%02X:%02X:%02X:%02X:%02X",
            address[0],
            address[1],
            address[2],
            address[3],
            address[4],
            address[5]);
    try {
      FileUtils.stringToFile(RNDIS_ETH_ADDR_PATH, addrString);
    } catch (IOException e) {
      Slog.e(TAG, "failed to write to " + RNDIS_ETH_ADDR_PATH);
    }
  }
  /**
   * Invoked on each preference click in this hierarchy, overrides PreferenceActivity's
   * implementation. Used to make sure we track the preference click events.
   */
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    /** TODO: Refactor and get rid of the if's using subclasses */
    if (mGsmUmtsOptions != null && mGsmUmtsOptions.preferenceTreeClick(preference) == true) {
      return true;
    } else if (mCdmaOptions != null && mCdmaOptions.preferenceTreeClick(preference) == true) {
      if (Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {

        mClickedPreference = preference;

        // In ECM mode launch ECM app dialog
        startActivityForResult(
            new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
            REQUEST_CODE_EXIT_ECM);
      }
      return true;
    } else if (preference == mButtonPreferredNetworkMode) {
      // displays the value taken from the Settings.System
      int settingsNetworkMode = getPreferredNetworkMode();
      mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
      return true;
    } else {
      // if the button is anything but the simple toggle preference,
      // we'll need to disable all preferences to reject all click
      // events until the sub-activity's UI comes up.
      preferenceScreen.setEnabled(false);
      // Let the intents be launched by the Preference manager
      return false;
    }
  }
Exemple #17
0
 public static boolean isAdVideoFinish() {
   if ("1".equals(SystemProperties.get("mstar.videoadvert.finished", "0"))) {
     return true;
   } else {
     return false;
   }
 }
Exemple #18
0
  /**
   * @param preference The key for the Preference item
   * @param property The system property to fetch
   * @param alt The default value, if the property doesn't exist
   */
  private void setSummary(String preference, String property, String alt) {
    try {
      findPreference(preference).setSummary(SystemProperties.get(property, alt));
    } catch (RuntimeException e) {

    }
  }
 /**
  * Returns an identifier for the current build that can be used to detect likely changes to
  * framework resources. The build identifier is made of several distinct values:
  *
  * <p>build fingerprint/framework version name/file size of framework resources apk
  *
  * <p>Only the build fingerprint should be necessary on user builds but the other values are
  * useful to detect changes on eng builds during development.
  *
  * <p>This identifier does not attempt to be exact: a new identifier does not necessarily mean the
  * preloaded drawables have changed. It is important however that whenever the list of preloaded
  * drawables changes, this identifier changes as well.
  *
  * @see #checkBuildIdentifier(java.io.BufferedReader, String)
  */
 private String getBuildIdentifier(String versionName) {
   return SystemProperties.get("ro.build.fingerprint", "")
       + '/'
       + versionName
       + '/'
       + String.valueOf(getFrameworkResourcesFile().length());
 }
  public void onAccountsChanged(String[] accountsArray) {
    if (!"yes".equals(SystemProperties.get("ro.config.sync"))) {
      return;
    }

    // - Get a cursor (A) over all selected calendars over all accounts
    // - Get a cursor (B) over all subscribed feeds for calendar
    // - If an item is in A but not B then add a subscription
    // - If an item is in B but not A then remove the subscription

    ContentResolver cr = getContext().getContentResolver();
    Cursor cursorA = null;
    Cursor cursorB = null;
    try {
      cursorA =
          Calendar.Calendars.query(
              cr,
              null /* projection */,
              Calendar.Calendars.SELECTED + "=1",
              CALENDAR_KEY_SORT_ORDER);
      int urlIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars.URL);
      int accountIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars._SYNC_ACCOUNT);
      cursorB =
          SubscribedFeeds.Feeds.query(
              cr,
              FEEDS_KEY_COLUMNS,
              SubscribedFeeds.Feeds.AUTHORITY + "=?",
              new String[] {Calendar.AUTHORITY},
              FEEDS_KEY_SORT_ORDER);
      int urlIndexB = cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds.FEED);
      int accountIndexB = cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds._SYNC_ACCOUNT);
      for (CursorJoiner.Result joinerResult :
          new CursorJoiner(cursorA, CALENDAR_KEY_COLUMNS, cursorB, FEEDS_KEY_COLUMNS)) {
        switch (joinerResult) {
          case LEFT:
            SubscribedFeeds.addFeed(
                cr,
                cursorA.getString(urlIndexA),
                cursorA.getString(accountIndexA),
                Calendar.AUTHORITY,
                CalendarClient.SERVICE);
            break;
          case RIGHT:
            SubscribedFeeds.deleteFeed(
                cr,
                cursorB.getString(urlIndexB),
                cursorB.getString(accountIndexB),
                Calendar.AUTHORITY);
            break;
          case BOTH:
            // do nothing, since the subscription already exists
            break;
        }
      }
    } finally {
      // check for null in case an exception occurred before the cursors got created
      if (cursorA != null) cursorA.close();
      if (cursorB != null) cursorB.close();
    }
  }
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
     SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
     updateHdcpValues();
     pokeSystemProperties();
     return true;
   } else if (preference == mWindowAnimationScale) {
     writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
     return true;
   } else if (preference == mTransitionAnimationScale) {
     writeAnimationScaleOption(1, mTransitionAnimationScale, newValue);
     return true;
   } else if (preference == mAnimatorDurationScale) {
     writeAnimationScaleOption(2, mAnimatorDurationScale, newValue);
     return true;
   } else if (preference == mOverlayDisplayDevices) {
     writeOverlayDisplayDevicesOptions(newValue);
     return true;
   } else if (preference == mOpenGLTraces) {
     writeOpenGLTracesOptions(newValue);
     return true;
   } else if (preference == mEnableTracesPref) {
     writeEnableTracesOptions();
     return true;
   } else if (preference == mAppProcessLimit) {
     writeAppProcessLimitOptions(newValue);
     return true;
   }
   return false;
 }
  /* Sets the default subscription. If only one phone instance is active that
   * subscription is set as default subscription. If both phone instances
   * are active the first instance "0" is set as default subscription
   */
  public static void setDefaultSubscription(int subId) {
    SystemProperties.set(PROPERTY_DEFAULT_SUBSCRIPTION, Integer.toString(subId));
    int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

    synchronized (sLockProxyPhones) {
      // Set the default phone in base class
      if (phoneId >= 0 && phoneId < sProxyPhones.length) {
        sProxyPhone = sProxyPhones[phoneId];
        sCommandsInterface = sCommandsInterfaces[phoneId];
        sMadeDefaults = true;
      }
    }

    // Update MCC MNC device configuration information
    String defaultMccMnc = TelephonyManager.getDefault().getSimOperatorNumericForPhone(phoneId);
    if (DBG) Rlog.d(LOG_TAG, "update mccmnc=" + defaultMccMnc);
    MccTable.updateMccMncConfiguration(sContext, defaultMccMnc, false);

    // Broadcast an Intent for default sub change
    Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
    Rlog.d(
        LOG_TAG,
        "setDefaultSubscription : " + subId + " Broadcasting Default Subscription Changed...");
    sContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
  }
Exemple #23
0
 /**
  * Whether the svlte feature support.
  *
  * @return the svlte feature support or not
  */
 public static final boolean isMediatekSVLteDcSupport() {
   if (SystemProperties.get(MTK_SVLTE_SUPPORT).equals("1")) {
     return true;
   } else {
     return false;
   }
 }
 static {
   sInitialized = false;
   if (!SystemProperties.getBoolean("config.disable_renderscript", false)) {
     try {
       Class<?> vm_runtime = Class.forName("dalvik.system.VMRuntime");
       Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime");
       sRuntime = get_runtime.invoke(null);
       registerNativeAllocation =
           vm_runtime.getDeclaredMethod("registerNativeAllocation", Integer.TYPE);
       registerNativeFree = vm_runtime.getDeclaredMethod("registerNativeFree", Integer.TYPE);
     } catch (Exception e) {
       Log.e(LOG_TAG, "Error loading GC methods: " + e);
       throw new RSRuntimeException("Error loading GC methods: " + e);
     }
     try {
       System.loadLibrary("rs_jni");
       _nInit();
       sInitialized = true;
       sPointerSize = rsnSystemGetPointerSize();
     } catch (UnsatisfiedLinkError e) {
       Log.e(LOG_TAG, "Error loading RS jni library: " + e);
       throw new RSRuntimeException("Error loading RS jni library: " + e);
     }
   }
 }
    private EGLConfig chooseEglConfig() {
      EGLConfig[] configs = new EGLConfig[1];
      int[] configsCount = new int[1];
      int[] configSpec = getConfig(sDirtyRegions);

      // Debug
      final String debug = SystemProperties.get(PRINT_CONFIG_PROPERTY, "");
      if ("all".equalsIgnoreCase(debug)) {
        sEgl.eglChooseConfig(sEglDisplay, configSpec, null, 0, configsCount);

        EGLConfig[] debugConfigs = new EGLConfig[configsCount[0]];
        sEgl.eglChooseConfig(sEglDisplay, configSpec, debugConfigs, configsCount[0], configsCount);

        for (EGLConfig config : debugConfigs) {
          printConfig(config);
        }
      }

      if (!sEgl.eglChooseConfig(sEglDisplay, configSpec, configs, 1, configsCount)) {
        throw new IllegalArgumentException(
            "eglChooseConfig failed " + GLUtils.getEGLErrorString(sEgl.eglGetError()));
      } else if (configsCount[0] > 0) {
        if ("choice".equalsIgnoreCase(debug)) {
          printConfig(configs[0]);
        }
        return configs[0];
      }

      return null;
    }
  String getSimOperator() {
    String oprator = null;

    switch (mSlot) {
      case -1:
      case 0:
        oprator = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "-1");
        break;
      case 1:
        oprator = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC_2, "-1");
        break;
      default:
        break;
    }

    return oprator;
  }
  private boolean testEncrypt() {
    String devicetest = SystemProperties.get("ro.esky.devicetest");

    if (devicetest.equals("esky")) {
      return true;
    }
    return false;
  }
  private synchronized void onDunDialupReq() {
    ConnectivityManager connmgr;
    String response;
    String[] dnsServers;

    dnsServers = new String[2];
    connmgr = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo MobileInfo = connmgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    NetworkInfo WifiInfo = connmgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (MobileInfo == null && WifiInfo == null) {
      Log.w(TAG, "dialup request, get network info failed");
      response = "unknown";
      dunDialupRspNative(response, BLUETOOTH_IFACE_ADDR_START, dnsServers);
      return;
    }
    NetworkInfo.State MobileState = NetworkInfo.State.UNKNOWN;
    NetworkInfo.State WifiState = NetworkInfo.State.UNKNOWN;

    if (MobileInfo != null) MobileState = MobileInfo.getState();
    if (WifiInfo != null) WifiState = WifiInfo.getState();

    if (MobileState == NetworkInfo.State.CONNECTED || WifiState == NetworkInfo.State.CONNECTED) {
      NetworkInfo.State state =
          (MobileState == NetworkInfo.State.CONNECTED) ? MobileState : WifiState;
      if (DBG) log("startUsingNetworkFeature: (" + state + ")");
      response = "active";
      dnsServers[0] = SystemProperties.get("net.dns1");
      dnsServers[1] = SystemProperties.get("net.dns2");
      if (DBG) log("Network connected, DNS1=" + dnsServers[0] + ", " + "DNS2=" + dnsServers[1]);
      if (dnsServers[1].isEmpty()) {
        dnsServers[1] = "8.8.8.8";
      }
      if (DBG) log("Network connected, DNS2=" + dnsServers[1] + ", " + "DNS1=" + dnsServers[0]);
    } else if (MobileState == NetworkInfo.State.SUSPENDED
        || WifiState == NetworkInfo.State.SUSPENDED) {
      response = "busy";
    } else if (MobileState == NetworkInfo.State.DISCONNECTED
        || WifiState == NetworkInfo.State.DISCONNECTED) {
      response = "unavailable";
    } else {
      response = "unknown";
    }
    if (DBG) log("dunDialupRspNative response: (" + response + ")");
    dunDialupRspNative(response, BLUETOOTH_IFACE_ADDR_START, dnsServers);
  }
 private int getPhoneTypeFromNetworkType() {
   // When the system property CURRENT_ACTIVE_PHONE, has not been set,
   // use the system property for default network type.
   // This is a fail safe, and can only happen at first boot.
   int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
   if (mode == -1) return PHONE_TYPE_NONE;
   return PhoneFactory.getPhoneType(mode);
 }
 private String getDefaultFunctions() {
   String func =
       SystemProperties.get(USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE);
   if (UsbManager.USB_FUNCTION_NONE.equals(func)) {
     func = UsbManager.USB_FUNCTION_MTP;
   }
   return func;
 }