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

Commit 39daf8d6 authored by Jack Yu's avatar Jack Yu
Browse files

Added getServiceState API to TelephonyManager.

Added the new API getServiceState to TelephonyManager so
the client can directly retrieve the service state without
being a phone state listener or broadcast receiver.

bug: 21207640
Change-Id: Icef46877bbc844d382cd910b15abd8f6b1d57b23
parent 6e924540
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -4848,4 +4848,21 @@ public class TelephonyManager {
        }
        return null;
    }

    /**
     * Returns the service state information on specified subscription. Callers require
     * either READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE to retrieve the information.
     * @hide
     */
    public ServiceState getServiceStateForSubscriber(int subId) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.getServiceStateForSubscriber(subId, getOpPackageName());
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#getServiceStateForSubscriber", e);
        }
        return null;
    }
}
 No newline at end of file
+10 −1
Original line number Diff line number Diff line
@@ -21,9 +21,10 @@ import android.os.Bundle;
import android.telecom.PhoneAccount;
import android.telephony.CellInfo;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo;
import android.telephony.RadioAccessFamily;
import android.telephony.ModemActivityInfo;
import android.telephony.ServiceState;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.OperatorInfo;
import java.util.List;
@@ -1005,4 +1006,12 @@ interface ITelephony {
     * Return the modem activity info.
     */
    ModemActivityInfo getModemActivityInfo();

    /**
     * Get the service state on specified subscription
     * @param subId Subscription id
     * @param callingPackage The package making the call
     * @return Service state on specified subscription.
     */
    ServiceState getServiceStateForSubscriber(int subId, String callingPackage);
}