예제 #1
0
  /** Returns whether the clings are enabled or should be shown */
  private boolean areClingsEnabled() {
    if (DISABLE_CLINGS) {
      return false;
    }

    // disable clings when running in a test harness
    if (ActivityManager.isRunningInTestHarness()) return false;

    // Disable clings for accessibility when explore by touch is enabled
    final AccessibilityManager a11yManager =
        (AccessibilityManager) mLauncher.getSystemService(Launcher.ACCESSIBILITY_SERVICE);
    if (a11yManager.isTouchExplorationEnabled()) {
      return false;
    }

    // Restricted secondary users (child mode) will potentially have very few apps
    // seeded when they start up for the first time. Clings won't work well with that
    boolean supportsLimitedUsers =
        android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
    Account[] accounts = AccountManager.get(mLauncher).getAccounts();
    if (supportsLimitedUsers && accounts.length == 0) {
      UserManager um = (UserManager) mLauncher.getSystemService(Context.USER_SERVICE);
      Bundle restrictions = um.getUserRestrictions();
      if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) {
        return false;
      }
    }
    if (Settings.Secure.getInt(mLauncher.getContentResolver(), SKIP_FIRST_USE_HINTS, 0) == 1) {
      return false;
    }
    return true;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i(TAG, "Referrer: " + getReferrer());

    mAm = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    if (savedInstanceState != null) {
      mOverrideConfig = savedInstanceState.getParcelable(KEY_CONFIGURATION);
      if (mOverrideConfig != null) {
        applyOverrideConfiguration(mOverrideConfig);
      }
    }

    UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
    List<UserInfo> users = um.getUsers();
    mSecondUser = Integer.MAX_VALUE;
    for (UserInfo ui : users) {
      if (ui.id != 0 && mSecondUser > ui.id) {
        mSecondUser = ui.id;
      }
    }

    /*
    AlertDialog ad = new AlertDialog.Builder(this).setTitle("title").setMessage("message").create();
    ad.getWindow().getAttributes().type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    ad.show();
    */
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    final ContentResolver cr = getContentResolver();
    final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    if (preference == mNetwork) {
      if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
        Settings.Secure.setLocationProviderEnabled(
            cr, LocationManager.NETWORK_PROVIDER, mNetwork.isChecked());
      }
    } else if (preference == mGps) {
      boolean enabled = mGps.isChecked();
      if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
        Settings.Secure.setLocationProviderEnabled(cr, LocationManager.GPS_PROVIDER, enabled);
        if (mAssistedGps != null) {
          mAssistedGps.setEnabled(enabled);
        }
      }
    } else if (preference == mAssistedGps) {
      Settings.Global.putInt(
          cr, Settings.Global.ASSISTED_GPS_ENABLED, mAssistedGps.isChecked() ? 1 : 0);
    } else {
      // If we didn't handle it, let preferences handle it.
      return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    return true;
  }
예제 #4
0
 private void checkUser() {
   try {
     UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
     int count = um.getUserCount();
     boolean adminUser = um.isSystemUser();
     Log.i("TAG", "isAdminUser : "******" / " + adminUser);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /**
   * Whether a user handle associated with the current user is that of the primary owner. That is,
   * whether there is a user handle which has an id which matches the owner's handle.
   *
   * @return Whether the current user is the primary user.
   */
  private boolean isPrimaryUser() {
    UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
    List<UserHandle> userHandles = userManager.getUserProfiles();
    for (int i = 0; i < userHandles.size(); i++) {
      if (userHandles.get(i).myUserId() == OWNER_HANDLE_ID) {
        return true;
      }
    }

    return false;
  }
  @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);
    }
  }
 /** Enable or disable all providers when the master toggle is changed. */
 private void onToggleLocationAccess(boolean checked) {
   final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
   if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
     return;
   }
   final ContentResolver cr = getContentResolver();
   Settings.Secure.setLocationProviderEnabled(cr, LocationManager.GPS_PROVIDER, checked);
   Settings.Secure.setLocationProviderEnabled(cr, LocationManager.NETWORK_PROVIDER, checked);
   updateLocationToggles();
   updateLtoServiceStatus(getActivity(), checked);
 }
 public void updateCache(Context context) {
   UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
   if (userManager != null) {
     int currentUserId = ActivityManager.getCurrentUser();
     List<UserInfo> profiles = userManager.getProfiles(currentUserId);
     synchronized (mCurrentProfiles) {
       mCurrentProfiles.clear();
       for (UserInfo user : profiles) {
         mCurrentProfiles.put(user.id, user);
       }
     }
   }
 }
  private void createHeader() {
    Activity activity = getActivity();
    FrameLayout pinnedHeader = (FrameLayout) mRootView.findViewById(R.id.pinned_header);
    mSpinnerHeader =
        (ViewGroup)
            activity.getLayoutInflater().inflate(R.layout.apps_filter_spinner, pinnedHeader, false);
    mFilterSpinner = (Spinner) mSpinnerHeader.findViewById(R.id.filter_spinner);
    mFilterAdapter = new FilterSpinnerAdapter(this);
    mFilterSpinner.setAdapter(mFilterAdapter);
    mFilterSpinner.setOnItemSelectedListener(this);
    pinnedHeader.addView(mSpinnerHeader, 0);

    mFilterAdapter.enableFilter(getDefaultFilter());
    if (mListType == LIST_TYPE_MAIN || mListType == LIST_TYPE_NOTIFICATION) {
      if (UserManager.get(getActivity()).getUserProfiles().size() > 1) {
        mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL);
        mFilterAdapter.enableFilter(FILTER_APPS_WORK);
      }
    }
    if (mListType == LIST_TYPE_NOTIFICATION) {
      mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
      mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
      mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
      mFilterAdapter.enableFilter(FILTER_APPS_NO_PEEKING);
    }
    if (mListType == LIST_TYPE_HIGH_POWER) {
      mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
    }
    if (mListType == LIST_TYPE_STORAGE) {
      mApplications.setOverrideFilter(new VolumeFilter(mVolumeUuid));
    }
  }
  private void cleanUpRemovedUsersLocked() {
    final List<UserInfo> users = mUserManager.getUsers(true);
    if (users == null || users.size() == 0) {
      throw new IllegalStateException("There can't be no users");
    }

    ArraySet<String> toDelete = new ArraySet<>();
    String[] fileNames = mUsageStatsDir.list();
    if (fileNames == null) {
      // No users to delete.
      return;
    }

    toDelete.addAll(Arrays.asList(fileNames));

    final int userCount = users.size();
    for (int i = 0; i < userCount; i++) {
      final UserInfo userInfo = users.get(i);
      toDelete.remove(Integer.toString(userInfo.id));
    }

    final int deleteCount = toDelete.size();
    for (int i = 0; i < deleteCount; i++) {
      deleteRecursively(new File(mUsageStatsDir, toDelete.valueAt(i)));
    }
  }
 private void addOtherUserItem(
     Context context,
     ArrayList<MergedItem> newMergedItems,
     SparseArray<MergedItem> userItems,
     MergedItem newItem) {
   MergedItem userItem = userItems.get(newItem.mUserId);
   boolean first = userItem == null || userItem.mCurSeq != mSequence;
   if (first) {
     UserInfo info = mUm.getUserInfo(newItem.mUserId);
     if (info == null) {
       // The user no longer exists, skip
       return;
     }
     if (mHideManagedProfiles && info.isManagedProfile()) {
       return;
     }
     if (userItem == null) {
       userItem = new MergedItem(newItem.mUserId);
       userItems.put(newItem.mUserId, userItem);
     } else {
       userItem.mChildren.clear();
     }
     userItem.mCurSeq = mSequence;
     userItem.mUser = new UserState();
     userItem.mUser.mInfo = info;
     userItem.mUser.mIcon = Utils.getUserIcon(context, mUm, info);
     userItem.mUser.mLabel = Utils.getUserLabel(context, info);
     newMergedItems.add(userItem);
   }
   userItem.mChildren.add(newItem);
 }
  public PermissionMonitor(Context context, INetworkManagementService netd) {
    mContext = context;
    mPackageManager = context.getPackageManager();
    mUserManager = UserManager.get(context);
    mNetd = netd;
    mIntentReceiver =
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
            int appUid = intent.getIntExtra(Intent.EXTRA_UID, -1);
            Uri appData = intent.getData();
            String appName = appData != null ? appData.getSchemeSpecificPart() : null;

            if (Intent.ACTION_USER_ADDED.equals(action)) {
              onUserAdded(user);
            } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
              onUserRemoved(user);
            } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
              onAppAdded(appName, appUid);
            } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
              onAppRemoved(appUid);
            }
          }
        };
  }
    /**
     * * Disables preferences that are less secure than required quality.
     *
     * @param quality the requested quality.
     */
    private void disableUnusablePreferences(final int quality, MutableBoolean allowBiometric) {
      final PreferenceScreen entries = getPreferenceScreen();
      final boolean onlyShowFallback =
          getActivity()
              .getIntent()
              .getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
      final boolean weakBiometricAvailable =
          mChooseLockSettingsHelper.utils().isBiometricWeakInstalled();

      // if there are multiple users, disable "None" setting
      UserManager mUm = (UserManager) getSystemService(Context.USER_SERVICE);
      List<UserInfo> users = mUm.getUsers(true);
      final boolean singleUser = users.size() == 1;

      for (int i = entries.getPreferenceCount() - 1; i >= 0; --i) {
        Preference pref = entries.getPreference(i);
        if (pref instanceof PreferenceScreen) {
          final String key = ((PreferenceScreen) pref).getKey();
          boolean enabled = true;
          boolean visible = true;
          if (KEY_UNLOCK_SET_OFF.equals(key)) {
            enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
            visible = singleUser; // don't show when there's more than 1 user
          } else if (KEY_UNLOCK_SET_NONE.equals(key)) {
            enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
          } else if (KEY_UNLOCK_SET_BIOMETRIC_WEAK.equals(key)) {
            enabled =
                quality <= DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK
                    || allowBiometric.value;
            visible = weakBiometricAvailable; // If not available, then don't show it.
          } else if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
            enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
          } else if (KEY_UNLOCK_SET_PIN.equals(key)) {
            enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
          } else if (KEY_UNLOCK_SET_PASSWORD.equals(key)) {
            enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
          }
          if (!visible || (onlyShowFallback && !allowedForFallback(key))) {
            entries.removePreference(pref);
          } else if (!enabled) {
            pref.setSummary(R.string.unlock_set_unlock_disabled_summary);
            pref.setEnabled(false);
          }
        }
      }
    }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   if (UserManager.get(getActivity()).hasUserRestriction(UserManager.DISALLOW_FACTORY_RESET)) {
     return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
   }
   mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
   establishFinalConfirmationState();
   return mContentView;
 }
 /** Return list of other users, excluding the current user. */
 private List<UserInfo> getUsersExcluding(UserInfo excluding) {
   final List<UserInfo> users = mUserManager.getUsers();
   final Iterator<UserInfo> i = users.iterator();
   while (i.hasNext()) {
     if (i.next().id == excluding.id) {
       i.remove();
     }
   }
   return users;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // If the user is not allowed to configure wifi, do not handle menu selections.
    if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_WIFI)) return false;

    switch (item.getItemId()) {
      case MENU_ID_WPS_PBC:
        showDialog(WPS_PBC_DIALOG_ID);
        return true;
      case MENU_ID_P2P:
        if (getActivity() instanceof PreferenceActivity) {
          ((PreferenceActivity) getActivity())
              .startPreferencePanel(
                  WifiP2pSettings.class.getCanonicalName(),
                  null,
                  R.string.wifi_p2p_settings_title,
                  null,
                  this,
                  0);
        } else {
          startFragment(this, WifiP2pSettings.class.getCanonicalName(), -1, null);
        }
        return true;
      case MENU_ID_WPS_PIN:
        showDialog(WPS_PIN_DIALOG_ID);
        return true;
      case MENU_ID_SCAN:
        if (mWifiManager.isWifiEnabled()) {
          mScanner.forceScan();
        }
        return true;
      case MENU_ID_ADD_NETWORK:
        if (mWifiManager.isWifiEnabled()) {
          onAddNetworkPressed();
        }
        return true;
      case MENU_ID_ADVANCED:
        if (getActivity() instanceof PreferenceActivity) {
          ((PreferenceActivity) getActivity())
              .startPreferencePanel(
                  AdvancedWifiSettings.class.getCanonicalName(),
                  null,
                  R.string.wifi_advanced_titlebar,
                  null,
                  this,
                  0);
        } else {
          startFragment(this, AdvancedWifiSettings.class.getCanonicalName(), -1, null);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   if (mReason == UNLAUNCHABLE_REASON_QUIET_MODE && which == DialogInterface.BUTTON_POSITIVE) {
     if (UserManager.get(this).trySetQuietModeDisabled(mUserId, mTarget) && mTarget != null) {
       try {
         startIntentSenderForResult(mTarget, -1, null, 0, 0, 0);
       } catch (IntentSender.SendIntentException e) {
         /* ignore */
       }
     }
   }
 }
  private PreferenceScreen createPreferenceHierarchy() {
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
      root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();

    mLocationAccess = (SwitchPreference) root.findPreference(KEY_LOCATION_TOGGLE);
    mNetwork = (CheckBoxPreference) root.findPreference(KEY_LOCATION_NETWORK);
    mGps = (CheckBoxPreference) root.findPreference(KEY_LOCATION_GPS);
    mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS);
    mGpsDownloadDataWifiOnly =
        (CheckBoxPreference) root.findPreference(KEY_GPS_DOWNLOAD_DATA_WIFI_ONLY);

    // Only enable these controls if this user is allowed to change location
    // sharing settings.
    final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    boolean isToggleAllowed = !um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
    if (mLocationAccess != null) mLocationAccess.setEnabled(isToggleAllowed);
    if (mNetwork != null) mNetwork.setEnabled(isToggleAllowed);
    if (mGps != null) mGps.setEnabled(isToggleAllowed);
    if (mAssistedGps != null) mAssistedGps.setEnabled(isToggleAllowed);
    if (mGpsDownloadDataWifiOnly != null) mGpsDownloadDataWifiOnly.setEnabled(isToggleAllowed);

    if (!LongTermOrbits.isSupported()) {
      root.removePreference(mGpsDownloadDataWifiOnly);
      mGpsDownloadDataWifiOnly = null;
    } else {
      if (saveDownloadDataWifiOnlyPref(getActivity())) {
        root.removePreference(mGpsDownloadDataWifiOnly);
        mGpsDownloadDataWifiOnly = null;
      }
    }

    mLocationAccess.setOnPreferenceChangeListener(this);
    return root;
  }
  // Intended to be called only once at startup, after the system is ready. Installs a broadcast
  // receiver to monitor ongoing UID changes, so this shouldn't/needn't be called again.
  public synchronized void startMonitoring() {
    log("Monitoring");

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_USER_ADDED);
    intentFilter.addAction(Intent.ACTION_USER_REMOVED);
    mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);

    intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    intentFilter.addDataScheme("package");
    mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);

    List<PackageInfo> apps = mPackageManager.getInstalledPackages(GET_PERMISSIONS);
    if (apps == null) {
      loge("No apps");
      return;
    }

    for (PackageInfo app : apps) {
      int uid = app.applicationInfo != null ? app.applicationInfo.uid : -1;
      if (uid < 0) {
        continue;
      }

      boolean isNetwork = hasNetworkPermission(app);
      boolean isSystem = hasSystemPermission(app);

      if (isNetwork || isSystem) {
        Boolean permission = mApps.get(uid);
        // If multiple packages share a UID (cf: android:sharedUserId) and ask for different
        // permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
        if (permission == null || permission == NETWORK) {
          mApps.put(uid, isSystem);
        }
      }
    }

    List<UserInfo> users = mUserManager.getUsers(true); // exclude dying users
    if (users != null) {
      for (UserInfo user : users) {
        mUsers.add(user.id);
      }
    }

    log("Users: " + mUsers.size() + ", Apps: " + mApps.size());
    update(mUsers, mApps, true);
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // If the user is not allowed to configure wifi, do not show the menu.
    if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_WIFI)) return;

    final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
    if (mSetupWizardMode) {
      // FIXME: add setIcon() when graphics are available
      menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
          .setIcon(R.drawable.ic_wps)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
      menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    } else {
      menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
          .setIcon(R.drawable.ic_wps)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
      menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
          .setIcon(R.drawable.ic_menu_add)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
      menu.add(Menu.NONE, MENU_ID_SCAN, 0, R.string.wifi_menu_scan)
          // .setIcon(R.drawable.ic_menu_scan_network)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
      menu.add(Menu.NONE, MENU_ID_WPS_PIN, 0, R.string.wifi_menu_wps_pin)
          .setEnabled(wifiIsEnabled)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
      if (mP2pSupported) {
        menu.add(Menu.NONE, MENU_ID_P2P, 0, R.string.wifi_menu_p2p)
            .setEnabled(wifiIsEnabled)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
      }
      menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
          // .setIcon(android.R.drawable.ic_menu_manage)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
    super.onCreateOptionsMenu(menu, inflater);
  }
  /**
   * Shows the latest access points available with supplimental information like the strength of
   * network and the security for it.
   */
  private void updateAccessPoints() {
    // Safeguard from some delayed event handling
    if (getActivity() == null) return;

    if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) {
      addMessagePreference(R.string.wifi_empty_list_user_restricted);
      return;
    }
    final int wifiState = mWifiManager.getWifiState();

    switch (wifiState) {
      case WifiManager.WIFI_STATE_ENABLED:
        // AccessPoints are automatically sorted with TreeSet.
        final Collection<AccessPoint> accessPoints = constructAccessPoints();
        getPreferenceScreen().removeAll();
        if (accessPoints.size() == 0) {
          addMessagePreference(R.string.wifi_empty_list_wifi_on);
        }
        for (AccessPoint accessPoint : accessPoints) {
          getPreferenceScreen().addPreference(accessPoint);
        }
        break;

      case WifiManager.WIFI_STATE_ENABLING:
        getPreferenceScreen().removeAll();
        break;

      case WifiManager.WIFI_STATE_DISABLING:
        addMessagePreference(R.string.wifi_stopping);
        break;

      case WifiManager.WIFI_STATE_DISABLED:
        setOffMessage();
        break;
    }
  }
  private void updateHeaderList(List<Header> target) {
    final boolean showDev =
        mDevelopmentPreferences.getBoolean(
            DevelopmentSettings.PREF_SHOW,
            android.os.Build.TYPE.equals("eng") || android.os.Build.TYPE.equals("userdebug"));
    int i = 0;

    mHeaderIndexMap.clear();
    while (i < target.size()) {
      Header header = target.get(i);
      // Ids are integers, so downcasting
      int id = (int) header.id;
      if (id == R.id.operator_settings
          || id == R.id.manufacturer_settings
          || id == R.id.advanced_settings
          || id == R.id.hybrid_settings) {
        Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
      } else if (id == R.id.launcher_settings) {
        Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
        launcherIntent.addCategory(Intent.CATEGORY_HOME);
        launcherIntent.addCategory(Intent.CATEGORY_DEFAULT);

        Intent launcherPreferencesIntent = new Intent(Intent.ACTION_MAIN);
        launcherPreferencesIntent.addCategory("com.cyanogenmod.category.LAUNCHER_PREFERENCES");

        ActivityInfo defaultLauncher =
            getPackageManager()
                .resolveActivity(launcherIntent, PackageManager.MATCH_DEFAULT_ONLY)
                .activityInfo;
        launcherPreferencesIntent.setPackage(defaultLauncher.packageName);
        ResolveInfo launcherPreferences =
            getPackageManager().resolveActivity(launcherPreferencesIntent, 0);
        if (launcherPreferences != null) {
          header.intent =
              new Intent()
                  .setClassName(
                      launcherPreferences.activityInfo.packageName,
                      launcherPreferences.activityInfo.name);
        } else {
          target.remove(header);
        }
      } else if (id == R.id.wifi_settings) {
        // Remove WiFi Settings if WiFi service is not available.
        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
          target.remove(i);
        }
      } else if (id == R.id.bluetooth_settings) {
        // Remove Bluetooth Settings if Bluetooth service is not available.
        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
          target.remove(i);
        }
      } else if (id == R.id.data_usage_settings) {
        // Remove data usage when kernel module not enabled
        final INetworkManagementService netManager =
            INetworkManagementService.Stub.asInterface(
                ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
        try {
          if (!netManager.isBandwidthControlEnabled()) {
            target.remove(i);
          }
        } catch (RemoteException e) {
          // ignored
        }
      } else if (id == R.id.account_settings) {
        int headerIndex = i + 1;
        i = insertAccountsHeaders(target, headerIndex);
      } else if (id == R.id.user_settings) {
        if (!UserHandle.MU_ENABLED
            || !UserManager.supportsMultipleUsers()
            || Utils.isMonkeyRunning()) {
          target.remove(i);
        }
      }

      if (target.get(i) == header
          && UserHandle.MU_ENABLED
          && UserHandle.myUserId() != 0
          && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
        target.remove(i);
      }

      // Increment if the current one wasn't removed by the Utils code.
      if (target.get(i) == header) {
        // Hold on to the first header, when we need to reset to the top-level
        if (mFirstHeader == null
            && HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) {
          mFirstHeader = header;
        }
        mHeaderIndexMap.put(id, i);
        i++;
      }
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
    }
    log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);

    mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mPm = getPackageManager();
    mUm = (UserManager) getSystemService(Context.USER_SERVICE);

    addPreferencesFromResource(R.xml.wireless_settings);

    final int myUserId = UserHandle.myUserId();
    final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;

    final Activity activity = getActivity();
    mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
    SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
    PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
    SwitchPreference nsd = (SwitchPreference) findPreference(KEY_TOGGLE_NSD);

    mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
    mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);

    mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);

    // Remove NSD checkbox by default
    getPreferenceScreen().removePreference(nsd);
    // mNsdEnabler = new NsdEnabler(activity, nsd);

    String toggleable =
        Settings.Global.getString(
            activity.getContentResolver(), Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);

    // enable/disable wimax depending on the value in config.xml
    final boolean isWimaxEnabled =
        !isSecondaryUser
            && this.getResources().getBoolean(com.android.internal.R.bool.config_wimaxEnabled);
    if (!isWimaxEnabled || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
      PreferenceScreen root = getPreferenceScreen();
      Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
      if (ps != null) root.removePreference(ps);
    } else {
      if (toggleable == null
          || !toggleable.contains(Settings.Global.RADIO_WIMAX) && isWimaxEnabled) {
        Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
        ps.setDependency(KEY_TOGGLE_AIRPLANE);
      }
    }

    // Manually set dependencies for Wifi when not toggleable.
    if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
      findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
    }
    // Disable VPN.
    if (isSecondaryUser || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
      removePreference(KEY_VPN_SETTINGS);
    }

    // Manually set dependencies for Bluetooth when not toggleable.
    if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
      // No bluetooth-dependent items in the list. Code kept in case one is added later.
    }

    // Manually set dependencies for NFC when not toggleable.
    if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
      findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
      findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
    }

    // Remove NFC if not available
    mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
    if (mNfcAdapter == null) {
      getPreferenceScreen().removePreference(nfc);
      getPreferenceScreen().removePreference(androidBeam);
      mNfcEnabler = null;
    }

    // Remove Mobile Network Settings and Manage Mobile Plan for secondary users,
    // if it's a wifi-only device, or if the settings are restricted.
    if (isSecondaryUser
        || Utils.isWifiOnly(getActivity())
        || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
      removePreference(KEY_MOBILE_NETWORK_SETTINGS);
      removePreference(KEY_MANAGE_MOBILE_PLAN);
    }
    // Remove Mobile Network Settings and Manage Mobile Plan
    // if config_show_mobile_plan sets false.
    final boolean isMobilePlanEnabled =
        this.getResources().getBoolean(R.bool.config_show_mobile_plan);
    if (!isMobilePlanEnabled) {
      Preference pref = findPreference(KEY_MANAGE_MOBILE_PLAN);
      if (pref != null) {
        removePreference(KEY_MANAGE_MOBILE_PLAN);
      }
    }

    // Remove Airplane Mode settings if it's a stationary device such as a TV.
    if (mPm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
      removePreference(KEY_TOGGLE_AIRPLANE);
    }

    // Enable Proxy selector settings if allowed.
    Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
    final DevicePolicyManager mDPM =
        (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
    // proxy UI disabled until we have better app support
    getPreferenceScreen().removePreference(mGlobalProxy);
    mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);

    // Disable Tethering if it's not allowed or if it's a wifi-only device
    final ConnectivityManager cm =
        (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (isSecondaryUser
        || !cm.isTetheringSupported()
        || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
      getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
    } else {
      Preference p = findPreference(KEY_TETHER_SETTINGS);
      p.setTitle(com.android.settingslib.Utils.getTetheringLabel(cm));

      // Grey out if provisioning is not available.
      p.setEnabled(!TetherSettings.isProvisioningNeededButUnavailable(getActivity()));
    }

    // Enable link to CMAS app settings depending on the value in config.xml.
    boolean isCellBroadcastAppLinkEnabled =
        this.getResources().getBoolean(com.android.internal.R.bool.config_cellBroadcastAppLinks);
    try {
      if (isCellBroadcastAppLinkEnabled) {
        if (mPm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
            == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
          isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
        }
      }
    } catch (IllegalArgumentException ignored) {
      isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
    }
    if (isSecondaryUser
        || !isCellBroadcastAppLinkEnabled
        || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
      PreferenceScreen root = getPreferenceScreen();
      Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
      if (ps != null) root.removePreference(ps);
    }
  }
        @Override
        public List<String> getNonIndexableKeys(Context context) {
          final ArrayList<String> result = new ArrayList<String>();

          result.add(KEY_TOGGLE_NSD);

          final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
          final int myUserId = UserHandle.myUserId();
          final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
          final boolean isWimaxEnabled =
              !isSecondaryUser
                  && context
                      .getResources()
                      .getBoolean(com.android.internal.R.bool.config_wimaxEnabled);
          if (!isWimaxEnabled
              || um.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
            result.add(KEY_WIMAX_SETTINGS);
          }

          if (isSecondaryUser) { // Disable VPN
            result.add(KEY_VPN_SETTINGS);
          }

          // Remove NFC if not available
          final NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
          if (manager != null) {
            NfcAdapter adapter = manager.getDefaultAdapter();
            if (adapter == null) {
              result.add(KEY_TOGGLE_NFC);
              result.add(KEY_ANDROID_BEAM_SETTINGS);
            }
          }

          // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device.
          if (isSecondaryUser || Utils.isWifiOnly(context)) {
            result.add(KEY_MOBILE_NETWORK_SETTINGS);
            result.add(KEY_MANAGE_MOBILE_PLAN);
          }

          // Remove Mobile Network Settings and Manage Mobile Plan
          // if config_show_mobile_plan sets false.
          final boolean isMobilePlanEnabled =
              context.getResources().getBoolean(R.bool.config_show_mobile_plan);
          if (!isMobilePlanEnabled) {
            result.add(KEY_MANAGE_MOBILE_PLAN);
          }

          final PackageManager pm = context.getPackageManager();

          // Remove Airplane Mode settings if it's a stationary device such as a TV.
          if (pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
            result.add(KEY_TOGGLE_AIRPLANE);
          }

          // proxy UI disabled until we have better app support
          result.add(KEY_PROXY_SETTINGS);

          // Disable Tethering if it's not allowed or if it's a wifi-only device
          ConnectivityManager cm =
              (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
          if (isSecondaryUser || !cm.isTetheringSupported()) {
            result.add(KEY_TETHER_SETTINGS);
          }

          // Enable link to CMAS app settings depending on the value in config.xml.
          boolean isCellBroadcastAppLinkEnabled =
              context
                  .getResources()
                  .getBoolean(com.android.internal.R.bool.config_cellBroadcastAppLinks);
          try {
            if (isCellBroadcastAppLinkEnabled) {
              if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
                  == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
                isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
              }
            }
          } catch (IllegalArgumentException ignored) {
            isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
          }
          if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
            result.add(KEY_CELL_BROADCAST_SETTINGS);
          }

          return result;
        }
예제 #25
0
 /** Check if we've hit the limit of how many users can be created. */
 private boolean isUserLimitReachedLocked() {
   int nUsers = mUsers.size();
   return nUsers >= UserManager.getMaxSupportedUsers();
 }
 /** Returns true if the current user is restricted from using location. */
 private boolean isUserLocationRestricted(int userId) {
   final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
   return um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, new UserHandle(userId));
 }
예제 #27
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load preferences from xml.
    addPreferencesFromResource(FRAGMENT_RES[mXmlResId]);
    PreferenceScreen screen = getPreferenceScreen();

    if (!FeatureOption.MTK_DT_SUPPORT) {
      removePreference(screen, "dualtalk_network_info");
      removePreference(screen, "dualtalk_bandmode");
    }

    // Duplicate with Network Selecting, remove them
    removePreference(screen, "digital_standard");
    if (ModemCategory.getModemType() == ModemCategory.MODEM_TD) {
      removePreference(screen, "rat_mode");
    }

    if (!FeatureOption.MTK_DT_SUPPORT) {
      removePreference(screen, "dualtalk_network_select");
    } else {
      removePreference(screen, "network_select");
    }

    // if
    // (NfcAdapter.getDefaultAdapter(getActivity().getApplicationContext())
    // == null) {
    // removePreference(screen, "nfc");
    // }
    // it's ok
    int versionCode =
        Settings.Global.getInt(getActivity().getContentResolver(), "nfc_controller_code", -1);
    if (FRAGMENT_RES[mXmlResId] == R.xml.connectivity) {
      switch (versionCode) {
        case MTK_NFC_CHIP_TYPE_MSR3110:
          Xlog.i(TAG, "MSR3110 nfc chip, call nfc");
          removePreference(screen, "hqanfc");
          break;
        case MTK_NFC_CHIP_TYPE_MT6605:
          Xlog.i(TAG, "MT6605 nfc chip, call hqanfc");
          removePreference(screen, "nfc");
          break;
        default:
          Xlog.i(TAG, "no nfc chip support");
          removePreference(screen, "hqanfc");
          removePreference(screen, "nfc");
          break;
      }
    }
    if (!FeatureOption.MTK_NFC_SUPPORT) {
      removePreference(screen, "nfc_dta");
    }
    /*if (!FeatureOption.MTK_LOG2SERVER_APP) {
        removePreference(screen, "log2server");
    }*/

    if (FeatureOption.EVDO_DT_SUPPORT
        || !FeatureOption.MTK_DT_SUPPORT
        || SystemProperties.getInt("ril.external.md", 0) == 0) {
      removePreference(screen, "ext_md_logger");
    }

    if (!FeatureOption.MTK_SMSREG_APP) {
      removePreference(screen, "device_manager");
    }

    if (FeatureOption.MTK_BSP_PACKAGE) {
      removePreference(screen, "auto_answer");
    }

    if (ChipSupport.isFeatureSupported(ChipSupport.MTK_FM_SUPPORT)) {
      if (!ChipSupport.isFeatureSupported(ChipSupport.MTK_FM_TX_SUPPORT)) {
        removePreference(screen, "fm_transmitter");
      }
    } else {
      removePreference(screen, "fm_receiver");
      removePreference(screen, "fm_transmitter");
    }

    // AGPS is not ready if MTK_AGPS_APP isn't defined
    if (!ChipSupport.isFeatureSupported(ChipSupport.MTK_AGPS_APP)
        || !ChipSupport.isFeatureSupported(ChipSupport.MTK_GPS_SUPPORT)) {
      removePreference(screen, "location_basedservice");
    }

    if (!ChipSupport.isFeatureSupported(ChipSupport.MTK_GPS_SUPPORT)) {
      removePreference(screen, "ygps");
      removePreference(screen, "cw_test");
    }

    // MATV is not ready if HAVE_MATV_FEATURE isn't defined
    if (!ChipSupport.isFeatureSupported(ChipSupport.HAVE_MATV_FEATURE)) {
      removePreference(screen, "matv");
    }

    // BT is not ready if MTK_BT_SUPPORT isn't defined
    if (!ChipSupport.isFeatureSupported(ChipSupport.MTK_BT_SUPPORT)) {
      removePreference(screen, "bluetooth");
    }

    // wifi is not ready if MTK_WLAN_SUPPORT isn't defined
    if (!ChipSupport.isFeatureSupported(ChipSupport.MTK_WLAN_SUPPORT)) {
      removePreference(screen, "wifi");
    }

    if (!isVoiceCapable() || isWifiOnly()) {
      removePreference(screen, "auto_answer");
      removePreference(screen, "repeat_call_test");
      removePreference(screen, "video_telephony");
    }

    if (!FeatureOption.MTK_VT3G324M_SUPPORT) {
      removePreference(screen, "video_telephony");
    }

    if (isWifiOnly()) {
      removePreference(screen, "GPRS");
      removePreference(screen, "Modem");
      removePreference(screen, "NetworkInfo");
      removePreference(screen, "Baseband");
      removePreference(screen, "SIMMeLock");
      removePreference(screen, "BandMode");
      removePreference(screen, "RAT Mode");
      removePreference(screen, "SWLA");
      removePreference(screen, "ModemTest");
    }

    // if it single sim, then the flow is the same as before
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      /**
       * if it is Gemini, then the flow is : it start a TabActivity, then the TabActivity will start
       * sim1 or sim2 simLock activity Intent to launch SIM lock TabActivity
       */
      // intent.setComponent(new
      // ComponentName("com.android.simmelock","com.android.simmelock.TabLockList"));
      removePreference(screen, "simme_lock1");
    } else {
      // Intent to launch SIM lock settings
      // intent.setComponent(new
      // ComponentName("com.android.simmelock","com.android.simmelock.LockList"));
      removePreference(screen, "simme_lock2");
    }
    Xlog.i(TAG, "ChipSupport.getChip(): " + ChipSupport.getChip());
    if (ChipSupport.MTK_6589_SUPPORT > ChipSupport.getChip()) {
      removePreference(screen, "de_sense");
      removePreference(screen, "camera89");
    } else {
      removePreference(screen, "camera");
    }

    if (!FeatureOption.MTK_FD_SUPPORT) {
      removePreference(screen, "fast_dormancy");
    }

    File innerLoadIndicator = new File(INNER_LOAD_INDICATOR_FILE);
    if (!innerLoadIndicator.exists()) {
      removePreference(screen, "system_update");
    }
    if (!ChipSupport.isChipInSet(ChipSupport.CHIP_657X_SERIES_NEW)) {
      removePreference(screen, "deep_idle");
      removePreference(screen, "sleep_mode");
      removePreference(screen, "dcm");
      removePreference(screen, "pll_cg");
      removePreference(screen, "cpu_dvfs");
      removePreference(screen, "mcdi_setting");
    }

    if (!FeatureOption.MTK_CDS_EM_SUPPORT) {
      removePreference(screen, "cds_information");
    }

    Preference pref = (Preference) findPreference("cmas");
    if (pref != null && !isActivityAvailable(pref.getIntent())) {
      removePreference(screen, "cmas");
    }

    if (!FeatureOption.MTK_WORLD_PHONE) {
      removePreference(screen, "world_phone");
    }

    if (!FeatureOption.EVDO_DT_SUPPORT) {
      removePreference(screen, "saber");
    }

    String mOptr = SystemProperties.get("ro.operator.optr");
    if (!"OP01".equals(mOptr)) {
      removePreference(screen, "ConfigureCheck2_Send_Test");
      removePreference(screen, "ConfigureCheck2_Self_Test");
    }

    if ("OP09".equals(mOptr)) { // For CT
      removePreference(screen, "network_select");
      removePreference(screen, "dualtalk_network_select");
    } else {
      removePreference(screen, "cdma_network_select");
    }

    if (!FeatureOption.MTK_DEVREG_APP) {
      removePreference(screen, "device_register");
    }

    if (!FeatureOption.MTK_WFD_SUPPORT) {
      removePreference(screen, "wfd_settings");
    }

    if (!FeatureOption.MTK_LTE_DC_SUPPORT) {
      removePreference(screen, "lte_config");
    }
    if (!FeatureOption.MTK_LTE_SUPPORT) {
      removePreference(screen, "lte_network_info");
    }
    removePreference(screen, "lte_network_mode");

    if (!CipUtil.isCipSupported()) {
      removePreference(screen, "cip");
    }

    if (UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers()) {
      // Remove all items used phone instance
      removePreference(screen, "bandmode");
      removePreference(screen, "te_dev_tool");
      removePreference(screen, "cds_information");
      removePreference(screen, "cfu");
      removePreference(screen, "fast_dormancy");
      removePreference(screen, "gprs");
      removePreference(screen, "hspa_info");
      removePreference(screen, "mobile_data_prefer");
      removePreference(screen, "modem_test");
      removePreference(screen, "modem_warning");
      removePreference(screen, "network_info");
      removePreference(screen, "dualtalk_network_info");
      removePreference(screen, "network_select");
      removePreference(screen, "cdma_network_select");
      removePreference(screen, "dualtalk_network_select");
      removePreference(screen, "rat_mode");
      removePreference(screen, "rf_desense_test");
      removePreference(screen, "swla");
      removePreference(screen, "simme_lock1");
      removePreference(screen, "simme_lock2");
      removePreference(screen, "world_phone");
      removePreference(screen, "lte_config");
      removePreference(screen, "lte_network_mode");
      removePreference(screen, "lte_network_info");
      removePreference(screen, "lte_tool");
    }

    if (!FeatureOption.MTK_DFO_RESOLUTION_SUPPORT) {
      removePreference(screen, "dfo");
    }
  }
 private boolean isUsbTransferAllowed() {
   UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
   return !userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
 }
예제 #29
0
 public void runGetMaxUsers() {
   System.out.println("Maximum supported users: " + UserManager.getMaxSupportedUsers());
 }