private void dumpInternal(PrintWriter pw) {
    pw.println("DISPLAY MANAGER (dumpsys display)");

    synchronized (mSyncRoot) {
      pw.println("  mOnlyCode=" + mOnlyCore);
      pw.println("  mSafeMode=" + mSafeMode);
      pw.println("  mPendingTraversal=" + mPendingTraversal);
      pw.println("  mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState));
      pw.println("  mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
      pw.println("  mDefaultViewport=" + mDefaultViewport);
      pw.println("  mExternalTouchViewport=" + mExternalTouchViewport);
      pw.println("  mSingleDisplayDemoMode=" + mSingleDisplayDemoMode);
      pw.println("  mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount);

      IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "    ");
      ipw.increaseIndent();

      pw.println();
      pw.println("Display Adapters: size=" + mDisplayAdapters.size());
      for (DisplayAdapter adapter : mDisplayAdapters) {
        pw.println("  " + adapter.getName());
        adapter.dumpLocked(ipw);
      }

      pw.println();
      pw.println("Display Devices: size=" + mDisplayDevices.size());
      for (DisplayDevice device : mDisplayDevices) {
        pw.println("  " + device.getDisplayDeviceInfoLocked());
        device.dumpLocked(ipw);
      }

      final int logicalDisplayCount = mLogicalDisplays.size();
      pw.println();
      pw.println("Logical Displays: size=" + logicalDisplayCount);
      for (int i = 0; i < logicalDisplayCount; i++) {
        int displayId = mLogicalDisplays.keyAt(i);
        LogicalDisplay display = mLogicalDisplays.valueAt(i);
        pw.println("  Display " + displayId + ":");
        display.dumpLocked(ipw);
      }

      final int callbackCount = mCallbacks.size();
      pw.println();
      pw.println("Callbacks: size=" + callbackCount);
      for (int i = 0; i < callbackCount; i++) {
        CallbackRecord callback = mCallbacks.valueAt(i);
        pw.println(
            "  "
                + i
                + ": mPid="
                + callback.mPid
                + ", mWifiDisplayScanRequested="
                + callback.mWifiDisplayScanRequested);
      }

      if (mDisplayPowerController != null) {
        mDisplayPowerController.dump(pw);
      }
    }
  }
  /**
   * Used by {@link LocationManager#getGpsStatus} to copy LocationManager's cached GpsStatus
   * instance to the client's copy. Since this method is only used within {@link
   * LocationManager#getGpsStatus}, it does not need to be synchronized.
   */
  void setStatus(GpsStatus status) {
    mTimeToFirstFix = status.getTimeToFirstFix();
    clearSatellites();

    SparseArray<GpsSatellite> otherSatellites = status.mSatellites;
    int otherSatellitesCount = otherSatellites.size();
    int satelliteIndex = 0;
    // merge both sparse arrays, note that we have already invalidated the elements in the
    // receiver array
    for (int i = 0; i < otherSatellitesCount; ++i) {
      GpsSatellite otherSatellite = otherSatellites.valueAt(i);
      int otherSatellitePrn = otherSatellite.getPrn();

      int satellitesCount = mSatellites.size();
      while (satelliteIndex < satellitesCount
          && mSatellites.valueAt(satelliteIndex).getPrn() < otherSatellitePrn) {
        ++satelliteIndex;
      }

      if (satelliteIndex < mSatellites.size()) {
        GpsSatellite satellite = mSatellites.valueAt(satelliteIndex);
        if (satellite.getPrn() == otherSatellitePrn) {
          satellite.setStatus(otherSatellite);
        } else {
          satellite = new GpsSatellite(otherSatellitePrn);
          satellite.setStatus(otherSatellite);
          mSatellites.put(otherSatellitePrn, satellite);
        }
      } else {
        GpsSatellite satellite = new GpsSatellite(otherSatellitePrn);
        satellite.setStatus(otherSatellite);
        mSatellites.append(otherSatellitePrn, satellite);
      }
    }
  }
예제 #3
0
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   // Slog.d(TAG, "received " + action);
   if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
     int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
     if (userId >= 0) {
       getImplForUser(userId).sendInitialBroadcasts();
     } else {
       Slog.w(TAG, "Incorrect user handle supplied in " + intent);
     }
   } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
     for (int i = 0; i < mAppWidgetServices.size(); i++) {
       AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
       service.onConfigurationChanged();
     }
   } else {
     int sendingUser = getSendingUserId();
     if (sendingUser == UserHandle.USER_ALL) {
       for (int i = 0; i < mAppWidgetServices.size(); i++) {
         AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
         service.onBroadcastReceived(intent);
       }
     } else {
       AppWidgetServiceImpl service = mAppWidgetServices.get(sendingUser);
       if (service != null) {
         service.onBroadcastReceived(intent);
       }
     }
   }
 }
예제 #4
0
 /**
  * Read as much as possible from the tag with the given key information.
  *
  * @param keyMap Keys (A and B) mapped to a sector. See {@link #buildNextKeyMapPart()}.
  * @return A Key-Value Pair. Keys are the sector numbers, values are the tag data. This tag data
  *     (values) are arrays containing one block per field (index 0-3 or 0-15). If a block is
  *     "null" it means that the block couldn't be read with the given key information.<br>
  *     On Error "null" will be returned (tag was removed during reading or keyMap is null). If
  *     none of the keys in the key map is valid for reading and therefore no sector is read, an
  *     empty set (SparseArray.size() == 0) will be returned.
  * @see #buildNextKeyMapPart()
  */
 public SparseArray<String[]> readAsMuchAsPossible(SparseArray<byte[][]> keyMap) {
   SparseArray<String[]> ret = null;
   if (keyMap != null && keyMap.size() > 0) {
     ret = new SparseArray<String[]>(keyMap.size());
     // For all entries in map do:
     for (int i = 0; i < keyMap.size(); i++) {
       String[][] results = new String[2][];
       try {
         if (keyMap.valueAt(i)[0] != null) {
           // Read with key A.
           results[0] = readSector(keyMap.keyAt(i), keyMap.valueAt(i)[0], false);
         }
         if (keyMap.valueAt(i)[1] != null) {
           // Read with key B.
           results[1] = readSector(keyMap.keyAt(i), keyMap.valueAt(i)[1], true);
         }
       } catch (TagLostException e) {
         return null;
       }
       // Merge results.
       if (results[0] != null || results[1] != null) {
         ret.put(keyMap.keyAt(i), mergeSectorData(results[0], results[1]));
       }
     }
     return ret;
   }
   return ret;
 }
예제 #5
0
 @Override
 public void run() {
   if (internaldetector.isOperational()) {
     if (null != mImage) {
       // ByteBuffer imgBuffr=
       Log.e(
           "IMG", "format : " + mImage.getFormat() + "  |  SIZE " + (mImage.getPlanes()).length);
       Frame frm =
           new Frame.Builder()
               .setImageData(
                   mImage.getPlanes()[0].getBuffer(),
                   mImage.getWidth(),
                   mImage.getHeight(),
                   ImageFormat.YV12)
               .build();
       SparseArray<Barcode> barcodes = internaldetector.detect(frm);
       for (int i = 0; i < barcodes.size(); i++) {
         if (barcodes.valueAt(i).rawValue.length() == 10
             || barcodes.valueAt(i).rawValue.length() == 13) {
           mBarcode = barcodes.valueAt(i).rawValue;
           Log.e("BARCODE", mBarcode);
         }
       }
     } else {
       Log.e("ImageReader", "NULL Image");
     }
   } else {
     Log.e("BARCODEERR", "Barcode not usable");
   }
   mImage.close();
   // internaldetector.s
 }
  /** Called by the Binder stub. */
  void dump(String[] args, PrintWriter pw) {
    synchronized (mLock) {
      final long screenOnTime = getScreenOnTimeLocked(checkAndGetTimeLocked());
      IndentingPrintWriter idpw = new IndentingPrintWriter(pw, "  ");
      ArraySet<String> argSet = new ArraySet<>();
      argSet.addAll(Arrays.asList(args));

      final int userCount = mUserState.size();
      for (int i = 0; i < userCount; i++) {
        idpw.printPair("user", mUserState.keyAt(i));
        idpw.println();
        idpw.increaseIndent();
        if (argSet.contains("--checkin")) {
          mUserState.valueAt(i).checkin(idpw, screenOnTime);
        } else {
          mUserState.valueAt(i).dump(idpw, screenOnTime);
          idpw.println();
          if (args.length > 0 && "history".equals(args[0])) {
            mAppIdleHistory.dump(idpw, mUserState.keyAt(i));
          }
        }
        idpw.decreaseIndent();
      }
      pw.write("Screen On Timebase:" + mScreenOnTime + "\n");
    }
  }
예제 #7
0
 /** Caches the list of user ids in an array, adjusting the array size when necessary. */
 private void updateUserIdsLocked() {
   int num = 0;
   for (int i = 0; i < mUsers.size(); i++) {
     if (!mUsers.valueAt(i).partial) {
       num++;
     }
   }
   final int[] newUsers = new int[num];
   int n = 0;
   for (int i = 0; i < mUsers.size(); i++) {
     if (!mUsers.valueAt(i).partial) {
       newUsers[n++] = mUsers.keyAt(i);
     }
   }
   mUserIds = newUsers;
 }
예제 #8
0
  /*
   * Writes the user list file in this format:
   *
   * <users nextSerialNumber="3">
   *   <user id="0"></user>
   *   <user id="2"></user>
   * </users>
   */
  private void writeUserListLocked() {
    FileOutputStream fos = null;
    AtomicFile userListFile = new AtomicFile(mUserListFile);
    try {
      fos = userListFile.startWrite();
      final BufferedOutputStream bos = new BufferedOutputStream(fos);

      // XmlSerializer serializer = XmlUtils.serializerInstance();
      final XmlSerializer serializer = new FastXmlSerializer();
      serializer.setOutput(bos, "utf-8");
      serializer.startDocument(null, true);
      serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

      serializer.startTag(null, TAG_USERS);
      serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
      serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion));

      for (int i = 0; i < mUsers.size(); i++) {
        UserInfo user = mUsers.valueAt(i);
        serializer.startTag(null, TAG_USER);
        serializer.attribute(null, ATTR_ID, Integer.toString(user.id));
        serializer.endTag(null, TAG_USER);
      }

      serializer.endTag(null, TAG_USERS);

      serializer.endDocument();
      userListFile.finishWrite(fos);
    } catch (Exception e) {
      userListFile.failWrite(fos);
      Slog.e(LOG_TAG, "Error writing user list");
    }
  }
 public void releaseDelegate() {
   int length = drawables.size();
   for (int i = 0; i < length; i++) {
     OneStateDrawable drawable = drawables.valueAt(i);
     drawable.releaseDelegate();
   }
 }
 private void clearSatellites() {
   int satellitesCount = mSatellites.size();
   for (int i = 0; i < satellitesCount; i++) {
     GpsSatellite satellite = mSatellites.valueAt(i);
     satellite.mValid = false;
   }
 }
예제 #11
0
 /** Sets whether view should scale down to fit moving part into screen. */
 @SuppressWarnings("unused") // Public API
 public void setAutoScaleEnabled(boolean isAutoScaleEnabled) {
   this.isAutoScaleEnabled = isAutoScaleEnabled;
   for (int i = 0, size = foldableItemsMap.size(); i < size; i++) {
     foldableItemsMap.valueAt(i).setAutoScaleEnabled(isAutoScaleEnabled);
   }
 }
예제 #12
0
  /** Reports whether the bundle contains any parcelled file descriptors. */
  public boolean hasFileDescriptors() {
    if (!mFdsKnown) {
      boolean fdFound = false; // keep going until we find one or run out of data

      if (mParcelledData != null) {
        if (mParcelledData.hasFileDescriptors()) {
          fdFound = true;
        }
      } else {
        // It's been unparcelled, so we need to walk the map
        for (int i = mMap.size() - 1; i >= 0 && !fdFound; i--) {
          Object obj = mMap.valueAt(i);
          if (obj instanceof Parcelable) {
            if ((((Parcelable) obj).describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR)
                != 0) {
              fdFound = true;
              break;
            }
          } else if (obj instanceof Parcelable[]) {
            Parcelable[] array = (Parcelable[]) obj;
            for (int n = array.length - 1; n >= 0; n--) {
              Parcelable p = array[n];
              if (p != null
                  && ((p.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0)) {
                fdFound = true;
                break;
              }
            }
          } else if (obj instanceof SparseArray) {
            SparseArray<? extends Parcelable> array = (SparseArray<? extends Parcelable>) obj;
            for (int n = array.size() - 1; n >= 0; n--) {
              Parcelable p = array.valueAt(n);
              if (p != null && (p.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
                fdFound = true;
                break;
              }
            }
          } else if (obj instanceof ArrayList) {
            ArrayList array = (ArrayList) obj;
            // an ArrayList here might contain either Strings or
            // Parcelables; only look inside for Parcelables
            if (!array.isEmpty() && (array.get(0) instanceof Parcelable)) {
              for (int n = array.size() - 1; n >= 0; n--) {
                Parcelable p = (Parcelable) array.get(n);
                if (p != null
                    && ((p.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0)) {
                  fdFound = true;
                  break;
                }
              }
            }
          }
        }
      }

      mHasFds = fdFound;
      mFdsKnown = true;
    }
    return mHasFds;
  }
 public List<FileDownloaderModel> getAllTask() {
   List<FileDownloaderModel> allTask = new ArrayList<>();
   for (int i = 0; i < mAllTasks.size(); i++) {
     allTask.add(mAllTasks.valueAt(i));
   }
   return allTask;
 }
 public void setImageRepeat(boolean repeat) {
   int length = drawables.size();
   for (int i = 0; i < length; i++) {
     OneStateDrawable drawable = drawables.valueAt(i);
     drawable.setImageRepeat(repeat);
   }
 }
 static {
   CMD_NAMES.append(CMD_NAV_LINE_PREVIOUS, "CMD_NAV_LINE_PREVIOUS");
   CMD_NAMES.append(CMD_NAV_LINE_NEXT, "CMD_NAV_LINE_NEXT");
   CMD_NAMES.append(CMD_NAV_ITEM_PREVIOUS, "CMD_NAV_ITEM_PREVIOUS");
   CMD_NAMES.append(CMD_NAV_ITEM_NEXT, "CMD_NAV_ITEM_NEXT");
   CMD_NAMES.append(CMD_NAV_PAN_LEFT, "CMD_NAV_PAN_LEFT");
   CMD_NAMES.append(CMD_NAV_PAN_RIGHT, "CMD_NAV_PAN_RIGHT");
   CMD_NAMES.append(CMD_NAV_TOP, "CMD_NAV_TOP");
   CMD_NAMES.append(CMD_NAV_BOTTOM, "CMD_NAV_BOTTOM");
   CMD_NAMES.append(CMD_ACTIVATE_CURRENT, "CMD_ACTIVATE_CURRENT");
   CMD_NAMES.append(CMD_SCROLL_BACKWARD, "CMD_SCROLL_BACKWARD");
   CMD_NAMES.append(CMD_SCROLL_FORWARD, "CMD_SCROLL_FORWARD");
   CMD_NAMES.append(CMD_SELECTION_START, "CMD_SELECTION_START");
   CMD_NAMES.append(CMD_SELECTION_END, "CMD_SELECTION_END");
   CMD_NAMES.append(CMD_SELECTION_SELECT_ALL, "CMD_SELECTION_SELECT_ALL");
   CMD_NAMES.append(CMD_SELECTION_CUT, "CMD_SELECTION_CUT");
   CMD_NAMES.append(CMD_SELECTION_COPY, "CMD_SELECTION_COPY");
   CMD_NAMES.append(CMD_SELECTION_PASTE, "CMD_SELECTION_PASTE");
   CMD_NAMES.append(CMD_ROUTE, "CMD_ROUTE");
   CMD_NAMES.append(CMD_BRAILLE_KEY, "CMD_BRAILLE_KEY");
   CMD_NAMES.append(CMD_KEY_ENTER, "CMD_KEY_ENTER");
   CMD_NAMES.append(CMD_KEY_DEL, "CMD_KEY_DEL");
   CMD_NAMES.append(CMD_KEY_FORWARD_DEL, "CMD_KEY_FORWARD_DEL");
   CMD_NAMES.append(CMD_GLOBAL_BACK, "CMD_GLOBAL_BACK");
   CMD_NAMES.append(CMD_GLOBAL_HOME, "CMD_GLOBAL_HOME");
   CMD_NAMES.append(CMD_GLOBAL_RECENTS, "CMD_GLOBAL_RECENTS");
   CMD_NAMES.append(CMD_GLOBAL_NOTIFICATIONS, "CMD_GLOBAL_NOTIFICATIONS");
   CMD_NAMES.append(CMD_HELP, "CMD_HELP");
   for (int i = 0; i < CMD_NAMES.size(); ++i) {
     NAMES_TO_CMDS.put(CMD_NAMES.valueAt(i), CMD_NAMES.keyAt(i));
   }
 }
예제 #16
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Canvas background color depends on whether there is an active touch
    if (mHasTouch) {
      canvas.drawColor(BACKGROUND_ACTIVE);
    } else {
      // draw inactive border
      canvas.drawRect(
          mBorderWidth,
          mBorderWidth,
          getWidth() - mBorderWidth,
          getHeight() - mBorderWidth,
          mBorderPaint);
    }

    // loop through all active touches and draw them
    for (int i = 0; i < mTouches.size(); i++) {

      // get the pointer id and associated data for this index
      int id = mTouches.keyAt(i);
      TouchHistory data = mTouches.valueAt(i);

      // draw the data and its history to the canvas
      drawCircle(canvas, id, data);
    }
  }
 @Override
 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
   if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
       != PackageManager.PERMISSION_GRANTED) {
     pw.println(
         "Permission Denial: can't dump torch service from from pid="
             + Binder.getCallingPid()
             + ", uid="
             + Binder.getCallingUid());
     return;
   }
   pw.println("Current torch service state:");
   pw.println(" Active cameras:");
   for (int i = 0; i < mCamerasInUse.size(); i++) {
     int cameraId = mCamerasInUse.keyAt(i);
     CameraUserRecord record = mCamerasInUse.valueAt(i);
     boolean isTorch = cameraId == mTorchCameraId;
     pw.print(" Camera " + cameraId + " (" + (isTorch ? "torch" : "camera"));
     pw.println("): pid=" + record.pid + "; uid=" + record.uid);
   }
   pw.println(" mTorchEnabled=" + mTorchEnabled);
   pw.println(" mTorchAvailable=" + mTorchAvailable);
   pw.println(" mTorchAppUid=" + mTorchAppUid);
   pw.println(" mTorchCameraId=" + mTorchCameraId);
   pw.println(" mCameraDevice=" + mCameraDevice);
   pw.println(" mOpeningCamera=" + mOpeningCamera);
 }
 private void saveWidgetsToDisk() {
   if (mWidgets.size() == 0) {
     mNoteWidgetData.delete();
     return;
   }
   try {
     ObjectOutputStream out = null;
     try {
       out = new ObjectOutputStream(new FileOutputStream(mNoteWidgetData));
       synchronized (mWidgets) {
         final int count = mWidgets.size();
         NoteWidget[] noteWidgets = new NoteWidget[count];
         for (int i = 0; i < count; i++) {
           noteWidgets[i] = mWidgets.valueAt(i);
         }
         out.writeObject(noteWidgets);
       }
     } finally {
       if (out != null) {
         out.close();
       }
     }
   } catch (IOException e) {
     mNoteWidgetData.delete();
   }
 }
 /** Refreshes the fragments currently in the transactions activity */
 @Override
 public void refresh(long accountId) {
   for (int i = 0; i < mFragmentPageReferenceMap.size(); i++) {
     mFragmentPageReferenceMap.valueAt(i).refresh(accountId);
   }
   mTitlePageIndicator.notifyDataSetChanged();
 }
예제 #20
0
 public int getNumOfVideosOn() {
   int rc = 0;
   for (int i = 0; i < _renders.size(); i++) {
     RenderViewData d = _renders.valueAt(i);
     if (d.isVideoOn()) rc++;
   }
   return rc;
 }
예제 #21
0
 public int getActiveRenders() {
   int rc = 0;
   for (int i = 0; i < _renders.size(); i++) {
     RenderViewData d = _renders.valueAt(i);
     if (!TextUtils.isEmpty(d._user)) rc++;
   }
   return rc;
 }
 @Override
 public Object[] getSections() {
   ArrayList<String> sections = new ArrayList<String>();
   for (int i = 0; i < mSections.size(); i++) {
     sections.add(mSections.valueAt(i));
   }
   return sections.toArray();
 }
 public void setDefaultColor(int defaultColor) {
   this.defaultColor = defaultColor;
   int length = drawables.size();
   for (int i = 0; i < length; i++) {
     OneStateDrawable drawable = drawables.valueAt(i);
     drawable.setDefaultColor(defaultColor);
   }
 }
 public int[] getClientIDs() {
   int length = clients.size();
   int[] ids = new int[length];
   for (int i = 0; i < length; ++i) {
     ids[i] = clients.valueAt(i).clientID;
   }
   return ids;
 }
예제 #25
0
 private void updatePageVisibility() {
   // for (Page page : pages.values()) {
   Page page;
   for (int i = 0; i < pages.size(); i++) {
     page = pages.valueAt(i);
     page.updateVisibility();
   }
 }
예제 #26
0
  private void setNativePointer(long nativePointer) {
    mNativePointer = nativePointer;
    nativeSetPrimaryDisplayId(mNativePointer, mMainSdkDisplayId);

    for (int i = 0; i < mIdMap.size(); ++i) {
      updateDisplayOnNativeSide(mIdMap.valueAt(i));
    }
  }
예제 #27
0
 /**
  * As list.
  *
  * @param <C> the generic type
  * @param sparseArray the sparse array
  * @return the collection
  */
 public static <C> Collection<C> asList(final SparseArray<C> sparseArray) {
   if (sparseArray == null) return null;
   final Collection<C> arrayList = new ArrayList<>(sparseArray.size());
   for (int i = 0; i < sparseArray.size(); i++) {
     arrayList.add(sparseArray.valueAt(i));
   }
   return arrayList;
 }
 private void unbindDrawableResources() {
   if (null != mBitmapCache) {
     for (int i = 0; i < mBitmapCache.size(); i++) {
       Bitmap bitmap = mBitmapCache.valueAt(i);
       bitmap.recycle();
     }
   }
 }
예제 #29
0
 private final List<Integer> getSelectedIds() {
   ArrayList<Integer> selectedIds = new ArrayList<Integer>();
   for (int index = 0; index < mSelectState.size(); index++) {
     if (mSelectState.valueAt(index)) {
       selectedIds.add(mSelectState.keyAt(index));
     }
   }
   return selectedIds;
 }
예제 #30
0
 @Override
 public long getLargestSampleTimestamp() {
   long largestParsedTimestampUs = Long.MIN_VALUE;
   for (int i = 0; i < sampleQueues.size(); i++) {
     largestParsedTimestampUs =
         Math.max(largestParsedTimestampUs, sampleQueues.valueAt(i).getLargestParsedTimestampUs());
   }
   return largestParsedTimestampUs;
 }