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)));
    }
  }
Beispiel #2
0
 public void sendMessage(TxData data) {
   for (int i = 0; i < list.size(); i++) {
     if (list.valueAt(i).getIpAddress() == data.getDevice()) {
       list.valueAt(i).sendMessage(data);
     }
   }
 }
Beispiel #3
0
 public void deleteSocket(String device) throws IOException {
   for (int i = 0; i < list.size(); i++) {
     if (list.valueAt(i).getIpAddress() == device) {
       list.valueAt(i).close();
       list.removeAt(i);
     }
   }
 }
 private CharSequence getDomainsSummary(String packageName) {
   // If the user has explicitly said "no" for this package, that's the
   // string we should show.
   int domainStatus = mPm.getIntentVerificationStatus(packageName, UserHandle.myUserId());
   if (domainStatus == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) {
     return mContext.getString(R.string.domain_urls_summary_none);
   }
   // Otherwise, ask package manager for the domains for this package,
   // and show the first one (or none if there aren't any).
   ArraySet<String> result = Utils.getHandledDomains(mPm, packageName);
   if (result.size() == 0) {
     return mContext.getString(R.string.domain_urls_summary_none);
   } else if (result.size() == 1) {
     return mContext.getString(R.string.domain_urls_summary_one, result.valueAt(0));
   } else {
     return mContext.getString(R.string.domain_urls_summary_some, result.valueAt(0));
   }
 }
 /** Returns the list of supported refresh rates in the default mode. */
 public float[] getDefaultRefreshRates() {
   Display.Mode[] modes = supportedModes;
   ArraySet<Float> rates = new ArraySet<>();
   Display.Mode defaultMode = getDefaultMode();
   for (int i = 0; i < modes.length; i++) {
     Display.Mode mode = modes[i];
     if (mode.getPhysicalWidth() == defaultMode.getPhysicalWidth()
         && mode.getPhysicalHeight() == defaultMode.getPhysicalHeight()) {
       rates.add(mode.getRefreshRate());
     }
   }
   float[] result = new float[rates.size()];
   int i = 0;
   for (Float rate : rates) {
     result[i++] = rate;
   }
   return result;
 }
Beispiel #6
0
 public void deleteAll() throws IOException {
   for (int i = 0; i < list.size(); i++) {
     list.valueAt(i).close();
   }
   list.clear();
 }
 // Dumpsys infrastructure
 public void dump(PrintWriter pw, String prefix, boolean full) {
   pw.print(prefix);
   UserHandle.formatUid(pw, callingUid);
   pw.print(" tag=");
   pw.println(tag);
   pw.print(prefix);
   pw.print("Source: uid=");
   UserHandle.formatUid(pw, getSourceUid());
   pw.print(" user="******" pkg=");
   pw.println(getSourcePackageName());
   if (full) {
     pw.print(prefix);
     pw.println("JobInfo:");
     pw.print(prefix);
     pw.print("  Service: ");
     pw.println(job.getService().flattenToShortString());
     if (job.isPeriodic()) {
       pw.print(prefix);
       pw.print("  PERIODIC: interval=");
       TimeUtils.formatDuration(job.getIntervalMillis(), pw);
       pw.print(" flex=");
       TimeUtils.formatDuration(job.getFlexMillis(), pw);
       pw.println();
     }
     if (job.isPersisted()) {
       pw.print(prefix);
       pw.println("  PERSISTED");
     }
     if (job.getPriority() != 0) {
       pw.print(prefix);
       pw.print("  Priority: ");
       pw.println(job.getPriority());
     }
     if (job.getFlags() != 0) {
       pw.print(prefix);
       pw.print("  Flags: ");
       pw.println(Integer.toHexString(job.getFlags()));
     }
     pw.print(prefix);
     pw.print("  Requires: charging=");
     pw.print(job.isRequireCharging());
     pw.print(" deviceIdle=");
     pw.println(job.isRequireDeviceIdle());
     if (job.getTriggerContentUris() != null) {
       pw.print(prefix);
       pw.println("  Trigger content URIs:");
       for (int i = 0; i < job.getTriggerContentUris().length; i++) {
         JobInfo.TriggerContentUri trig = job.getTriggerContentUris()[i];
         pw.print(prefix);
         pw.print("    ");
         pw.print(Integer.toHexString(trig.getFlags()));
         pw.print(' ');
         pw.println(trig.getUri());
       }
       if (job.getTriggerContentUpdateDelay() >= 0) {
         pw.print(prefix);
         pw.print("  Trigger update delay: ");
         TimeUtils.formatDuration(job.getTriggerContentUpdateDelay(), pw);
         pw.println();
       }
       if (job.getTriggerContentMaxDelay() >= 0) {
         pw.print(prefix);
         pw.print("  Trigger max delay: ");
         TimeUtils.formatDuration(job.getTriggerContentMaxDelay(), pw);
         pw.println();
       }
     }
     if (job.getNetworkType() != JobInfo.NETWORK_TYPE_NONE) {
       pw.print(prefix);
       pw.print("  Network type: ");
       pw.println(job.getNetworkType());
     }
     if (job.getMinLatencyMillis() != 0) {
       pw.print(prefix);
       pw.print("  Minimum latency: ");
       TimeUtils.formatDuration(job.getMinLatencyMillis(), pw);
       pw.println();
     }
     if (job.getMaxExecutionDelayMillis() != 0) {
       pw.print(prefix);
       pw.print("  Max execution delay: ");
       TimeUtils.formatDuration(job.getMaxExecutionDelayMillis(), pw);
       pw.println();
     }
     pw.print(prefix);
     pw.print("  Backoff: policy=");
     pw.print(job.getBackoffPolicy());
     pw.print(" initial=");
     TimeUtils.formatDuration(job.getInitialBackoffMillis(), pw);
     pw.println();
     if (job.hasEarlyConstraint()) {
       pw.print(prefix);
       pw.println("  Has early constraint");
     }
     if (job.hasLateConstraint()) {
       pw.print(prefix);
       pw.println("  Has late constraint");
     }
   }
   pw.print(prefix);
   pw.print("Required constraints:");
   dumpConstraints(pw, requiredConstraints);
   pw.println();
   if (full) {
     pw.print(prefix);
     pw.print("Satisfied constraints:");
     dumpConstraints(pw, satisfiedConstraints);
     pw.println();
     pw.print(prefix);
     pw.print("Unsatisfied constraints:");
     dumpConstraints(pw, (requiredConstraints & ~satisfiedConstraints));
     pw.println();
     if (dozeWhitelisted) {
       pw.print(prefix);
       pw.println("Doze whitelisted: true");
     }
   }
   if (changedAuthorities != null) {
     pw.print(prefix);
     pw.println("Changed authorities:");
     for (int i = 0; i < changedAuthorities.size(); i++) {
       pw.print(prefix);
       pw.print("  ");
       pw.println(changedAuthorities.valueAt(i));
     }
     if (changedUris != null) {
       pw.print(prefix);
       pw.println("Changed URIs:");
       for (int i = 0; i < changedUris.size(); i++) {
         pw.print(prefix);
         pw.print("  ");
         pw.println(changedUris.valueAt(i));
       }
     }
   }
   pw.print(prefix);
   pw.print("Earliest run time: ");
   pw.println(formatRunTime(earliestRunTimeElapsedMillis, NO_EARLIEST_RUNTIME));
   pw.print(prefix);
   pw.print("Latest run time: ");
   pw.println(formatRunTime(latestRunTimeElapsedMillis, NO_LATEST_RUNTIME));
   if (numFailures != 0) {
     pw.print(prefix);
     pw.print("Num failures: ");
     pw.println(numFailures);
   }
 }