// Path: Android/app/src/main/java/app/intra/net/doh/Transaction.java
// public class Transaction implements Serializable {
// 
//   public enum Status {
//     COMPLETE,
//     SEND_FAIL,
//     HTTP_ERROR,
//     BAD_RESPONSE,
//     INTERNAL_ERROR,
//     CANCELED
//   }
// 
//   public Transaction(DnsPacket query, long timestamp) {
//     this.name = query.getQueryName();
//     this.type = query.getQueryType();
//     this.queryTime = timestamp;
//   }
// 
//   public final long queryTime;
//   public final String name;
//   public final short type;
//   public long responseTime;
//   public Status status;
//   public byte[] response;
//   public Calendar responseCalendar;
//   public String serverIp;
// }


import static android.content.Context.MODE_PRIVATE;
import android.content.Context;
import android.content.SharedPreferences;
import app.intra.net.doh.Transaction;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Queue;
/*
Copyright 2018 Jigsaw Operations LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package app.intra.sys;



/**
 * A class for tracking DNS transactions.  This class counts the number of successful transactions,
 * records the last minute of query timestamps, and optionally maintains a history of recent
 * transactions.
 * Thread-safe.
 */
public class QueryTracker {

  private static final String NUM_REQUESTS = "numRequests";

  private static final int HISTORY_SIZE = 100;
  private static final int ACTIVITY_MEMORY_MS = 60 * 1000;  // One minute

  private long numRequests = 0;
// Path: Android/app/src/main/java/app/intra/net/doh/Transaction.java
// public class Transaction implements Serializable {
// 
//   public enum Status {
//     COMPLETE,
//     SEND_FAIL,
//     HTTP_ERROR,
//     BAD_RESPONSE,
//     INTERNAL_ERROR,
//     CANCELED
//   }
// 
//   public Transaction(DnsPacket query, long timestamp) {
//     this.name = query.getQueryName();
//     this.type = query.getQueryType();
//     this.queryTime = timestamp;
//   }
// 
//   public final long queryTime;
//   public final String name;
//   public final short type;
//   public long responseTime;
//   public Status status;
//   public byte[] response;
//   public Calendar responseCalendar;
//   public String serverIp;
// }


// Path: Android/app/src/main/java/app/intra/sys/QueryTracker.java
import static android.content.Context.MODE_PRIVATE;
import android.content.Context;
import android.content.SharedPreferences;
import app.intra.net.doh.Transaction;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Queue;

/*
Copyright 2018 Jigsaw Operations LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package app.intra.sys;



/**
 * A class for tracking DNS transactions.  This class counts the number of successful transactions,
 * records the last minute of query timestamps, and optionally maintains a history of recent
 * transactions.
 * Thread-safe.
 */
public class QueryTracker {

  private static final String NUM_REQUESTS = "numRequests";

  private static final int HISTORY_SIZE = 100;
  private static final int ACTIVITY_MEMORY_MS = 60 * 1000;  // One minute

  private long numRequests = 0;
  private Queue<Transaction> recentTransactions = new LinkedList<>();