Merge "resolved conflicts for merge of c1edfc2c to master"

This commit is contained in:
Gabriel Peal
2014-03-25 19:22:41 +00:00
committed by Android (Google) Code Review

View File

@@ -16,6 +16,7 @@
package android.telephony; package android.telephony;
import android.annotation.PrivateApi;
import android.annotation.SdkConstant; import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context; import android.content.Context;
@@ -25,6 +26,7 @@ import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.telephony.Rlog;
import android.util.Log; import android.util.Log;
import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.IPhoneSubInfo;
@@ -64,31 +66,10 @@ public class TelephonyManager {
private static final String TAG = "TelephonyManager"; private static final String TAG = "TelephonyManager";
private static ITelephonyRegistry sRegistry; private static ITelephonyRegistry sRegistry;
private final Context mContext;
/** @hide */ private final HashMap<CallStateListener,Listener> mListeners
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
= new HashMap<CallStateListener,Listener>(); = new HashMap<CallStateListener,Listener>();
private final Context mContext;
private static class Listener extends ITelephonyListener.Stub { private static class Listener extends ITelephonyListener.Stub {
final CallStateListener mListener; 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 /** @hide
/* @deprecated - use getSystemService as described above */ /* @deprecated - use getSystemService as described above */
public static TelephonyManager getDefault() { public static TelephonyManager getDefault() {
@@ -1920,439 +1923,369 @@ public class TelephonyManager {
* Expose the rest of ITelephony to @PrivateApi * Expose the rest of ITelephony to @PrivateApi
*/ */
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void dial(String number) { public void dial(String number) {
try { try {
getITelephony().dial(number); getITelephony().dial(number);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#dial"); Log.e(TAG, "Error calling ITelephony#dial", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void call(String callingPackage, String number) { public void call(String callingPackage, String number) {
try { try {
getITelephony().call(callingPackage, number); getITelephony().call(callingPackage, number);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#call"); Log.e(TAG, "Error calling ITelephony#call", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean showCallScreen() { public boolean showCallScreen() {
try { try {
return getITelephony().showCallScreen(); return getITelephony().showCallScreen();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#showCallScreen"); Log.e(TAG, "Error calling ITelephony#showCallScreen", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean showCallScreenWithDialpad(boolean showDialpad) { public boolean showCallScreenWithDialpad(boolean showDialpad) {
try { try {
return getITelephony().showCallScreenWithDialpad(showDialpad); return getITelephony().showCallScreenWithDialpad(showDialpad);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#showCallScreenWithDialpad"); Log.e(TAG, "Error calling ITelephony#showCallScreenWithDialpad", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean endCall() { public boolean endCall() {
try { try {
return getITelephony().endCall(); return getITelephony().endCall();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#endCall"); Log.e(TAG, "Error calling ITelephony#endCall", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void answerRingingCall() { public void answerRingingCall() {
try { try {
getITelephony().answerRingingCall(); getITelephony().answerRingingCall();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#answerRingingCall"); Log.e(TAG, "Error calling ITelephony#answerRingingCall", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void toggleHold() { public void toggleHold() {
try { try {
getITelephony().toggleHold(); getITelephony().toggleHold();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#toggleHold"); Log.e(TAG, "Error calling ITelephony#toggleHold", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void merge() { public void merge() {
try { try {
getITelephony().merge(); getITelephony().merge();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#merge"); Log.e(TAG, "Error calling ITelephony#merge", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void swap() { public void swap() {
try { try {
getITelephony().swap(); getITelephony().swap();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#swap"); Log.e(TAG, "Error calling ITelephony#swap", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void mute(boolean mute) { public void mute(boolean mute) {
try { try {
getITelephony().mute(mute); getITelephony().mute(mute);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#mute"); Log.e(TAG, "Error calling ITelephony#mute", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void silenceRinger() { public void silenceRinger() {
try { try {
getITelephony().silenceRinger(); getITelephony().silenceRinger();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#silenceRinger"); Log.e(TAG, "Error calling ITelephony#silenceRinger", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isOffhook() { public boolean isOffhook() {
try { try {
return getITelephony().isOffhook(); return getITelephony().isOffhook();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isOffhook"); Log.e(TAG, "Error calling ITelephony#isOffhook", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isRinging() { public boolean isRinging() {
try { try {
return getITelephony().isRinging(); return getITelephony().isRinging();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isRinging"); Log.e(TAG, "Error calling ITelephony#isRinging", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isIdle() { public boolean isIdle() {
try { try {
return getITelephony().isIdle(); return getITelephony().isIdle();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isIdle"); Log.e(TAG, "Error calling ITelephony#isIdle", e);
} }
return true; return true;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isRadioOn() { public boolean isRadioOn() {
try { try {
return getITelephony().isRadioOn(); return getITelephony().isRadioOn();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isRadioOn"); Log.e(TAG, "Error calling ITelephony#isRadioOn", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isSimPinEnabled() { public boolean isSimPinEnabled() {
try { try {
return getITelephony().isSimPinEnabled(); return getITelephony().isSimPinEnabled();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isSimPinEnabled"); Log.e(TAG, "Error calling ITelephony#isSimPinEnabled", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void cancelMissedCallsNotification() { public void cancelMissedCallsNotification() {
try { try {
getITelephony().cancelMissedCallsNotification(); getITelephony().cancelMissedCallsNotification();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#cancelMissedCallsNotification"); Log.e(TAG, "Error calling ITelephony#cancelMissedCallsNotification", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean supplyPin(String pin) { public boolean supplyPin(String pin) {
try { try {
return getITelephony().supplyPin(pin); return getITelephony().supplyPin(pin);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#supplyPin"); Log.e(TAG, "Error calling ITelephony#supplyPin", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean supplyPuk(String puk, String pin) { public boolean supplyPuk(String puk, String pin) {
try { try {
return getITelephony().supplyPuk(puk, pin); return getITelephony().supplyPuk(puk, pin);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#supplyPuk"); Log.e(TAG, "Error calling ITelephony#supplyPuk", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public int[] supplyPinReportResult(String pin) { public int[] supplyPinReportResult(String pin) {
try { try {
return getITelephony().supplyPinReportResult(pin); return getITelephony().supplyPinReportResult(pin);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#supplyPinReportResult"); Log.e(TAG, "Error calling ITelephony#supplyPinReportResult", e);
} }
return new int[0]; return new int[0];
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public int[] supplyPukReportResult(String puk, String pin) { public int[] supplyPukReportResult(String puk, String pin) {
try { try {
return getITelephony().supplyPukReportResult(puk, pin); return getITelephony().supplyPukReportResult(puk, pin);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#]"); Log.e(TAG, "Error calling ITelephony#]", e);
} }
return new int[0]; return new int[0];
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean handlePinMmi(String dialString) { public boolean handlePinMmi(String dialString) {
try { try {
return getITelephony().handlePinMmi(dialString); return getITelephony().handlePinMmi(dialString);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#handlePinMmi"); Log.e(TAG, "Error calling ITelephony#handlePinMmi", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void toggleRadioOnOff() { public void toggleRadioOnOff() {
try { try {
getITelephony().toggleRadioOnOff(); getITelephony().toggleRadioOnOff();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff"); Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean setRadio(boolean turnOn) { public boolean setRadio(boolean turnOn) {
try { try {
return getITelephony().setRadio(turnOn); return getITelephony().setRadio(turnOn);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#setRadio"); Log.e(TAG, "Error calling ITelephony#setRadio", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean setRadioPower(boolean turnOn) { public boolean setRadioPower(boolean turnOn) {
try { try {
return getITelephony().setRadioPower(turnOn); return getITelephony().setRadioPower(turnOn);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#setRadioPower"); Log.e(TAG, "Error calling ITelephony#setRadioPower", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void updateServiceLocation() { public void updateServiceLocation() {
try { try {
getITelephony().updateServiceLocation(); getITelephony().updateServiceLocation();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#updateServiceLocation"); Log.e(TAG, "Error calling ITelephony#updateServiceLocation", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public int enableApnType(String type) { public int enableApnType(String type) {
try { try {
return getITelephony().enableApnType(type); return getITelephony().enableApnType(type);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#enableApnType"); Log.e(TAG, "Error calling ITelephony#enableApnType", e);
} }
return PhoneConstants.APN_REQUEST_FAILED; return PhoneConstants.APN_REQUEST_FAILED;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public int disableApnType(String type) { public int disableApnType(String type) {
try { try {
return getITelephony().disableApnType(type); return getITelephony().disableApnType(type);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#disableApnType"); Log.e(TAG, "Error calling ITelephony#disableApnType", e);
} }
return PhoneConstants.APN_REQUEST_FAILED; return PhoneConstants.APN_REQUEST_FAILED;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean enableDataConnectivity() { public boolean enableDataConnectivity() {
try { try {
return getITelephony().enableDataConnectivity(); return getITelephony().enableDataConnectivity();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#enableDataConnectivity"); Log.e(TAG, "Error calling ITelephony#enableDataConnectivity", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean disableDataConnectivity() { public boolean disableDataConnectivity() {
try { try {
return getITelephony().disableDataConnectivity(); return getITelephony().disableDataConnectivity();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#disableDataConnectivity"); Log.e(TAG, "Error calling ITelephony#disableDataConnectivity", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean isDataConnectivityPossible() { public boolean isDataConnectivityPossible() {
try { try {
return getITelephony().isDataConnectivityPossible(); return getITelephony().isDataConnectivityPossible();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible"); Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public boolean needsOtaServiceProvisioning() { public boolean needsOtaServiceProvisioning() {
try { try {
return getITelephony().needsOtaServiceProvisioning(); return getITelephony().needsOtaServiceProvisioning();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning"); Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", e);
} }
return false; return false;
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void playDtmfTone(char digit, boolean timedShortCode) { public void playDtmfTone(char digit, boolean timedShortCode) {
try { try {
getITelephony().playDtmfTone(digit, timedShortCode); getITelephony().playDtmfTone(digit, timedShortCode);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#playDtmfTone"); Log.e(TAG, "Error calling ITelephony#playDtmfTone", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void stopDtmfTone() { public void stopDtmfTone() {
try { try {
getITelephony().stopDtmfTone(); getITelephony().stopDtmfTone();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#stopDtmfTone"); Log.e(TAG, "Error calling ITelephony#stopDtmfTone", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void addCallStateListener(CallStateListener listener) { public void addCallStateListener(CallStateListener listener) {
try { try {
if (listener == null) { if (listener == null) {
@@ -2364,14 +2297,12 @@ public class TelephonyManager {
getITelephony().addListener(l); getITelephony().addListener(l);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#addListener"); Log.e(TAG, "Error calling ITelephony#addListener", e);
} }
} }
/** /** @hide */
* @hide @PrivateApi
* @PrivateApi
*/
public void removeCallStateListener(CallStateListener listener) { public void removeCallStateListener(CallStateListener listener) {
try { try {
final Listener l = mListeners.remove(listener); final Listener l = mListeners.remove(listener);
@@ -2381,7 +2312,7 @@ public class TelephonyManager {
getITelephony().removeListener(l); getITelephony().removeListener(l);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#removeListener"); Log.e(TAG, "Error calling ITelephony#removeListener", e);
} }
} }
} }