test_class.declarator: uriLocations = new HashMap<>()
test_class.original_string: HashMap<String, Uri> uriLocations = new HashMap<>();
test_class.type: HashMap<String, Uri>
test_class.var_name: uriLocations
test_class.file: app/src/test/java/org/jak_linux/dns66/db/RuleDatabaseUpdateTaskTest.java
test_class.identifier: RuleDatabaseUpdateTaskTest
test_case.body: @Test
      public void testReleaseGarbagePermissions() throws Exception {
          Context mockContext = mock(Context.class);
          ContentResolver mockResolver = mock(ContentResolver.class);
          when(mockContext.getContentResolver()).thenReturn(mockResolver);
  
          final List<UriPermission> persistedPermissions = new LinkedList<>();
          when(mockResolver.getPersistedUriPermissions()).thenReturn(persistedPermissions);
  
          UriPermission usedPermission = mock(UriPermission.class);
          when(usedPermission.getUri()).thenReturn(newUri("content://used"));
          persistedPermissions.add(usedPermission);
  
          UriPermission garbagePermission = mock(UriPermission.class);
          when(garbagePermission.getUri()).thenReturn(newUri("content://garbage"));
          persistedPermissions.add(garbagePermission);
  
          doAnswer(new Answer<Void>() {
              @Override
              public Void answer(InvocationOnMock invocation) throws Throwable {
                  Iterator<UriPermission> iter = persistedPermissions.iterator();
                  while (iter.hasNext()) {
                      UriPermission perm = iter.next();
                      if (perm.getUri() == invocation.getArgumentAt(0, Uri.class))
                          iter.remove();
                  }
                  return null;
              }
          }).when(mockResolver, "releasePersistableUriPermission", any(Uri.class), anyInt());
  
          Configuration configuration = new Configuration();
          configuration.hosts.items.add(newItemForLocation("content://used"));
  
          assertTrue(persistedPermissions.contains(usedPermission));
          assertTrue(persistedPermissions.contains(garbagePermission));
  
          new RuleDatabaseUpdateTask(mockContext, configuration, false).releaseGarbagePermissions();
  
          assertTrue(persistedPermissions.contains(usedPermission));
          assertFalse(persistedPermissions.contains(garbagePermission));
      }
test_case.class_method_signature: RuleDatabaseUpdateTaskTest.testReleaseGarbagePermissions()
test_case.full_signature: @Test public void testReleaseGarbagePermissions()
test_case.identifier: testReleaseGarbagePermissions
test_case.invocations: mock mock thenReturn when getContentResolver thenReturn when getPersistedUriPermissions mock thenReturn when getUri newUri add mock thenReturn when getUri newUri add when doAnswer iterator hasNext next getUri getArgumentAt remove any anyInt add newItemForLocation assertTrue contains assertTrue contains releaseGarbagePermissions assertTrue contains assertFalse contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testReleaseGarbagePermissions()
focal_class.declarator: lastErrors = new AtomicReference<>(null)
focal_class.modifier: public static final
focal_class.original_string: public static final AtomicReference<List<String>> lastErrors = new AtomicReference<>(null);
focal_class.type: AtomicReference<List<String>>
focal_class.var_name: lastErrors
focal_class.declarator: TAG = "RuleDatabaseUpdateTask"
focal_class.modifier: private static final
focal_class.original_string: private static final String TAG = "RuleDatabaseUpdateTask";
focal_class.type: String
focal_class.var_name: TAG
focal_class.declarator: UPDATE_NOTIFICATION_ID = 42
focal_class.modifier: private static final
focal_class.original_string: private static final int UPDATE_NOTIFICATION_ID = 42;
focal_class.type: int
focal_class.var_name: UPDATE_NOTIFICATION_ID
focal_class.declarator: context
focal_class.original_string: Context context;
focal_class.type: Context
focal_class.var_name: context
focal_class.declarator: configuration
focal_class.original_string: Configuration configuration;
focal_class.type: Configuration
focal_class.var_name: configuration
focal_class.declarator: errors = new ArrayList<>()
focal_class.original_string: ArrayList<String> errors = new ArrayList<>();
focal_class.type: ArrayList<String>
focal_class.var_name: errors
focal_class.declarator: pending = new ArrayList<>()
focal_class.original_string: List<String> pending = new ArrayList<>();
focal_class.type: List<String>
focal_class.var_name: pending
focal_class.declarator: done = new ArrayList<>()
focal_class.original_string: List<String> done = new ArrayList<>();
focal_class.type: List<String>
focal_class.var_name: done
focal_class.declarator: notificationManager
focal_class.modifier: private
focal_class.original_string: private NotificationManager notificationManager;
focal_class.type: NotificationManager
focal_class.var_name: notificationManager
focal_class.declarator: notificationBuilder
focal_class.modifier: private
focal_class.original_string: private NotificationCompat.Builder notificationBuilder;
focal_class.type: NotificationCompat.Builder
focal_class.var_name: notificationBuilder
focal_class.file: app/src/main/java/org/jak_linux/dns66/db/RuleDatabaseUpdateTask.java
focal_class.identifier: RuleDatabaseUpdateTask
focal_class.class_method_signature: RuleDatabaseUpdateTask.RuleDatabaseUpdateTask(Context context, Configuration configuration, boolean notifications)
focal_class.full_signature: public  RuleDatabaseUpdateTask(Context context, Configuration configuration, boolean notifications)
focal_class.identifier: RuleDatabaseUpdateTask
focal_class.modifiers: public
focal_class.parameters: (Context context, Configuration configuration, boolean notifications)
focal_class.signature:  RuleDatabaseUpdateTask(Context context, Configuration configuration, boolean notifications)
focal_class.class_method_signature: RuleDatabaseUpdateTask.setupNotificationBuilder()
focal_class.full_signature: private void setupNotificationBuilder()
focal_class.identifier: setupNotificationBuilder
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void setupNotificationBuilder()
focal_class.class_method_signature: RuleDatabaseUpdateTask.doInBackground(final Void... configurations)
focal_class.full_signature: @Override protected Void doInBackground(final Void... configurations)
focal_class.identifier: doInBackground
focal_class.modifiers: @Override protected
focal_class.parameters: (final Void... configurations)
focal_class.return: Void
focal_class.signature: Void doInBackground(final Void... configurations)
focal_class.class_method_signature: RuleDatabaseUpdateTask.releaseGarbagePermissions()
focal_class.full_signature:  void releaseGarbagePermissions()
focal_class.identifier: releaseGarbagePermissions
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void releaseGarbagePermissions()
focal_class.class_method_signature: RuleDatabaseUpdateTask.isGarbage(Uri uri)
focal_class.full_signature: private boolean isGarbage(Uri uri)
focal_class.identifier: isGarbage
focal_class.modifiers: private
focal_class.parameters: (Uri uri)
focal_class.return: boolean
focal_class.signature: boolean isGarbage(Uri uri)
focal_class.class_method_signature: RuleDatabaseUpdateTask.getCommand(Configuration.Item item)
focal_class.full_signature: @NonNull RuleDatabaseItemUpdateRunnable getCommand(Configuration.Item item)
focal_class.identifier: getCommand
focal_class.modifiers: @NonNull
focal_class.parameters: (Configuration.Item item)
focal_class.return: RuleDatabaseItemUpdateRunnable
focal_class.signature: RuleDatabaseItemUpdateRunnable getCommand(Configuration.Item item)
focal_class.class_method_signature: RuleDatabaseUpdateTask.updateProgressNotification()
focal_class.full_signature: private synchronized void updateProgressNotification()
focal_class.identifier: updateProgressNotification
focal_class.modifiers: private synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updateProgressNotification()
focal_class.class_method_signature: RuleDatabaseUpdateTask.postExecute()
focal_class.full_signature: private synchronized void postExecute()
focal_class.identifier: postExecute
focal_class.modifiers: private synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void postExecute()
focal_class.class_method_signature: RuleDatabaseUpdateTask.addError(Configuration.Item item, String message)
focal_class.full_signature: synchronized void addError(Configuration.Item item, String message)
focal_class.identifier: addError
focal_class.modifiers: synchronized
focal_class.parameters: (Configuration.Item item, String message)
focal_class.return: void
focal_class.signature: void addError(Configuration.Item item, String message)
focal_class.class_method_signature: RuleDatabaseUpdateTask.addDone(Configuration.Item item)
focal_class.full_signature: synchronized void addDone(Configuration.Item item)
focal_class.identifier: addDone
focal_class.modifiers: synchronized
focal_class.parameters: (Configuration.Item item)
focal_class.return: void
focal_class.signature: void addDone(Configuration.Item item)
focal_class.class_method_signature: RuleDatabaseUpdateTask.addBegin(Configuration.Item item)
focal_class.full_signature: synchronized void addBegin(Configuration.Item item)
focal_class.identifier: addBegin
focal_class.modifiers: synchronized
focal_class.parameters: (Configuration.Item item)
focal_class.return: void
focal_class.signature: void addBegin(Configuration.Item item)
focal_class.class_method_signature: RuleDatabaseUpdateTask.pendingCount()
focal_class.full_signature: synchronized long pendingCount()
focal_class.identifier: pendingCount
focal_class.modifiers: synchronized
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long pendingCount()
focal_class.superclass: extends AsyncTask<Void, Void, Void>
focal_method.body: void releaseGarbagePermissions() {
          ContentResolver contentResolver = context.getContentResolver();
          for (UriPermission permission : contentResolver.getPersistedUriPermissions()) {
              if (isGarbage(permission.getUri())) {
                  Log.i(TAG, "releaseGarbagePermissions: Releasing permission for " + permission.getUri());
                  contentResolver.releasePersistableUriPermission(permission.getUri(), Intent.FLAG_GRANT_READ_URI_PERMISSION);
              } else {
                  Log.v(TAG, "releaseGarbagePermissions: Keeping permission for " + permission.getUri());
              }
          }
      }
focal_method.class_method_signature: RuleDatabaseUpdateTask.releaseGarbagePermissions()
focal_method.full_signature:  void releaseGarbagePermissions()
focal_method.identifier: releaseGarbagePermissions
focal_method.invocations: getContentResolver getPersistedUriPermissions isGarbage getUri i getUri releasePersistableUriPermission getUri v getUri
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void releaseGarbagePermissions()