Merge changes from topic "146593004"
* changes:
Remove usage of @hide @Deprecated Telephony API in NPMS
Use proper Telephony API to supply sim pin and puk.
Hook supplyPin and supplyPuk to proper impl with subId specified
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index 367a7bd..0ffe05d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -26,8 +26,6 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -37,7 +35,6 @@
import android.view.WindowManager;
import android.widget.ImageView;
-import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants;
@@ -254,12 +251,22 @@
@Override
public void run() {
- try {
- if (DEBUG) {
- Log.v(TAG, "call supplyPinReportResultForSubscriber(subid=" + mSubId + ")");
- }
- final int[] result = ITelephony.Stub.asInterface(ServiceManager
- .checkService("phone")).supplyPinReportResultForSubscriber(mSubId, mPin);
+ if (DEBUG) {
+ Log.v(TAG, "call supplyPinReportResultForSubscriber(subid=" + mSubId + ")");
+ }
+ TelephonyManager telephonyManager =
+ ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE))
+ .createForSubscriptionId(mSubId);
+ final int[] result = telephonyManager.supplyPinReportResult(mPin);
+ if (result == null || result.length == 0) {
+ Log.e(TAG, "Error result for supplyPinReportResult.");
+ post(new Runnable() {
+ @Override
+ public void run() {
+ onSimCheckResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
+ }
+ });
+ } else {
if (DEBUG) {
Log.v(TAG, "supplyPinReportResult returned: " + result[0] + " " + result[1]);
}
@@ -269,14 +276,6 @@
onSimCheckResponse(result[0], result[1]);
}
});
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException for supplyPinReportResult:", e);
- post(new Runnable() {
- @Override
- public void run() {
- onSimCheckResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
- }
- });
}
}
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index 81f8c67..abadcfd 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
@@ -25,8 +25,6 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -36,7 +34,6 @@
import android.view.WindowManager;
import android.widget.ImageView;
-import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants;
@@ -314,10 +311,20 @@
@Override
public void run() {
- try {
- if (DEBUG) Log.v(TAG, "call supplyPukReportResult()");
- final int[] result = ITelephony.Stub.asInterface(ServiceManager
- .checkService("phone")).supplyPukReportResultForSubscriber(mSubId, mPuk, mPin);
+ if (DEBUG) Log.v(TAG, "call supplyPukReportResult()");
+ TelephonyManager telephonyManager =
+ ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE))
+ .createForSubscriptionId(mSubId);
+ final int[] result = telephonyManager.supplyPukReportResult(mPuk, mPin);
+ if (result == null || result.length == 0) {
+ Log.e(TAG, "Error result for supplyPukReportResult.");
+ post(new Runnable() {
+ @Override
+ public void run() {
+ onSimLockChangedResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
+ }
+ });
+ } else {
if (DEBUG) {
Log.v(TAG, "supplyPukReportResult returned: " + result[0] + " " + result[1]);
}
@@ -327,14 +334,6 @@
onSimLockChangedResponse(result[0], result[1]);
}
});
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException for supplyPukReportResult:", e);
- post(new Runnable() {
- @Override
- public void run() {
- onSimLockChangedResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
- }
- });
}
}
}
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 795ed55..18c6e3a 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -3038,12 +3038,13 @@
// Verify they're not lying about package name
mAppOps.checkPackage(callingUid, callingPackage);
+ final SubscriptionManager sm;
final SubscriptionInfo si;
final PersistableBundle config;
final long token = Binder.clearCallingIdentity();
try {
- si = mContext.getSystemService(SubscriptionManager.class)
- .getActiveSubscriptionInfo(subId);
+ sm = mContext.getSystemService(SubscriptionManager.class);
+ si = sm.getActiveSubscriptionInfo(subId);
config = mCarrierConfigManager.getConfigForSubId(subId);
} finally {
Binder.restoreCallingIdentity(token);
@@ -3051,7 +3052,7 @@
// First check: is caller the CarrierService?
if (si != null) {
- if (si.isEmbedded() && si.canManageSubscription(mContext, callingPackage)) {
+ if (si.isEmbedded() && sm.canManageSubscription(si, callingPackage)) {
return;
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index f2c0aa6..4b66f44 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8134,9 +8134,9 @@
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.supplyPin(pin);
+ return telephony.supplyPinForSubscriber(getSubId(), pin);
} catch (RemoteException e) {
- Log.e(TAG, "Error calling ITelephony#supplyPin", e);
+ Log.e(TAG, "Error calling ITelephony#supplyPinForSubscriber", e);
}
return false;
}
@@ -8148,9 +8148,9 @@
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.supplyPuk(puk, pin);
+ return telephony.supplyPukForSubscriber(getSubId(), puk, pin);
} catch (RemoteException e) {
- Log.e(TAG, "Error calling ITelephony#supplyPuk", e);
+ Log.e(TAG, "Error calling ITelephony#supplyPukForSubscriber", e);
}
return false;
}
@@ -8162,9 +8162,9 @@
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.supplyPinReportResult(pin);
+ return telephony.supplyPinReportResultForSubscriber(getSubId(), pin);
} catch (RemoteException e) {
- Log.e(TAG, "Error calling ITelephony#supplyPinReportResult", e);
+ Log.e(TAG, "Error calling ITelephony#supplyPinReportResultForSubscriber", e);
}
return new int[0];
}
@@ -8176,7 +8176,7 @@
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.supplyPukReportResult(puk, pin);
+ return telephony.supplyPukReportResultForSubscriber(getSubId(), puk, pin);
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#]", e);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 0baac71..c0d6369 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -117,13 +117,6 @@
*/
boolean isRadioOnForSubscriberWithFeature(int subId, String callingPackage, String callingFeatureId);
- /**
- * Supply a pin to unlock the SIM. Blocks until a result is determined.
- * @param pin The pin to check.
- * @return whether the operation was a success.
- */
- @UnsupportedAppUsage
- boolean supplyPin(String pin);
/**
* Supply a pin to unlock the SIM for particular subId.
@@ -139,15 +132,6 @@
* Blocks until a result is determined.
* @param puk The puk to check.
* pin The new pin to be set in SIM
- * @return whether the operation was a success.
- */
- boolean supplyPuk(String puk, String pin);
-
- /**
- * Supply puk to unlock the SIM and set SIM pin to new pin.
- * Blocks until a result is determined.
- * @param puk The puk to check.
- * pin The new pin to be set in SIM
* @param subId user preferred subId.
* @return whether the operation was a success.
*/
@@ -160,15 +144,6 @@
* @return retValue[0] = Phone.PIN_RESULT_SUCCESS on success. Otherwise error code
* retValue[1] = number of attempts remaining if known otherwise -1
*/
- int[] supplyPinReportResult(String pin);
-
- /**
- * Supply a pin to unlock the SIM. Blocks until a result is determined.
- * Returns a specific success/error code.
- * @param pin The pin to check.
- * @return retValue[0] = Phone.PIN_RESULT_SUCCESS on success. Otherwise error code
- * retValue[1] = number of attempts remaining if known otherwise -1
- */
int[] supplyPinReportResultForSubscriber(int subId, String pin);
/**
@@ -180,17 +155,6 @@
* @return retValue[0] = Phone.PIN_RESULT_SUCCESS on success. Otherwise error code
* retValue[1] = number of attempts remaining if known otherwise -1
*/
- int[] supplyPukReportResult(String puk, String pin);
-
- /**
- * Supply puk to unlock the SIM and set SIM pin to new pin.
- * Blocks until a result is determined.
- * Returns a specific success/error code
- * @param puk The puk to check
- * pin The pin to check.
- * @return retValue[0] = Phone.PIN_RESULT_SUCCESS on success. Otherwise error code
- * retValue[1] = number of attempts remaining if known otherwise -1
- */
int[] supplyPukReportResultForSubscriber(int subId, String puk, String pin);
/**