Java Code Examples for android.util.ArrayMap#entrySet()

The following examples show how to use android.util.ArrayMap#entrySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnoozeHelper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
protected boolean cancel(int userId, String pkg, String tag, int id) {
    if (mSnoozedNotifications.containsKey(userId)) {
        ArrayMap<String, NotificationRecord> recordsForPkg =
                mSnoozedNotifications.get(userId).get(pkg);
        if (recordsForPkg != null) {
            final Set<Map.Entry<String, NotificationRecord>> records = recordsForPkg.entrySet();
            String key = null;
            for (Map.Entry<String, NotificationRecord> record : records) {
                final StatusBarNotification sbn = record.getValue().sbn;
                if (Objects.equals(sbn.getTag(), tag) && sbn.getId() == id) {
                    record.getValue().isCanceled = true;
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 2
Source File: ResourcesLoader.java    From buck with Apache License 2.0 6 votes vote down vote up
@TargetApi(NOUGAT)
private static void updateResourceKeys(Context context, String originalResourcePath)
    throws InvocationTargetException, IllegalAccessException, NoSuchFieldException, IOException {
  List<String> exoResourcePaths = getExoPaths(context);
  if (exoResourcePaths.isEmpty()) {
    return;
  }
  String resDir = exoResourcePaths.get(0);
  String[] splitResDirs =
      exoResourcePaths
          .subList(1, exoResourcePaths.size())
          .toArray(new String[exoResourcePaths.size() - 1]);

  ArrayMap<?, ?> resourceImpls = ResourcesManagerInternal.getInstance().getResourceImpls();
  ArrayMap<Object, Object> newResourceImpls = new ArrayMap<>(resourceImpls.size());
  for (Map.Entry<?, ?> entry : resourceImpls.entrySet()) {
    Object key = entry.getKey();
    ResourcesKeyInternal keyInternal = new ResourcesKeyInternal(key);
    if (keyInternal.getResDir().equals(originalResourcePath)) {
      keyInternal.setResDir(resDir);
      keyInternal.setSplitResDirs(splitResDirs);
      newResourceImpls.put(key, entry.getValue());
    }
  }
  ResourcesManagerInternal.getInstance().setResourceImpls(newResourceImpls);
}
 
Example 3
Source File: DebugService.java    From input-samples with Apache License 2.0 5 votes vote down vote up
static FillResponse createResponse(@NonNull Context context,
        @NonNull ArrayMap<String, AutofillId> fields, int numDatasets,
        boolean authenticateDatasets) {
    String packageName = context.getPackageName();
    FillResponse.Builder response = new FillResponse.Builder();
    // 1.Add the dynamic datasets
    for (int i = 1; i <= numDatasets; i++) {
        Dataset unlockedDataset = newUnlockedDataset(fields, packageName, i);
        if (authenticateDatasets) {
            Dataset.Builder lockedDataset = new Dataset.Builder();
            for (Entry<String, AutofillId> field : fields.entrySet()) {
                String hint = field.getKey();
                AutofillId id = field.getValue();
                String value = i + "-" + hint;
                IntentSender authentication =
                        SimpleAuthActivity.newIntentSenderForDataset(context, unlockedDataset);
                RemoteViews presentation = newDatasetPresentation(packageName,
                        "Tap to auth " + value);
                lockedDataset.setValue(id, null, presentation)
                        .setAuthentication(authentication);
            }
            response.addDataset(lockedDataset.build());
        } else {
            response.addDataset(unlockedDataset);
        }
    }

    // 2.Add save info
    Collection<AutofillId> ids = fields.values();
    AutofillId[] requiredIds = new AutofillId[ids.size()];
    ids.toArray(requiredIds);
    response.setSaveInfo(
            // We're simple, so we're generic
            new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());

    // 3.Profit!
    return response.build();
}
 
Example 4
Source File: DebugService.java    From android-AutofillFramework with Apache License 2.0 5 votes vote down vote up
static FillResponse createResponse(@NonNull Context context,
        @NonNull ArrayMap<String, AutofillId> fields, int numDatasets,
        boolean authenticateDatasets) {
    String packageName = context.getPackageName();
    FillResponse.Builder response = new FillResponse.Builder();
    // 1.Add the dynamic datasets
    for (int i = 1; i <= numDatasets; i++) {
        Dataset unlockedDataset = newUnlockedDataset(fields, packageName, i);
        if (authenticateDatasets) {
            Dataset.Builder lockedDataset = new Dataset.Builder();
            for (Entry<String, AutofillId> field : fields.entrySet()) {
                String hint = field.getKey();
                AutofillId id = field.getValue();
                String value = i + "-" + hint;
                IntentSender authentication =
                        SimpleAuthActivity.newIntentSenderForDataset(context, unlockedDataset);
                RemoteViews presentation = newDatasetPresentation(packageName,
                        "Tap to auth " + value);
                lockedDataset.setValue(id, null, presentation)
                        .setAuthentication(authentication);
            }
            response.addDataset(lockedDataset.build());
        } else {
            response.addDataset(unlockedDataset);
        }
    }

    // 2.Add save info
    Collection<AutofillId> ids = fields.values();
    AutofillId[] requiredIds = new AutofillId[ids.size()];
    ids.toArray(requiredIds);
    response.setSaveInfo(
            // We're simple, so we're generic
            new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());

    // 3.Profit!
    return response.build();
}
 
Example 5
Source File: Debug.java    From Android-Plugin-Framework with MIT License 4 votes vote down vote up
public static boolean trackHuaweiReceivers() {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        return false;
    }
    boolean maybeLeak = false;
    Object mLoadedApk = new HackApplication(FairyGlobal.getHostApplication()).getLoadedApk();
    if (mLoadedApk != null) {
        Object object = new HackLoadedApk(mLoadedApk).getReceivers();
        if (object != null && object instanceof ArrayMap) {
            ArrayMap arrayMap = (ArrayMap) object;
            Set entrySet = arrayMap.entrySet();
            Iterator entrySetIterator = entrySet.iterator();
            JSONObject jsonObject = new JSONObject();
            while(entrySetIterator.hasNext()) {
                Object entry = entrySetIterator.next();
                if (entry instanceof Map.Entry) {
                    String key1 = ((Map.Entry)entry).getKey().getClass().getName();
                    Object value = ((Map.Entry)entry).getValue();
                    if (value instanceof ArrayMap) {
                        Iterator valueIterator = ((ArrayMap)value).entrySet().iterator();
                        while (valueIterator.hasNext()) {
                            Object valueEntry = valueIterator.next();
                            if (valueEntry instanceof Map.Entry) {
                                String key2 = ((Map.Entry)valueEntry).getKey().getClass().getName();
                                String key = key1 + "->" + key2;
                                int count = jsonObject.optInt(key);
                                count++;
                                try {
                                    jsonObject.put(key, count);
                                } catch (JSONException e) {
                                }
                                if (count >=10) {
                                    maybeLeak = true;
                                }
                            }
                        }
                    }
                }
            }
            Log.e("Debug_track", jsonObject.toString());
        }
    }
    return maybeLeak;
}