Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f90186d9 authored by Santos Cordon's avatar Santos Cordon
Browse files

Add PhoneManager to expose functionality to phone/dialer apps.

Eventually, this will house the TelecommManager methods.

Change-Id: Id8b08d88a06a7b4e90a4a7f702ba56526e108ca5
parent f5116d01
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -7099,13 +7099,13 @@ package android.content {
    field public static final java.lang.String NFC_SERVICE = "nfc";
    field public static final java.lang.String NOTIFICATION_SERVICE = "notification";
    field public static final java.lang.String NSD_SERVICE = "servicediscovery";
    field public static final java.lang.String PHONE_SERVICE = "phone_service";
    field public static final java.lang.String POWER_SERVICE = "power";
    field public static final java.lang.String PRINT_SERVICE = "print";
    field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
    field public static final java.lang.String SEARCH_SERVICE = "search";
    field public static final java.lang.String SENSOR_SERVICE = "sensor";
    field public static final java.lang.String STORAGE_SERVICE = "storage";
    field public static final java.lang.String TELECOMM_SERVICE = "telecomm";
    field public static final java.lang.String TELEPHONY_SERVICE = "phone";
    field public static final java.lang.String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
    field public static final java.lang.String TV_INPUT_SERVICE = "tv_input";
@@ -21768,6 +21768,14 @@ package android.os.storage {
}
package android.phone {
  public final class PhoneManager {
    method public boolean handlePinMmi(java.lang.String);
  }
}
package android.preference {
  public class CheckBoxPreference extends android.preference.TwoStatePreference {
@@ -27850,9 +27858,6 @@ package android.telecomm {
    field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.intent.extra.START_CALL_WITH_SPEAKERPHONE";
  }
  public class TelecommManager {
  }
  public class VideoCallProfile implements android.os.Parcelable {
    ctor public VideoCallProfile(int, int);
    method public int describeContents();
+8 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ import android.os.SystemVibrator;
import android.os.UserManager;
import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.phone.PhoneManager;
import android.print.IPrintManager;
import android.print.PrintManager;
import android.service.fingerprint.IFingerprintService;
@@ -560,6 +561,13 @@ class ContextImpl extends Context {
                            ITelecommService.Stub.asInterface(b));
                }});

        registerService(PHONE_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    IBinder b = ServiceManager.getService(TELECOMM_SERVICE);
                    return new PhoneManager(ctx.getOuterContext(),
                            ITelecommService.Stub.asInterface(b));
                }});

        registerService(UI_MODE_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    return new UiModeManager();
+13 −2
Original line number Diff line number Diff line
@@ -2164,8 +2164,8 @@ public abstract class Context {
     * @see android.media.MediaRouter
     * @see #TELEPHONY_SERVICE
     * @see android.telephony.TelephonyManager
     * @see #TELECOMM_SERVICE
     * @see android.telecomm.TelecommManager
     * @see #PHONE_SERVICE
     * @see android.phone.PhoneManager
     * @see #INPUT_METHOD_SERVICE
     * @see android.view.inputmethod.InputMethodManager
     * @see #UI_MODE_SERVICE
@@ -2502,9 +2502,20 @@ public abstract class Context {
     *
     * @see #getSystemService
     * @see android.telecomm.TelecommManager
     * @hide
     */
    public static final String TELECOMM_SERVICE = "telecomm";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.phone.PhoneManager} to manage phone-related features
     * of the device.
     *
     * @see #getSystemService
     * @see android.phone.PhoneManager
     */
    public static final String PHONE_SERVICE = "phone_service";  // "phone" used by telephony.

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.text.ClipboardManager} for accessing and modifying
+68 −0
Original line number Diff line number Diff line
/*
 * 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));
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import com.android.internal.telecomm.ITelecommService;

/**
 * Provides access to Telecomm-related functionality.
 * TODO(santoscordon): Move this all into PhoneManager.
 * @hide
 */
public class TelecommManager {
    private static final String TAG = "TelecommManager";