refactor radioPowerState

Bug: 117349311
Test: Telephony unit test
Change-Id: I84185d91abd64bb6a7c64718693a7c3e0992dc9d
Merged-in: I84185d91abd64bb6a7c64718693a7c3e0992dc9d
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index cef0e53..3d44717 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -4923,6 +4923,31 @@
     }
 
     /**
+     * Get the current modem radio state for the given slot.
+     * @param slotIndex slot index.
+     * @param callingPackage the name of the package making the call.
+     * @return the current radio power state from the modem
+     */
+    @Override
+    public int getRadioPowerState(int slotIndex, String callingPackage) {
+        Phone phone = PhoneFactory.getPhone(slotIndex);
+        if (phone != null) {
+            if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
+                    mApp, phone.getSubId(), callingPackage, "getRadioPowerState")) {
+                return TelephonyManager.RADIO_POWER_UNAVAILABLE;
+            }
+
+            final long identity = Binder.clearCallingIdentity();
+            try {
+                return phone.getRadioPowerState();
+            } finally {
+                Binder.restoreCallingIdentity(identity);
+            }
+        }
+        return TelephonyManager.RADIO_POWER_UNAVAILABLE;
+    }
+
+    /**
      * Checks if data roaming is enabled on the subscription with id {@code subId}.
      *
      * <p>Requires one of the following permissions: