下面列出了android.util.ArrayMap#entrySet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
@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);
}
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();
}
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();
}
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;
}