15eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry/*
25eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * Copyright (C) 2016 The Android Open Source Project
35eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry *
45eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * Licensed under the Apache License, Version 2.0 (the "License");
55eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * you may not use this file except in compliance with the License.
65eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * You may obtain a copy of the License at
75eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry *
85eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry *      http://www.apache.org/licenses/LICENSE-2.0
95eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry *
105eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * Unless required by applicable law or agreed to in writing, software
115eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * distributed under the License is distributed on an "AS IS" BASIS,
125eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * See the License for the specific language governing permissions and
145eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * limitations under the License
155eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry */
165eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
175eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastrypackage com.android.internal.telephony;
185eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
195eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastryimport android.content.Context;
205eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastryimport android.os.AsyncTask;
215eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastryimport android.provider.BlockedNumberContract;
225eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastryimport android.telephony.Rlog;
235eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
245eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry/**
255eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * An {@link AsyncTask} that notifies the Blocked number provider that emergency services were
265eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * contacted. See {@link BlockedNumberContract.SystemContract#notifyEmergencyContact(Context)}
275eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * for details.
285eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry * {@hide}
295eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry */
305eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastrypublic class AsyncEmergencyContactNotifier extends AsyncTask<Void, Void, Void> {
315eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    private static final String TAG = "AsyncEmergencyContactNotifier";
325eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
335eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    private final Context mContext;
345eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
355eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    public AsyncEmergencyContactNotifier(Context context) {
365eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry        mContext = context;
375eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    }
385eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry
395eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    @Override
405eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    protected Void doInBackground(Void... params) {
415eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry        try {
425eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry            BlockedNumberContract.SystemContract.notifyEmergencyContact(mContext);
435eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry        } catch (Exception e) {
445eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry            Rlog.e(TAG, "Exception notifying emergency contact: " + e);
455eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry        }
465eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry        return null;
475eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry    }
485eccb26b2bcf3a51326596e1b0bb49b073d2f9fcAbhijith Shastry}
49