aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2023-01-11 22:47:03 -0800
committerXin Li <delphij@google.com>2023-01-11 22:47:03 -0800
commit0e52ee10f74fb42d38acd83a88fc1389b6f10c5f (patch)
treea580dcfcea909ddbf9692774451839705622b7a2
parentf6b78305c988217d04f583854e384cff571867bf (diff)
parent25091b701e598d6bd8924837d60cbe807bad8662 (diff)
downloadsl4a-0e52ee10f74fb42d38acd83a88fc1389b6f10c5f.tar.gz
Merge tm-qpr-dev-plus-aosp-without-vendor@9467136
Bug: 264720040 Merged-In: I711001032a82d8ed586fb3aa89c269a72d127b59 Change-Id: Ife4993759b6a4250b369d3ec3cd8655c90206ddf
-rw-r--r--Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java25
-rw-r--r--Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java113
2 files changed, 129 insertions, 9 deletions
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
index c1eb4564..8e54d810 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
@@ -635,27 +635,34 @@ public class BluetoothConnectionFacade extends RpcReceiver {
}
/**
- * Bond to a device using Out of Band Data.
+ * Bond to a device using Out of Band Data over LE transport.
*
* @param address String representation of address like "00:11:22:33:44:55"
* @param transport String "1", "2", "3" to match TRANSPORT_*
* @param c Hex String of the 16 octet confirmation
* @param r Hex String of the 16 octet randomizer
+ * @param addressType type of address provided to match BluetoothDevice#ADDRESS_TYPE_*
*/
- @Rpc(description = "Creates and Out of Band bond.")
- public void bluetoothCreateBondOutOfBand(@RpcParameter(name = "address") String address,
- @RpcParameter(name = "transport") String transport,
- @RpcParameter(name = "c") String c, @RpcParameter(name = "r") String r) {
- Log.d("bluetoothCreateBondOutOfBand(" + address + ", " + transport + "," + c + ", "
+ @Rpc(description = "Creates and Out of Band LE bond.")
+ public void bluetoothCreateLeBondOutOfBand(@RpcParameter(name = "address") String address,
+ @RpcParameter(name = "c") String c, @RpcParameter(name = "r") String r,
+ @RpcParameter(name = "addressType") @RpcDefault("1") Integer addressType) {
+ Log.d("bluetoothCreateLeBondOutOfBand(" + address + ", " + addressType + "," + c + ", "
+ r + ")");
- BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteDevice(address);
+ BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteLeDevice(address, addressType);
byte[] addressBytes = new byte[7];
int i = 0;
for (String s : address.split(":")) {
addressBytes[i] = hexStringToByteArray(s)[0];
i++;
}
- addressBytes[i] = 0x01;
+
+ // Inserts the address type if one is provided
+ if (addressType == BluetoothDevice.ADDRESS_TYPE_PUBLIC
+ || addressType == BluetoothDevice.ADDRESS_TYPE_RANDOM) {
+ addressBytes[i] = addressType.byteValue();
+ }
+
OobData p192 = null;
OobData p256 = new OobData.LeBuilder(hexStringToByteArray(c),
addressBytes, OobData.LE_DEVICE_ROLE_BOTH_PREFER_CENTRAL)
@@ -663,7 +670,7 @@ public class BluetoothConnectionFacade extends RpcReceiver {
.build();
mContext.registerReceiver(new BondBroadcastReceiver(),
new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
- remoteDevice.createBondOutOfBand(Integer.parseInt(transport), p192, p256);
+ remoteDevice.createBondOutOfBand(BluetoothDevice.TRANSPORT_LE, p192, p256);
}
private class BondBroadcastReceiver extends BroadcastReceiver {
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
index 33a573bb..bcd51446 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
@@ -37,6 +37,7 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.PinResult;
import com.android.internal.telephony.RILConstants;
@@ -1010,6 +1011,21 @@ public class TelephonyManagerFacade extends RpcReceiver {
}
/**
+ * Check if the Subscription ID is valid.
+ * @param subId the subscription ID
+ * @return {true} if subId is valid, {false} otherwise.
+ */
+ @Rpc(description = "Check if the Subscription ID is valid.")
+ public boolean telephonyIsSubscriptionIdValid(
+ @RpcParameter(name = "subId") Integer subId){
+ if (subId == null || !SubscriptionManager.isValidSubscriptionId(subId)) {
+ Log.e("Invalid or null subscription ID");
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Supply the puk code and pin for locked SIM.
* @param puk the puk code string
* @param pin the puk pin string
@@ -1023,6 +1039,25 @@ public class TelephonyManagerFacade extends RpcReceiver {
}
/**
+ * Supply the puk code and pin for locked SIM of specified subscription ID.
+ * @param subId the subscription ID
+ * @param puk the puk code string
+ * @param pin the puk pin string
+ * @return true or false for supplying the puk code and pin successfully or unsuccessfully.
+ */
+ @Rpc(description = "Supply Puk and Pin for locked SIM " +
+ "for specified subscription ID.")
+ public boolean telephonySupplyPukForSubscription(
+ @RpcParameter(name = "subId") Integer subId,
+ @RpcParameter(name = "puk") String puk,
+ @RpcParameter(name = "pin") String pin) {
+ if (!telephonyIsSubscriptionIdValid(subId)) {
+ return false;
+ }
+ return mTelephonyManager.createForSubscriptionId(subId).supplyPuk(puk, pin);
+ }
+
+ /**
* Supply pin for locked SIM.
* @param pin the puk pin string
* @return true or false for supplying the pin successfully or unsuccessfully.
@@ -1033,6 +1068,84 @@ public class TelephonyManagerFacade extends RpcReceiver {
return mTelephonyManager.supplyPin(pin);
}
+ /**
+ * Supply pin for locked SIM of specified subscription ID.
+ * @param subId the subscription ID
+ * @param pin the puk pin string
+ * @return true or false for supplying the pin successfully or unsuccessfully.
+ */
+ @Rpc(description = "Supply Pin for locked SIM " +
+ "for specified subscription ID.")
+ public boolean telephonySupplyPinForSubscription(
+ @RpcParameter(name = "subId") Integer subId,
+ @RpcParameter(name = "pin") String pin) {
+ if (!telephonyIsSubscriptionIdValid(subId)) {
+ return false;
+ }
+ return mTelephonyManager.createForSubscriptionId(subId).supplyPin(pin);
+ }
+
+ /**
+ * Enable or disable the ICC PIN lock of specified subscription ID.
+ * @param subId the subscription ID
+ * @param enabled "true" for enable, "false" for disable.
+ * @param pin needed to enable or disable the ICC PIN lock
+ * @return true or false for enable/disable the pin successfully or unsuccessfully.
+ */
+ @Rpc(description = "Enable or disable the ICC PIN lock " +
+ "for specified subscription ID.")
+ public boolean telephonySetIccLockEnabledForSubscription(
+ @RpcParameter(name = "subId") Integer subId,
+ @RpcParameter(name = "enabled") Boolean enabled,
+ @RpcParameter(name = "pin") String pin) {
+ if (!telephonyIsSubscriptionIdValid(subId)) {
+ return false;
+ }
+ PinResult result= mTelephonyManager.createForSubscriptionId(subId).setIccLockEnabled(enabled,pin);
+ if(result != null) {
+ return (result.getResult() == PinResult.PIN_RESULT_TYPE_SUCCESS);
+ }
+ return false;
+ }
+
+ /**
+ * Check whether ICC PIN lock is enabled.
+ * @param subId the subscription ID
+ * @return true or false for changing the ICC lock PIN successfully or unsuccessfully.
+ */
+ @Rpc(description = "Check whether ICC PIN lock is enabled " +
+ "for specified subscription ID.")
+ public boolean telephonyIsIccLockEnabled(
+ @RpcParameter(name = "subId") Integer subId) {
+ if (!telephonyIsSubscriptionIdValid(subId)) {
+ return false;
+ }
+ return mTelephonyManager.createForSubscriptionId(subId).isIccLockEnabled();
+ }
+
+ /**
+ * Change the ICC lock PIN of specified subscription ID.
+ * @param subId the subscription ID
+ * @param oldPin is the old PIN.
+ * @param newPin is the new PIN.
+ * @return true or false for changing the ICC lock PIN successfully or unsuccessfully.
+ */
+ @Rpc(description = "Change the ICC lock PIN " +
+ "for specified subscription ID.")
+ public boolean telephonyChangeIccLockPinForSubscription(
+ @RpcParameter(name = "subId") Integer subId,
+ @RpcParameter(name = "oldPin") String oldPin,
+ @RpcParameter(name = "newPin") String newPin) {
+ if (!telephonyIsSubscriptionIdValid(subId)) {
+ return false;
+ }
+ PinResult result= mTelephonyManager.createForSubscriptionId(subId).changeIccLockPin(oldPin,newPin);
+ if(result != null) {
+ return (result.getResult() == PinResult.PIN_RESULT_TYPE_SUCCESS);
+ }
+ return false;
+ }
+
@Rpc(description = "Returns the unique subscriber ID (such as IMSI) " +
"for default subscription ID, or null if unavailable")
public String telephonyGetSubscriberId() {