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

Commit 5e44cadf authored by Gabriel Peal's avatar Gabriel Peal Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of c1edfc2c to master"

parents 05f79758 8b5f2b08
Loading
Loading
Loading
Loading
+136 −205
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.telephony;

import android.annotation.PrivateApi;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
@@ -25,6 +26,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.telephony.Rlog;
import android.util.Log;

import com.android.internal.telephony.IPhoneSubInfo;
@@ -64,31 +66,10 @@ public class TelephonyManager {
    private static final String TAG = "TelephonyManager";

    private static ITelephonyRegistry sRegistry;
    private final Context mContext;

    /** @hide */
    public TelephonyManager(Context context) {
        Context appContext = context.getApplicationContext();
        if (appContext != null) {
            mContext = appContext;
        } else {
            mContext = context;
        }

        if (sRegistry == null) {
            sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
        }
    }

    /** @hide */
    private TelephonyManager() {
        mContext = null;
    }

    private static TelephonyManager sInstance = new TelephonyManager();
    private HashMap<CallStateListener, Listener> mListeners
    private final HashMap<CallStateListener,Listener> mListeners
            = new HashMap<CallStateListener,Listener>();
    private final Context mContext;

    private static class Listener extends ITelephonyListener.Stub {
        final CallStateListener mListener;
@@ -120,6 +101,28 @@ public class TelephonyManager {
        }
    }

    /** @hide */
    public TelephonyManager(Context context) {
        Context appContext = context.getApplicationContext();
        if (appContext != null) {
            mContext = appContext;
        } else {
            mContext = context;
        }

        if (sRegistry == null) {
            sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
        }
    }

    /** @hide */
    private TelephonyManager() {
        mContext = null;
    }

    private static TelephonyManager sInstance = new TelephonyManager();

    /** @hide
    /* @deprecated - use getSystemService as described above */
    public static TelephonyManager getDefault() {
@@ -1920,439 +1923,369 @@ public class TelephonyManager {
     * Expose the rest of ITelephony to @PrivateApi
     */

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void dial(String number) {
        try {
            getITelephony().dial(number);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#dial");
            Log.e(TAG, "Error calling ITelephony#dial", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void call(String callingPackage, String number) {
        try {
            getITelephony().call(callingPackage, number);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#call");
            Log.e(TAG, "Error calling ITelephony#call", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean showCallScreen() {
        try {
            return getITelephony().showCallScreen();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#showCallScreen");
            Log.e(TAG, "Error calling ITelephony#showCallScreen", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean showCallScreenWithDialpad(boolean showDialpad) {
        try {
            return getITelephony().showCallScreenWithDialpad(showDialpad);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#showCallScreenWithDialpad");
            Log.e(TAG, "Error calling ITelephony#showCallScreenWithDialpad", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean endCall() {
        try {
            return getITelephony().endCall();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#endCall");
            Log.e(TAG, "Error calling ITelephony#endCall", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void answerRingingCall() {
        try {
            getITelephony().answerRingingCall();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#answerRingingCall");
            Log.e(TAG, "Error calling ITelephony#answerRingingCall", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void toggleHold() {
        try {
            getITelephony().toggleHold();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#toggleHold");
            Log.e(TAG, "Error calling ITelephony#toggleHold", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void merge() {
        try {
            getITelephony().merge();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#merge");
            Log.e(TAG, "Error calling ITelephony#merge", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void swap() {
        try {
            getITelephony().swap();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#swap");
            Log.e(TAG, "Error calling ITelephony#swap", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void mute(boolean mute) {
        try {
            getITelephony().mute(mute);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#mute");
            Log.e(TAG, "Error calling ITelephony#mute", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void silenceRinger() {
        try {
            getITelephony().silenceRinger();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#silenceRinger");
            Log.e(TAG, "Error calling ITelephony#silenceRinger", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isOffhook() {
        try {
            return getITelephony().isOffhook();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isOffhook");
            Log.e(TAG, "Error calling ITelephony#isOffhook", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isRinging() {
        try {
            return getITelephony().isRinging();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isRinging");
            Log.e(TAG, "Error calling ITelephony#isRinging", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isIdle() {
        try {
            return getITelephony().isIdle();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isIdle");
            Log.e(TAG, "Error calling ITelephony#isIdle", e);
        }
        return true;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isRadioOn() {
        try {
            return getITelephony().isRadioOn();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isRadioOn");
            Log.e(TAG, "Error calling ITelephony#isRadioOn", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isSimPinEnabled() {
        try {
            return getITelephony().isSimPinEnabled();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isSimPinEnabled");
            Log.e(TAG, "Error calling ITelephony#isSimPinEnabled", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void cancelMissedCallsNotification() {
        try {
            getITelephony().cancelMissedCallsNotification();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#cancelMissedCallsNotification");
            Log.e(TAG, "Error calling ITelephony#cancelMissedCallsNotification", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean supplyPin(String pin) {
        try {
            return getITelephony().supplyPin(pin);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#supplyPin");
            Log.e(TAG, "Error calling ITelephony#supplyPin", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean supplyPuk(String puk, String pin) {
        try {
            return getITelephony().supplyPuk(puk, pin);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#supplyPuk");
            Log.e(TAG, "Error calling ITelephony#supplyPuk", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public int[] supplyPinReportResult(String pin) {
        try {
            return getITelephony().supplyPinReportResult(pin);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#supplyPinReportResult");
            Log.e(TAG, "Error calling ITelephony#supplyPinReportResult", e);
        }
        return new int[0];
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public int[] supplyPukReportResult(String puk, String pin) {
        try {
            return getITelephony().supplyPukReportResult(puk, pin);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#]");
            Log.e(TAG, "Error calling ITelephony#]", e);
        }
        return new int[0];
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean handlePinMmi(String dialString) {
        try {
            return getITelephony().handlePinMmi(dialString);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#handlePinMmi");
            Log.e(TAG, "Error calling ITelephony#handlePinMmi", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void toggleRadioOnOff() {
        try {
            getITelephony().toggleRadioOnOff();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff");
            Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean setRadio(boolean turnOn) {
        try {
            return getITelephony().setRadio(turnOn);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setRadio");
            Log.e(TAG, "Error calling ITelephony#setRadio", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean setRadioPower(boolean turnOn) {
        try {
            return getITelephony().setRadioPower(turnOn);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setRadioPower");
            Log.e(TAG, "Error calling ITelephony#setRadioPower", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void updateServiceLocation() {
        try {
            getITelephony().updateServiceLocation();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#updateServiceLocation");
            Log.e(TAG, "Error calling ITelephony#updateServiceLocation", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public int enableApnType(String type) {
        try {
            return getITelephony().enableApnType(type);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#enableApnType");
            Log.e(TAG, "Error calling ITelephony#enableApnType", e);
        }
        return PhoneConstants.APN_REQUEST_FAILED;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public int disableApnType(String type) {
        try {
            return getITelephony().disableApnType(type);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#disableApnType");
            Log.e(TAG, "Error calling ITelephony#disableApnType", e);
        }
        return PhoneConstants.APN_REQUEST_FAILED;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean enableDataConnectivity() {
        try {
            return getITelephony().enableDataConnectivity();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#enableDataConnectivity");
            Log.e(TAG, "Error calling ITelephony#enableDataConnectivity", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean disableDataConnectivity() {
        try {
            return getITelephony().disableDataConnectivity();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#disableDataConnectivity");
            Log.e(TAG, "Error calling ITelephony#disableDataConnectivity", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean isDataConnectivityPossible() {
        try {
            return getITelephony().isDataConnectivityPossible();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible");
            Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public boolean needsOtaServiceProvisioning() {
        try {
            return getITelephony().needsOtaServiceProvisioning();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning");
            Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", e);
        }
        return false;
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void playDtmfTone(char digit, boolean timedShortCode) {
        try {
            getITelephony().playDtmfTone(digit, timedShortCode);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#playDtmfTone");
            Log.e(TAG, "Error calling ITelephony#playDtmfTone", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void stopDtmfTone() {
        try {
            getITelephony().stopDtmfTone();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#stopDtmfTone");
            Log.e(TAG, "Error calling ITelephony#stopDtmfTone", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void addCallStateListener(CallStateListener listener) {
        try {
            if (listener == null) {
@@ -2364,14 +2297,12 @@ public class TelephonyManager {
                getITelephony().addListener(l);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#addListener");
            Log.e(TAG, "Error calling ITelephony#addListener", e);
        }
    }

    /**
     * @hide
     * @PrivateApi
     */
    /** @hide */
    @PrivateApi
    public void removeCallStateListener(CallStateListener listener) {
        try {
            final Listener l = mListeners.remove(listener);
@@ -2381,7 +2312,7 @@ public class TelephonyManager {
                getITelephony().removeListener(l);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#removeListener");
            Log.e(TAG, "Error calling ITelephony#removeListener", e);
        }
    }
}