private String getCustomText() {
    String mCustomURI =
        Settings.System.getString(
            mContext.getContentResolver(), Settings.System.QUICK_SETTINGS_CUSTOM);
    String text = "";
    try {
      text =
          "Custom ("
              + mPm.resolveActivity(Intent.parseUri(mCustomURI, 0), 0).activityInfo.loadLabel(mPm)
              + ")";
    } catch (Exception e) {
      return "Custom";
    }

    return text;
  }
  private Drawable getCustomDrawable() {
    String mCustomURI =
        Settings.System.getString(
            mContext.getContentResolver(), Settings.System.QUICK_SETTINGS_CUSTOM);
    Drawable customIcon = null;
    try {
      customIcon = CustomIconUtil.getInstance(mContext).loadFromFile();
      if (customIcon == null) {
        customIcon = mPm.getActivityIcon(Intent.parseUri(mCustomURI, 0));
      }
    } catch (Exception e) {
      e.printStackTrace();
      return getIconDrawable("");
    }

    return customIcon;
  }
  private void updateGlowTimesSummary() {
    int resId;
    String combinedTime =
        Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[1])
            + "|"
            + Settings.System.getString(
                mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[0]);

    String[] glowArray = getResources().getStringArray(R.array.glow_times_values);

    if (glowArray[0].equals(combinedTime)) {
      resId = R.string.glow_times_off;
      mGlowTimes.setValueIndex(0);
    } else if (glowArray[1].equals(combinedTime)) {
      resId = R.string.glow_times_superquick;
      mGlowTimes.setValueIndex(1);
    } else if (glowArray[2].equals(combinedTime)) {
      resId = R.string.glow_times_quick;
      mGlowTimes.setValueIndex(2);
    } else {
      resId = R.string.glow_times_normal;
      mGlowTimes.setValueIndex(3);
    }
    mGlowTimes.setSummary(getResources().getString(resId));
  }
  public KeyguardViewMediator(
      Context context, PhoneWindowManager callback, LocalPowerManager powerManager) {
    mContext = context;

    mRealPowerManager = powerManager;
    mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock =
        mPM.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
    mWakeLock.setReferenceCounted(false);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);

    mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
    mWakeAndHandOff.setReferenceCounted(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(DELAYED_KEYGUARD_ACTION);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    context.registerReceiver(mBroadCastReceiver, filter);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mCallback = callback;

    mUpdateMonitor = new KeyguardUpdateMonitor(context);

    mUpdateMonitor.registerInfoCallback(this);
    mUpdateMonitor.registerSimStateCallback(this);

    mLockPatternUtils = new LockPatternUtils(mContext);
    mKeyguardViewProperties =
        new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);

    mKeyguardViewManager =
        new KeyguardViewManager(
            context, WindowManagerImpl.getDefault(), this, mKeyguardViewProperties, mUpdateMonitor);

    mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
    mUserPresentIntent.addFlags(
        Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);

    final ContentResolver cr = mContext.getContentResolver();
    mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);

    mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    String soundPath = Settings.System.getString(cr, Settings.System.LOCK_SOUND);
    if (soundPath != null) {
      mLockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mLockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
    soundPath = Settings.System.getString(cr, Settings.System.UNLOCK_SOUND);
    if (soundPath != null) {
      mUnlockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mUnlockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
  }
 private void updateQuietHoursSummary() {
   ContentResolver resolver = getContentResolver();
   if (Settings.System.getInt(resolver, Settings.System.QUIET_HOURS_ENABLED, 0) == 1) {
     String start = Settings.System.getString(resolver, Settings.System.QUIET_HOURS_START);
     String end = Settings.System.getString(resolver, Settings.System.QUIET_HOURS_END);
     mQuietHours.setSummary(
         getString(R.string.quiet_hours_active_period, returnTime(start), returnTime(end)));
   } else {
     mQuietHours.setSummary(getString(R.string.quiet_hours_summary));
   }
 }
 private void loadButtons() {
   mNumberofButtons =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_BUTTONS_QTY, 3);
   mButtons.clear();
   for (int i = 0; i < mNumberofButtons; i++) {
     String click =
         Settings.System.getString(mContentRes, Settings.System.NAVIGATION_CUSTOM_ACTIVITIES[i]);
     String longclick =
         Settings.System.getString(
             mContentRes, Settings.System.NAVIGATION_LONGPRESS_ACTIVITIES[i]);
     String iconuri =
         Settings.System.getString(mContentRes, Settings.System.NAVIGATION_CUSTOM_APP_ICONS[i]);
     mButtons.add(new NavBarButton(click, longclick, iconuri));
   }
 }
Exemplo n.º 7
0
 // set wallpaper as background
 private void setBackground(Context bcontext, ViewGroup layout) {
   // Settings.System.LOCKSCREEN_BACKGROUND
   String mLockBack =
       Settings.System.getString(bcontext.getContentResolver(), "lockscreen_background");
   if (mLockBack != null) {
     if (!mLockBack.isEmpty()) {
       try {
         layout.setBackgroundColor(Integer.parseInt(mLockBack));
       } catch (NumberFormatException e) {
       }
     } else {
       String lockWallpaper = "";
       try {
         lockWallpaper =
             bcontext.createPackageContext("com.cyanogenmod.cmparts", 0).getFilesDir()
                 + "/lockwallpaper";
       } catch (NameNotFoundException e1) {
       }
       if (!lockWallpaper.isEmpty()) {
         Bitmap lockb = BitmapFactory.decodeFile(lockWallpaper);
         layout.setBackgroundDrawable(new BitmapDrawable(lockb));
       }
     }
   }
 }
  private void playSounds(boolean locked) {
    // User feedback for keyguard.

    if (mSuppressNextLockSound) {
      mSuppressNextLockSound = false;
      return;
    }

    final ContentResolver cr = mContext.getContentResolver();
    if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) {
      final String whichSound = locked ? Settings.System.LOCK_SOUND : Settings.System.UNLOCK_SOUND;
      final String soundPath = Settings.System.getString(cr, whichSound);
      if (soundPath != null) {
        final Uri soundUri = Uri.parse("file://" + soundPath);
        if (soundUri != null) {
          final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
          if (sfx != null) {
            sfx.setStreamType(AudioManager.STREAM_SYSTEM);
            sfx.play();
          } else {
            Log.d(TAG, "playSounds: failed to load ringtone from uri: " + soundUri);
          }
        } else {
          Log.d(TAG, "playSounds: could not parse Uri: " + soundPath);
        }
      } else {
        Log.d(TAG, "playSounds: whichSound = " + whichSound + "; soundPath was null");
      }
    }
  }
Exemplo n.º 9
0
  private static String getAlarmPath(Context context, Alarm alarm) {
    String alert = alarm.alert.toString();
    Uri alertUri = null;
    if (alert.contains("alarm_alert")) {
      String value = Settings.System.getString(context.getContentResolver(), "alarm_alert");
      alertUri = Uri.parse(value);
    } else {
      alertUri = alarm.alert;
    }
    String[] project = {"_data"};
    String path = "";
    Cursor cursor = context.getContentResolver().query(alertUri, project, null, null, null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        path = cursor.getString(0);
        Log.v("path" + path);
      }
    } catch (Exception ex) {

    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }
    return path;
  }
Exemplo n.º 10
0
  private void loadAlarm() {
    remoteViews.setImageViewResource(R.id.alarm_image, R.drawable.icon);
    nextAlarm =
        Settings.System.getString(this.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);
    Pattern hourPattern = Pattern.compile("([01]?[0-9]|2[0-3]):[0-5][0-9]");
    Pattern dayPatternEs = Pattern.compile("^[A-Za-z\u00e1]{2}");
    Pattern dayPatternEn = Pattern.compile("^[A-Za-z]{2}");
    Pattern dayPatternRu = Pattern.compile("^[\u0410-\u044f]{2}");
    Matcher hourMatcher = hourPattern.matcher(nextAlarm);
    Matcher dayMatcherEs = dayPatternEs.matcher(nextAlarm);
    Matcher dayMatcherEn = dayPatternEn.matcher(nextAlarm);
    Matcher dayMatcherRu = dayPatternRu.matcher(nextAlarm);

    if (hourMatcher.find()) {
      hour = hourMatcher.group();
    }

    if (dayMatcherEn.find()) {
      day = util.dayFormattedToDay(dayMatcherEn.group(), hour);
    } else if (dayMatcherRu.find()) {
      day = util.dayFormattedToDay(dayMatcherRu.group(), hour);
    } else if (dayMatcherEs.find()) {
      day = util.dayFormattedToDay(dayMatcherEs.group(), hour);
    } else {
      day = this.getString(R.string.withoutDay);
    }
  }
  private void loadData(boolean defaults) {
    if (!defaults) {
      try {
        ContentResolver cr = getContentResolver();
        mLevels = parseIntArray(Settings.System.getString(cr, Settings.System.LIGHT_SENSOR_LEVELS));

        mLcdValues =
            parseIntArray(Settings.System.getString(cr, Settings.System.LIGHT_SENSOR_LCD_VALUES));

        mBtnValues =
            parseIntArray(
                Settings.System.getString(cr, Settings.System.LIGHT_SENSOR_BUTTON_VALUES));

        mKbValues =
            parseIntArray(
                Settings.System.getString(cr, Settings.System.LIGHT_SENSOR_KEYBOARD_VALUES));

        // Sanity check
        int N = mLevels.length;
        if (N < 1
            || mLcdValues.length != (N + 1)
            || mBtnValues.length != (N + 1)
            || mKbValues.length != (N + 1)) {
          throw new Exception("sanity check failed");
        }
      } catch (Exception e) {
        // Use defaults since we can't trust custom values
        defaults = true;
      }
    }

    if (defaults) {
      mLevels =
          getResources().getIntArray(com.android.internal.R.array.config_autoBrightnessLevels);
      mLcdValues =
          getResources()
              .getIntArray(com.android.internal.R.array.config_autoBrightnessLcdBacklightValues);
      mBtnValues =
          getResources()
              .getIntArray(com.android.internal.R.array.config_autoBrightnessButtonBacklightValues);
      mKbValues =
          getResources()
              .getIntArray(
                  com.android.internal.R.array.config_autoBrightnessKeyboardBacklightValues);
    }
    createEditor();
  }
Exemplo n.º 12
0
 /**
  * @return A formatted string of the next alarm (for showing on the lock screen), or null if there
  *     is no next alarm.
  */
 public String getNextAlarm() {
   String nextAlarm =
       Settings.System.getString(mContentResolver, Settings.System.NEXT_ALARM_FORMATTED);
   if (nextAlarm == null || TextUtils.isEmpty(nextAlarm)) {
     return null;
   }
   return nextAlarm;
 }
Exemplo n.º 13
0
  public static String timeFormat(Context context) {
    String time_hour =
        Settings.System.getString(context.getContentResolver(), Settings.System.TIME_12_24);

    String time_format = "HH:mm";
    if (time_hour.equals("12")) time_format = "hh:mm aaa";
    return time_format;
  }
Exemplo n.º 14
0
 public static String getMid(Context context) {
   TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   String imei = tm.getDeviceId();
   String AndroidID =
       android.provider.Settings.System.getString(context.getContentResolver(), "android_id");
   String serialNo = getDeviceSerialForMid2();
   String m2 = getMD5Str("" + imei + AndroidID + serialNo);
   return m2;
 }
 public static String getCurrentTiles(Context context) {
   String tiles =
       Settings.System.getString(
           context.getContentResolver(), Settings.System.QUICK_SETTINGS_TILES);
   if (tiles == null) {
     tiles = getDefaultTiles(context);
   }
   return tiles;
 }
Exemplo n.º 16
0
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   mWaveView = ((GlowPadView) mActivity.findViewById(R.id.lock_target));
   mWaveView.setOnTriggerListener(this);
   initializeView(
       Settings.System.getString(
           mActivity.getContentResolver(), Settings.System.LOCKSCREEN_TARGETS));
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.global_actions);

    final PreferenceScreen prefScreen = getPreferenceScreen();
    final ContentResolver contentResolver = getContext().getContentResolver();

    final String[] defaultActions =
        getContext()
            .getResources()
            .getStringArray(com.android.internal.R.array.config_globalActionsList);
    final List<String> defaultActionsList = Arrays.asList(defaultActions);

    final String[] allActions =
        getContext()
            .getResources()
            .getStringArray(com.android.internal.R.array.values_globalActionsList);

    final String enabledActions =
        Settings.System.getString(contentResolver, Settings.System.GLOBAL_ACTIONS_LIST);

    List<String> enabledActionsList = null;
    if (enabledActions != null) {
      enabledActionsList = Arrays.asList(enabledActions.split(","));
    }

    mGlobalActionsMap = new LinkedHashMap<String, Boolean>();
    for (String actionKey : allActions) {
      if (enabledActionsList != null) {
        mGlobalActionsMap.put(actionKey, enabledActionsList.contains(actionKey));
      } else {
        mGlobalActionsMap.put(actionKey, defaultActionsList.contains(actionKey));
      }
    }
    final UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
    boolean multiUser = um.isUserSwitcherEnabled();
    Preference userPref = null;
    int count = prefScreen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
      Preference p = prefScreen.getPreference(i);
      if (p instanceof SwitchPreference) {
        SwitchPreference action = (SwitchPreference) p;
        String key = action.getKey();
        if (key.equals("users") && !multiUser) {
          userPref = action;
        }
        action.setChecked(mGlobalActionsMap.get(key));
      }
    }
    if (userPref != null) {
      prefScreen.removePreference(userPref);
    }
  }
Exemplo n.º 18
0
 @SuppressWarnings("deprecation")
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   threaded_application mainapp = (threaded_application) this.getApplication();
   if (key.equals("throttle_name_preference")) {
     String defaultName =
         getApplicationContext().getResources().getString(R.string.prefThrottleNameDefaultValue);
     String currentValue = sharedPreferences.getString(key, defaultName).trim();
     // if new name is blank or the default name, make it unique
     if (currentValue.equals("") || currentValue.equals(defaultName)) {
       String deviceId =
           Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID);
       if (deviceId != null && deviceId.length() >= 4) {
         deviceId = deviceId.substring(deviceId.length() - 4);
       } else {
         Random rand = new Random();
         deviceId = String.valueOf(rand.nextInt(9999)); // use random string
       }
       String uniqueDefaultName = defaultName + " " + deviceId;
       sharedPreferences
           .edit()
           .putString(key, uniqueDefaultName)
           .commit(); // save new name to prefs
     }
   } else if (key.equals("maximum_throttle_preference")) {
     String defaultVal =
         getApplicationContext()
             .getResources()
             .getString(R.string.prefMaximumThrottleDefaultValue);
     String currentValue = sharedPreferences.getString(key, defaultVal).trim();
     // limit new value to 100 (%)
     try {
       int maxThrot = Integer.parseInt(currentValue);
       if (maxThrot > 100) {
         sharedPreferences.edit().putString(key, "100").commit(); // save new name to prefs
       }
     } catch (NumberFormatException e) {
       sharedPreferences.edit().putString(key, defaultVal).commit(); // save new name to prefs
     }
   } else if (key.equals("WebViewLocation")) {
     mainapp.alert_activities(message_type.WEBVIEW_LOC, "");
   } else if (key.equals("ThrottleOrientation")) {
     // if mode was fixed (Port or Land) won't get callback so need explicit call here
     mainapp.setActivityOrientation(this);
   } else if (key.equals("InitialWebPage")) {
     mainapp.alert_activities(message_type.INITIAL_WEBPAGE, "");
   } else if (key.equals("InitialThrotWebPage")) {
     mainapp.alert_activities(message_type.INITIAL_WEBPAGE, "");
   } else if (key.equals("DelimiterPreference")) {
     mainapp.alert_activities(message_type.LOCATION_DELIMITER, "");
   } else if (key.equals("ClockDisplayTypePreference")) {
     mainapp.sendMsg(mainapp.comm_msg_handler, message_type.CLOCK_DISPLAY);
   }
 }
Exemplo n.º 19
0
  /**
   * When playing ringtone or in Phone ringtone interface, check the corresponding file get from
   * media with the uri get from setting. If the file is not exist, restore to default ringtone.
   */
  private void restoreRingtoneIfNotExist(String settingName) {
    String ringtoneUri = Settings.System.getString(mContext.getContentResolver(), settingName);
    if (ringtoneUri == null) {
      return;
    }

    ContentResolver res = mContext.getContentResolver();
    Cursor c = null;
    try {
      c =
          mContext
              .getContentResolver()
              .query(
                  Uri.parse(ringtoneUri),
                  new String[] {MediaStore.Audio.Media.TITLE},
                  null,
                  null,
                  null);
      // Check whether the corresponding file of Uri is exist.
      if (!hasData(c)) {
        c =
            res.acquireProvider("media")
                .query(
                    null,
                    MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
                    new String[] {"_id"},
                    MediaStore.Audio.AudioColumns.IS_RINGTONE
                        + "=1 and "
                        + MediaStore.Audio.Media.DISPLAY_NAME
                        + "=?",
                    new String[] {getDefaultRingtoneFileName(settingName)},
                    null,
                    null);

        // Set the setting to the Uri of default ringtone.
        if (hasData(c) && c.moveToFirst()) {
          int rowId = c.getInt(0);
          Settings.System.putString(
              mContext.getContentResolver(),
              settingName,
              ContentUris.withAppendedId(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, rowId)
                  .toString());
        }
      }
    } catch (RemoteException e) {
      Log.e(TAG, "RemoteException in restoreRingtoneIfNotExist()", e);
    } finally {
      if (c != null) {
        c.close();
      }
    }
  }
  private ArrayList<String> parseIntents() {

    final ArrayList<String> mQuickIntents = new ArrayList<String>();

    String[] temp =
        Settings.System.getString(mResolver, Settings.System.QUICK_LAUNCH_TARGETS, "").split("<>");

    for (String s : temp) {
      if (!s.isEmpty()) mQuickIntents.add(s);
    }
    if (mQuickIntents.isEmpty()) mQuickIntents.add("");
    return mQuickIntents;
  }
Exemplo n.º 21
0
  private void refreshAlarm() {
    if (mNextAlarm == null) return;

    String nextAlarm =
        Settings.System.getString(getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);
    if (!TextUtils.isEmpty(nextAlarm)) {
      mNextAlarm.setText(nextAlarm);
      // mNextAlarm.setCompoundDrawablesWithIntrinsicBounds(
      //    android.R.drawable.ic_lock_idle_alarm, 0, 0, 0);
      mNextAlarm.setVisibility(View.VISIBLE);
    } else {
      mNextAlarm.setVisibility(View.INVISIBLE);
    }
  }
Exemplo n.º 22
0
 /** Clock views can call this to refresh their alarm to the next upcoming value. * */
 public static void refreshAlarm(Context context, View clock) {
   String nextAlarm =
       Settings.System.getString(
           context.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);
   TextView nextAlarmView;
   nextAlarmView = (TextView) clock.findViewById(R.id.nextAlarm);
   if (!TextUtils.isEmpty(nextAlarm) && nextAlarmView != null) {
     nextAlarmView.setText(context.getString(R.string.control_set_alarm_with_existing, nextAlarm));
     nextAlarmView.setContentDescription(
         context.getResources().getString(R.string.next_alarm_description, nextAlarm));
     nextAlarmView.setVisibility(View.VISIBLE);
   } else {
     nextAlarmView.setVisibility(View.GONE);
   }
 }
Exemplo n.º 23
0
    @Override
    public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();

      if (GocMessage.BT_CONNECTED.equals(action)) {
        // 蓝牙连接
        btPair.setEnabled(true);
        btPair.setBackgroundResource(R.drawable.settings_list_bg);
        btConnectStatus.setText(Config.BT_PARI_NAME);
        btConnectOperate.setText("断开连接");
        try {
          handler.removeCallbacks(r);
        } catch (Exception e) {

        }
      } else if (GocMessage.BT_DISCONNECTED.equals(action)) {
        // 蓝牙断开连接
        btPair.setEnabled(true);
        btPair.setBackgroundResource(R.drawable.settings_list_bg);
        btConnectStatus.setText(Config.BT_PARI_NAME);
        btConnectOperate.setText("开始配对");
        try {
          handler.removeCallbacks(r);
        } catch (Exception e) {

        }
      } else if (GocMessage.CONTACT_SYNC_DONE.equals(action)) {
        if (pdSC != null) pdSC.dismiss();
        switchButton.setEnabled(true);
      } else if (GocMessage.CONTACT_DELETE_DONE.equals(action)) {
        if (pdCC != null) pdCC.dismiss();
      } else if ("com.tchip.ACC_OFF".equals(action)) {
        BTSettings.this.finish();
      } else if ("com.tchip.ACC_ON".equals(action)) {
        String btStatus = Settings.System.getString(getContentResolver(), "bt_enable");
        switchButton.setChecked(btStatus.equals("1"));
        switchButton.setEnabled(true);
      } else if (GocMessage.BT_OPENED.equals(action)) {
        // 打开蓝牙
        switchButton.setChecked(true);
      } else if (GocMessage.BT_CLOSED.equals(action)) {
        // 关闭蓝牙
        switchButton.setChecked(false);
      } else if (GocMessage.BT_NAME_GET.equals(action)) {
        // 蓝牙名称获取成功
        btName.setText(Config.BT_NAME);
      }
    }
Exemplo n.º 24
0
  private String fetchHardInfo() {
    TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
    outputText = new StringBuffer();
    outputText.append("deviceID:" + tm.getDeviceId());
    // 获取手机号码,部分手机可以获取,不能获取的为空
    outputText.append("手机号:" + tm.getLine1Number());
    // 获取IMSI号码
    outputText.append("唯一的用户ID:" + tm.getSubscriberId());

    outputText.append("设备型号:" + Build.MODEL);
    outputText.append("操作系统版本:" + Build.VERSION.SDK);
    outputText.append("操作系统版本:" + Build.VERSION.RELEASE);

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    outputText.append("手机屏幕分辨率:" + displayMetrics.widthPixels + "x" + displayMetrics.heightPixels);

    outputText.append(
        "设备IMEI:" + android.provider.Settings.System.getString(getContentResolver(), "android_id"));

    // 获取运营商信息
    String providersName = getProvidersName(tm.getSubscriberId());
    outputText.append("运营商:" + providersName);
    outputText.append("CPU最大频率:" + getMaxCpuFreq());

    outputText.append("CPU信息:" + getCpuInfo());

    outputText.append("RAM总大小:" + getTotalMemroy());
    outputText.append("RAM可用大小:" + getAvailMemroy());
    outputText.append("ROM总大小:" + getRomMemroy()[0]);
    outputText.append("ROM可用:" + getRomMemroy()[1]);
    outputText.append("ROM可用:" + getSDCardMemroy()[0]);

    outputText.append("电池电量:" + getSDCardMemroy()[0]);

    outputText.append("MAC地址:" + getMAC());

    outputText.append("SDCard存在:" + existSDCard());
    outputText.append("SDCard的总量:" + getSDAllSize() + "MB");
    outputText.append("SDCard的剩余:" + getSDFreeSize() + "MB");

    return outputText.toString();
  }
  /**
   * Returns true if user preference is set to 24-hour format.
   *
   * @param context the context to use for the content resolver
   * @return true if 24 hour time format is selected, false otherwise.
   */
  public static boolean is24HourFormat(Context context) {
    String value =
        Settings.System.getString(context.getContentResolver(), Settings.System.TIME_12_24);

    if (value == null) {
      Locale locale = context.getResources().getConfiguration().locale;

      synchronized (sLocaleLock) {
        if (sIs24HourLocale != null && sIs24HourLocale.equals(locale)) {
          return sIs24Hour;
        }
      }

      java.text.DateFormat natural =
          java.text.DateFormat.getTimeInstance(java.text.DateFormat.LONG, locale);

      if (natural instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) natural;
        String pattern = sdf.toPattern();

        if (pattern.indexOf('H') >= 0) {
          value = "24";
        } else {
          value = "12";
        }
      } else {
        value = "12";
      }

      synchronized (sLocaleLock) {
        sIs24HourLocale = locale;
        sIs24Hour = value.equals("24");
      }

      return sIs24Hour;
    }

    return value.equals("24");
  }
  @SuppressLint("SimpleDateFormat")
  @SuppressWarnings("deprecation")
  private static void setupSmartAlarm(MethodHookParam param, int timeout) {
    if (((Intent) param.args[0]).getBooleanExtra("alarmSet", false)) {
      Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
      String nextAlarm =
          Settings.System.getString(
              context.getContentResolver(), android.provider.Settings.System.NEXT_ALARM_FORMATTED);
      DateFormat sdf = new SimpleDateFormat("EEE hh:mm aa");
      Date alarmDate = null;
      try {
        alarmDate = sdf.parse(nextAlarm);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      int alarmDay = alarmDate.getDay();
      Calendar now = Calendar.getInstance();
      Date currentDate = now.getTime();
      int todayDay = currentDate.getDay();
      int daysDiff = 0;
      if (todayDay > alarmDay) {
        daysDiff = ((7 + (alarmDay - todayDay)) % 7) + 1;
      } else {
        daysDiff = ((7 + (alarmDay - todayDay)) % 7);
      }
      now.add(Calendar.DATE, daysDiff);
      Date alarmFulldate = now.getTime();
      alarmFulldate.setHours(alarmDate.getHours());
      alarmFulldate.setMinutes(alarmDate.getMinutes());
      alarmFulldate.setSeconds(0);
      long millis = alarmFulldate.getTime() - new Date().getTime();

      if (millis > (timeout * 60 * 1000)) {
        ((Intent) param.args[0]).putExtra("alarmSet", false);
      }
    }
  }
Exemplo n.º 27
0
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Uri data = intent.getData();
    entrance = data.getSchemeSpecificPart();

    // get the super and parent-child's password.
    superPwd = android.provider.Settings.System.getString(getContentResolver(), "password");
    if (null == superPwd) {
      superPwd = Config.PROGRAMME_LOCK;
    }

    bootDefaultStatus = intent.getIntExtra("service_id", 0);
    if (bootDefaultStatus == 0) {
      if (null != entrance) {
        parserLastProgram();
        parserEntrance();
      }
    }
    // start to play boot default channel.
    else {
      LogUtils.printLog(1, 3, TAG, "--- start to play default channel " + bootDefaultStatus);
      go2BootDefaultChannel(bootDefaultStatus);
    }
  }
  private String getProperSummary(int i) {
    String uri =
        Settings.System.getString(
            getActivity().getContentResolver(),
            Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[i]);

    if (uri == null) return getResources().getString(R.string.lockscreen_action_none);

    if (uri.startsWith("**")) {
      if (uri.equals("**unlock**"))
        return getResources().getString(R.string.lockscreen_action_unlock);
      else if (uri.equals("**sound**"))
        return getResources().getString(R.string.lockscreen_action_sound);
      else if (uri.equals("**camera**"))
        return getResources().getString(R.string.lockscreen_action_camera);
      else if (uri.equals("**phone**"))
        return getResources().getString(R.string.lockscreen_action_phone);
      else if (uri.equals("**null**"))
        return getResources().getString(R.string.lockscreen_action_none);
    } else {
      return mPicker.getFriendlyNameForUri(uri);
    }
    return null;
  }
 public void refreshButtons() {
   if (mNumberofButtons == 0) {
     return;
   }
   int navBarColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_COLOR, -1);
   int navButtonColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_TINT, -1);
   float navButtonAlpha =
       Settings.System.getFloat(
           mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, STOCK_ALPHA);
   int glowColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_TINT, 0);
   float BarAlpha = 1.0f;
   String alphas[];
   String settingValue =
       Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_ALPHA_CONFIG);
   if (!TextUtils.isEmpty(settingValue)) {
     alphas = settingValue.split(";");
     BarAlpha = Float.parseFloat(alphas[0]) / 255;
   }
   int a = Math.round(BarAlpha * 255);
   Drawable mBackground =
       AwesomeConstants.getSystemUIDrawable(mContext, "com.android.systemui:drawable/nav_bar_bg");
   if (mBackground instanceof ColorDrawable) {
     BackgroundAlphaColorDrawable bacd =
         new BackgroundAlphaColorDrawable(
             navBarColor > 0 ? navBarColor : ((ColorDrawable) mBackground).getColor());
     bacd.setAlpha(a);
     mNavBarContainer.setBackground(bacd);
   } else {
     mBackground.setAlpha(a);
     mNavBarContainer.setBackground(mBackground);
   }
   for (int i = 0; i < mNumberofButtons; i++) {
     ImageButton ib = mButtonViews.get(i);
     Drawable d = mButtons.get(i).getIcon();
     if (navButtonColor != -1) {
       d.setColorFilter(navButtonColor, PorterDuff.Mode.SRC_ATOP);
     }
     ib.setImageDrawable(d);
     ib.setOnClickListener(mNavBarClickListener);
     ib.setVisibility(View.VISIBLE);
     ib.setAlpha(navButtonAlpha);
     StateListDrawable sld = new StateListDrawable();
     sld.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(glowColor));
     sld.addState(StateSet.WILD_CARD, mNavBarContainer.getBackground());
     ib.setBackground(sld);
   }
   for (int i = mNumberofButtons; i < mButtonViews.size(); i++) {
     ImageButton ib = mButtonViews.get(i);
     ib.setVisibility(View.GONE);
   }
   int menuloc = Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0);
   switch (menuloc) {
     case SHOW_BOTH_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_LEFT_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.INVISIBLE);
       break;
     case SHOW_RIGHT_MENU:
       mLeftMenu.setVisibility(View.INVISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_DONT:
       mLeftMenu.setVisibility(View.GONE);
       mRightMenu.setVisibility(View.GONE);
       break;
   }
   if (navButtonColor != -1) {
     mLeftMenu.setColorFilter(navButtonColor);
     mRightMenu.setColorFilter(navButtonColor);
   }
 }
Exemplo n.º 30
0
    public void run() {
      // parser the entrance of dvb.
      Uri data = getIntent().getData();
      entrance = data.getSchemeSpecificPart();

      bootDefaultStatus = getIntent().getIntExtra("service_id", 0);

      synchronized (LoadDriveService.class) {
        // load drive and init the CA.
        nativeDrive = new NativeDrive(SplashActivity.this);
        nativeDrive.pvwareDRVInit();
        nativeDrive.CAInit();

        NativeSystemInfo SystemInfo = new NativeSystemInfo();
        SystemInfo.SystemInfoInit(SplashActivity.this);
      }
      // load player
      NativePlayer dvbPlayer = NativePlayer.getInstance();
      dvbPlayer.DVBPlayerInit(null);
      dvbPlayer.DVBPlayerSetStopMode(1);

      // parser the last play program.
      parserLastProgram();

      // process rec logic.
      synchronized (SplashActivity.class) {
        PVR_Rec_Status_t recFile = dvbPlayer.new PVR_Rec_Status_t();
        dvbPlayer.DVBPlayerPvrRecGetStatus(recFile);
        int status = recFile.getEnState();
        LogUtils.printLog(1, 3, TAG, "-----Rec File return value----->>>" + status);
        if (status == 2 || status == 3) {
          recStatus = true;
          recBundle = parserRecProgram();
        }
      }

      // delete the time.ts.
      StorageUtils util = new StorageUtils(SplashActivity.this);
      MountInfoBean mountInfoBean = util.getMobileHDDInfo();
      if (null != mountInfoBean) {
        // set ts file's name.
        String tmsFilePath = mountInfoBean.getPath() + "/time.ts";
        LogUtils.printLog(1, 3, TAG, "------time file path------->>>" + tmsFilePath);
        File file = new File(tmsFilePath);
        if (file.exists()) {
          dvbPlayer.DVBPlayerPvrRemoveFile(tmsFilePath);
        }
      }

      // get the super and parent-child's password.
      superPwd = android.provider.Settings.System.getString(getContentResolver(), "password");
      if (null == superPwd) {
        superPwd = Config.SUPER_PASSWORD;
      }

      // get programme grade.
      try {
        grade = android.provider.Settings.System.getInt(getContentResolver(), "eit_grade");
      } catch (SettingNotFoundException e) {
        // get the eit grade exception, set the default value.
        grade = 1;
        e.printStackTrace();
      }
      handler.sendEmptyMessage(Config.CONNECTION_SUCCESS);
    }