Merge "Update oob bonding interface to use oob data's address type" into tm-qpr-dev am: c6c03738e9
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/sl4a/+/20085617
Change-Id: I7e4e7989a467c856c153477a129535e1bda286ae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Common/src/com/googlecode/android_scripting/facade/DataUsageController.java b/Common/src/com/googlecode/android_scripting/facade/DataUsageController.java
index 6ec89ed..3e9aa05 100644
--- a/Common/src/com/googlecode/android_scripting/facade/DataUsageController.java
+++ b/Common/src/com/googlecode/android_scripting/facade/DataUsageController.java
@@ -16,8 +16,11 @@
package com.googlecode.android_scripting.facade;
+import static android.app.usage.NetworkStats.Bucket.METERED_YES;
import static android.net.ConnectivityManager.TYPE_MOBILE;
import static android.net.NetworkStats.UID_ALL;
+import static android.net.NetworkTemplate.MATCH_MOBILE;
+import static android.net.NetworkTemplate.MATCH_WIFI;
import static android.telephony.TelephonyManager.SIM_STATE_READY;
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
@@ -39,6 +42,7 @@
import java.time.ZonedDateTime;
import java.util.Locale;
+import java.util.Set;
/**
* DataUsageController.
@@ -87,7 +91,8 @@
if (subscriberId == null) {
return warn("no subscriber id");
}
- NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
+ NetworkTemplate template = new NetworkTemplate.Builder(MATCH_MOBILE)
+ .setMeteredness(METERED_YES).setSubscriberIds(Set.of(subscriberId)).build();
template = NetworkTemplate.normalize(template, mTelephonyManager.getMergedSubscriberIds());
return getDataUsageInfo(template);
@@ -101,7 +106,8 @@
if (subscriberId == null) {
return warn("no subscriber id");
}
- NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
+ NetworkTemplate template = new NetworkTemplate.Builder(MATCH_MOBILE)
+ .setMeteredness(METERED_YES).setSubscriberIds(Set.of(subscriberId)).build();
template = NetworkTemplate.normalize(template, mTelephonyManager.getMergedSubscriberIds());
return getDataUsageInfo(template, uId);
@@ -112,7 +118,7 @@
* @return DataUsageInfo: The Wifi data usage information.
*/
public DataUsageInfo getWifiDataUsageInfo() {
- NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
+ NetworkTemplate template = new NetworkTemplate.Builder(MATCH_WIFI).build();
return getDataUsageInfo(template);
}
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
index ba61ded..bc73e6a 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
@@ -151,9 +151,9 @@
// HID mouse movement
private static final byte[] RIGHT = {0, 1, 0, 0};
- private static final byte[] DOWN = {0, 0, -1, 0};
+ private static final byte[] DOWN = {0, 0, 1, 0};
private static final byte[] LEFT = {0, -1, 0, 0};
- private static final byte[] UP = {0, 0, 1, 0};
+ private static final byte[] UP = {0, 0, -1, 0};
// Default values.
private static final int QOS_TOKEN_RATE = 800; // 9 bytes * 1000000 us / 11250 us
@@ -430,6 +430,34 @@
}
/**
+ * Send a bytes array data report to a connected HID host using interrupt channel.
+ * @param deviceID name or MAC address or the HID input host
+ * @param id report Id, as defined in descriptor. Can be 0 in case Report Id are not defined in
+ * descriptor.
+ * @param report byte array to be sent into HID device
+ * @return true if successfully sent the report; otherwise false
+ * @throws Exception error from Bluetooth HidDevService
+ */
+ @Rpc(description = "Send bytes array report to a connected HID host using interrupt channel.")
+ public Boolean bluetoothHidDeviceSendBytesArrayReport(
+ @RpcParameter(name = "deviceID",
+ description = "Name or MAC address of a bluetooth device.")
+ String deviceID,
+ @RpcParameter(name = "descriptor",
+ description = "Descriptor of the report")
+ Integer id,
+ @RpcParameter(name = "report")
+ byte[] report) throws Exception {
+ if (sHidDeviceProfile == null) {
+ return false;
+ }
+
+ BluetoothDevice device = BluetoothFacade.getDevice(sHidDeviceProfile.getConnectedDevices(),
+ deviceID);
+ return sHidDeviceProfile.sendReport(device, id, report);
+ }
+
+ /**
* Send a report to the connected HID host as reply for GET_REPORT request from the HID host.
* @param deviceID name or MAC address or the HID input host
* @param type type of the report, as in request
@@ -463,6 +491,39 @@
}
/**
+ * Send a bytes array report to the connected HID host as reply for GET_REPORT request
+ * from the HID host.
+ * @param deviceID name or MAC address or the HID input host
+ * @param type type of the report, as in request
+ * @param id id of the report, as in request
+ * @param report byte array to be sent into HID device
+ * @return true if successfully sent the reply report; otherwise false
+ * @throws Exception error from Bluetooth HidDevService
+ */
+ @Rpc(description = "Send reply bytes array report to a connected HID..")
+ public Boolean bluetoothHidDeviceReplyBytesArrayReport(
+ @RpcParameter(name = "deviceID",
+ description = "Name or MAC address of a bluetooth device.")
+ String deviceID,
+ @RpcParameter(name = "type",
+ description = "Type as in the report.")
+ Integer type,
+ @RpcParameter(name = "id",
+ description = "id as in the report.")
+ Integer id,
+ @RpcParameter(name = "report")
+ byte[] report) throws Exception {
+ if (sHidDeviceProfile == null) {
+ return false;
+ }
+
+ BluetoothDevice device = BluetoothFacade.getDevice(sHidDeviceProfile.getConnectedDevices(),
+ deviceID);
+ return sHidDeviceProfile.replyReport(
+ device, (byte) (int) type, (byte) (int) id, report);
+ }
+
+ /**
* Send error handshake message as reply for invalid SET_REPORT request from the HID host.
* @param deviceID name or MAC address or the HID input host
* @param error error byte
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 e60e5f1..33a573b 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
@@ -32,6 +32,7 @@
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneStateListener;
+import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
@@ -190,7 +191,10 @@
@Rpc(description = "Get network preference for subscription.")
public String telephonyGetPreferredNetworkTypesForSubscription(
@RpcParameter(name = "subId") Integer subId) {
- int networkPreferenceInt = mTelephonyManager.getPreferredNetworkType(subId);
+ int networkPreferenceInt =
+ RadioAccessFamily.getNetworkTypeFromRaf(
+ (int) mTelephonyManager.createForSubscriptionId(
+ subId).getAllowedNetworkTypesBitmask());
return TelephonyUtils.getNetworkModeStringfromInt(networkPreferenceInt);
}
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
index 0b1318f..2bc1f22 100755
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
@@ -2154,7 +2154,7 @@
if (bandList != null) {
// Build a JSON array of bands represented as operating classes
- Log.d("onFailure list of supported bands: " + bandList);
+ Log.d("onFailure list of supported bands: " + Arrays.toString(bandList));
JSONArray formattedBandList = new JSONArray();
for (int i = 0; i < bandList.length; i++) {
formattedBandList.put(bandList[i]);
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
index bea4a82..300c98c 100644
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
@@ -27,7 +27,6 @@
import android.net.wifi.WifiScanner.ScanSettings;
import android.os.Bundle;
import android.os.SystemClock;
-import android.provider.Settings.Global;
import android.provider.Settings.SettingNotFoundException;
import com.googlecode.android_scripting.Log;
@@ -400,7 +399,7 @@
@RpcParameter(name = "scanSettings") JSONObject scanSettings)
throws JSONException {
ScanSettings ss = parseScanSettings(scanSettings);
- Log.d("startWifiScannerScan with " + ss.channels);
+ Log.d("startWifiScannerScan with " + Arrays.toString(ss.channels));
WifiScanListener listener = genBackgroundWifiScanListener();
mScan.startBackgroundScan(ss, listener);
return listener.mIndex;
@@ -450,7 +449,7 @@
@RpcParameter(name = "scanSettings") JSONObject scanSettings)
throws JSONException {
ScanSettings ss = parseScanSettings(scanSettings);
- Log.d("startWifiScannerScan with " + ss.channels);
+ Log.d("startWifiScannerScan with " + Arrays.toString(ss.channels));
WifiScanListener listener = genWifiScanListener();
mScan.startScan(ss, listener);
return listener.mIndex;