• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.documentsui;
18 
19 import static androidx.core.util.Preconditions.checkNotNull;
20 
21 import android.content.Context;
22 import android.os.AsyncTask;
23 
24 import com.android.documentsui.base.UserId;
25 
26 import java.lang.ref.WeakReference;
27 
28 /**
29  * A task to request disabling quiet mode for a given user.
30  */
31 class RequestQuietModeDisabledTask extends AsyncTask<Void, Void, Void> {
32 
33     private final WeakReference<Context> mContextWeakReference;
34     private final UserId mUserId;
35 
RequestQuietModeDisabledTask(Context context, UserId userId)36     RequestQuietModeDisabledTask(Context context, UserId userId) {
37         mContextWeakReference = new WeakReference<>(checkNotNull(context));
38         mUserId = checkNotNull(userId);
39     }
40 
41     @Override
doInBackground(Void... voids)42     protected Void doInBackground(Void... voids) {
43         Context context = mContextWeakReference.get();
44         if (context != null) {
45             mUserId.requestQuietModeDisabled(context);
46         }
47         return null;
48     }
49 }
50