diff options
| author | Santos Cordon <santoscordon@google.com> | 2014-07-01 13:35:35 -0700 |
|---|---|---|
| committer | Santos Cordon <santoscordon@google.com> | 2014-07-02 18:01:56 +0000 |
| commit | f90186d93effe424128bc0e39699ab05f80d025b (patch) | |
| tree | 30692bccc010bd9c0f9f658264b1023bf2d3c230 /phone/java/android | |
| parent | f5116d01b20f21ba32cd9eaa3412daf97f41c623 (diff) | |
| download | frameworks_base-f90186d93effe424128bc0e39699ab05f80d025b.zip frameworks_base-f90186d93effe424128bc0e39699ab05f80d025b.tar.gz frameworks_base-f90186d93effe424128bc0e39699ab05f80d025b.tar.bz2 | |
Add PhoneManager to expose functionality to phone/dialer apps.
Eventually, this will house the TelecommManager methods.
Change-Id: Id8b08d88a06a7b4e90a4a7f702ba56526e108ca5
Diffstat (limited to 'phone/java/android')
| -rw-r--r-- | phone/java/android/phone/PhoneManager.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/phone/java/android/phone/PhoneManager.java b/phone/java/android/phone/PhoneManager.java new file mode 100644 index 0000000..cbef347 --- /dev/null +++ b/phone/java/android/phone/PhoneManager.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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 + * + * http://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 android.phone; + +import android.content.Context; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.util.Log; + +import com.android.internal.telecomm.ITelecommService; +import com.android.internal.telephony.ITelephony; + +/** + * Exposes call-related functionality for use by phone and dialer apps. + */ +public final class PhoneManager { + private static final String TAG = PhoneManager.class.getSimpleName(); + + private final Context mContext; + private final ITelecommService mService; + + /** + * @hide + */ + public PhoneManager(Context context, ITelecommService service) { + Context appContext = context.getApplicationContext(); + if (appContext != null) { + mContext = appContext; + } else { + mContext = context; + } + + mService = service; + } + + /** + * Processes the specified dial string as an MMI code. + * + * @param dialString The digits to dial. + * @return True if the digits were processed as an MMI code, false otherwise. + */ + public boolean handlePinMmi(String dialString) { + try { + return getITelephony().handlePinMmi(dialString); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#handlePinMmi", e); + } + return false; + } + + private ITelephony getITelephony() { + return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); + } +} |
