// Path: app/src/test/java/android/os/AsyncTask.java
// public abstract class AsyncTask<Params, Progress, Result> {
// 
//   protected abstract Result doInBackground(Params... params);
// 
//   protected void onPostExecute(Result result) {}
// 
//   protected void onProgressUpdate(Progress... values) {}
// 
//   public AsyncTask<Params, Progress, Result> execute(Params... params) {
//     Result result = doInBackground(params);
//     onPostExecute(result);
//     return this;
//   }
// }


import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.NonNull;
import android.util.Log;
import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import com.softartdev.lastfm.CallException;
import com.softartdev.lastfm.Caller;
import com.softartdev.lastfm.Session;
import com.softartdev.lastfm.Track;
import com.softartdev.lastfm.scrobble.ScrobbleData;
import com.softartdev.lastfm.scrobble.ScrobbleResult;
   * Returns {@code true} if this client is authenticated and can be used to make calls to the
   * Last.fm API. A client will be authenticated if it was created with {@link
   * LastfmClient(LastfmApi, Caller, String, String)}, or was authenticated after creation with
   * {@link #getSession(String, Handler.Callback)}.
   */
  public boolean isAuthenticated() {
    return session != null;
  }

  /** Returns the URL to redirect users to for browser-based authentication. */
  public Uri getAuthUrl() {
    return Uri.parse(
        "http://www.last.fm/api/auth/?api_key=" + API_KEY + "&cb=scroball://authenticate");
  }

  /**
   * Authenticates with the Last.fm API using the browser-based token authentication, setting up an
   * active session on this client.
   *
   * @param token token received from the Last.fm API through a redirect.
   * @param callback callback which will be called with an {@link AuthResult} as the message
   *     payload.
   */
  public void getSession(String token, Handler.Callback callback) {
    new GetSessionTask(
            api,
            caller,
            message -> {
              AuthResult result = (AuthResult) message.obj;
              if (result.sessionKey().isPresent()) {
// Path: app/src/test/java/android/os/AsyncTask.java
// public abstract class AsyncTask<Params, Progress, Result> {
// 
//   protected abstract Result doInBackground(Params... params);
// 
//   protected void onPostExecute(Result result) {}
// 
//   protected void onProgressUpdate(Progress... values) {}
// 
//   public AsyncTask<Params, Progress, Result> execute(Params... params) {
//     Result result = doInBackground(params);
//     onPostExecute(result);
//     return this;
//   }
// }


// Path: app/src/main/java/com/peterjosling/scroball/LastfmClient.java
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.NonNull;
import android.util.Log;
import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import com.softartdev.lastfm.CallException;
import com.softartdev.lastfm.Caller;
import com.softartdev.lastfm.Session;
import com.softartdev.lastfm.Track;
import com.softartdev.lastfm.scrobble.ScrobbleData;
import com.softartdev.lastfm.scrobble.ScrobbleResult;

   * Returns {@code true} if this client is authenticated and can be used to make calls to the
   * Last.fm API. A client will be authenticated if it was created with {@link
   * LastfmClient(LastfmApi, Caller, String, String)}, or was authenticated after creation with
   * {@link #getSession(String, Handler.Callback)}.
   */
  public boolean isAuthenticated() {
    return session != null;
  }

  /** Returns the URL to redirect users to for browser-based authentication. */
  public Uri getAuthUrl() {
    return Uri.parse(
        "http://www.last.fm/api/auth/?api_key=" + API_KEY + "&cb=scroball://authenticate");
  }

  /**
   * Authenticates with the Last.fm API using the browser-based token authentication, setting up an
   * active session on this client.
   *
   * @param token token received from the Last.fm API through a redirect.
   * @param callback callback which will be called with an {@link AuthResult} as the message
   *     payload.
   */
  public void getSession(String token, Handler.Callback callback) {
    new GetSessionTask(
            api,
            caller,
            message -> {
              AuthResult result = (AuthResult) message.obj;
              if (result.sessionKey().isPresent()) {
                setSession(result.sessionKey().get());