• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.google.android.downloader;
16 
17 import com.google.common.util.concurrent.ListenableFuture;
18 
19 /** Interface for dealing with connectivity checking and handling in the downloader. */
20 public interface ConnectivityHandler {
21   /**
22    * Handles the checking connectivity for the given {@link DownloadConstraints}. This method must
23    * return a {@link ListenableFuture} that resolves when the constraints are satisfied.
24    *
25    * <p>The returned future may be resolved in failure state with a {@link
26    * java.util.concurrent.TimeoutException} if too much time without sufficient connectivity has
27    * been observed. The future may also be cancelled (resulting in a {@link
28    * java.util.concurrent.CancellationException}) if observing connectivity changes is no longer
29    * necessary. Either state will be given special treatment to retry downloads. Any other failure
30    * state will be considered fatal and will fail ongoing downloads.
31    */
checkConnectivity(DownloadConstraints constraints)32   ListenableFuture<Void> checkConnectivity(DownloadConstraints constraints);
33 }
34