Merge "Avoid Bluetooth gets turned on by enableBle"
diff --git a/core/api/current.txt b/core/api/current.txt
index bc61d15..2c2c679 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -954,7 +954,7 @@
field public static final int measureWithLargestChild = 16843476; // 0x10102d4
field public static final int mediaRouteButtonStyle = 16843693; // 0x10103ad
field public static final int mediaRouteTypes = 16843694; // 0x10103ae
- field public static final int memtagMode = 16844313; // 0x1010619
+ field public static final int memtagMode = 16844324; // 0x1010624
field public static final int menuCategory = 16843230; // 0x10101de
field public static final int mimeGroup = 16844309; // 0x1010615
field public static final int mimeType = 16842790; // 0x1010026
@@ -978,7 +978,7 @@
field public static final int multiArch = 16843918; // 0x101048e
field public static final int multiprocess = 16842771; // 0x1010013
field public static final int name = 16842755; // 0x1010003
- field public static final int nativeHeapZeroInitialized = 16844314; // 0x101061a
+ field public static final int nativeHeapZeroInitialized = 16844325; // 0x1010625
field public static final int navigationBarColor = 16843858; // 0x1010452
field public static final int navigationBarDividerColor = 16844141; // 0x101056d
field public static final int navigationContentDescription = 16843969; // 0x10104c1
@@ -29936,6 +29936,11 @@
ctor public OperationCanceledException(String);
}
+ public interface OutcomeReceiver<R, E extends java.lang.Throwable> {
+ method public default void onError(@NonNull E);
+ method public void onResult(@NonNull R);
+ }
+
public final class Parcel {
method public void appendFrom(android.os.Parcel, int, int);
method @Nullable public android.os.IBinder[] createBinderArray();
@@ -41031,6 +41036,7 @@
method public String getNetworkOperator();
method public String getNetworkOperatorName();
method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public int getNetworkSelectionMode();
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void getNetworkSlicingConfiguration(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.telephony.data.SlicingConfig,android.telephony.TelephonyManager.SlicingException>);
method public String getNetworkSpecifier();
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getNetworkType();
method @Deprecated public int getPhoneCount();
@@ -41264,6 +41270,13 @@
field public static final int ERROR_TIMEOUT = 1; // 0x1
}
+ public static class TelephonyManager.SlicingException extends java.lang.Exception {
+ ctor public TelephonyManager.SlicingException(int);
+ method public int getErrorCode();
+ field public static final int ERROR_MODEM_ERROR = 2; // 0x2
+ field public static final int ERROR_TIMEOUT = 1; // 0x1
+ }
+
public abstract static class TelephonyManager.UssdResponseCallback {
ctor public TelephonyManager.UssdResponseCallback();
method public void onReceiveUssdResponse(android.telephony.TelephonyManager, String, CharSequence);
@@ -41439,6 +41452,88 @@
method @NonNull public android.telephony.data.ApnSetting.Builder setUser(@Nullable String);
}
+ public final class NetworkSliceInfo implements android.os.Parcelable {
+ method public int describeContents();
+ method @IntRange(from=0xffffffff, to=0xfffffe) public int getMappedHplmnSliceDifferentiator();
+ method public int getMappedHplmnSliceServiceType();
+ method @IntRange(from=0xffffffff, to=0xfffffe) public int getSliceDifferentiator();
+ method public int getSliceServiceType();
+ method public int getStatus();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.NetworkSliceInfo> CREATOR;
+ field public static final int SLICE_DIFFERENTIATOR_NO_SLICE = -1; // 0xffffffff
+ field public static final int SLICE_SERVICE_TYPE_EMBB = 1; // 0x1
+ field public static final int SLICE_SERVICE_TYPE_MIOT = 3; // 0x3
+ field public static final int SLICE_SERVICE_TYPE_NONE = 0; // 0x0
+ field public static final int SLICE_SERVICE_TYPE_URLLC = 2; // 0x2
+ field public static final int SLICE_STATUS_ALLOWED = 2; // 0x2
+ field public static final int SLICE_STATUS_CONFIGURED = 1; // 0x1
+ field public static final int SLICE_STATUS_DEFAULT_CONFIGURED = 5; // 0x5
+ field public static final int SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_PLMN = 3; // 0x3
+ field public static final int SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_REGISTERED_AREA = 4; // 0x4
+ field public static final int SLICE_STATUS_UNKNOWN = 0; // 0x0
+ }
+
+ public static final class NetworkSliceInfo.Builder {
+ ctor public NetworkSliceInfo.Builder();
+ method @NonNull public android.telephony.data.NetworkSliceInfo build();
+ method @NonNull public android.telephony.data.NetworkSliceInfo.Builder setMappedHplmnSliceDifferentiator(@IntRange(from=0xffffffff, to=0xfffffe) int);
+ method @NonNull public android.telephony.data.NetworkSliceInfo.Builder setMappedHplmnSliceServiceType(int);
+ method @NonNull public android.telephony.data.NetworkSliceInfo.Builder setSliceDifferentiator(@IntRange(from=0xffffffff, to=0xfffffe) int);
+ method @NonNull public android.telephony.data.NetworkSliceInfo.Builder setSliceServiceType(int);
+ method @NonNull public android.telephony.data.NetworkSliceInfo.Builder setStatus(int);
+ }
+
+ public final class RouteSelectionDescriptor implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public java.util.List<java.lang.String> getDataNetworkName();
+ method @IntRange(from=0x0, to=0xff) public int getPrecedence();
+ method public int getSessionType();
+ method @NonNull public java.util.List<android.telephony.data.NetworkSliceInfo> getSliceInfo();
+ method public int getSscMode();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.RouteSelectionDescriptor> CREATOR;
+ field public static final int ROUTE_SSC_MODE_1 = 1; // 0x1
+ field public static final int ROUTE_SSC_MODE_2 = 2; // 0x2
+ field public static final int ROUTE_SSC_MODE_3 = 3; // 0x3
+ field public static final int SESSION_TYPE_IPV4 = 0; // 0x0
+ field public static final int SESSION_TYPE_IPV4V6 = 2; // 0x2
+ field public static final int SESSION_TYPE_IPV6 = 1; // 0x1
+ }
+
+ public final class SlicingConfig implements android.os.Parcelable {
+ ctor public SlicingConfig();
+ method public int describeContents();
+ method @NonNull public java.util.List<android.telephony.data.NetworkSliceInfo> getSliceInfo();
+ method @NonNull public java.util.List<android.telephony.data.UrspRule> getUrspRules();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.SlicingConfig> CREATOR;
+ }
+
+ public final class TrafficDescriptor implements android.os.Parcelable {
+ method public int describeContents();
+ method @Nullable public String getDataNetworkName();
+ method @Nullable public String getOsAppId();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.TrafficDescriptor> CREATOR;
+ }
+
+ public static final class TrafficDescriptor.Builder {
+ ctor public TrafficDescriptor.Builder();
+ method @NonNull public android.telephony.data.TrafficDescriptor build();
+ method @NonNull public android.telephony.data.TrafficDescriptor.Builder setDataNetworkName(@NonNull String);
+ method @NonNull public android.telephony.data.TrafficDescriptor.Builder setOsAppId(@NonNull String);
+ }
+
+ public final class UrspRule implements android.os.Parcelable {
+ method public int describeContents();
+ method @IntRange(from=0x0, to=0xff) public int getPrecedence();
+ method @NonNull public java.util.List<android.telephony.data.RouteSelectionDescriptor> getRouteSelectionDescriptor();
+ method @NonNull public java.util.List<android.telephony.data.TrafficDescriptor> getTrafficDescriptors();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.UrspRule> CREATOR;
+ }
+
}
package android.telephony.emergency {
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 385c407..906a595 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -9671,6 +9671,25 @@
field public static final String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming";
}
+ public final class ModemActivityInfo implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public android.telephony.ModemActivityInfo getDelta(@NonNull android.telephony.ModemActivityInfo);
+ method public long getIdleTimeMillis();
+ method public static int getNumTxPowerLevels();
+ method public long getReceiveTimeMillis();
+ method public long getSleepTimeMillis();
+ method public long getTimestampMillis();
+ method public long getTransmitDurationMillisAtPowerLevel(int);
+ method @NonNull public android.util.Range<java.lang.Integer> getTransmitPowerRange(int);
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ModemActivityInfo> CREATOR;
+ field public static final int TX_POWER_LEVEL_0 = 0; // 0x0
+ field public static final int TX_POWER_LEVEL_1 = 1; // 0x1
+ field public static final int TX_POWER_LEVEL_2 = 2; // 0x2
+ field public static final int TX_POWER_LEVEL_3 = 3; // 0x3
+ field public static final int TX_POWER_LEVEL_4 = 4; // 0x4
+ }
+
public final class NetworkRegistrationInfo implements android.os.Parcelable {
method @Nullable public android.telephony.DataSpecificRegistrationInfo getDataSpecificInfo();
method public int getRegistrationState();
@@ -10337,6 +10356,7 @@
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void reportDefaultNetworkStatus(boolean);
method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestModemActivityInfo(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.telephony.ModemActivityInfo,android.telephony.TelephonyManager.ModemActivityInfoException>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestNumberVerification(@NonNull android.telephony.PhoneNumberRange, long, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.NumberVerificationCallback);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetAllCarrierActions();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetCarrierKeysForImsiEncryption();
@@ -10509,6 +10529,14 @@
field public static final int RESULT_SUCCESS = 0; // 0x0
}
+ public static class TelephonyManager.ModemActivityInfoException extends java.lang.Exception {
+ method public int getErrorCode();
+ field public static final int ERROR_INVALID_INFO_RECEIVED = 2; // 0x2
+ field public static final int ERROR_MODEM_RESPONSE_ERROR = 3; // 0x3
+ field public static final int ERROR_PHONE_NOT_AVAILABLE = 1; // 0x1
+ field public static final int ERROR_UNKNOWN = 0; // 0x0
+ }
+
public final class ThermalMitigationRequest implements android.os.Parcelable {
method public int describeContents();
method @Nullable public android.telephony.DataThrottlingRequest getDataThrottlingRequest();
@@ -10633,7 +10661,7 @@
method public int getPduSessionId();
method public int getProtocolType();
method public long getRetryDurationMillis();
- method @Nullable public android.telephony.data.SliceInfo getSliceInfo();
+ method @Nullable public android.telephony.data.NetworkSliceInfo getSliceInfo();
method @Deprecated public int getSuggestedRetryTime();
method @NonNull public java.util.List<android.telephony.data.TrafficDescriptor> getTrafficDescriptors();
method public void writeToParcel(android.os.Parcel, int);
@@ -10669,7 +10697,7 @@
method @NonNull public android.telephony.data.DataCallResponse.Builder setPduSessionId(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryDurationMillis(long);
- method @NonNull public android.telephony.data.DataCallResponse.Builder setSliceInfo(@Nullable android.telephony.data.SliceInfo);
+ method @NonNull public android.telephony.data.DataCallResponse.Builder setSliceInfo(@Nullable android.telephony.data.NetworkSliceInfo);
method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setTrafficDescriptors(@NonNull java.util.List<android.telephony.data.TrafficDescriptor>);
}
@@ -10742,7 +10770,7 @@
method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @NonNull android.telephony.data.DataServiceCallback);
- method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @IntRange(from=0, to=15) int, @Nullable android.telephony.data.SliceInfo, @Nullable android.telephony.data.TrafficDescriptor, boolean, @NonNull android.telephony.data.DataServiceCallback);
+ method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @IntRange(from=0, to=15) int, @Nullable android.telephony.data.NetworkSliceInfo, @Nullable android.telephony.data.TrafficDescriptor, boolean, @NonNull android.telephony.data.DataServiceCallback);
}
public class DataServiceCallback {
@@ -10800,32 +10828,6 @@
method public final void updateQualifiedNetworkTypes(int, @NonNull java.util.List<java.lang.Integer>);
}
- public final class SliceInfo implements android.os.Parcelable {
- method public int describeContents();
- method @IntRange(from=android.telephony.data.SliceInfo.MIN_SLICE_DIFFERENTIATOR, to=android.telephony.data.SliceInfo.MAX_SLICE_DIFFERENTIATOR) public int getMappedHplmnSliceDifferentiator();
- method public int getMappedHplmnSliceServiceType();
- method @IntRange(from=android.telephony.data.SliceInfo.MIN_SLICE_DIFFERENTIATOR, to=android.telephony.data.SliceInfo.MAX_SLICE_DIFFERENTIATOR) public int getSliceDifferentiator();
- method public int getSliceServiceType();
- method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.SliceInfo> CREATOR;
- field public static final int MAX_SLICE_DIFFERENTIATOR = 16777214; // 0xfffffe
- field public static final int MIN_SLICE_DIFFERENTIATOR = -1; // 0xffffffff
- field public static final int SLICE_DIFFERENTIATOR_NO_SLICE = -1; // 0xffffffff
- field public static final int SLICE_SERVICE_TYPE_EMBB = 1; // 0x1
- field public static final int SLICE_SERVICE_TYPE_MIOT = 3; // 0x3
- field public static final int SLICE_SERVICE_TYPE_NONE = 0; // 0x0
- field public static final int SLICE_SERVICE_TYPE_URLLC = 2; // 0x2
- }
-
- public static final class SliceInfo.Builder {
- ctor public SliceInfo.Builder();
- method @NonNull public android.telephony.data.SliceInfo build();
- method @NonNull public android.telephony.data.SliceInfo.Builder setMappedHplmnSliceDifferentiator(@IntRange(from=android.telephony.data.SliceInfo.MIN_SLICE_DIFFERENTIATOR, to=android.telephony.data.SliceInfo.MAX_SLICE_DIFFERENTIATOR) int);
- method @NonNull public android.telephony.data.SliceInfo.Builder setMappedHplmnSliceServiceType(int);
- method @NonNull public android.telephony.data.SliceInfo.Builder setSliceDifferentiator(@IntRange(from=android.telephony.data.SliceInfo.MIN_SLICE_DIFFERENTIATOR, to=android.telephony.data.SliceInfo.MAX_SLICE_DIFFERENTIATOR) int);
- method @NonNull public android.telephony.data.SliceInfo.Builder setSliceServiceType(int);
- }
-
public final class ThrottleStatus implements android.os.Parcelable {
method public int describeContents();
method public int getApnType();
@@ -10854,15 +10856,6 @@
method @NonNull public android.telephony.data.ThrottleStatus.Builder setTransportType(int);
}
- public final class TrafficDescriptor implements android.os.Parcelable {
- ctor public TrafficDescriptor(@Nullable String, @Nullable String);
- method public int describeContents();
- method @Nullable public String getDnn();
- method @Nullable public String getOsAppId();
- method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.TrafficDescriptor> CREATOR;
- }
-
}
package android.telephony.euicc {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 6613947..d905bbe 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1649,6 +1649,28 @@
field public static final String MBMS_STREAMING_SERVICE_OVERRIDE_METADATA = "mbms-streaming-service-override";
}
+ public final class ModemActivityInfo implements android.os.Parcelable {
+ ctor public ModemActivityInfo(long, int, int, @NonNull int[], int);
+ method public int describeContents();
+ method @NonNull public android.telephony.ModemActivityInfo getDelta(@NonNull android.telephony.ModemActivityInfo);
+ method public long getIdleTimeMillis();
+ method public static int getNumTxPowerLevels();
+ method public long getReceiveTimeMillis();
+ method public long getSleepTimeMillis();
+ method public long getTimestampMillis();
+ method public long getTransmitDurationMillisAtPowerLevel(int);
+ method @NonNull public android.util.Range<java.lang.Integer> getTransmitPowerRange(int);
+ method public boolean isEmpty();
+ method public boolean isValid();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ModemActivityInfo> CREATOR;
+ field public static final int TX_POWER_LEVEL_0 = 0; // 0x0
+ field public static final int TX_POWER_LEVEL_1 = 1; // 0x1
+ field public static final int TX_POWER_LEVEL_2 = 2; // 0x2
+ field public static final int TX_POWER_LEVEL_3 = 3; // 0x3
+ field public static final int TX_POWER_LEVEL_4 = 4; // 0x4
+ }
+
public class PhoneNumberUtils {
method public static int getMinMatchForTest();
method public static void setMinMatchForTest(int);
diff --git a/core/java/Android.bp b/core/java/Android.bp
index eee696b..675cea8 100644
--- a/core/java/Android.bp
+++ b/core/java/Android.bp
@@ -341,6 +341,27 @@
],
}
+java_library {
+ name: "modules-utils-statemachine",
+ srcs: [
+ "com/android/internal/util/IState.java",
+ "com/android/internal/util/State.java",
+ "com/android/internal/util/StateMachine.java",
+ ],
+ libs: [
+ "framework-annotations-lib",
+ "unsupportedappusage",
+ ],
+ sdk_version: "module_current",
+ min_sdk_version: "29",
+
+ visibility: ["//visibility:public"],
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+}
+
filegroup {
name: "framework-ims-common-shared-srcs",
srcs: [
diff --git a/core/java/android/app/IntentService.java b/core/java/android/app/IntentService.java
index 71b28fb..6c435b9 100644
--- a/core/java/android/app/IntentService.java
+++ b/core/java/android/app/IntentService.java
@@ -54,7 +54,7 @@
* @see android.support.v4.app.JobIntentService
*
* @deprecated IntentService is subject to all the
- * <a href="/preview/features/background.html">background execution limits</a>
+ * <a href="{@docRoot}about/versions/oreo/background.html">background execution limits</a>
* imposed with Android 8.0 (API level 26). Consider using {@link androidx.work.WorkManager}
* or {@link androidx.core.app.JobIntentService}, which uses jobs
* instead of services when running on Android 8.0 or higher.
diff --git a/core/java/android/bluetooth/BluetoothLeAudio.java b/core/java/android/bluetooth/BluetoothLeAudio.java
index 75fcab9..6bbe95e 100644
--- a/core/java/android/bluetooth/BluetoothLeAudio.java
+++ b/core/java/android/bluetooth/BluetoothLeAudio.java
@@ -65,9 +65,6 @@
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
* {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
* {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
- *
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
- * receive.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_LE_AUDIO_CONNECTION_STATE_CHANGED =
@@ -82,9 +79,6 @@
* be null if no device is active. </li>
* </ul>
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
- * receive.
- *
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@@ -92,12 +86,148 @@
"android.bluetooth.action.LE_AUDIO_ACTIVE_DEVICE_CHANGED";
/**
+ * Intent used to broadcast group node status information.
+ *
+ * <p>This intent will have 3 extra:
+ * <ul>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. It can
+ * be null if no device is active. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_GROUP_ID} - Group id. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_GROUP_NODE_STATUS} - Group node status. </li>
+ * </ul>
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LE_AUDIO_GROUP_NODE_STATUS_CHANGED =
+ "android.bluetooth.action.LE_AUDIO_GROUP_NODE_STATUS_CHANGED";
+
+
+ /**
+ * Intent used to broadcast group status information.
+ *
+ * <p>This intent will have 4 extra:
+ * <ul>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. It can
+ * be null if no device is active. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_GROUP_ID} - Group id. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_GROUP_STATUS} - Group status. </li>
+ * </ul>
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LE_AUDIO_GROUP_STATUS_CHANGED =
+ "android.bluetooth.action.LE_AUDIO_GROUP_STATUS_CHANGED";
+
+ /**
+ * Intent used to broadcast group audio configuration changed information.
+ *
+ * <p>This intent will have 5 extra:
+ * <ul>
+ * <li> {@link #EXTRA_LE_AUDIO_GROUP_ID} - Group id. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_DIRECTION} - Direction as bit mask. </li>
+ * <li> {@link #EXTRA_LE_AUDIO_SINK_LOCATION} - Sink location as per Bluetooth Assigned
+ * Numbers </li>
+ * <li> {@link #EXTRA_LE_AUDIO_SOURCE_LOCATION} - Source location as per Bluetooth Assigned
+ * Numbers </li>
+ * <li> {@link #EXTRA_LE_AUDIO_AVAILABLE_CONTEXTS} - Available contexts for group as per
+ * Bluetooth Assigned Numbers </li>
+ * </ul>
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LE_AUDIO_CONF_CHANGED =
+ "android.bluetooth.action.LE_AUDIO_CONF_CHANGED";
+
+ /**
+ * Indicates conversation between humans as, for example, in telephony or video calls.
+ * @hide
+ */
+ public static final int CONTEXT_TYPE_COMMUNICATION = 0x0002;
+
+ /**
+ * Indicates media as, for example, in music, public radio, podcast or video soundtrack.
+ * @hide
+ */
+ public static final int CONTEXT_TYPE_MEDIA = 0x0004;
+
+ /**
* This represents an invalid group ID.
*
* @hide
*/
public static final int GROUP_ID_INVALID = IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID;
+ /**
+ * Contains group id.
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_GROUP_ID =
+ "android.bluetooth.extra.LE_AUDIO_GROUP_ID";
+
+ /**
+ * Contains group node status, can be any of
+ * <p>
+ * <ul>
+ * <li> {@link #GROUP_NODE_ADDED} </li>
+ * <li> {@link #GROUP_NODE_REMOVED} </li>
+ * </ul>
+ * <p>
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_GROUP_NODE_STATUS =
+ "android.bluetooth.extra.LE_AUDIO_GROUP_NODE_STATUS";
+
+ /**
+ * Contains group status, can be any of
+ *
+ * <p>
+ * <ul>
+ * <li> {@link #GROUP_STATUS_IDLE} </li>
+ * <li> {@link #GROUP_STATUS_STREAMING} </li>
+ * <li> {@link #GROUP_STATUS_SUSPENDED} </li>
+ * <li> {@link #GROUP_STATUS_RECONFIGURED} </li>
+ * <li> {@link #GROUP_STATUS_DESTROYED} </li>
+ * </ul>
+ * <p>
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_GROUP_STATUS =
+ "android.bluetooth.extra.LE_AUDIO_GROUP_STATUS";
+
+ /**
+ * Contains bit mask for direction, bit 0 set when Sink, bit 1 set when Source.
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_DIRECTION =
+ "android.bluetooth.extra.LE_AUDIO_DIRECTION";
+
+ /**
+ * Contains source location as per Bluetooth Assigned Numbers
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_SOURCE_LOCATION =
+ "android.bluetooth.extra.LE_AUDIO_SOURCE_LOCATION";
+
+ /**
+ * Contains sink location as per Bluetooth Assigned Numbers
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_SINK_LOCATION =
+ "android.bluetooth.extra.LE_AUDIO_SINK_LOCATION";
+
+ /**
+ * Contains available context types for group as per Bluetooth Assigned Numbers
+ * @hide
+ */
+ public static final String EXTRA_LE_AUDIO_AVAILABLE_CONTEXTS =
+ "android.bluetooth.extra.LE_AUDIO_AVAILABLE_CONTEXTS";
+
private BluetoothAdapter mAdapter;
private final BluetoothProfileConnector<IBluetoothLeAudio> mProfileConnector =
new BluetoothProfileConnector(this, BluetoothProfile.LE_AUDIO, "BluetoothLeAudio",
diff --git a/core/java/android/content/pm/parsing/component/ParsedIntentInfo.java b/core/java/android/content/pm/parsing/component/ParsedIntentInfo.java
index 0ba92cc..504a7bd 100644
--- a/core/java/android/content/pm/parsing/component/ParsedIntentInfo.java
+++ b/core/java/android/content/pm/parsing/component/ParsedIntentInfo.java
@@ -19,7 +19,6 @@
import android.annotation.Nullable;
import android.content.IntentFilter;
import android.os.Parcel;
-import android.os.Parcelable;
import android.util.Pair;
import com.android.internal.util.DataClass;
@@ -168,19 +167,6 @@
+ '}';
}
- public static final Parcelable.Creator<ParsedIntentInfo> CREATOR =
- new Parcelable.Creator<ParsedIntentInfo>() {
- @Override
- public ParsedIntentInfo createFromParcel(Parcel source) {
- return new ParsedIntentInfo(source);
- }
-
- @Override
- public ParsedIntentInfo[] newArray(int size) {
- return new ParsedIntentInfo[size];
- }
- };
-
public boolean isHasDefault() {
return hasDefault;
}
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index 0a76a9c..9e78a6b 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -1440,14 +1440,14 @@
* Assuming that the bottom edge of the device faces the
* user and that the screen is face-up, tilting the top edge
* of the device toward the ground creates a positive pitch
- * angle. The range of values is -π to π.</li>
+ * angle. The range of values is -π/2 to π/2.</li>
* <li>values[2]: <i>Roll</i>, angle of rotation about the y axis. This
* value represents the angle between a plane perpendicular
* to the device's screen and a plane perpendicular to the
* ground. Assuming that the bottom edge of the device faces
* the user and that the screen is face-up, tilting the left
* edge of the device toward the ground creates a positive
- * roll angle. The range of values is -π/2 to π/2.</li>
+ * roll angle. The range of values is -π to π.</li>
* </ul>
* <p>
* Applying these three rotations in the azimuth, pitch, roll order
diff --git a/core/java/android/os/OutcomeReceiver.java b/core/java/android/os/OutcomeReceiver.java
new file mode 100644
index 0000000..01b2764
--- /dev/null
+++ b/core/java/android/os/OutcomeReceiver.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+import android.annotation.NonNull;
+
+/**
+ * Callback interface intended for use when an asynchronous operation may result in a failure.
+ *
+ * This interface may be used in cases where an asynchronous API may complete either with a value
+ * or with a {@link Throwable} that indicates an error.
+ * @param <R> The type of the result that's being sent.
+ * @param <E> The type of the {@link Throwable} that contains more information about the error.
+ */
+public interface OutcomeReceiver<R, E extends Throwable> {
+ /**
+ * Called when the asynchronous operation succeeds and delivers a result value.
+ * @param result The value delivered by the asynchronous operation.
+ */
+ void onResult(@NonNull R result);
+
+ /**
+ * Called when the asynchronous operation fails. The mode of failure is indicated by the
+ * {@link Throwable} passed as an argument to this method.
+ * @param error A subclass of {@link Throwable} with more details about the error that occurred.
+ */
+ default void onError(@NonNull E error) {}
+}
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 575eb37..a2716d2 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -282,6 +282,8 @@
@CriticalNative
private static native void nativeMarkSensitive(long nativePtr);
+ @FastNative
+ private static native void nativeMarkForBinder(long nativePtr, IBinder binder);
@CriticalNative
private static native int nativeDataSize(long nativePtr);
@CriticalNative
@@ -498,6 +500,16 @@
/**
* Parcel data should be zero'd before realloc'd or deleted.
+ *
+ * Note: currently this feature requires multiple things to work in concert:
+ * - markSensitive must be called on every relative Parcel
+ * - FLAG_CLEAR_BUF must be passed into the kernel
+ * This requires having code which does the right thing in every method and in every backend
+ * of AIDL. Rather than exposing this API, it should be replaced with a single API on
+ * IBinder objects which can be called once, and the information should be fed into the
+ * Parcel using markForBinder APIs. In terms of code size and number of API calls, this is
+ * much more extensible.
+ *
* @hide
*/
public final void markSensitive() {
@@ -505,9 +517,23 @@
}
/**
+ * Associate this parcel with a binder object. This marks the parcel as being prepared for a
+ * transaction on this specific binder object. Based on this, the format of the wire binder
+ * protocol may change. This should be called before any data is written to the parcel. If this
+ * is called multiple times, this will only be marked for the last binder. For future
+ * compatibility, it is recommended to call this on all parcels which are being sent over
+ * binder.
+ *
+ * @hide
+ */
+ public void markForBinder(@NonNull IBinder binder) {
+ nativeMarkForBinder(mNativePtr, binder);
+ }
+
+ /**
* Returns the total amount of data contained in the parcel.
*/
- public final int dataSize() {
+ public int dataSize() {
return nativeDataSize(mNativePtr);
}
@@ -665,7 +691,6 @@
* @hide
*/
public static boolean hasFileDescriptors(Object value) {
- getValueType(value); // Will throw if value is not supported
if (value instanceof LazyValue) {
return ((LazyValue) value).hasFileDescriptors();
} else if (value instanceof Parcelable) {
@@ -706,6 +731,8 @@
}
}
}
+ } else {
+ getValueType(value); // Will throw if value is not supported
}
return false;
}
@@ -3418,15 +3445,7 @@
public void writeToParcel(Parcel out) {
if (mObject == null) {
- int restore = mSource.dataPosition();
- try {
- mSource.setDataPosition(mPosition);
- out.writeInt(mSource.readInt()); // Type
- out.writeInt(mSource.readInt()); // Length
- out.appendFrom(mSource, mSource.dataPosition(), mLength);
- } finally {
- mSource.setDataPosition(restore);
- }
+ out.appendFrom(mSource, mPosition, mLength + 8);
} else {
out.writeValue(mObject);
}
diff --git a/core/java/android/os/ServiceManager.java b/core/java/android/os/ServiceManager.java
index 06a2c87..4e8418b 100644
--- a/core/java/android/os/ServiceManager.java
+++ b/core/java/android/os/ServiceManager.java
@@ -29,7 +29,14 @@
import java.util.Map;
-/** @hide */
+/**
+ * Manage binder services as registered with the binder context manager. These services must be
+ * declared statically on an Android device (SELinux access_vector service_manager, w/ service
+ * names in service_contexts files), and they do not follow the activity lifecycle. When
+ * building applications, android.app.Service should be preferred.
+ *
+ * @hide
+ **/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public final class ServiceManager {
private static final String TAG = "ServiceManager";
diff --git a/core/java/android/os/connectivity/CellularBatteryStats.java b/core/java/android/os/connectivity/CellularBatteryStats.java
index 121fd33..fc17002 100644
--- a/core/java/android/os/connectivity/CellularBatteryStats.java
+++ b/core/java/android/os/connectivity/CellularBatteryStats.java
@@ -109,7 +109,7 @@
CellSignalStrength.getNumSignalStrengthLevels()));
mTxTimeMs = Arrays.copyOfRange(
txTimeMs, 0,
- Math.min(txTimeMs.length, ModemActivityInfo.TX_POWER_LEVELS));
+ Math.min(txTimeMs.length, ModemActivityInfo.getNumTxPowerLevels()));
mMonitoredRailChargeConsumedMaMs = monitoredRailChargeConsumedMaMs;
}
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index f0f0867..505f400 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -2351,7 +2351,10 @@
final int ellipsisStringLen = ellipsisString.length();
// Use the ellipsis string only if there are that at least as many characters to replace.
final boolean useEllipsisString = ellipsisCount >= ellipsisStringLen;
- for (int i = 0; i < ellipsisCount; i++) {
+ final int min = Math.max(0, start - ellipsisStart - lineStart);
+ final int max = Math.min(ellipsisCount, end - ellipsisStart - lineStart);
+
+ for (int i = min; i < max; i++) {
final char c;
if (useEllipsisString && i < ellipsisStringLen) {
c = ellipsisString.charAt(i);
@@ -2360,9 +2363,7 @@
}
final int a = i + ellipsisStart + lineStart;
- if (start <= a && a < end) {
- dest[destoff + a - start] = c;
- }
+ dest[destoff + a - start] = c;
}
}
diff --git a/core/java/android/util/apk/OWNERS b/core/java/android/util/apk/OWNERS
index 52c9550..0f4e869 100644
--- a/core/java/android/util/apk/OWNERS
+++ b/core/java/android/util/apk/OWNERS
@@ -1 +1,3 @@
include /core/java/android/content/pm/OWNERS
+cbrubaker@google.com
+mpgroover@google.com
diff --git a/core/java/android/webkit/URLUtil.java b/core/java/android/webkit/URLUtil.java
index 844b156..c7609a6 100644
--- a/core/java/android/webkit/URLUtil.java
+++ b/core/java/android/webkit/URLUtil.java
@@ -310,7 +310,7 @@
String extension = null;
// If we couldn't do anything with the hint, move toward the content disposition
- if (filename == null && contentDisposition != null) {
+ if (contentDisposition != null) {
filename = parseContentDisposition(contentDisposition);
if (filename != null) {
int index = filename.lastIndexOf('/') + 1;
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index dd2940f..e8db609 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -66,7 +66,6 @@
import android.telephony.CellSignalStrength;
import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.ModemActivityInfo;
-import android.telephony.ModemActivityInfo.TransmitPower;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
@@ -7205,7 +7204,7 @@
public ControllerActivityCounterImpl getOrCreateModemControllerActivityLocked() {
if (mModemControllerActivity == null) {
mModemControllerActivity = new ControllerActivityCounterImpl(mBsi.mOnBatteryTimeBase,
- ModemActivityInfo.TX_POWER_LEVELS);
+ ModemActivityInfo.getNumTxPowerLevels());
}
return mModemControllerActivity;
}
@@ -8687,7 +8686,7 @@
if (in.readInt() != 0) {
mModemControllerActivity = new ControllerActivityCounterImpl(mBsi.mOnBatteryTimeBase,
- ModemActivityInfo.TX_POWER_LEVELS, in);
+ ModemActivityInfo.getNumTxPowerLevels(), in);
} else {
mModemControllerActivity = null;
}
@@ -9953,7 +9952,7 @@
mBluetoothActivity = new ControllerActivityCounterImpl(mOnBatteryTimeBase,
NUM_BT_TX_LEVELS);
mModemActivity = new ControllerActivityCounterImpl(mOnBatteryTimeBase,
- ModemActivityInfo.TX_POWER_LEVELS);
+ ModemActivityInfo.getNumTxPowerLevels());
mMobileRadioActiveTimer = new StopwatchTimer(mClocks, null, -400, null, mOnBatteryTimeBase);
mMobileRadioActivePerAppTimer = new StopwatchTimer(mClocks, null, -401, null,
mOnBatteryTimeBase);
@@ -11131,26 +11130,7 @@
}
}
- private ModemActivityInfo mLastModemActivityInfo =
- new ModemActivityInfo(0, 0, 0, new int[0], 0);
-
- private ModemActivityInfo getDeltaModemActivityInfo(ModemActivityInfo activityInfo) {
- if (activityInfo == null) {
- return null;
- }
- int[] txTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS];
- for (int i = 0; i < ModemActivityInfo.TX_POWER_LEVELS; i++) {
- txTimeMs[i] = activityInfo.getTransmitPowerInfo().get(i).getTimeInMillis()
- - mLastModemActivityInfo.getTransmitPowerInfo().get(i).getTimeInMillis();
- }
- ModemActivityInfo deltaInfo = new ModemActivityInfo(activityInfo.getTimestamp(),
- activityInfo.getSleepTimeMillis() - mLastModemActivityInfo.getSleepTimeMillis(),
- activityInfo.getIdleTimeMillis() - mLastModemActivityInfo.getIdleTimeMillis(),
- txTimeMs,
- activityInfo.getReceiveTimeMillis() - mLastModemActivityInfo.getReceiveTimeMillis());
- mLastModemActivityInfo = activityInfo;
- return deltaInfo;
- }
+ private ModemActivityInfo mLastModemActivityInfo = null;
/**
* Distribute Cell radio energy info and network traffic to apps.
@@ -11159,7 +11139,9 @@
if (DEBUG_ENERGY) {
Slog.d(TAG, "Updating mobile radio stats with " + activityInfo);
}
- ModemActivityInfo deltaInfo = getDeltaModemActivityInfo(activityInfo);
+ ModemActivityInfo deltaInfo = mLastModemActivityInfo == null ? activityInfo
+ : mLastModemActivityInfo.getDelta(activityInfo);
+ mLastModemActivityInfo = activityInfo;
// Add modem tx power to history.
addModemTxPowerToHistory(deltaInfo);
@@ -11191,10 +11173,9 @@
mModemActivity.getSleepTimeCounter().addCountLocked(
deltaInfo.getSleepTimeMillis());
mModemActivity.getRxTimeCounter().addCountLocked(deltaInfo.getReceiveTimeMillis());
- for (int lvl = 0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
+ for (int lvl = 0; lvl < ModemActivityInfo.getNumTxPowerLevels(); lvl++) {
mModemActivity.getTxTimeCounters()[lvl]
- .addCountLocked(deltaInfo.getTransmitPowerInfo()
- .get(lvl).getTimeInMillis());
+ .addCountLocked(deltaInfo.getTransmitDurationMillisAtPowerLevel(lvl));
}
// POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V.
@@ -11208,11 +11189,11 @@
mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_IDLE)
+ deltaInfo.getReceiveTimeMillis() *
mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_RX);
- List<TransmitPower> txPowerInfo = deltaInfo.getTransmitPowerInfo();
- for (int i = 0; i < Math.min(txPowerInfo.size(),
+ for (int i = 0; i < Math.min(ModemActivityInfo.getNumTxPowerLevels(),
CellSignalStrength.getNumSignalStrengthLevels()); i++) {
- energyUsed += txPowerInfo.get(i).getTimeInMillis() * mPowerProfile
- .getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_TX, i);
+ energyUsed += deltaInfo.getTransmitDurationMillisAtPowerLevel(i)
+ * mPowerProfile.getAveragePower(
+ PowerProfile.POWER_MODEM_CONTROLLER_TX, i);
}
// We store the power drain as mAms.
@@ -11307,10 +11288,10 @@
}
if (totalTxPackets > 0 && entry.txPackets > 0) {
- for (int lvl = 0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
- long txMs =
- entry.txPackets * deltaInfo.getTransmitPowerInfo()
- .get(lvl).getTimeInMillis();
+ for (int lvl = 0; lvl < ModemActivityInfo.getNumTxPowerLevels();
+ lvl++) {
+ long txMs = entry.txPackets
+ * deltaInfo.getTransmitDurationMillisAtPowerLevel(lvl);
txMs /= totalTxPackets;
activityCounter.getTxTimeCounters()[lvl].addCountLocked(txMs);
}
@@ -11341,20 +11322,16 @@
if (activityInfo == null) {
return;
}
- List<TransmitPower> txPowerInfo = activityInfo.getTransmitPowerInfo();
- if (txPowerInfo == null || txPowerInfo.size() != ModemActivityInfo.TX_POWER_LEVELS) {
- return;
- }
final long elapsedRealtime = mClocks.elapsedRealtime();
final long uptime = mClocks.uptimeMillis();
int levelMaxTimeSpent = 0;
- for (int i = 1; i < txPowerInfo.size(); i++) {
- if (txPowerInfo.get(i).getTimeInMillis() > txPowerInfo.get(levelMaxTimeSpent)
- .getTimeInMillis()) {
+ for (int i = 1; i < ModemActivityInfo.getNumTxPowerLevels(); i++) {
+ if (activityInfo.getTransmitDurationMillisAtPowerLevel(i)
+ > activityInfo.getTransmitDurationMillisAtPowerLevel(levelMaxTimeSpent)) {
levelMaxTimeSpent = i;
}
}
- if (levelMaxTimeSpent == ModemActivityInfo.TX_POWER_LEVELS - 1) {
+ if (levelMaxTimeSpent == ModemActivityInfo.getNumTxPowerLevels() - 1) {
mHistoryCur.states2 |= HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG;
addHistoryRecordLocked(elapsedRealtime, uptime);
}
@@ -12771,7 +12748,7 @@
timeInRxSignalStrengthLevelMs[i]
= getPhoneSignalStrengthTime(i, rawRealTime, which) / 1000;
}
- long[] txTimeMs = new long[Math.min(ModemActivityInfo.TX_POWER_LEVELS,
+ long[] txTimeMs = new long[Math.min(ModemActivityInfo.getNumTxPowerLevels(),
counter.getTxTimeCounters().length)];
long totalTxTimeMs = 0;
for (int i = 0; i < txTimeMs.length; i++) {
@@ -14817,7 +14794,7 @@
mBluetoothActivity = new ControllerActivityCounterImpl(mOnBatteryTimeBase,
NUM_BT_TX_LEVELS, in);
mModemActivity = new ControllerActivityCounterImpl(mOnBatteryTimeBase,
- ModemActivityInfo.TX_POWER_LEVELS, in);
+ ModemActivityInfo.getNumTxPowerLevels(), in);
mHasWifiReporting = in.readInt() != 0;
mHasBluetoothReporting = in.readInt() != 0;
mHasModemReporting = in.readInt() != 0;
diff --git a/core/java/com/android/internal/util/IState.java b/core/java/com/android/internal/util/IState.java
index 07837bf..41b3d5e 100644
--- a/core/java/com/android/internal/util/IState.java
+++ b/core/java/com/android/internal/util/IState.java
@@ -27,12 +27,12 @@
public interface IState {
/**
- * Returned by processMessage to indicate the the message was processed.
+ * Returned by processMessage to indicate the message was processed.
*/
static final boolean HANDLED = true;
/**
- * Returned by processMessage to indicate the the message was NOT processed.
+ * Returned by processMessage to indicate the message was NOT processed.
*/
static final boolean NOT_HANDLED = false;
diff --git a/core/java/com/android/internal/util/State.java b/core/java/com/android/internal/util/State.java
index 4613dad..d5c0f60 100644
--- a/core/java/com/android/internal/util/State.java
+++ b/core/java/com/android/internal/util/State.java
@@ -16,6 +16,7 @@
package com.android.internal.util;
+import android.annotation.SuppressLint;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Message;
@@ -25,6 +26,7 @@
*
* The class for implementing states in a StateMachine
*/
+@SuppressLint("AndroidFrameworkRequiresPermission")
public class State implements IState {
/**
diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java
index 4cff785..cb8d9d1 100644
--- a/core/java/com/android/internal/util/StateMachine.java
+++ b/core/java/com/android/internal/util/StateMachine.java
@@ -48,7 +48,7 @@
* in Object Oriented programming and are used to perform initialization and
* cleanup of the state respectively. The <code>getName</code> method returns the
* name of the state; the default implementation returns the class name. It may be
- * desirable to have <code>getName</code> return the the state instance name instead,
+ * desirable to have <code>getName</code> return the state instance name instead,
* in particular if a particular state class has multiple instances.</p>
*
* <p>When a state machine is created, <code>addState</code> is used to build the
@@ -433,14 +433,14 @@
/**
* Convenience constant that maybe returned by processMessage
- * to indicate the the message was processed and is not to be
+ * to indicate the message was processed and is not to be
* processed by parent states
*/
public static final boolean HANDLED = true;
/**
* Convenience constant that maybe returned by processMessage
- * to indicate the the message was NOT processed and is to be
+ * to indicate the message was NOT processed and is to be
* processed by parent states
*/
public static final boolean NOT_HANDLED = false;
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index 701960e..6fb2904 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -75,3 +75,7 @@
# VINTF
per-file android_os_VintfObject* = file:platform/system/libvintf:/OWNERS
per-file android_os_VintfRuntimeInfo* = file:platform/system/libvintf:/OWNERS
+
+# Battery
+per-file com_android_internal_os_Kernel* = file:/BATTERY_STATS_OWNERS
+per-file com_android_internal_os_*MultiStateCounter* = file:/BATTERY_STATS_OWNERS
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index 241570a..ac32038 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -98,6 +98,15 @@
}
}
+static void android_os_Parcel_markForBinder(JNIEnv* env, jclass clazz, jlong nativePtr,
+ jobject binder)
+{
+ Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
+ if (parcel) {
+ parcel->markForBinder(ibinderForJavaObject(env, binder));
+ }
+}
+
static jint android_os_Parcel_dataSize(jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -766,7 +775,9 @@
static const JNINativeMethod gParcelMethods[] = {
// @CriticalNative
- {"nativeMarkSensitive", "(J)V", (void*)android_os_Parcel_markSensitive},
+ {"nativeMarkSensitive", "(J)V", (void*)android_os_Parcel_markSensitive},
+ // @FastNative
+ {"nativeMarkForBinder", "(JLandroid/os/IBinder;)V", (void*)android_os_Parcel_markForBinder},
// @CriticalNative
{"nativeDataSize", "(J)I", (void*)android_os_Parcel_dataSize},
// @CriticalNative
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 8b9a688..515c08d 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -62,7 +62,6 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
-#include <sys/utsname.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -837,26 +836,6 @@
}
}
-static bool NeedsNoRandomizeWorkaround() {
-#if !defined(__arm__)
- return false;
-#else
- int major;
- int minor;
- struct utsname uts;
- if (uname(&uts) == -1) {
- return false;
- }
-
- if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) {
- return false;
- }
-
- // Kernels before 3.4.* need the workaround.
- return (major < 3) || ((major == 3) && (minor < 4));
-#endif
-}
-
// Utility to close down the Zygote socket file descriptors while
// the child is still running as root with Zygote's privileges. Each
// descriptor (if any) is closed via dup3(), replacing it with a valid
@@ -1687,15 +1666,6 @@
// runtime.
runtime_flags &= ~RuntimeFlags::GWP_ASAN_LEVEL_MASK;
- if (NeedsNoRandomizeWorkaround()) {
- // Work around ARM kernel ASLR lossage (http://b/5817320).
- int old_personality = personality(0xffffffff);
- int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE);
- if (new_personality == -1) {
- ALOGW("personality(%d) failed: %s", new_personality, strerror(errno));
- }
- }
-
SetCapabilities(permitted_capabilities, effective_capabilities, permitted_capabilities,
fail_fn);
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 6a4702b..c1c1858 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3046,6 +3046,9 @@
<public name="canPauseRecording" />
<!-- attribute definitions go here -->
<public name="requireDeviceScreenOn" />
+ </public-group>
+
+ <public-group type="attr" first-id="0x01010624">
<public name="memtagMode" />
<public name="nativeHeapZeroInitialized" />
</public-group>
diff --git a/core/res/res/xml/sms_short_codes.xml b/core/res/res/xml/sms_short_codes.xml
index 37d059a..f1c66c5 100644
--- a/core/res/res/xml/sms_short_codes.xml
+++ b/core/res/res/xml/sms_short_codes.xml
@@ -265,7 +265,7 @@
<!-- USA: 5-6 digits (premium codes from https://www.premiumsmsrefunds.com/ShortCodes.htm),
visual voicemail code for T-Mobile: 122 -->
- <shortcode country="us" pattern="\\d{5,6}" premium="20433|21(?:344|472)|22715|23(?:333|847)|24(?:15|28)0|25209|27(?:449|606|663)|28498|305(?:00|83)|32(?:340|941)|33(?:166|786|849)|34746|35(?:182|564)|37975|38(?:135|146|254)|41(?:366|463)|42335|43(?:355|500)|44(?:578|711|811)|45814|46(?:157|173|327)|46666|47553|48(?:221|277|669)|50(?:844|920)|51(?:062|368)|52944|54(?:723|892)|55928|56483|57370|59(?:182|187|252|342)|60339|61(?:266|982)|62478|64(?:219|898)|65(?:108|500)|69(?:208|388)|70877|71851|72(?:078|087|465)|73(?:288|588|882|909|997)|74(?:034|332|815)|76426|79213|81946|83177|84(?:103|685)|85797|86(?:234|236|666)|89616|90(?:715|842|938)|91(?:362|958)|94719|95297|96(?:040|666|835|969)|97(?:142|294|688)|99(?:689|796|807)" standard="44567|244444" free="122|87902|21696|24614|28003|30356|33669|40196|41064|41270|43753|44034|46645|52413|56139|57969|61785|66975|75136|76227|81398|83952|85140|86566|86799|95737|96684|99245" />
+ <shortcode country="us" pattern="\\d{5,6}" premium="20433|21(?:344|472)|22715|23(?:333|847)|24(?:15|28)0|25209|27(?:449|606|663)|28498|305(?:00|83)|32(?:340|941)|33(?:166|786|849)|34746|35(?:182|564)|37975|38(?:135|146|254)|41(?:366|463)|42335|43(?:355|500)|44(?:578|711|811)|45814|46(?:157|173|327)|46666|47553|48(?:221|277|669)|50(?:844|920)|51(?:062|368)|52944|54(?:723|892)|55928|56483|57370|59(?:182|187|252|342)|60339|61(?:266|982)|62478|64(?:219|898)|65(?:108|500)|69(?:208|388)|70877|71851|72(?:078|087|465)|73(?:288|588|882|909|997)|74(?:034|332|815)|76426|79213|81946|83177|84(?:103|685)|85797|86(?:234|236|666)|89616|90(?:715|842|938)|91(?:362|958)|94719|95297|96(?:040|666|835|969)|97(?:142|294|688)|99(?:689|796|807)" standard="44567|244444" free="122|87902|21696|24614|28003|30356|33669|40196|41064|41270|43753|44034|46645|52413|56139|57969|61785|66975|75136|76227|81398|83952|85140|86566|86799|95737|96684|99245|611611" />
<!-- Vietnam: 1-5 digits (standard system default, not country specific) -->
<shortcode country="vn" pattern="\\d{1,5}" free="5001|9055" />
diff --git a/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java b/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java
index edf473e..b85cb9c 100644
--- a/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java
+++ b/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java
@@ -542,83 +542,83 @@
public void testStateMachineEnterExitTransitionToTest() throws Exception {
//if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
- StateMachineEnterExitTransitionToTest smEnterExitTranstionToTest =
- new StateMachineEnterExitTransitionToTest("smEnterExitTranstionToTest");
- smEnterExitTranstionToTest.start();
- if (smEnterExitTranstionToTest.isDbg()) {
+ StateMachineEnterExitTransitionToTest smEnterExitTransitionToTest =
+ new StateMachineEnterExitTransitionToTest("smEnterExitTransitionToTest");
+ smEnterExitTransitionToTest.start();
+ if (smEnterExitTransitionToTest.isDbg()) {
tlog("testStateMachineEnterExitTransitionToTest E");
}
- synchronized (smEnterExitTranstionToTest) {
- smEnterExitTranstionToTest.sendMessage(TEST_CMD_1);
+ synchronized (smEnterExitTransitionToTest) {
+ smEnterExitTransitionToTest.sendMessage(TEST_CMD_1);
try {
// wait for the messages to be handled
- smEnterExitTranstionToTest.wait();
+ smEnterExitTransitionToTest.wait();
} catch (InterruptedException e) {
tloge("testStateMachineEnterExitTransitionToTest: exception while waiting "
+ e.getMessage());
}
}
- dumpLogRecs(smEnterExitTranstionToTest);
+ dumpLogRecs(smEnterExitTransitionToTest);
- assertEquals(9, smEnterExitTranstionToTest.getLogRecCount());
+ assertEquals(9, smEnterExitTransitionToTest.getLogRecCount());
LogRec lr;
- lr = smEnterExitTranstionToTest.getLogRec(0);
+ lr = smEnterExitTransitionToTest.getLogRec(0);
assertEquals(ENTER, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS1, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS1, lr.getState());
- lr = smEnterExitTranstionToTest.getLogRec(1);
+ lr = smEnterExitTransitionToTest.getLogRec(1);
assertEquals(EXIT, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS1, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS1, lr.getState());
- lr = smEnterExitTranstionToTest.getLogRec(2);
+ lr = smEnterExitTransitionToTest.getLogRec(2);
assertEquals(ENTER, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS2, lr.getState());
- lr = smEnterExitTranstionToTest.getLogRec(3);
+ lr = smEnterExitTransitionToTest.getLogRec(3);
assertEquals(TEST_CMD_1, lr.getWhat());
- assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS2, lr.getOriginalState());
- assertEquals(smEnterExitTranstionToTest.mS3, lr.getDestState());
+ assertEquals(smEnterExitTransitionToTest.mS2, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS2, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS3, lr.getDestState());
- lr = smEnterExitTranstionToTest.getLogRec(4);
+ lr = smEnterExitTransitionToTest.getLogRec(4);
assertEquals(TEST_CMD_1, lr.getWhat());
- assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS2, lr.getOriginalState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
+ assertEquals(smEnterExitTransitionToTest.mS2, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS2, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getDestState());
assertEquals(EXIT, lr.getInfo());
- lr = smEnterExitTranstionToTest.getLogRec(5);
+ lr = smEnterExitTransitionToTest.getLogRec(5);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(ENTER, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS3, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS3, lr.getOriginalState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
+ assertEquals(smEnterExitTransitionToTest.mS3, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS3, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getDestState());
- lr = smEnterExitTranstionToTest.getLogRec(6);
+ lr = smEnterExitTransitionToTest.getLogRec(6);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(EXIT, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS3, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS3, lr.getOriginalState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
+ assertEquals(smEnterExitTransitionToTest.mS3, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS3, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getDestState());
- lr = smEnterExitTranstionToTest.getLogRec(7);
+ lr = smEnterExitTransitionToTest.getLogRec(7);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(ENTER, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getOriginalState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getDestState());
- lr = smEnterExitTranstionToTest.getLogRec(8);
+ lr = smEnterExitTransitionToTest.getLogRec(8);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(EXIT, lr.getInfo());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getState());
- assertEquals(smEnterExitTranstionToTest.mS4, lr.getOriginalState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getState());
+ assertEquals(smEnterExitTransitionToTest.mS4, lr.getOriginalState());
- if (smEnterExitTranstionToTest.isDbg()) {
+ if (smEnterExitTransitionToTest.isDbg()) {
tlog("testStateMachineEnterExitTransitionToTest X");
}
}
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index d22e97c..8390ae4 100755
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -5273,6 +5273,40 @@
}
}
+ /**
+ * Indicate Le Audio output device connection state change and eventually suppress
+ * the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent.
+ * @param device Bluetooth device connected/disconnected
+ * @param state new connection state (BluetoothProfile.STATE_xxx)
+ * @param suppressNoisyIntent if true the
+ * {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent will not be sent.
+ * {@hide}
+ */
+ public void setBluetoothLeAudioOutDeviceConnectionState(BluetoothDevice device, int state,
+ boolean suppressNoisyIntent) {
+ final IAudioService service = getService();
+ try {
+ service.setBluetoothLeAudioOutDeviceConnectionState(device, state, suppressNoisyIntent);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Indicate Le Audio input connection state change.
+ * @param device Bluetooth device connected/disconnected
+ * @param state new connection state (BluetoothProfile.STATE_xxx)
+ * {@hide}
+ */
+ public void setBluetoothLeAudioInDeviceConnectionState(BluetoothDevice device, int state) {
+ final IAudioService service = getService();
+ try {
+ service.setBluetoothLeAudioInDeviceConnectionState(device, state);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
/**
* Indicate A2DP source or sink connection state change and eventually suppress
* the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent.
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index ed48b56..73bc428 100755
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -256,6 +256,11 @@
void setBluetoothHearingAidDeviceConnectionState(in BluetoothDevice device,
int state, boolean suppressNoisyIntent, int musicDevice);
+ void setBluetoothLeAudioOutDeviceConnectionState(in BluetoothDevice device, int state,
+ boolean suppressNoisyIntent);
+
+ void setBluetoothLeAudioInDeviceConnectionState(in BluetoothDevice device, int state);
+
void setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device,
int state, int profile, boolean suppressNoisyIntent, int a2dpVolume);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
index 34fdc1e..c4cb6a1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
@@ -101,6 +101,7 @@
private PbapServerProfile mPbapProfile;
private HearingAidProfile mHearingAidProfile;
private SapProfile mSapProfile;
+ private VolumeControlProfile mVolumeControlProfile;
/**
* Mapping from profile name, e.g. "HEADSET" to profile object.
@@ -220,6 +221,16 @@
mSapProfile = new SapProfile(mContext, mDeviceManager, this);
addProfile(mSapProfile, SapProfile.NAME, BluetoothSap.ACTION_CONNECTION_STATE_CHANGED);
}
+ if (mVolumeControlProfile == null
+ && supportedList.contains(BluetoothProfile.VOLUME_CONTROL)) {
+ if (DEBUG) {
+ Log.d(TAG, "Adding local Volume Control profile");
+ }
+ mVolumeControlProfile = new VolumeControlProfile();
+ // Note: no event handler for VCP, only for being connectable.
+ mProfileNameMap.put(VolumeControlProfile.NAME, mVolumeControlProfile);
+ }
+
mEventManager.registerProfileIntentReceiver();
}
@@ -565,6 +576,12 @@
removedProfiles.remove(mSapProfile);
}
+ if (mVolumeControlProfile != null
+ && ArrayUtils.contains(uuids, BluetoothUuid.VOLUME_CONTROL)) {
+ profiles.add(mVolumeControlProfile);
+ removedProfiles.remove(mVolumeControlProfile);
+ }
+
if (DEBUG) {
Log.d(TAG,"New Profiles" + profiles.toString());
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java
new file mode 100644
index 0000000..511df28
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settingslib.bluetooth;
+
+import android.bluetooth.BluetoothClass;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothProfile;
+
+/**
+ * VolumeControlProfile handles Bluetooth Volume Control Controller role
+ */
+public class VolumeControlProfile implements LocalBluetoothProfile {
+ private static final String TAG = "VolumeControlProfile";
+ static final String NAME = "VCP";
+ // Order of this profile in device profiles list
+ private static final int ORDINAL = 23;
+
+ @Override
+ public boolean accessProfileEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isAutoConnectable() {
+ return true;
+ }
+
+ @Override
+ public int getConnectionStatus(BluetoothDevice device) {
+ return BluetoothProfile.STATE_DISCONNECTED; // Settings app doesn't handle VCP
+ }
+
+ @Override
+ public boolean isEnabled(BluetoothDevice device) {
+ return false;
+ }
+
+ @Override
+ public int getConnectionPolicy(BluetoothDevice device) {
+ return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; // Settings app doesn't handle VCP
+ }
+
+ @Override
+ public boolean setEnabled(BluetoothDevice device, boolean enabled) {
+ return false;
+ }
+
+ @Override
+ public boolean isProfileReady() {
+ return true;
+ }
+
+ @Override
+ public int getProfileId() {
+ return BluetoothProfile.VOLUME_CONTROL;
+ }
+
+ public String toString() {
+ return NAME;
+ }
+
+ @Override
+ public int getOrdinal() {
+ return ORDINAL;
+ }
+
+ @Override
+ public int getNameResource(BluetoothDevice device) {
+ return 0; // VCP profile not displayed in UI
+ }
+
+ @Override
+ public int getSummaryResourceForDevice(BluetoothDevice device) {
+ return 0; // VCP profile not displayed in UI
+ }
+
+ @Override
+ public int getDrawableResource(BluetoothClass btClass) {
+ // no icon for VCP
+ return 0;
+ }
+}
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 10600e3..0e9a51d 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -513,7 +513,7 @@
<provider android:name=".HeapDumpProvider"
android:authorities="com.android.shell.heapdump"
android:grantUriPermissions="true"
- android:exported="true" />
+ android:exported="false" />
<activity
android:name=".BugreportWarningActivity"
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index b1ffaeb..6d85273 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -734,11 +734,8 @@
}
ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting);
- if (!r.mAllowWhileInUsePermissionInFgs) {
- r.mAllowWhileInUsePermissionInFgs =
- shouldAllowWhileInUsePermissionInFgsLocked(callingPackage, callingPid,
- callingUid, service, r, allowBackgroundActivityStarts);
- }
+ setFgsRestrictionLocked(callingPackage, callingPid, callingUid, r,
+ allowBackgroundActivityStarts);
return cmp;
}
@@ -1411,14 +1408,6 @@
+ String.format("0x%08X", manifestType)
+ " in service element of manifest file");
}
- // If the foreground service is not started from TOP process, do not allow it to
- // have while-in-use location/camera/microphone access.
- if (!r.mAllowWhileInUsePermissionInFgs) {
- Slog.w(TAG,
- "Foreground service started from background can not have "
- + "location/camera/microphone access: service "
- + r.shortInstanceName);
- }
}
boolean alreadyStartedOp = false;
boolean stopProcStatsOp = false;
@@ -1466,6 +1455,57 @@
ignoreForeground = true;
}
+ if (!ignoreForeground) {
+ if (r.mStartForegroundCount == 0) {
+ /*
+ If the service was started with startService(), not
+ startForegroundService(), and if startForeground() isn't called within
+ mFgsStartForegroundTimeoutMs, then we check the state of the app
+ (who owns the service, which is the app that called startForeground())
+ again. If the app is in the foreground, or in any other cases where
+ FGS-starts are allowed, then we still allow the FGS to be started.
+ Otherwise, startForeground() would fail.
+
+ If the service was started with startForegroundService(), then the service
+ must call startForeground() within a timeout anyway, so we don't need this
+ check.
+ */
+ if (!r.fgRequired) {
+ final long delayMs = SystemClock.elapsedRealtime() - r.createRealTime;
+ if (delayMs > mAm.mConstants.mFgsStartForegroundTimeoutMs) {
+ resetFgsRestrictionLocked(r);
+ setFgsRestrictionLocked(r.serviceInfo.packageName, r.app.pid,
+ r.appInfo.uid, r, false);
+ EventLog.writeEvent(0x534e4554, "183147114",
+ r.appInfo.uid,
+ "call setFgsRestrictionLocked again due to "
+ + "startForegroundTimeout");
+ }
+ }
+ } else if (r.mStartForegroundCount >= 1) {
+ // The second or later time startForeground() is called after service is
+ // started. Check for app state again.
+ final long delayMs = SystemClock.elapsedRealtime() -
+ r.mLastSetFgsRestrictionTime;
+ if (delayMs > mAm.mConstants.mFgsStartForegroundTimeoutMs) {
+ resetFgsRestrictionLocked(r);
+ setFgsRestrictionLocked(r.serviceInfo.packageName, r.app.pid,
+ r.appInfo.uid, r, false);
+ EventLog.writeEvent(0x534e4554, "183147114", r.appInfo.uid,
+ "call setFgsRestrictionLocked for "
+ + (r.mStartForegroundCount + 1) + "th startForeground");
+ }
+ }
+ // If the foreground service is not started from TOP process, do not allow it to
+ // have while-in-use location/camera/microphone access.
+ if (!r.mAllowWhileInUsePermissionInFgs) {
+ Slog.w(TAG,
+ "Foreground service started from background can not have "
+ + "location/camera/microphone access: service "
+ + r.shortInstanceName);
+ }
+ }
+
// Apps under strict background restrictions simply don't get to have foreground
// services, so now that we've enforced the startForegroundService() contract
// we only do the machinery of making the service foreground when the app
@@ -1501,6 +1541,7 @@
active.mNumActive++;
}
r.isForeground = true;
+ r.mStartForegroundCount++;
if (!stopProcStatsOp) {
ServiceState stracker = r.getTracker();
if (stracker != null) {
@@ -1559,6 +1600,7 @@
decActiveForegroundAppLocked(smap, r);
}
r.isForeground = false;
+ resetFgsRestrictionLocked(r);
ServiceState stracker = r.getTracker();
if (stracker != null) {
stracker.setForeground(false, mAm.mProcessStats.getMemFactorLocked(),
@@ -2118,12 +2160,7 @@
}
}
- if (!s.mAllowWhileInUsePermissionInFgs) {
- s.mAllowWhileInUsePermissionInFgs =
- shouldAllowWhileInUsePermissionInFgsLocked(callingPackage,
- callingPid, callingUid,
- service, s, false);
- }
+ setFgsRestrictionLocked(callingPackage, callingPid, callingUid, s, false);
if (s.app != null) {
if ((flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
@@ -3419,7 +3456,7 @@
r.isForeground = false;
r.foregroundId = 0;
r.foregroundNoti = null;
- r.mAllowWhileInUsePermissionInFgs = false;
+ resetFgsRestrictionLocked(r);
// Clear start entries.
r.clearDeliveredStartsLocked();
@@ -4900,7 +4937,7 @@
* @return true if allow, false otherwise.
*/
private boolean shouldAllowWhileInUsePermissionInFgsLocked(String callingPackage,
- int callingPid, int callingUid, Intent intent, ServiceRecord r,
+ int callingPid, int callingUid, ServiceRecord r,
boolean allowBackgroundActivityStarts) {
// Is the background FGS start restriction turned on?
if (!mAm.mConstants.mFlagBackgroundFgsStartRestrictionEnabled) {
@@ -4986,6 +5023,28 @@
boolean canAllowWhileInUsePermissionInFgsLocked(int callingPid, int callingUid,
String callingPackage) {
return shouldAllowWhileInUsePermissionInFgsLocked(
- callingPackage, callingPid, callingUid, null, null, false);
+ callingPackage, callingPid, callingUid, null, false);
+ }
+
+ /**
+ * In R, mAllowWhileInUsePermissionInFgs is to allow while-in-use permissions in foreground
+ * service or not. while-in-use permissions in FGS started from background might be restricted.
+ * @param callingPackage caller app's package name.
+ * @param callingUid caller app's uid.
+ * @param r the service to start.
+ * @return true if allow, false otherwise.
+ */
+ private void setFgsRestrictionLocked(String callingPackage,
+ int callingPid, int callingUid, ServiceRecord r,
+ boolean allowBackgroundActivityStarts) {
+ r.mLastSetFgsRestrictionTime = SystemClock.elapsedRealtime();
+ if (!r.mAllowWhileInUsePermissionInFgs) {
+ r.mAllowWhileInUsePermissionInFgs = shouldAllowWhileInUsePermissionInFgsLocked(
+ callingPackage, callingPid, callingUid, r, allowBackgroundActivityStarts);
+ }
+ }
+
+ private void resetFgsRestrictionLocked(ServiceRecord r) {
+ r.mAllowWhileInUsePermissionInFgs = false;
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java
index 7be843f..00d8208e 100644
--- a/services/core/java/com/android/server/am/ActivityManagerConstants.java
+++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java
@@ -88,6 +88,7 @@
static final String KEY_PROCESS_START_ASYNC = "process_start_async";
static final String KEY_MEMORY_INFO_THROTTLE_TIME = "memory_info_throttle_time";
static final String KEY_TOP_TO_FGS_GRACE_DURATION = "top_to_fgs_grace_duration";
+ static final String KEY_FGS_START_FOREGROUND_TIMEOUT = "fgs_start_foreground_timeout";
static final String KEY_PENDINGINTENT_WARNING_THRESHOLD = "pendingintent_warning_threshold";
private static final int DEFAULT_MAX_CACHED_PROCESSES = 32;
@@ -121,6 +122,7 @@
private static final boolean DEFAULT_PROCESS_START_ASYNC = true;
private static final long DEFAULT_MEMORY_INFO_THROTTLE_TIME = 5*60*1000;
private static final long DEFAULT_TOP_TO_FGS_GRACE_DURATION = 15 * 1000;
+ private static final int DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS = 10 * 1000;
private static final int DEFAULT_PENDINGINTENT_WARNING_THRESHOLD = 2000;
// Flag stored in the DeviceConfig API.
@@ -273,6 +275,12 @@
// this long.
public long TOP_TO_FGS_GRACE_DURATION = DEFAULT_TOP_TO_FGS_GRACE_DURATION;
+ /**
+ * When service started from background, before the timeout it can be promoted to FGS by calling
+ * Service.startForeground().
+ */
+ volatile long mFgsStartForegroundTimeoutMs = DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS;
+
// Indicates whether the activity starts logging is enabled.
// Controlled by Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED
volatile boolean mFlagActivityStartsLoggingEnabled;
@@ -421,6 +429,9 @@
case KEY_MIN_ASSOC_LOG_DURATION:
updateMinAssocLogDuration();
break;
+ case KEY_FGS_START_FOREGROUND_TIMEOUT:
+ updateFgsStartForegroundTimeout();
+ break;
default:
break;
}
@@ -697,6 +708,13 @@
/* defaultValue */ DEFAULT_MIN_ASSOC_LOG_DURATION);
}
+ private void updateFgsStartForegroundTimeout() {
+ mFgsStartForegroundTimeoutMs = DeviceConfig.getLong(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ KEY_FGS_START_FOREGROUND_TIMEOUT,
+ DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS);
+ }
+
void dump(PrintWriter pw) {
pw.println("ACTIVITY MANAGER SETTINGS (dumpsys activity settings) "
+ Settings.Global.ACTIVITY_MANAGER_CONSTANTS + ":");
@@ -769,6 +787,8 @@
pw.println(Arrays.toString(IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.toArray()));
pw.print(" "); pw.print(KEY_MIN_ASSOC_LOG_DURATION); pw.print("=");
pw.println(MIN_ASSOC_LOG_DURATION);
+ pw.print(" "); pw.print(KEY_FGS_START_FOREGROUND_TIMEOUT); pw.print("=");
+ pw.println(mFgsStartForegroundTimeoutMs);
pw.println();
if (mOverrideMaxCachedProcesses >= 0) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index af89907..50f3520 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -94,7 +94,6 @@
import com.android.server.compat.PlatformCompat;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -787,8 +786,7 @@
return -1;
}
- File file = new File(filename);
- file.delete();
+ // Writes an error message to stderr on failure
ParcelFileDescriptor fd = openFileForSystem(filename, "w");
if (fd == null) {
return -1;
@@ -942,16 +940,16 @@
String logNameTimeString = LOG_NAME_TIME_FORMATTER.format(localDateTime);
heapFile = "/data/local/tmp/heapdump-" + logNameTimeString + ".prof";
}
- pw.println("File: " + heapFile);
- pw.flush();
- File file = new File(heapFile);
- file.delete();
+ // Writes an error message to stderr on failure
ParcelFileDescriptor fd = openFileForSystem(heapFile, "w");
if (fd == null) {
return -1;
}
+ pw.println("File: " + heapFile);
+ pw.flush();
+
final CountDownLatch latch = new CountDownLatch(1);
final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() {
diff --git a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
index 39f79ca..ef47b1e 100644
--- a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
+++ b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
@@ -22,6 +22,7 @@
import android.net.wifi.WifiManager;
import android.os.BatteryStats;
import android.os.Bundle;
+import android.os.OutcomeReceiver;
import android.os.Parcelable;
import android.os.Process;
import android.os.ServiceManager;
@@ -40,6 +41,7 @@
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.function.pooled.PooledLambda;
+import java.util.concurrent.ExecutionException;
import libcore.util.EmptyArray;
import java.util.concurrent.CompletableFuture;
@@ -405,7 +407,7 @@
// We will request data from external processes asynchronously, and wait on a timeout.
SynchronousResultReceiver wifiReceiver = null;
SynchronousResultReceiver bluetoothReceiver = null;
- SynchronousResultReceiver modemReceiver = null;
+ CompletableFuture<ModemActivityInfo> modemFuture = CompletableFuture.completedFuture(null);
boolean railUpdated = false;
if ((updateFlags & BatteryStatsImpl.ExternalStatsSync.UPDATE_WIFI) != 0) {
@@ -460,8 +462,22 @@
}
if (mTelephony != null) {
- modemReceiver = new SynchronousResultReceiver("telephony");
- mTelephony.requestModemActivityInfo(modemReceiver);
+ CompletableFuture<ModemActivityInfo> temp = new CompletableFuture<>();
+ mTelephony.requestModemActivityInfo(Runnable::run,
+ new OutcomeReceiver<ModemActivityInfo,
+ TelephonyManager.ModemActivityInfoException>() {
+ @Override
+ public void onResult(ModemActivityInfo result) {
+ temp.complete(result);
+ }
+
+ @Override
+ public void onError(TelephonyManager.ModemActivityInfoException e) {
+ Slog.w(TAG, "error reading modem stats:" + e);
+ temp.complete(null);
+ }
+ });
+ modemFuture = temp;
}
if (!railUpdated) {
synchronized (mStats) {
@@ -472,7 +488,17 @@
final WifiActivityEnergyInfo wifiInfo = awaitControllerInfo(wifiReceiver);
final BluetoothActivityEnergyInfo bluetoothInfo = awaitControllerInfo(bluetoothReceiver);
- final ModemActivityInfo modemInfo = awaitControllerInfo(modemReceiver);
+ ModemActivityInfo modemInfo = null;
+ try {
+ modemInfo = modemFuture.get(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS,
+ TimeUnit.MILLISECONDS);
+ } catch (TimeoutException | InterruptedException e) {
+ Slog.w(TAG, "timeout or interrupt reading modem stats: " + e);
+ } catch (ExecutionException e) {
+ Slog.w(TAG, "exception reading modem stats: " + e.getCause());
+ }
+ final long elapsedRealtime = SystemClock.elapsedRealtime();
+ final long uptime = SystemClock.uptimeMillis();
synchronized (mStats) {
mStats.addHistoryEventLocked(
@@ -519,11 +545,7 @@
}
if (modemInfo != null) {
- if (modemInfo.isValid()) {
- mStats.updateMobileRadioState(modemInfo);
- } else {
- Slog.w(TAG, "modem info is invalid: " + modemInfo);
- }
+ mStats.updateMobileRadioState(modemInfo);
}
}
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index 580ceca..34ba3e0 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -1208,7 +1208,7 @@
public void noteModemControllerActivity(ModemActivityInfo info) {
enforceCallingPermission();
- if (info == null || !info.isValid()) {
+ if (info == null) {
Slog.e(TAG, "invalid modem data given: " + info);
return;
}
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 1b65dba..0e62828 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -142,6 +142,10 @@
// allow while-in-use permissions in foreground service or not.
// while-in-use permissions in FGS started from background might be restricted.
boolean mAllowWhileInUsePermissionInFgs;
+ // The number of times Service.startForeground() is called;
+ int mStartForegroundCount;
+ // Last time mAllowWhileInUsePermissionInFgs is set.
+ long mLastSetFgsRestrictionTime;
// the most recent package that start/bind this service.
String mRecentCallingPackage;
@@ -406,6 +410,8 @@
}
pw.print(prefix); pw.print("allowWhileInUsePermissionInFgs=");
pw.println(mAllowWhileInUsePermissionInFgs);
+ pw.print(prefix); pw.print("startForegroundCount=");
+ pw.println(mStartForegroundCount);
pw.print(prefix); pw.print("recentCallingPackage=");
pw.println(mRecentCallingPackage);
if (delayed) {
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index cd3d27d..b5e6c11 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -563,6 +563,37 @@
sendLMsgNoDelay(MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info);
}
+ private static final class LeAudioDeviceConnectionInfo {
+ final @NonNull BluetoothDevice mDevice;
+ final @AudioService.BtProfileConnectionState int mState;
+ final boolean mSupprNoisy;
+ final @NonNull String mEventSource;
+
+ LeAudioDeviceConnectionInfo(@NonNull BluetoothDevice device,
+ @AudioService.BtProfileConnectionState int state,
+ boolean suppressNoisyIntent, @NonNull String eventSource) {
+ mDevice = device;
+ mState = state;
+ mSupprNoisy = suppressNoisyIntent;
+ mEventSource = eventSource;
+ }
+ }
+
+ /*package*/ void postBluetoothLeAudioOutDeviceConnectionState(
+ @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state,
+ boolean suppressNoisyIntent, @NonNull String eventSource) {
+ final LeAudioDeviceConnectionInfo info = new LeAudioDeviceConnectionInfo(
+ device, state, suppressNoisyIntent, eventSource);
+ sendLMsgNoDelay(MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info);
+ }
+
+ /*package*/ void postBluetoothLeAudioInDeviceConnectionState(
+ @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state,
+ @NonNull String eventSource) {
+ final LeAudioDeviceConnectionInfo info = new LeAudioDeviceConnectionInfo(
+ device, state, false, eventSource);
+ sendLMsgNoDelay(MSG_L_LE_AUDIO_DEVICE_IN_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info);
+ }
/**
* Current Bluetooth SCO audio active state indicated by BtHelper via setBluetoothScoOn().
@@ -849,6 +880,23 @@
delay);
}
+ /*package*/ void postSetLeAudioOutConnectionState(
+ @AudioService.BtProfileConnectionState int state,
+ @NonNull BluetoothDevice device, int delay) {
+ sendILMsg(MSG_IL_SET_LE_AUDIO_OUT_CONNECTION_STATE, SENDMSG_QUEUE,
+ state,
+ device,
+ delay);
+ }
+
+ /*package*/ void postSetLeAudioInConnectionState(
+ @AudioService.BtProfileConnectionState int state,
+ @NonNull BluetoothDevice device) {
+ sendILMsgNoDelay(MSG_IL_SET_LE_AUDIO_IN_CONNECTION_STATE, SENDMSG_QUEUE,
+ state,
+ device);
+ }
+
/*package*/ void postDisconnectA2dp() {
sendMsgNoDelay(MSG_DISCONNECT_A2DP, SENDMSG_QUEUE);
}
@@ -1154,7 +1202,20 @@
synchronized (mDeviceStateLock) {
mDeviceInventory.onSetHearingAidConnectionState(
(BluetoothDevice) msg.obj, msg.arg1,
- mAudioService.getHearingAidStreamType());
+ mAudioService.getBluetoothContextualVolumeStream());
+ }
+ break;
+ case MSG_IL_SET_LE_AUDIO_OUT_CONNECTION_STATE:
+ synchronized (mDeviceStateLock) {
+ mDeviceInventory.onSetLeAudioOutConnectionState(
+ (BluetoothDevice) msg.obj, msg.arg1,
+ mAudioService.getBluetoothContextualVolumeStream());
+ }
+ break;
+ case MSG_IL_SET_LE_AUDIO_IN_CONNECTION_STATE:
+ synchronized (mDeviceStateLock) {
+ mDeviceInventory.onSetLeAudioInConnectionState(
+ (BluetoothDevice) msg.obj, msg.arg1);
}
break;
case MSG_BT_HEADSET_CNCT_FAILED:
@@ -1343,6 +1404,31 @@
final int capturePreset = msg.arg1;
mDeviceInventory.onSaveClearPreferredDevicesForCapturePreset(capturePreset);
} break;
+ case MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT: {
+ final LeAudioDeviceConnectionInfo info =
+ (LeAudioDeviceConnectionInfo) msg.obj;
+ AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
+ "setLeAudioDeviceOutConnectionState state=" + info.mState
+ + " addr=" + info.mDevice.getAddress()
+ + " supprNoisy=" + info.mSupprNoisy
+ + " src=" + info.mEventSource)).printLog(TAG));
+ synchronized (mDeviceStateLock) {
+ mDeviceInventory.setBluetoothLeAudioOutDeviceConnectionState(
+ info.mDevice, info.mState, info.mSupprNoisy);
+ }
+ } break;
+ case MSG_L_LE_AUDIO_DEVICE_IN_CONNECTION_CHANGE_EXT: {
+ final LeAudioDeviceConnectionInfo info =
+ (LeAudioDeviceConnectionInfo) msg.obj;
+ AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
+ "setLeAudioDeviceInConnectionState state=" + info.mState
+ + " addr=" + info.mDevice.getAddress()
+ + " src=" + info.mEventSource)).printLog(TAG));
+ synchronized (mDeviceStateLock) {
+ mDeviceInventory.setBluetoothLeAudioInDeviceConnectionState(info.mDevice,
+ info.mState);
+ }
+ } break;
default:
Log.wtf(TAG, "Invalid message " + msg.what);
}
@@ -1424,6 +1510,11 @@
private static final int MSG_IL_SET_PREF_DEVICES_FOR_STRATEGY = 40;
private static final int MSG_I_REMOVE_PREF_DEVICES_FOR_STRATEGY = 41;
+ private static final int MSG_IL_SET_LE_AUDIO_OUT_CONNECTION_STATE = 42;
+ private static final int MSG_IL_SET_LE_AUDIO_IN_CONNECTION_STATE = 43;
+ private static final int MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT = 44;
+ private static final int MSG_L_LE_AUDIO_DEVICE_IN_CONNECTION_CHANGE_EXT = 45;
+
private static boolean isMessageHandledUnderWakelock(int msgId) {
switch(msgId) {
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
@@ -1439,6 +1530,8 @@
case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT_DISCONNECTION:
case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT:
case MSG_CHECK_MUTE_MUSIC:
+ case MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT:
+ case MSG_L_LE_AUDIO_DEVICE_IN_CONNECTION_CHANGE_EXT:
return true;
default:
return false;
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 82586b8..78daabc 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -21,6 +21,7 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHearingAid;
+import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
import android.content.Intent;
import android.media.AudioDeviceAttributes;
@@ -423,6 +424,45 @@
}
}
+ /*package*/ void onSetLeAudioConnectionState(BluetoothDevice btDevice,
+ @AudioService.BtProfileConnectionState int state, int streamType, int device) {
+ String address = btDevice.getAddress();
+ if (!BluetoothAdapter.checkBluetoothAddress(address)) {
+ address = "";
+ }
+ AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent(
+ "onSetLeAudioConnectionState addr=" + address));
+
+ synchronized (mDevicesLock) {
+ DeviceInfo di = null;
+ boolean isConnected = false;
+
+ String key = DeviceInfo.makeDeviceListKey(device, btDevice.getAddress());
+ di = mConnectedDevices.get(key);
+ isConnected = di != null;
+
+ if (isConnected && state != BluetoothProfile.STATE_CONNECTED) {
+ makeLeAudioDeviceUnavailable(address, device);
+ } else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
+ makeLeAudioDeviceAvailable(address, BtHelper.getName(btDevice), streamType,
+ device, "onSetLeAudioConnectionState");
+ }
+ }
+ }
+
+ /*package*/ void onSetLeAudioOutConnectionState(BluetoothDevice btDevice,
+ @AudioService.BtProfileConnectionState int state, int streamType) {
+ // TODO: b/198610537 clarify DEVICE_OUT_BLE_HEADSET vs DEVICE_OUT_BLE_SPEAKER criteria
+ onSetLeAudioConnectionState(btDevice, state, streamType,
+ AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ }
+
+ /*package*/ void onSetLeAudioInConnectionState(BluetoothDevice btDevice,
+ @AudioService.BtProfileConnectionState int state) {
+ onSetLeAudioConnectionState(btDevice, state, AudioSystem.STREAM_DEFAULT,
+ AudioSystem.DEVICE_IN_BLE_HEADSET);
+ }
+
@GuardedBy("AudioDeviceBroker.mDeviceStateLock")
/*package*/ void onBluetoothA2dpActiveDeviceChange(
@NonNull BtHelper.BluetoothA2dpDeviceInfo btInfo, int event) {
@@ -943,6 +983,28 @@
}
}
+ /*package*/ int setBluetoothLeAudioOutDeviceConnectionState(
+ @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state,
+ boolean suppressNoisyIntent) {
+ synchronized (mDevicesLock) {
+ /* Active device become null and it's previous device is not connected anymore */
+ int delay = 0;
+ if (!suppressNoisyIntent) {
+ int intState = (state == BluetoothLeAudio.STATE_CONNECTED) ? 1 : 0;
+ delay = checkSendBecomingNoisyIntentInt(AudioSystem.DEVICE_OUT_BLE_HEADSET,
+ intState, AudioSystem.DEVICE_NONE);
+ }
+ mDeviceBroker.postSetLeAudioOutConnectionState(state, device, delay);
+ return delay;
+ }
+ }
+
+ /*package*/ void setBluetoothLeAudioInDeviceConnectionState(
+ @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state) {
+ synchronized (mDevicesLock) {
+ mDeviceBroker.postSetLeAudioInConnectionState(state, device);
+ }
+ }
//-------------------------------------------------------------------
// Internal utilities
@@ -1115,6 +1177,36 @@
}
@GuardedBy("mDevicesLock")
+ private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int device,
+ String eventSource) {
+ if (device != AudioSystem.DEVICE_NONE) {
+ AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_AVAILABLE,
+ address, name, AudioSystem.AUDIO_FORMAT_DEFAULT);
+ mConnectedDevices.put(DeviceInfo.makeDeviceListKey(device, address),
+ new DeviceInfo(device, name, address, AudioSystem.AUDIO_FORMAT_DEFAULT));
+ mDeviceBroker.postAccessoryPlugMediaUnmute(device);
+ }
+
+ if (streamType == AudioSystem.STREAM_DEFAULT) {
+ // No need to update volume for input devices
+ return;
+ }
+
+ mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable");
+ }
+
+ @GuardedBy("mDevicesLock")
+ private void makeLeAudioDeviceUnavailable(String address, int device) {
+ if (device != AudioSystem.DEVICE_NONE) {
+ AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_UNAVAILABLE,
+ address, "", AudioSystem.AUDIO_FORMAT_DEFAULT);
+ mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(device, address));
+ }
+
+ setCurrentAudioRouteNameIfPossible(null, false /*fromA2dp*/);
+ }
+
+ @GuardedBy("mDevicesLock")
private void setCurrentAudioRouteNameIfPossible(String name, boolean fromA2dp) {
synchronized (mCurAudioRoutes) {
if (TextUtils.equals(mCurAudioRoutes.bluetoothName, name)) {
@@ -1150,6 +1242,7 @@
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID);
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_BLE_SET);
}
// must be called before removing the device from mConnectedDevices
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index d0a3079..97a20c4 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -163,6 +163,7 @@
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -307,6 +308,12 @@
// retry delay in case of failure to indicate system ready to AudioFlinger
private static final int INDICATE_SYSTEM_READY_RETRY_DELAY_MS = 1000;
+ // Bits representing connected devices to monitor playback monitor voice activity
+ private static final int CONNECTED_STATE_HEARING_AID_BIT = 0;
+ private static final int CONNECTED_STATE_LE_AUDIO_BIT = 1;
+
+ private BitSet mConnectedStateBitset = new BitSet(2);
+
/** @see AudioSystemThread */
private AudioSystemThread mAudioSystemThread;
/** @see AudioHandler */
@@ -2529,7 +2536,7 @@
if (device == AudioSystem.DEVICE_OUT_HEARING_AID) {
// only modify the hearing aid attenuation when the stream to modify matches
// the one expected by the hearing aid
- if (streamType == getHearingAidStreamType()) {
+ if (streamType == getBluetoothContextualVolumeStream()) {
if (DEBUG_VOL) {
Log.d(TAG, "adjustSreamVolume postSetHearingAidVolumeIndex index="
+ newIndex + " stream=" + streamType);
@@ -2872,11 +2879,11 @@
}
}
- /*package*/ int getHearingAidStreamType() {
- return getHearingAidStreamType(mMode);
+ /*package*/ int getBluetoothContextualVolumeStream() {
+ return getBluetoothContextualVolumeStream(mMode);
}
- private int getHearingAidStreamType(int mode) {
+ private int getBluetoothContextualVolumeStream(int mode) {
switch (mode) {
case AudioSystem.MODE_IN_COMMUNICATION:
case AudioSystem.MODE_IN_CALL:
@@ -2922,7 +2929,7 @@
}
private void updateHearingAidVolumeOnVoiceActivityUpdate() {
- final int streamType = getHearingAidStreamType();
+ final int streamType = getBluetoothContextualVolumeStream();
final int index = getStreamVolume(streamType);
sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_VOICE_ACTIVITY_HEARING_AID,
mVoiceActive.get(), streamType, index));
@@ -2954,7 +2961,7 @@
return;
}
- int streamType = getHearingAidStreamType(newMode);
+ int streamType = getBluetoothContextualVolumeStream(newMode);
final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet(
AudioSystem.getDevicesForStream(streamType));
@@ -3036,7 +3043,7 @@
}
if (device == AudioSystem.DEVICE_OUT_HEARING_AID
- && streamType == getHearingAidStreamType()) {
+ && streamType == getBluetoothContextualVolumeStream()) {
Log.i(TAG, "setStreamVolume postSetHearingAidVolumeIndex index=" + index
+ " stream=" + streamType);
mDeviceBroker.postSetHearingAidVolumeIndex(index, streamType);
@@ -5496,15 +5503,68 @@
throw new IllegalArgumentException("Illegal BluetoothProfile state for device "
+ " (dis)connection, got " + state);
}
- if (state == BluetoothProfile.STATE_CONNECTED) {
- mPlaybackMonitor.registerPlaybackCallback(mVoiceActivityMonitor, true);
- } else {
- mPlaybackMonitor.unregisterPlaybackCallback(mVoiceActivityMonitor);
+ synchronized (mConnectedStateBitset) {
+ if (state == BluetoothProfile.STATE_CONNECTED) {
+ if (mConnectedStateBitset.isEmpty()) {
+ mPlaybackMonitor.registerPlaybackCallback(mVoiceActivityMonitor, true);
+ }
+ mConnectedStateBitset.set(CONNECTED_STATE_HEARING_AID_BIT);
+ } else {
+ mConnectedStateBitset.clear(CONNECTED_STATE_HEARING_AID_BIT);
+ if (mConnectedStateBitset.isEmpty()) {
+ mPlaybackMonitor.unregisterPlaybackCallback(mVoiceActivityMonitor);
+ }
+ }
}
mDeviceBroker.postBluetoothHearingAidDeviceConnectionState(
device, state, suppressNoisyIntent, musicDevice, "AudioService");
}
+ private void setBluetoothLeAudioDeviceConnectionState(@NonNull BluetoothDevice device,
+ @BtProfileConnectionState int state) {
+ if (device == null) {
+ throw new IllegalArgumentException("Illegal null device");
+ }
+ if (state != BluetoothProfile.STATE_CONNECTED
+ && state != BluetoothProfile.STATE_DISCONNECTED) {
+ throw new IllegalArgumentException("Illegal BluetoothProfile state for device "
+ + " (dis)connection, got " + state);
+ }
+ synchronized (mConnectedStateBitset) {
+ if (state == BluetoothProfile.STATE_CONNECTED) {
+ if (mConnectedStateBitset.isEmpty()) {
+ mPlaybackMonitor.registerPlaybackCallback(mVoiceActivityMonitor, true);
+ }
+ mConnectedStateBitset.set(CONNECTED_STATE_LE_AUDIO_BIT);
+ } else {
+ mConnectedStateBitset.clear(CONNECTED_STATE_LE_AUDIO_BIT);
+ if (mConnectedStateBitset.isEmpty()) {
+ mPlaybackMonitor.unregisterPlaybackCallback(mVoiceActivityMonitor);
+ }
+ }
+ }
+ }
+
+ /**
+ * See AudioManager.setBluetoothLeAudioOutDeviceConnectionState()
+ */
+ public void setBluetoothLeAudioOutDeviceConnectionState(
+ @NonNull BluetoothDevice device, @BtProfileConnectionState int state,
+ boolean suppressNoisyIntent) {
+ setBluetoothLeAudioDeviceConnectionState(device, state);
+ mDeviceBroker.postBluetoothLeAudioOutDeviceConnectionState(device, state,
+ suppressNoisyIntent, "AudioService");
+ }
+
+ /**
+ * See AudioManager.setBluetoothLeAudioInDeviceConnectionState()
+ */
+ public void setBluetoothLeAudioInDeviceConnectionState(
+ @NonNull BluetoothDevice device, @BtProfileConnectionState int state) {
+ setBluetoothLeAudioDeviceConnectionState(device, state);
+ mDeviceBroker.postBluetoothLeAudioInDeviceConnectionState(device, state, "AudioService");
+ }
+
/**
* See AudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent()
*/
diff --git a/services/core/java/com/android/server/connectivity/PacProxyService.java b/services/core/java/com/android/server/connectivity/PacProxyService.java
index b2df535..3a97765 100644
--- a/services/core/java/com/android/server/connectivity/PacProxyService.java
+++ b/services/core/java/com/android/server/connectivity/PacProxyService.java
@@ -34,7 +34,6 @@
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
-import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.RemoteCallbackList;
@@ -42,6 +41,7 @@
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
@@ -357,8 +357,9 @@
}
}
};
- mContext.bindService(intent, mConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE);
+ mContext.bindServiceAsUser(intent, mConnection,
+ Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE,
+ UserHandle.SYSTEM);
intent = new Intent();
intent.setClassName(PROXY_PACKAGE, PROXY_SERVICE);
@@ -398,9 +399,9 @@
}
}
};
- mContext.bindService(intent,
+ mContext.bindServiceAsUser(intent, mProxyConnection,
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE,
- new HandlerExecutor(mNetThreadHandler), mProxyConnection);
+ mNetThreadHandler, UserHandle.SYSTEM);
}
private void unbind() {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 5babfeb..f83d059 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -123,6 +123,7 @@
import android.app.ITransientNotification;
import android.app.ITransientNotificationCallback;
import android.app.IUriGrantsManager;
+import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -479,6 +480,8 @@
final ArrayMap<NotificationRecord, ArrayList<CancelNotificationRunnable>> mDelayedCancelations =
new ArrayMap<>();
+ private KeyguardManager mKeyguardManager;
+
// The last key in this list owns the hardware.
ArrayList<String> mLights = new ArrayList<>();
@@ -1726,6 +1729,11 @@
}
@VisibleForTesting
+ void setKeyguardManager(KeyguardManager keyguardManager) {
+ mKeyguardManager = keyguardManager;
+ }
+
+ @VisibleForTesting
ShortcutHelper getShortcutHelper() {
return mShortcutHelper;
}
@@ -2330,6 +2338,7 @@
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManagerInternal = getLocalService(AudioManagerInternal.class);
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
+ mKeyguardManager = getContext().getSystemService(KeyguardManager.class);
mZenModeHelper.onSystemReady();
mRoleObserver = new RoleObserver(getContext().getSystemService(RoleManager.class),
mPackageManager, getContext().getMainExecutor());
@@ -6902,7 +6911,6 @@
boolean beep = false;
boolean blink = false;
- final Notification notification = record.getSbn().getNotification();
final String key = record.getKey();
// Should this notification make noise, vibe, or use the LED?
@@ -6924,7 +6932,7 @@
if (!record.isUpdate
&& record.getImportance() > IMPORTANCE_MIN
&& !suppressedByDnd) {
- sendAccessibilityEvent(notification, record.getSbn().getPackageName());
+ sendAccessibilityEvent(record);
sentAccessibilityEvent = true;
}
@@ -6946,7 +6954,7 @@
boolean hasAudibleAlert = hasValidSound || hasValidVibrate;
if (hasAudibleAlert && !shouldMuteNotificationLocked(record)) {
if (!sentAccessibilityEvent) {
- sendAccessibilityEvent(notification, record.getSbn().getPackageName());
+ sendAccessibilityEvent(record);
sentAccessibilityEvent = true;
}
if (DBG) Slog.v(TAG, "Interrupting!");
@@ -7663,17 +7671,30 @@
return (x < low) ? low : ((x > high) ? high : x);
}
- void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
+ void sendAccessibilityEvent(NotificationRecord record) {
if (!mAccessibilityManager.isEnabled()) {
return;
}
- AccessibilityEvent event =
+ final Notification notification = record.getNotification();
+ final CharSequence packageName = record.getSbn().getPackageName();
+ final AccessibilityEvent event =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
event.setPackageName(packageName);
event.setClassName(Notification.class.getName());
- event.setParcelableData(notification);
- CharSequence tickerText = notification.tickerText;
+ final int visibilityOverride = record.getPackageVisibilityOverride();
+ final int notifVisibility = visibilityOverride == NotificationManager.VISIBILITY_NO_OVERRIDE
+ ? notification.visibility : visibilityOverride;
+ final int userId = record.getUser().getIdentifier();
+ final boolean needPublic = userId >= 0 && mKeyguardManager.isDeviceLocked(userId);
+ if (needPublic && notifVisibility != Notification.VISIBILITY_PUBLIC) {
+ // Emit the public version if we're on the lockscreen and this notification isn't
+ // publicly visible.
+ event.setParcelableData(notification.publicVersion);
+ } else {
+ event.setParcelableData(notification);
+ }
+ final CharSequence tickerText = notification.tickerText;
if (!TextUtils.isEmpty(tickerText)) {
event.getText().add(tickerText);
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 1173df6..4767823 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -14289,9 +14289,15 @@
return new ParceledListSlice<IntentFilter>(result) {
@Override
protected void writeElement(IntentFilter parcelable, Parcel dest, int callFlags) {
- // IntentFilter has final Parcelable methods, so redirect to the subclass
- ((ParsedIntentInfo) parcelable).writeIntentInfoToParcel(dest,
- callFlags);
+ parcelable.writeToParcel(dest, callFlags);
+ }
+
+ @Override
+ protected void writeParcelableCreator(IntentFilter parcelable, Parcel dest) {
+ // All Parcel#writeParcelableCreator does is serialize the class name to
+ // access via reflection to grab its CREATOR. This does that manually, pointing
+ // to the parent IntentFilter so that all of the subclass fields are ignored.
+ dest.writeString(IntentFilter.class.getName());
}
};
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 836e615..ae940d0 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -608,6 +608,8 @@
private int mPowerButtonSuppressionDelayMillis = POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS;
+ private boolean mLockNowPending = false;
+
private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4;
private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5;
@@ -4941,6 +4943,7 @@
mKeyguardDelegate.doKeyguardTimeout(options);
}
mLockScreenTimerActive = false;
+ mLockNowPending = false;
options = null;
}
}
@@ -4950,7 +4953,7 @@
}
}
- ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
+ final ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
@Override
public void lockNow(Bundle options) {
@@ -4962,6 +4965,9 @@
mScreenLockTimeout.setLockOptions(options);
}
mHandler.post(mScreenLockTimeout);
+ synchronized (mScreenLockTimeout) {
+ mLockNowPending = true;
+ }
}
// TODO (b/113840485): Move this logic to DisplayPolicy when lockscreen supports multi-display.
@@ -4977,6 +4983,10 @@
private void updateLockScreenTimeout() {
synchronized (mScreenLockTimeout) {
+ if (mLockNowPending) {
+ Log.w(TAG, "lockNow pending, ignore updating lockscreen timeout");
+ return;
+ }
final boolean enable = !mAllowLockscreenWhenOnDisplays.isEmpty()
&& mDefaultDisplayPolicy.isAwake()
&& mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId);
diff --git a/services/core/java/com/android/server/role/RoleManagerService.java b/services/core/java/com/android/server/role/RoleManagerService.java
index 392792d..b75bce8 100644
--- a/services/core/java/com/android/server/role/RoleManagerService.java
+++ b/services/core/java/com/android/server/role/RoleManagerService.java
@@ -662,6 +662,12 @@
@Override
public String getDefaultSmsPackage(int userId) {
+ userId = handleIncomingUser(userId, false, "getDefaultSmsPackage");
+ if (!mUserManagerInternal.exists(userId)) {
+ Slog.e(LOG_TAG, "user " + userId + " does not exist");
+ return null;
+ }
+
long identity = Binder.clearCallingIdentity();
try {
return CollectionUtils.firstOrNull(
diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
index 0390015..71b3e61 100644
--- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
+++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
@@ -102,6 +102,7 @@
import android.os.IStoraged;
import android.os.IThermalEventListener;
import android.os.IThermalService;
+import android.os.OutcomeReceiver;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.os.RemoteException;
@@ -172,6 +173,7 @@
import com.android.server.storage.DiskStatsFileLogger;
import com.android.server.storage.DiskStatsLoggingService;
+import java.util.concurrent.ExecutionException;
import libcore.io.IoUtils;
import org.json.JSONArray;
@@ -1731,22 +1733,47 @@
int pullModemActivityInfoLocked(int atomTag, List<StatsEvent> pulledData) {
long token = Binder.clearCallingIdentity();
try {
- SynchronousResultReceiver modemReceiver = new SynchronousResultReceiver("telephony");
- mTelephony.requestModemActivityInfo(modemReceiver);
- final ModemActivityInfo modemInfo = awaitControllerInfo(modemReceiver);
+ CompletableFuture<ModemActivityInfo> modemFuture = new CompletableFuture<>();
+ mTelephony.requestModemActivityInfo(Runnable::run,
+ new OutcomeReceiver<ModemActivityInfo,
+ TelephonyManager.ModemActivityInfoException>() {
+ @Override
+ public void onResult(ModemActivityInfo result) {
+ modemFuture.complete(result);
+ }
+
+ @Override
+ public void onError(TelephonyManager.ModemActivityInfoException e) {
+ Slog.w(TAG, "error reading modem stats:" + e);
+ modemFuture.complete(null);
+ }
+ });
+
+ ModemActivityInfo modemInfo;
+ try {
+ modemInfo = modemFuture.get(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS,
+ TimeUnit.MILLISECONDS);
+ } catch (TimeoutException | InterruptedException e) {
+ Slog.w(TAG, "timeout or interrupt reading modem stats: " + e);
+ return StatsManager.PULL_SKIP;
+ } catch (ExecutionException e) {
+ Slog.w(TAG, "exception reading modem stats: " + e.getCause());
+ return StatsManager.PULL_SKIP;
+ }
+
if (modemInfo == null) {
return StatsManager.PULL_SKIP;
}
StatsEvent e = StatsEvent.newBuilder()
.setAtomId(atomTag)
- .writeLong(modemInfo.getTimestamp())
+ .writeLong(modemInfo.getTimestampMillis())
.writeLong(modemInfo.getSleepTimeMillis())
.writeLong(modemInfo.getIdleTimeMillis())
- .writeLong(modemInfo.getTransmitPowerInfo().get(0).getTimeInMillis())
- .writeLong(modemInfo.getTransmitPowerInfo().get(1).getTimeInMillis())
- .writeLong(modemInfo.getTransmitPowerInfo().get(2).getTimeInMillis())
- .writeLong(modemInfo.getTransmitPowerInfo().get(3).getTimeInMillis())
- .writeLong(modemInfo.getTransmitPowerInfo().get(4).getTimeInMillis())
+ .writeLong(modemInfo.getTransmitDurationMillisAtPowerLevel(0))
+ .writeLong(modemInfo.getTransmitDurationMillisAtPowerLevel(1))
+ .writeLong(modemInfo.getTransmitDurationMillisAtPowerLevel(2))
+ .writeLong(modemInfo.getTransmitDurationMillisAtPowerLevel(3))
+ .writeLong(modemInfo.getTransmitDurationMillisAtPowerLevel(4))
.writeLong(modemInfo.getReceiveTimeMillis())
.build();
pulledData.add(e);
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index d78e02b..f2f6b1d 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -176,7 +176,7 @@
"android.frameworks.stats@1.0",
"android.system.suspend.control-V1-cpp",
"android.system.suspend.control.internal-cpp",
- "android.system.suspend@1.0",
+ "android.system.suspend-V1-ndk",
"service.incremental",
],
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index 7a6d310..4922b2c 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -18,11 +18,12 @@
//#define LOG_NDEBUG 0
+#include <aidl/android/system/suspend/ISystemSuspend.h>
+#include <aidl/android/system/suspend/IWakeLock.h>
#include <android/hardware/power/1.1/IPower.h>
#include <android/hardware/power/Boost.h>
#include <android/hardware/power/IPower.h>
#include <android/hardware/power/Mode.h>
-#include <android/system/suspend/1.0/ISystemSuspend.h>
#include <android/system/suspend/ISuspendControlService.h>
#include <android/system/suspend/internal/ISuspendControlServiceInternal.h>
#include <nativehelper/JNIHelp.h>
@@ -33,6 +34,7 @@
#include <limits.h>
#include <android-base/chrono_utils.h>
+#include <android/binder_manager.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/Log.h>
#include <binder/IServiceManager.h>
@@ -40,23 +42,23 @@
#include <hardware/power.h>
#include <hardware_legacy/power.h>
#include <hidl/ServiceManagement.h>
+#include <utils/Log.h>
+#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/misc.h>
-#include <utils/String8.h>
-#include <utils/Log.h>
#include "com_android_server_power_PowerManagerService.h"
+using aidl::android::system::suspend::ISystemSuspend;
+using aidl::android::system::suspend::IWakeLock;
+using aidl::android::system::suspend::WakeLockType;
+using android::String8;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::power::Boost;
using android::hardware::power::Mode;
-using android::hardware::power::V1_0::PowerHint;
using android::hardware::power::V1_0::Feature;
-using android::String8;
-using android::system::suspend::V1_0::ISystemSuspend;
-using android::system::suspend::V1_0::IWakeLock;
-using android::system::suspend::V1_0::WakeLockType;
+using android::hardware::power::V1_0::PowerHint;
using android::system::suspend::ISuspendControlService;
using IPowerV1_1 = android::hardware::power::V1_1::IPower;
using IPowerV1_0 = android::hardware::power::V1_0::IPower;
@@ -352,20 +354,21 @@
}
}
-static sp<ISystemSuspend> gSuspendHal = nullptr;
+static std::shared_ptr<ISystemSuspend> gSuspendHal = nullptr;
static sp<ISuspendControlService> gSuspendControl = nullptr;
static sp<system::suspend::internal::ISuspendControlServiceInternal> gSuspendControlInternal =
nullptr;
-static sp<IWakeLock> gSuspendBlocker = nullptr;
+static std::shared_ptr<IWakeLock> gSuspendBlocker = nullptr;
static std::mutex gSuspendMutex;
// Assume SystemSuspend HAL is always alive.
// TODO: Force device to restart if SystemSuspend HAL dies.
-sp<ISystemSuspend> getSuspendHal() {
+std::shared_ptr<ISystemSuspend> getSuspendHal() {
static std::once_flag suspendHalFlag;
- std::call_once(suspendHalFlag, [](){
- ::android::hardware::details::waitForHwService(ISystemSuspend::descriptor, "default");
- gSuspendHal = ISystemSuspend::getService();
+ std::call_once(suspendHalFlag, []() {
+ const std::string suspendInstance = std::string() + ISystemSuspend::descriptor + "/default";
+ gSuspendHal = ISystemSuspend::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(suspendInstance.c_str())));
assert(gSuspendHal != nullptr);
});
return gSuspendHal;
@@ -403,7 +406,7 @@
std::lock_guard<std::mutex> lock(gSuspendMutex);
if (gSuspendBlocker) {
gSuspendBlocker->release();
- gSuspendBlocker.clear();
+ gSuspendBlocker = nullptr;
}
}
}
@@ -411,9 +414,10 @@
void disableAutoSuspend() {
std::lock_guard<std::mutex> lock(gSuspendMutex);
if (!gSuspendBlocker) {
- sp<ISystemSuspend> suspendHal = getSuspendHal();
- gSuspendBlocker = suspendHal->acquireWakeLock(WakeLockType::PARTIAL,
- "PowerManager.SuspendLockout");
+ std::shared_ptr<ISystemSuspend> suspendHal = getSuspendHal();
+ suspendHal->acquireWakeLock(WakeLockType::PARTIAL, "PowerManager.SuspendLockout",
+ &gSuspendBlocker);
+ assert(gSuspendBlocker != nullptr);
}
}
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index 5ecf6bb..6e01f69 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -79,7 +79,6 @@
// These are not normally accessible from apps so they must be explicitly included.
jni_libs: [
- "libbacktrace",
"libbase",
"libbinder",
"libc++",
diff --git a/services/tests/uiservicestests/Android.bp b/services/tests/uiservicestests/Android.bp
index 541fc63..2448026 100644
--- a/services/tests/uiservicestests/Android.bp
+++ b/services/tests/uiservicestests/Android.bp
@@ -55,7 +55,6 @@
jni_libs: [
"libdexmakerjvmtiagent",
"libmultiplejvmtiagentsinterferenceagent",
- "libbacktrace",
"libbase",
"libbinder",
"libc++",
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
index ad15a99..11ea4a4 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -46,6 +46,7 @@
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
+import android.app.KeyguardManager;
import android.app.Notification;
import android.app.Notification.Builder;
import android.app.NotificationChannel;
@@ -103,6 +104,8 @@
NotificationUsageStats mUsageStats;
@Mock
IAccessibilityManager mAccessibilityService;
+ @Mock
+ KeyguardManager mKeyguardManager;
NotificationRecordLoggerFake mNotificationRecordLogger = new NotificationRecordLoggerFake();
private InstanceIdSequence mNotificationInstanceIdSequence = new InstanceIdSequenceFake(
1 << 30);
@@ -147,6 +150,7 @@
when(mAudioManager.getStreamVolume(anyInt())).thenReturn(10);
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mUsageStats.isAlertRateLimited(any())).thenReturn(false);
+ when(mKeyguardManager.isDeviceLocked(anyInt())).thenReturn(false);
long serviceReturnValue = IntPair.of(
AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED,
@@ -168,6 +172,7 @@
mService.setFallbackVibrationPattern(FALLBACK_VIBRATION_PATTERN);
mService.setUsageStats(mUsageStats);
mService.setAccessibilityManager(accessibilityManager);
+ mService.setKeyguardManager(mKeyguardManager);
mService.mScreenOn = false;
mService.mInCallStateOffHook = false;
mService.mNotificationPulseEnabled = true;
@@ -484,6 +489,94 @@
}
@Test
+ public void testLockedPrivateA11yRedaction() throws Exception {
+ NotificationRecord r = getBeepyNotification();
+ r.setPackageVisibilityOverride(NotificationManager.VISIBILITY_NO_OVERRIDE);
+ r.getNotification().visibility = Notification.VISIBILITY_PRIVATE;
+ when(mKeyguardManager.isDeviceLocked(anyInt())).thenReturn(true);
+ AccessibilityManager accessibilityManager = Mockito.mock(AccessibilityManager.class);
+ when(accessibilityManager.isEnabled()).thenReturn(true);
+ mService.setAccessibilityManager(accessibilityManager);
+
+ mService.buzzBeepBlinkLocked(r);
+
+ ArgumentCaptor<AccessibilityEvent> eventCaptor =
+ ArgumentCaptor.forClass(AccessibilityEvent.class);
+
+ verify(accessibilityManager, times(1))
+ .sendAccessibilityEvent(eventCaptor.capture());
+
+ AccessibilityEvent event = eventCaptor.getValue();
+ assertEquals(r.getNotification().publicVersion, event.getParcelableData());
+ }
+
+ @Test
+ public void testLockedOverridePrivateA11yRedaction() throws Exception {
+ NotificationRecord r = getBeepyNotification();
+ r.setPackageVisibilityOverride(Notification.VISIBILITY_PRIVATE);
+ r.getNotification().visibility = Notification.VISIBILITY_PUBLIC;
+ when(mKeyguardManager.isDeviceLocked(anyInt())).thenReturn(true);
+ AccessibilityManager accessibilityManager = Mockito.mock(AccessibilityManager.class);
+ when(accessibilityManager.isEnabled()).thenReturn(true);
+ mService.setAccessibilityManager(accessibilityManager);
+
+ mService.buzzBeepBlinkLocked(r);
+
+ ArgumentCaptor<AccessibilityEvent> eventCaptor =
+ ArgumentCaptor.forClass(AccessibilityEvent.class);
+
+ verify(accessibilityManager, times(1))
+ .sendAccessibilityEvent(eventCaptor.capture());
+
+ AccessibilityEvent event = eventCaptor.getValue();
+ assertEquals(r.getNotification().publicVersion, event.getParcelableData());
+ }
+
+ @Test
+ public void testLockedPublicA11yNoRedaction() throws Exception {
+ NotificationRecord r = getBeepyNotification();
+ r.setPackageVisibilityOverride(NotificationManager.VISIBILITY_NO_OVERRIDE);
+ r.getNotification().visibility = Notification.VISIBILITY_PUBLIC;
+ when(mKeyguardManager.isDeviceLocked(anyInt())).thenReturn(true);
+ AccessibilityManager accessibilityManager = Mockito.mock(AccessibilityManager.class);
+ when(accessibilityManager.isEnabled()).thenReturn(true);
+ mService.setAccessibilityManager(accessibilityManager);
+
+ mService.buzzBeepBlinkLocked(r);
+
+ ArgumentCaptor<AccessibilityEvent> eventCaptor =
+ ArgumentCaptor.forClass(AccessibilityEvent.class);
+
+ verify(accessibilityManager, times(1))
+ .sendAccessibilityEvent(eventCaptor.capture());
+
+ AccessibilityEvent event = eventCaptor.getValue();
+ assertEquals(r.getNotification(), event.getParcelableData());
+ }
+
+ @Test
+ public void testUnlockedPrivateA11yNoRedaction() throws Exception {
+ NotificationRecord r = getBeepyNotification();
+ r.setPackageVisibilityOverride(NotificationManager.VISIBILITY_NO_OVERRIDE);
+ r.getNotification().visibility = Notification.VISIBILITY_PRIVATE;
+ when(mKeyguardManager.isDeviceLocked(anyInt())).thenReturn(false);
+ AccessibilityManager accessibilityManager = Mockito.mock(AccessibilityManager.class);
+ when(accessibilityManager.isEnabled()).thenReturn(true);
+ mService.setAccessibilityManager(accessibilityManager);
+
+ mService.buzzBeepBlinkLocked(r);
+
+ ArgumentCaptor<AccessibilityEvent> eventCaptor =
+ ArgumentCaptor.forClass(AccessibilityEvent.class);
+
+ verify(accessibilityManager, times(1))
+ .sendAccessibilityEvent(eventCaptor.capture());
+
+ AccessibilityEvent event = eventCaptor.getValue();
+ assertEquals(r.getNotification(), event.getParcelableData());
+ }
+
+ @Test
public void testBeepInsistently() throws Exception {
NotificationRecord r = getInsistentBeepyNotification();
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index 5e3d26a..705b491 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -81,7 +81,8 @@
* <pre>
* {@code
* <service android:name="your.package.YourInCallServiceImplementation"
- * android:permission="android.permission.BIND_INCALL_SERVICE">
+ * android:permission="android.permission.BIND_INCALL_SERVICE"
+ * android:exported="true">
* <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
* <meta-data android:name="android.telecom.IN_CALL_SERVICE_RINGING"
* android:value="true" />
@@ -91,6 +92,10 @@
* </service>
* }
* </pre>
+ *
+ * <em>Note: You should NOT mark your {@link InCallService} with the attribute
+ * {@code android:exported="false"}; doing so can result in a failure to bind to your implementation
+ * during calls.</em>
* <p>
* In addition to implementing the {@link InCallService} API, you must also declare an activity in
* your manifest which handles the {@link Intent#ACTION_DIAL} intent. The example below illustrates
diff --git a/telephony/java/android/telephony/ModemActivityInfo.java b/telephony/java/android/telephony/ModemActivityInfo.java
index debb119..0bf8ce6 100644
--- a/telephony/java/android/telephony/ModemActivityInfo.java
+++ b/telephony/java/android/telephony/ModemActivityInfo.java
@@ -16,8 +16,12 @@
package android.telephony;
+import android.annotation.DurationMillisLong;
+import android.annotation.ElapsedRealtimeLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
@@ -25,46 +29,50 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
+import java.util.Objects;
/**
- * Reports modem activity information.
+ * Contains information about the modem's activity. May be useful for power stats reporting.
* @hide
*/
+@SystemApi
+@TestApi
public final class ModemActivityInfo implements Parcelable {
+ private static final int TX_POWER_LEVELS = 5;
+
/**
- * Tx(transmit) power level. see power index below
- * <ul>
- * <li> index 0 = tx_power < 0dBm. </li>
- * <li> index 1 = 0dBm < tx_power < 5dBm. </li>
- * <li> index 2 = 5dBm < tx_power < 15dBm. </li>
- * <li> index 3 = 15dBm < tx_power < 20dBm. </li>
- * <li> index 4 = tx_power > 20dBm. </li>
- * </ul>
- */
- public static final int TX_POWER_LEVELS = 5;
- /**
- * Tx(transmit) power level 0: tx_power < 0dBm
+ * Corresponds to transmit power of less than 0dBm.
*/
public static final int TX_POWER_LEVEL_0 = 0;
+
/**
- * Tx(transmit) power level 1: 0dBm < tx_power < 5dBm
+ * Corresponds to transmit power between 0dBm and 5dBm.
*/
public static final int TX_POWER_LEVEL_1 = 1;
+
/**
- * Tx(transmit) power level 2: 5dBm < tx_power < 15dBm
+ * Corresponds to transmit power between 5dBm and 15dBm.
*/
public static final int TX_POWER_LEVEL_2 = 2;
+
/**
- * Tx(transmit) power level 3: 15dBm < tx_power < 20dBm.
+ * Corresponds to transmit power between 15dBm and 20dBm.
*/
public static final int TX_POWER_LEVEL_3 = 3;
+
/**
- * Tx(transmit) power level 4: tx_power > 20dBm
+ * Corresponds to transmit power above 20dBm.
*/
public static final int TX_POWER_LEVEL_4 = 4;
+ /**
+ * The number of transmit power levels. Fixed by HAL definition.
+ */
+ public static int getNumTxPowerLevels() {
+ return TX_POWER_LEVELS;
+ }
+
/** @hide */
@IntDef(prefix = {"TX_POWER_LEVEL_"}, value = {
TX_POWER_LEVEL_0,
@@ -82,34 +90,39 @@
new Range<>(5, 15),
new Range<>(15, 20),
new Range<>(20, Integer.MAX_VALUE)
-
};
private long mTimestamp;
private int mSleepTimeMs;
private int mIdleTimeMs;
- private List<TransmitPower> mTransmitPowerInfo = new ArrayList<>(TX_POWER_LEVELS);
+ private int[] mTxTimeMs;
private int mRxTimeMs;
+ /**
+ * @hide
+ */
+ @TestApi
public ModemActivityInfo(long timestamp, int sleepTimeMs, int idleTimeMs,
@NonNull int[] txTimeMs, int rxTimeMs) {
+ Objects.requireNonNull(txTimeMs);
+ if (txTimeMs.length != TX_POWER_LEVELS) {
+ throw new IllegalArgumentException("txTimeMs must have length == TX_POWER_LEVELS");
+ }
mTimestamp = timestamp;
mSleepTimeMs = sleepTimeMs;
mIdleTimeMs = idleTimeMs;
- populateTransmitPowerRange(txTimeMs);
+ mTxTimeMs = txTimeMs;
mRxTimeMs = rxTimeMs;
}
- /** helper API to populate tx power range for each bucket **/
- private void populateTransmitPowerRange(@NonNull int[] transmitPowerMs) {
- int i = 0;
- for ( ; i < Math.min(transmitPowerMs.length, TX_POWER_LEVELS); i++) {
- mTransmitPowerInfo.add(i, new TransmitPower(TX_POWER_RANGES[i], transmitPowerMs[i]));
- }
- // Make sure that mTransmitPowerInfo is fully initialized.
- for ( ; i < TX_POWER_LEVELS; i++) {
- mTransmitPowerInfo.add(i, new TransmitPower(TX_POWER_RANGES[i], 0));
- }
+ /**
+ * Provided for convenience in manipulation since the API exposes long values but internal
+ * representations are ints.
+ * @hide
+ */
+ public ModemActivityInfo(long timestamp, long sleepTimeMs, long idleTimeMs,
+ @NonNull int[] txTimeMs, long rxTimeMs) {
+ this(timestamp, (int) sleepTimeMs, (int) idleTimeMs, txTimeMs, (int) rxTimeMs);
}
@Override
@@ -118,7 +131,7 @@
+ " mTimestamp=" + mTimestamp
+ " mSleepTimeMs=" + mSleepTimeMs
+ " mIdleTimeMs=" + mIdleTimeMs
- + " mTransmitPowerInfo[]=" + mTransmitPowerInfo.toString()
+ + " mTxTimeMs[]=" + Arrays.toString(mTxTimeMs)
+ " mRxTimeMs=" + mRxTimeMs
+ "}";
}
@@ -129,14 +142,12 @@
public static final @android.annotation.NonNull Parcelable.Creator<ModemActivityInfo> CREATOR =
new Parcelable.Creator<ModemActivityInfo>() {
- public ModemActivityInfo createFromParcel(Parcel in) {
+ public ModemActivityInfo createFromParcel(@NonNull Parcel in) {
long timestamp = in.readLong();
int sleepTimeMs = in.readInt();
int idleTimeMs = in.readInt();
int[] txTimeMs = new int[TX_POWER_LEVELS];
- for (int i = 0; i < TX_POWER_LEVELS; i++) {
- txTimeMs[i] = in.readInt();
- }
+ in.readIntArray(txTimeMs);
int rxTimeMs = in.readInt();
return new ModemActivityInfo(timestamp, sleepTimeMs, idleTimeMs,
txTimeMs, rxTimeMs);
@@ -147,21 +158,25 @@
}
};
- public void writeToParcel(Parcel dest, int flags) {
+ /**
+ * @param dest The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written.
+ */
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeLong(mTimestamp);
dest.writeInt(mSleepTimeMs);
dest.writeInt(mIdleTimeMs);
- for (int i = 0; i < TX_POWER_LEVELS; i++) {
- dest.writeInt(mTransmitPowerInfo.get(i).getTimeInMillis());
- }
+ dest.writeIntArray(mTxTimeMs);
dest.writeInt(mRxTimeMs);
}
/**
- * @return milliseconds since boot, including mTimeInMillis spent in sleep.
- * @see SystemClock#elapsedRealtime()
+ * Gets the timestamp at which this modem activity info was recorded.
+ *
+ * @return The timestamp, as returned by {@link SystemClock#elapsedRealtime()}, when this
+ * {@link ModemActivityInfo} was recorded.
*/
- public long getTimestamp() {
+ public @ElapsedRealtimeLong long getTimestampMillis() {
return mTimestamp;
}
@@ -171,35 +186,48 @@
}
/**
- * @return an arrayList of {@link TransmitPower} with each element representing the total time where
- * transmitter is awake time (in ms) for a given power range (in dbm).
+ * Gets the amount of time the modem spent transmitting at a certain power level.
*
- * @see #TX_POWER_LEVELS
+ * @param powerLevel The power level to query.
+ * @return The amount of time, in milliseconds, that the modem spent transmitting at the
+ * given power level.
*/
- @NonNull
- public List<TransmitPower> getTransmitPowerInfo() {
- return mTransmitPowerInfo;
+ public @DurationMillisLong long getTransmitDurationMillisAtPowerLevel(
+ @TxPowerLevel int powerLevel) {
+ return mTxTimeMs[powerLevel];
+ }
+
+ /**
+ * Gets the range of transmit powers corresponding to a certain power level.
+ *
+ * @param powerLevel The power level to query
+ * @return A {@link Range} object representing the range of intensities (in dBm) to which this
+ * power level corresponds.
+ */
+ public @NonNull Range<Integer> getTransmitPowerRange(@TxPowerLevel int powerLevel) {
+ return TX_POWER_RANGES[powerLevel];
}
/** @hide */
public void setTransmitTimeMillis(int[] txTimeMs) {
- populateTransmitPowerRange(txTimeMs);
- }
-
- /** @hide */
- @NonNull
- public int[] getTransmitTimeMillis() {
- int[] transmitTimeMillis = new int[TX_POWER_LEVELS];
- for (int i = 0; i < transmitTimeMillis.length; i++) {
- transmitTimeMillis[i] = mTransmitPowerInfo.get(i).getTimeInMillis();
- }
- return transmitTimeMillis;
+ mTxTimeMs = Arrays.copyOf(txTimeMs, TX_POWER_LEVELS);
}
/**
- * @return total mTimeInMillis (in ms) when modem is in a low power or sleep state.
+ * @return The raw array of transmit power durations
+ * @hide
*/
- public int getSleepTimeMillis() {
+ @NonNull
+ public int[] getTransmitTimeMillis() {
+ return mTxTimeMs;
+ }
+
+ /**
+ * Gets the amount of time (in milliseconds) when the modem is in a low power or sleep state.
+ *
+ * @return Time in milliseconds.
+ */
+ public @DurationMillisLong long getSleepTimeMillis() {
return mSleepTimeMs;
}
@@ -209,10 +237,44 @@
}
/**
- * @return total mTimeInMillis (in ms) when modem is awake but neither the transmitter nor receiver are
- * active.
+ * Provided for convenience, since the API surface needs to return longs but internal
+ * representations are ints.
+ * @hide
*/
- public int getIdleTimeMillis() {
+ public void setSleepTimeMillis(long sleepTimeMillis) {
+ mSleepTimeMs = (int) sleepTimeMillis;
+ }
+
+ /**
+ * Computes the difference between this instance of {@link ModemActivityInfo} and another
+ * instance.
+ *
+ * This method should be used to compute the amount of activity that has happened between two
+ * samples of modem activity taken at separate times. The sample passed in as an argument to
+ * this method should be the one that's taken later in time (and therefore has more activity).
+ * @param other The other instance of {@link ModemActivityInfo} to diff against.
+ * @return An instance of {@link ModemActivityInfo} representing the difference in modem
+ * activity.
+ */
+ public @NonNull ModemActivityInfo getDelta(@NonNull ModemActivityInfo other) {
+ int[] txTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS];
+ for (int i = 0; i < ModemActivityInfo.TX_POWER_LEVELS; i++) {
+ txTimeMs[i] = other.mTxTimeMs[i] - mTxTimeMs[i];
+ }
+ return new ModemActivityInfo(other.getTimestampMillis(),
+ other.getSleepTimeMillis() - getSleepTimeMillis(),
+ other.getIdleTimeMillis() - getIdleTimeMillis(),
+ txTimeMs,
+ other.getReceiveTimeMillis() - getReceiveTimeMillis());
+ }
+
+ /**
+ * Gets the amount of time (in milliseconds) when the modem is awake but neither transmitting
+ * nor receiving.
+ *
+ * @return Time in milliseconds.
+ */
+ public @DurationMillisLong long getIdleTimeMillis() {
return mIdleTimeMs;
}
@@ -222,9 +284,20 @@
}
/**
- * @return rx(receive) mTimeInMillis in ms.
+ * Provided for convenience, since the API surface needs to return longs but internal
+ * representations are ints.
+ * @hide
*/
- public int getReceiveTimeMillis() {
+ public void setIdleTimeMillis(long idleTimeMillis) {
+ mIdleTimeMs = (int) idleTimeMillis;
+ }
+
+ /**
+ * Gets the amount of time (in milliseconds) when the modem is awake and receiving data.
+ *
+ * @return Time in milliseconds.
+ */
+ public @DurationMillisLong long getReceiveTimeMillis() {
return mRxTimeMs;
}
@@ -234,71 +307,56 @@
}
/**
+ * Provided for convenience, since the API surface needs to return longs but internal
+ * representations are ints.
+ * @hide
+ */
+ public void setReceiveTimeMillis(long receiveTimeMillis) {
+ mRxTimeMs = (int) receiveTimeMillis;
+ }
+
+ /**
* Indicates if the modem has reported valid {@link ModemActivityInfo}.
*
* @return {@code true} if this {@link ModemActivityInfo} record is valid,
* {@code false} otherwise.
+ * @hide
*/
+ @TestApi
public boolean isValid() {
- for (TransmitPower powerInfo : getTransmitPowerInfo()) {
- if(powerInfo.getTimeInMillis() < 0) {
- return false;
- }
- }
+ boolean isTxPowerValid = Arrays.stream(mTxTimeMs).allMatch((i) -> i >= 0);
- return ((getIdleTimeMillis() >= 0) && (getSleepTimeMillis() >= 0)
+ return isTxPowerValid && ((getIdleTimeMillis() >= 0) && (getSleepTimeMillis() >= 0)
&& (getReceiveTimeMillis() >= 0) && !isEmpty());
}
- private boolean isEmpty() {
- for (TransmitPower txVal : getTransmitPowerInfo()) {
- if(txVal.getTimeInMillis() != 0) {
- return false;
- }
- }
+ /** @hide */
+ @TestApi
+ public boolean isEmpty() {
+ boolean isTxPowerEmpty = mTxTimeMs == null || mTxTimeMs.length == 0
+ || Arrays.stream(mTxTimeMs).allMatch((i) -> i == 0);
- return ((getIdleTimeMillis() == 0) && (getSleepTimeMillis() == 0)
+ return isTxPowerEmpty && ((getIdleTimeMillis() == 0) && (getSleepTimeMillis() == 0)
&& (getReceiveTimeMillis() == 0));
}
- /**
- * Transmit power Information, including the power range in dbm and the total time (in ms) where
- * the transmitter is active/awake for this power range.
- * e.g, range: 0dbm(lower) ~ 5dbm(upper)
- * time: 5ms
- */
- public class TransmitPower {
- private int mTimeInMillis;
- private Range<Integer> mPowerRangeInDbm;
- /** @hide */
- public TransmitPower(@NonNull Range<Integer> range, int time) {
- this.mTimeInMillis = time;
- this.mPowerRangeInDbm = range;
- }
- /**
- * @return the total time in ms where the transmitter is active/wake for this power range
- * {@link #getPowerRangeInDbm()}.
- */
- public int getTimeInMillis() {
- return mTimeInMillis;
- }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ModemActivityInfo that = (ModemActivityInfo) o;
+ return mTimestamp == that.mTimestamp
+ && mSleepTimeMs == that.mSleepTimeMs
+ && mIdleTimeMs == that.mIdleTimeMs
+ && mRxTimeMs == that.mRxTimeMs
+ && Arrays.equals(mTxTimeMs, that.mTxTimeMs);
+ }
- /**
- * @return the power range in dbm. e.g, range: 0dbm(lower) ~ 5dbm(upper)
- */
- @NonNull
- public Range<Integer> getPowerRangeInDbm() {
- return mPowerRangeInDbm;
- }
-
- @Override
- public String toString() {
- return "TransmitPower{"
- + " mTimeInMillis=" + mTimeInMillis
- + " mPowerRangeInDbm={" + mPowerRangeInDbm.getLower()
- + "," + mPowerRangeInDbm.getUpper()
- + "}}";
- }
+ @Override
+ public int hashCode() {
+ int result = Objects.hash(mTimestamp, mSleepTimeMs, mIdleTimeMs, mRxTimeMs);
+ result = 31 * result + Arrays.hashCode(mTxTimeMs);
+ return result;
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 4189784..f55dc8b 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -57,7 +57,9 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.os.OutcomeReceiver;
import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ResultReceiver;
@@ -84,6 +86,7 @@
import android.telephony.VisualVoicemailService.VisualVoicemailTask;
import android.telephony.data.ApnSetting;
import android.telephony.data.ApnSetting.MvnoType;
+import android.telephony.data.SlicingConfig;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.emergency.EmergencyNumber.EmergencyServiceCategories;
import android.telephony.gba.UaSecurityProtocolIdentifier;
@@ -176,6 +179,9 @@
*/
public static final String MODEM_ACTIVITY_RESULT_KEY = "controller_activity";
+ /** @hide */
+ public static final String EXCEPTION_RESULT_KEY = "exception";
+
/**
* The process name of the Phone app as well as many other apps that use this process name, such
* as settings and vendor components.
@@ -10855,26 +10861,149 @@
return null;
}
-
/**
- * Requests the modem activity info. The recipient will place the result
- * in `result`.
- * @param result The object on which the recipient will send the resulting
- * {@link android.telephony.ModemActivityInfo} object with key of
- * {@link #MODEM_ACTIVITY_RESULT_KEY}.
+ * Exception that may be supplied to the callback provided in {@link #requestModemActivityInfo}.
* @hide
*/
- public void requestModemActivityInfo(@NonNull ResultReceiver result) {
+ @SystemApi
+ public static class ModemActivityInfoException extends Exception {
+ /** Indicates that an unknown error occurred */
+ public static final int ERROR_UNKNOWN = 0;
+
+ /**
+ * Indicates that the modem or phone processes are not available (such as when the device
+ * is in airplane mode).
+ */
+ public static final int ERROR_PHONE_NOT_AVAILABLE = 1;
+
+ /**
+ * Indicates that the modem supplied an invalid instance of {@link ModemActivityInfo}
+ */
+ public static final int ERROR_INVALID_INFO_RECEIVED = 2;
+
+ /**
+ * Indicates that the modem encountered an internal failure when processing the request
+ * for activity info.
+ */
+ public static final int ERROR_MODEM_RESPONSE_ERROR = 3;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"ERROR_"},
+ value = {
+ ERROR_UNKNOWN,
+ ERROR_PHONE_NOT_AVAILABLE,
+ ERROR_INVALID_INFO_RECEIVED,
+ ERROR_MODEM_RESPONSE_ERROR,
+ })
+ public @interface ModemActivityInfoError {}
+
+ private final int mErrorCode;
+
+ /** @hide */
+ public ModemActivityInfoException(@ModemActivityInfoError int errorCode) {
+ mErrorCode = errorCode;
+ }
+
+ public @ModemActivityInfoError int getErrorCode() {
+ return mErrorCode;
+ }
+
+ @Override
+ public String toString() {
+ switch (mErrorCode) {
+ case ERROR_UNKNOWN: return "ERROR_UNKNOWN";
+ case ERROR_PHONE_NOT_AVAILABLE: return "ERROR_PHONE_NOT_AVAILABLE";
+ case ERROR_INVALID_INFO_RECEIVED: return "ERROR_INVALID_INFO_RECEIVED";
+ case ERROR_MODEM_RESPONSE_ERROR: return "ERROR_MODEM_RESPONSE_ERROR";
+ default: return "UNDEFINED";
+ }
+ }
+ }
+
+ /**
+ * Requests the current modem activity info.
+ *
+ * The provided instance of {@link ModemActivityInfo} represents the cumulative activity since
+ * the last restart of the phone process.
+ *
+ * @param callback A callback object to which the result will be delivered. If there was an
+ * error processing the request, {@link OutcomeReceiver#onError} will be called
+ * with more details about the error.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
+ public void requestModemActivityInfo(@NonNull @CallbackExecutor Executor executor,
+ @NonNull OutcomeReceiver<ModemActivityInfo, ModemActivityInfoException> callback) {
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
+
+ // Pass no handler into the receiver, since we're going to be trampolining the call to the
+ // listener onto the provided executor.
+ ResultReceiver wrapperResultReceiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle data) {
+ if (data == null) {
+ Log.w(TAG, "requestModemActivityInfo: received null bundle");
+ sendErrorToListener(ModemActivityInfoException.ERROR_UNKNOWN);
+ return;
+ }
+ data.setDefusable(true);
+ if (data.containsKey(EXCEPTION_RESULT_KEY)) {
+ int receivedErrorCode = data.getInt(EXCEPTION_RESULT_KEY);
+ sendErrorToListener(receivedErrorCode);
+ return;
+ }
+
+ if (!data.containsKey(MODEM_ACTIVITY_RESULT_KEY)) {
+ Log.w(TAG, "requestModemActivityInfo: Bundle did not contain expected key");
+ sendErrorToListener(ModemActivityInfoException.ERROR_UNKNOWN);
+ return;
+ }
+ Parcelable receivedResult = data.getParcelable(MODEM_ACTIVITY_RESULT_KEY);
+ if (!(receivedResult instanceof ModemActivityInfo)) {
+ Log.w(TAG, "requestModemActivityInfo: Bundle contained something that wasn't "
+ + "a ModemActivityInfo.");
+ sendErrorToListener(ModemActivityInfoException.ERROR_UNKNOWN);
+ return;
+ }
+ ModemActivityInfo modemActivityInfo = (ModemActivityInfo) receivedResult;
+ if (!modemActivityInfo.isValid()) {
+ Log.w(TAG, "requestModemActivityInfo: Received an invalid ModemActivityInfo");
+ sendErrorToListener(ModemActivityInfoException.ERROR_INVALID_INFO_RECEIVED);
+ return;
+ }
+ Log.d(TAG, "requestModemActivityInfo: Sending result to app: " + modemActivityInfo);
+ sendResultToListener(modemActivityInfo);
+ }
+
+ private void sendResultToListener(ModemActivityInfo info) {
+ Binder.withCleanCallingIdentity(() ->
+ executor.execute(() ->
+ callback.onResult(info)));
+ }
+
+ private void sendErrorToListener(int code) {
+ ModemActivityInfoException e = new ModemActivityInfoException(code);
+ Binder.withCleanCallingIdentity(() ->
+ executor.execute(() ->
+ callback.onError(e)));
+ }
+ };
+
try {
ITelephony service = getITelephony();
if (service != null) {
- service.requestModemActivityInfo(result);
+ service.requestModemActivityInfo(wrapperResultReceiver);
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getModemActivityInfo", e);
}
- result.send(0, null);
+ executor.execute(() -> callback.onError(
+ new ModemActivityInfoException(
+ ModemActivityInfoException.ERROR_PHONE_NOT_AVAILABLE)));
}
/**
@@ -15093,4 +15222,96 @@
return PhoneCapability.DEFAULT_SSSS_CAPABILITY;
}
}
+
+ /**
+ * Exception that may be supplied to the callback in {@link #getNetworkSlicingConfiguration} if
+ * something goes awry.
+ */
+ public static class SlicingException extends Exception {
+ /**
+ * Getting the current slicing configuration successfully. Used internally only.
+ * @hide
+ */
+ public static final int SUCCESS = 0;
+
+ /**
+ * The system timed out waiting for a response from the Radio.
+ */
+ public static final int ERROR_TIMEOUT = 1;
+
+ /**
+ * The modem returned a failure.
+ */
+ public static final int ERROR_MODEM_ERROR = 2;
+
+ /** @hide */
+ @IntDef(prefix = {"ERROR_"}, value = {
+ ERROR_TIMEOUT,
+ ERROR_MODEM_ERROR,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SlicingError {}
+
+ private final int mErrorCode;
+
+ public SlicingException(@SlicingError int errorCode) {
+ mErrorCode = errorCode;
+ }
+
+ /**
+ * Fetches the error code associated with this exception.
+ * @return An error code.
+ */
+ public @SlicingError int getErrorCode() {
+ return mErrorCode;
+ }
+ }
+
+ /** @hide */
+ public static final String KEY_SLICING_CONFIG_HANDLE = "slicing_config_handle";
+
+ /**
+ * Request to get the current slicing configuration including URSP rules and
+ * NSSAIs (configured, allowed and rejected).
+ *
+ * This method can be invoked if one of the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * </ul>
+ *
+ * @param executor the executor on which callback will be invoked.
+ * @param callback a callback to receive the current slicing configuration.
+ */
+ @SuppressAutoDoc // No support for carrier privileges (b/72967236).
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public void getNetworkSlicingConfiguration(
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OutcomeReceiver<SlicingConfig, SlicingException> callback) {
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
+
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony == null) {
+ throw new IllegalStateException("telephony service is null.");
+ }
+ telephony.getSlicingConfig(new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle result) {
+ if (resultCode != SlicingException.SUCCESS) {
+ executor.execute(() -> callback.onError(
+ new SlicingException(resultCode)));
+ return;
+ }
+ SlicingConfig slicingConfig =
+ result.getParcelable(KEY_SLICING_CONFIG_HANDLE);
+ executor.execute(() -> callback.onResult(slicingConfig));
+ }
+ });
+ } catch (RemoteException ex) {
+ ex.rethrowAsRuntimeException();
+ }
+ }
}
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
index ad57b91..5008307 100644
--- a/telephony/java/android/telephony/data/DataCallResponse.java
+++ b/telephony/java/android/telephony/data/DataCallResponse.java
@@ -138,7 +138,7 @@
private final int mPduSessionId;
private final Qos mDefaultQos;
private final List<QosBearerSession> mQosBearerSessions;
- private final SliceInfo mSliceInfo;
+ private final NetworkSliceInfo mSliceInfo;
private final List<TrafficDescriptor> mTrafficDescriptors;
/**
@@ -201,7 +201,8 @@
@Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6,
@HandoverFailureMode int handoverFailureMode, int pduSessionId,
@Nullable Qos defaultQos, @Nullable List<QosBearerSession> qosBearerSessions,
- @Nullable SliceInfo sliceInfo, @Nullable List<TrafficDescriptor> trafficDescriptors) {
+ @Nullable NetworkSliceInfo sliceInfo,
+ @Nullable List<TrafficDescriptor> trafficDescriptors) {
mCause = cause;
mSuggestedRetryTime = suggestedRetryTime;
mId = id;
@@ -254,7 +255,7 @@
mDefaultQos = source.readParcelable(Qos.class.getClassLoader());
mQosBearerSessions = new ArrayList<>();
source.readList(mQosBearerSessions, QosBearerSession.class.getClassLoader());
- mSliceInfo = source.readParcelable(SliceInfo.class.getClassLoader());
+ mSliceInfo = source.readParcelable(NetworkSliceInfo.class.getClassLoader());
mTrafficDescriptors = new ArrayList<>();
source.readList(mTrafficDescriptors, TrafficDescriptor.class.getClassLoader());
}
@@ -408,7 +409,7 @@
* @return The slice info related to this data connection.
*/
@Nullable
- public SliceInfo getSliceInfo() {
+ public NetworkSliceInfo getSliceInfo() {
return mSliceInfo;
}
@@ -620,7 +621,7 @@
private List<QosBearerSession> mQosBearerSessions = new ArrayList<>();
- private SliceInfo mSliceInfo;
+ private NetworkSliceInfo mSliceInfo;
private List<TrafficDescriptor> mTrafficDescriptors = new ArrayList<>();
@@ -851,13 +852,13 @@
* The Slice used for this data connection.
* <p/>
* If a handover occurs from EPDG to 5G,
- * this is the {@link SliceInfo} used in {@link DataService#setupDataCall}.
+ * this is the {@link NetworkSliceInfo} used in {@link DataService#setupDataCall}.
*
* @param sliceInfo the slice info for the data call
*
* @return The same instance of the builder.
*/
- public @NonNull Builder setSliceInfo(@Nullable SliceInfo sliceInfo) {
+ public @NonNull Builder setSliceInfo(@Nullable NetworkSliceInfo sliceInfo) {
mSliceInfo = sliceInfo;
return this;
}
diff --git a/telephony/java/android/telephony/data/DataService.java b/telephony/java/android/telephony/data/DataService.java
index f5f29c6..17e6f32 100644
--- a/telephony/java/android/telephony/data/DataService.java
+++ b/telephony/java/android/telephony/data/DataService.java
@@ -217,7 +217,7 @@
boolean isRoaming, boolean allowRoaming,
@SetupDataReason int reason,
@Nullable LinkProperties linkProperties,
- @IntRange(from = 0, to = 15) int pduSessionId, @Nullable SliceInfo sliceInfo,
+ @IntRange(from = 0, to = 15) int pduSessionId, @Nullable NetworkSliceInfo sliceInfo,
@Nullable TrafficDescriptor trafficDescriptor, boolean matchAllRuleAllowed,
@NonNull DataServiceCallback callback) {
/* Call the old version since the new version isn't supported */
@@ -414,13 +414,13 @@
public final int reason;
public final LinkProperties linkProperties;
public final int pduSessionId;
- public final SliceInfo sliceInfo;
+ public final NetworkSliceInfo sliceInfo;
public final TrafficDescriptor trafficDescriptor;
public final boolean matchAllRuleAllowed;
public final IDataServiceCallback callback;
SetupDataCallRequest(int accessNetworkType, DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, LinkProperties linkProperties, int pduSessionId,
- SliceInfo sliceInfo, TrafficDescriptor trafficDescriptor,
+ NetworkSliceInfo sliceInfo, TrafficDescriptor trafficDescriptor,
boolean matchAllRuleAllowed, IDataServiceCallback callback) {
this.accessNetworkType = accessNetworkType;
this.dataProfile = dataProfile;
@@ -707,7 +707,7 @@
@Override
public void setupDataCall(int slotIndex, int accessNetworkType, DataProfile dataProfile,
boolean isRoaming, boolean allowRoaming, int reason,
- LinkProperties linkProperties, int pduSessionId, SliceInfo sliceInfo,
+ LinkProperties linkProperties, int pduSessionId, NetworkSliceInfo sliceInfo,
TrafficDescriptor trafficDescriptor, boolean matchAllRuleAllowed,
IDataServiceCallback callback) {
mHandler.obtainMessage(DATA_SERVICE_REQUEST_SETUP_DATA_CALL, slotIndex, 0,
diff --git a/telephony/java/android/telephony/data/IDataService.aidl b/telephony/java/android/telephony/data/IDataService.aidl
index 81f5fd3..1346946 100644
--- a/telephony/java/android/telephony/data/IDataService.aidl
+++ b/telephony/java/android/telephony/data/IDataService.aidl
@@ -19,7 +19,7 @@
import android.net.LinkProperties;
import android.telephony.data.DataProfile;
import android.telephony.data.IDataServiceCallback;
-import android.telephony.data.SliceInfo;
+import android.telephony.data.NetworkSliceInfo;
import android.telephony.data.TrafficDescriptor;
/**
@@ -31,7 +31,7 @@
void removeDataServiceProvider(int slotId);
void setupDataCall(int slotId, int accessNetwork, in DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, in LinkProperties linkProperties,
- int pduSessionId, in SliceInfo sliceInfo,
+ int pduSessionId, in NetworkSliceInfo sliceInfo,
in TrafficDescriptor trafficDescriptor, boolean matchAllRuleAllowed,
IDataServiceCallback callback);
void deactivateDataCall(int slotId, int cid, int reason, IDataServiceCallback callback);
diff --git a/telephony/java/android/telephony/data/SliceInfo.aidl b/telephony/java/android/telephony/data/NetworkSliceInfo.aidl
similarity index 95%
rename from telephony/java/android/telephony/data/SliceInfo.aidl
rename to telephony/java/android/telephony/data/NetworkSliceInfo.aidl
index 286ea5e..e1a11f2 100644
--- a/telephony/java/android/telephony/data/SliceInfo.aidl
+++ b/telephony/java/android/telephony/data/NetworkSliceInfo.aidl
@@ -17,4 +17,4 @@
/** @hide */
package android.telephony.data;
-parcelable SliceInfo;
+parcelable NetworkSliceInfo;
diff --git a/telephony/java/android/telephony/data/SliceInfo.java b/telephony/java/android/telephony/data/NetworkSliceInfo.java
similarity index 68%
rename from telephony/java/android/telephony/data/SliceInfo.java
rename to telephony/java/android/telephony/data/NetworkSliceInfo.java
index 609d111..232a930 100644
--- a/telephony/java/android/telephony/data/SliceInfo.java
+++ b/telephony/java/android/telephony/data/NetworkSliceInfo.java
@@ -19,8 +19,6 @@
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
-import android.annotation.SuppressLint;
-import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -35,11 +33,8 @@
* SliceServiceType defines the type of service provided by the slice, and SliceDifferentiator is
* used to differentiate between multiple slices of the same type. If the devices is not on HPLMN,
* the mappedHplmn versions of these 2 fields indicate the corresponding values in HPLMN.
- *
- * @hide
*/
-@SystemApi
-public final class SliceInfo implements Parcelable {
+public final class NetworkSliceInfo implements Parcelable {
/**
* When set on a Slice Differentiator, this value indicates that there is no corresponding
* Slice.
@@ -68,14 +63,14 @@
/**
* The min acceptable value for a Slice Differentiator
+ * @hide
*/
- @SuppressLint("MinMaxConstant")
public static final int MIN_SLICE_DIFFERENTIATOR = -1;
/**
* The max acceptable value for a Slice Differentiator
+ * @hide
*/
- @SuppressLint("MinMaxConstant")
public static final int MAX_SLICE_DIFFERENTIATOR = 0xFFFFFE;
/** @hide */
@@ -88,6 +83,62 @@
@Retention(RetentionPolicy.SOURCE)
public @interface SliceServiceType {}
+ /**
+ * The slice status is unknown. This can happen during IWLAN->cellular handover when the
+ * NetworkSliceInfo is received over IWLAN.
+ */
+ public static final int SLICE_STATUS_UNKNOWN = 0;
+
+ /**
+ * The slice is configured but not allowed or rejected yet.
+ */
+ public static final int SLICE_STATUS_CONFIGURED = 1;
+
+ /**
+ * The slice is allowed to be used.
+ */
+ public static final int SLICE_STATUS_ALLOWED = 2;
+
+ /**
+ * The slice is rejected because not available in PLMN.
+ */
+ public static final int SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_PLMN = 3;
+
+ /**
+ * The slice is rejected because not available in registered area.
+ */
+ public static final int SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_REGISTERED_AREA = 4;
+
+ /**
+ * The slice is configured by home operator(HPLMN) in default and is used if configured/allowed
+ * slices are not available for the serving PLMN.
+ */
+ public static final int SLICE_STATUS_DEFAULT_CONFIGURED = 5;
+
+ /**
+ * The min acceptable value for a slice status.
+ * @hide
+ */
+ public static final int MIN_SLICE_STATUS = SLICE_STATUS_UNKNOWN;
+
+ /**
+ * The max acceptable value for a slice status.
+ * @hide
+ */
+ public static final int MAX_SLICE_STATUS = SLICE_STATUS_DEFAULT_CONFIGURED;
+
+ /** @hide */
+ @IntDef(prefix = { "SLICE_STATUS_" }, value = {
+ SLICE_STATUS_UNKNOWN,
+ SLICE_STATUS_CONFIGURED,
+ SLICE_STATUS_ALLOWED,
+ SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_PLMN,
+ SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_REGISTERED_AREA,
+ SLICE_STATUS_DEFAULT_CONFIGURED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SliceStatus {}
+
@SliceServiceType
private final int mSliceServiceType;
@@ -97,14 +148,18 @@
private final int mMappedHplmnSliceServiceType;
@IntRange(from = MIN_SLICE_DIFFERENTIATOR, to = MAX_SLICE_DIFFERENTIATOR)
private final int mMappedHplmnSliceDifferentiator;
+ @SliceStatus
+ @IntRange(from = MIN_SLICE_STATUS, to = MAX_SLICE_STATUS)
+ private final int mStatus;
- private SliceInfo(@SliceServiceType int sliceServiceType,
+ private NetworkSliceInfo(@SliceServiceType int sliceServiceType,
int sliceDifferentiator, int mappedHplmnSliceServiceType,
- int mappedHplmnSliceDifferentiator) {
+ int mappedHplmnSliceDifferentiator, int status) {
mSliceServiceType = sliceServiceType;
mSliceDifferentiator = sliceDifferentiator;
mMappedHplmnSliceDifferentiator = mappedHplmnSliceDifferentiator;
mMappedHplmnSliceServiceType = mappedHplmnSliceServiceType;
+ mStatus = status;
}
/**
@@ -141,7 +196,7 @@
}
/**
- * This Slice Differentiator corresponds to a {@link SliceInfo} (S-NSSAI) of the HPLMN;
+ * This Slice Differentiator corresponds to a {@link NetworkSliceInfo} (S-NSSAI) of the HPLMN;
* {@link #getSliceDifferentiator()} is mapped to this value.
* <p/>
* Returns {@link #SLICE_DIFFERENTIATOR_NO_SLICE} if either of the following are true:
@@ -157,11 +212,21 @@
return mMappedHplmnSliceDifferentiator;
}
- private SliceInfo(@NonNull Parcel in) {
+ /**
+ * Field to indicate the current status of the slice.
+ * @return the current status for this slice info.
+ */
+ @SliceStatus
+ public int getStatus() {
+ return mStatus;
+ }
+
+ private NetworkSliceInfo(@NonNull Parcel in) {
mSliceServiceType = in.readInt();
mSliceDifferentiator = in.readInt();
mMappedHplmnSliceServiceType = in.readInt();
mMappedHplmnSliceDifferentiator = in.readInt();
+ mStatus = in.readInt();
}
@Override
@@ -175,20 +240,21 @@
dest.writeInt(mSliceDifferentiator);
dest.writeInt(mMappedHplmnSliceServiceType);
dest.writeInt(mMappedHplmnSliceDifferentiator);
+ dest.writeInt(mStatus);
}
- public static final @android.annotation.NonNull Parcelable.Creator<SliceInfo> CREATOR =
- new Parcelable.Creator<SliceInfo>() {
+ public static final @android.annotation.NonNull Parcelable.Creator<NetworkSliceInfo> CREATOR =
+ new Parcelable.Creator<NetworkSliceInfo>() {
@Override
@NonNull
- public SliceInfo createFromParcel(@NonNull Parcel source) {
- return new SliceInfo(source);
+ public NetworkSliceInfo createFromParcel(@NonNull Parcel source) {
+ return new NetworkSliceInfo(source);
}
@Override
@NonNull
- public SliceInfo[] newArray(int size) {
- return new SliceInfo[size];
+ public NetworkSliceInfo[] newArray(int size) {
+ return new NetworkSliceInfo[size];
}
};
@@ -200,6 +266,7 @@
+ ", mMappedHplmnSliceServiceType="
+ sliceServiceTypeToString(mMappedHplmnSliceServiceType)
+ ", mMappedHplmnSliceDifferentiator=" + mMappedHplmnSliceDifferentiator
+ + ", mStatus=" + sliceStatusToString(mStatus)
+ '}';
}
@@ -218,25 +285,45 @@
}
}
+ private static String sliceStatusToString(@SliceStatus int sliceStatus) {
+ switch(sliceStatus) {
+ case SLICE_STATUS_UNKNOWN:
+ return "UNKNOWN";
+ case SLICE_STATUS_CONFIGURED:
+ return "CONFIGURED";
+ case SLICE_STATUS_ALLOWED:
+ return "ALLOWED";
+ case SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_PLMN:
+ return "REJECTED_NOT_AVAILABLE_IN_PLMN";
+ case SLICE_STATUS_REJECTED_NOT_AVAILABLE_IN_REGISTERED_AREA:
+ return "REJECTED_NOT_AVAILABLE_IN_REGISTERED_AREA";
+ case SLICE_STATUS_DEFAULT_CONFIGURED:
+ return "DEFAULT_CONFIGURED";
+ default:
+ return Integer.toString(sliceStatus);
+ }
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- SliceInfo sliceInfo = (SliceInfo) o;
+ NetworkSliceInfo sliceInfo = (NetworkSliceInfo) o;
return mSliceServiceType == sliceInfo.mSliceServiceType
&& mSliceDifferentiator == sliceInfo.mSliceDifferentiator
&& mMappedHplmnSliceServiceType == sliceInfo.mMappedHplmnSliceServiceType
- && mMappedHplmnSliceDifferentiator == sliceInfo.mMappedHplmnSliceDifferentiator;
+ && mMappedHplmnSliceDifferentiator == sliceInfo.mMappedHplmnSliceDifferentiator
+ && mStatus == sliceInfo.mStatus;
}
@Override
public int hashCode() {
return Objects.hash(mSliceServiceType, mSliceDifferentiator, mMappedHplmnSliceServiceType,
- mMappedHplmnSliceDifferentiator);
+ mMappedHplmnSliceDifferentiator, mStatus);
}
/**
- * Provides a convenient way to set the fields of a {@link SliceInfo} when creating a
+ * Provides a convenient way to set the fields of a {@link NetworkSliceInfo} when creating a
* new instance.
*
* <p>The example below shows how you might create a new {@code SliceInfo}:
@@ -257,6 +344,9 @@
private int mMappedHplmnSliceServiceType = SLICE_SERVICE_TYPE_NONE;
@IntRange(from = MIN_SLICE_DIFFERENTIATOR, to = MAX_SLICE_DIFFERENTIATOR)
private int mMappedHplmnSliceDifferentiator = SLICE_DIFFERENTIATOR_NO_SLICE;
+ @SliceStatus
+ @IntRange(from = MIN_SLICE_STATUS, to = MAX_SLICE_STATUS)
+ private int mStatus = SLICE_STATUS_UNKNOWN;
/**
* Default constructor for Builder.
@@ -281,8 +371,7 @@
* A value of {@link #SLICE_DIFFERENTIATOR_NO_SLICE} indicates that there is no
* corresponding Slice.
*
- * @throws IllegalArgumentException if the parameter is not between
- * {@link #MIN_SLICE_DIFFERENTIATOR} and {@link #MAX_SLICE_DIFFERENTIATOR}.
+ * @throws IllegalArgumentException if the parameter is not in the expected range.
*
* @return The same instance of the builder.
*/
@@ -316,8 +405,7 @@
* A value of {@link #SLICE_DIFFERENTIATOR_NO_SLICE} indicates that there is no
* corresponding Slice of the HPLMN.
*
- * @throws IllegalArgumentException if the parameter is not between
- * {@link #MIN_SLICE_DIFFERENTIATOR} and {@link #MAX_SLICE_DIFFERENTIATOR}.
+ * @throws IllegalArgumentException if the parameter is not in the expected range.
*
* @return The same instance of the builder.
*/
@@ -334,14 +422,31 @@
}
/**
- * Build the {@link SliceInfo}.
+ * Set the slice status.
*
- * @return the {@link SliceInfo} object.
+ * @throws IllegalArgumentException if the status is invalid.
+ *
+ * @return The same instance of the builder.
*/
@NonNull
- public SliceInfo build() {
- return new SliceInfo(this.mSliceServiceType, this.mSliceDifferentiator,
- this.mMappedHplmnSliceServiceType, this.mMappedHplmnSliceDifferentiator);
+ public Builder setStatus(@SliceStatus int status) {
+ if (status < MIN_SLICE_STATUS || status > MAX_SLICE_STATUS) {
+ throw new IllegalArgumentException("The slice status is not valid");
+ }
+ this.mStatus = status;
+ return this;
+ }
+
+ /**
+ * Build the {@link NetworkSliceInfo}.
+ *
+ * @return the {@link NetworkSliceInfo} object.
+ */
+ @NonNull
+ public NetworkSliceInfo build() {
+ return new NetworkSliceInfo(this.mSliceServiceType, this.mSliceDifferentiator,
+ this.mMappedHplmnSliceServiceType, this.mMappedHplmnSliceDifferentiator,
+ this.mStatus);
}
}
}
diff --git a/telephony/java/android/telephony/data/SliceInfo.aidl b/telephony/java/android/telephony/data/RouteSelectionDescriptor.aidl
similarity index 87%
copy from telephony/java/android/telephony/data/SliceInfo.aidl
copy to telephony/java/android/telephony/data/RouteSelectionDescriptor.aidl
index 286ea5e..563a00e 100644
--- a/telephony/java/android/telephony/data/SliceInfo.aidl
+++ b/telephony/java/android/telephony/data/RouteSelectionDescriptor.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-/** @hide */
package android.telephony.data;
-parcelable SliceInfo;
+parcelable RouteSelectionDescriptor;
diff --git a/telephony/java/android/telephony/data/RouteSelectionDescriptor.java b/telephony/java/android/telephony/data/RouteSelectionDescriptor.java
new file mode 100644
index 0000000..c2457f2
--- /dev/null
+++ b/telephony/java/android/telephony/data/RouteSelectionDescriptor.java
@@ -0,0 +1,263 @@
+/**
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.data;
+
+import android.annotation.IntDef;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a single route selection descriptor as defined in
+ * 3GPP TS 24.526.
+ */
+public final class RouteSelectionDescriptor implements Parcelable {
+ /**
+ * The min acceptable value for the precedence of a route selection descriptor.
+ * @hide
+ */
+ public static final int MIN_ROUTE_PRECEDENCE = 0;
+
+ /**
+ * The max acceptable value for the precedence of a route selection descriptor.
+ * @hide
+ */
+ public static final int MAX_ROUTE_PRECEDENCE = 255;
+
+ /**
+ * The route selection descriptor is for the session with IPV4 type.
+ */
+ public static final int SESSION_TYPE_IPV4 = 0;
+
+ /**
+ * The route selection descriptor is for the session with IPV6 type.
+ */
+ public static final int SESSION_TYPE_IPV6 = 1;
+
+ /**
+ * The route selection descriptor is for the session with both IP and IPV6 types.
+ */
+ public static final int SESSION_TYPE_IPV4V6 = 2;
+
+ /** @hide */
+ @IntDef(prefix = { "SESSION_TYPE_" }, value = {
+ SESSION_TYPE_IPV4,
+ SESSION_TYPE_IPV6,
+ SESSION_TYPE_IPV4V6,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RouteSessionType {}
+
+ /**
+ * The route selection descriptor is using SSC mode 1. The session will provide continual
+ * support when UE's location is updated.
+ */
+ public static final int ROUTE_SSC_MODE_1 = 1;
+
+ /**
+ * The route selection descriptor is using SSC mode 2. The new session for the same network
+ * will be established after releasing the old session when UE's location is updated.
+ */
+ public static final int ROUTE_SSC_MODE_2 = 2;
+
+ /**
+ * The route selection descriptor is using SSC mode 3. The new session for the same network is
+ * allowed to be established before releasing the old session when UE's location is updated.
+ */
+ public static final int ROUTE_SSC_MODE_3 = 3;
+
+ /**
+ * The min acceptable value for the SSC mode of a route selection descriptor.
+ * @hide
+ */
+ public static final int MIN_ROUTE_SSC_MODE = ROUTE_SSC_MODE_1;
+
+ /**
+ * The max acceptable value for the SSC mode of a route selection descriptor.
+ * @hide
+ */
+ public static final int MAX_ROUTE_SSC_MODE = ROUTE_SSC_MODE_3;
+
+ /** @hide */
+ @IntDef(prefix = { "ROUTE_SSC_MODE_" }, value = {
+ ROUTE_SSC_MODE_1,
+ ROUTE_SSC_MODE_2,
+ ROUTE_SSC_MODE_3,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RouteSscMode {}
+
+ @IntRange(from = MIN_ROUTE_PRECEDENCE, to = MAX_ROUTE_PRECEDENCE)
+ private final int mPrecedence;
+ @RouteSessionType
+ private final int mSessionType;
+ @RouteSscMode
+ @IntRange(from = MIN_ROUTE_SSC_MODE, to = MAX_ROUTE_SSC_MODE)
+ private final int mSscMode;
+ private final List<NetworkSliceInfo> mSliceInfo;
+ private final List<String> mDnn;
+
+ /** @hide */
+ RouteSelectionDescriptor(android.hardware.radio.V1_6.RouteSelectionDescriptor rsd) {
+ this(rsd.precedence, rsd.sessionType.value(), rsd.sscMode.value(), rsd.sliceInfo,
+ rsd.dnn);
+ }
+
+ /** @hide */
+ public RouteSelectionDescriptor(int precedence, int sessionType, int sscMode,
+ List<android.hardware.radio.V1_6.SliceInfo> sliceInfo, List<String> dnn) {
+ mPrecedence = precedence;
+ mSessionType = sessionType;
+ mSscMode = sscMode;
+ mSliceInfo = new ArrayList<NetworkSliceInfo>();
+ for (android.hardware.radio.V1_6.SliceInfo si : sliceInfo) {
+ mSliceInfo.add(sliceInfoBuilder(si));
+ }
+ mDnn = new ArrayList<String>();
+ mDnn.addAll(dnn);
+ }
+
+ private NetworkSliceInfo sliceInfoBuilder(android.hardware.radio.V1_6.SliceInfo si) {
+ NetworkSliceInfo.Builder builder = new NetworkSliceInfo.Builder()
+ .setSliceServiceType(si.sst)
+ .setMappedHplmnSliceServiceType(si.mappedHplmnSst);
+ if (si.sliceDifferentiator != NetworkSliceInfo.SLICE_DIFFERENTIATOR_NO_SLICE) {
+ builder
+ .setSliceDifferentiator(si.sliceDifferentiator)
+ .setMappedHplmnSliceDifferentiator(si.mappedHplmnSD);
+ }
+ return builder.build();
+ }
+
+ private RouteSelectionDescriptor(Parcel p) {
+ mPrecedence = p.readInt();
+ mSessionType = p.readInt();
+ mSscMode = p.readInt();
+ mSliceInfo = p.createTypedArrayList(NetworkSliceInfo.CREATOR);
+ mDnn = new ArrayList<String>();
+ p.readStringList(mDnn);
+ }
+
+ /**
+ * Precedence value in the range of 0 to 255. Higher value has lower precedence.
+ * @return the precedence value for this route selection descriptor.
+ */
+ @IntRange(from = MIN_ROUTE_PRECEDENCE, to = MAX_ROUTE_PRECEDENCE)
+ public int getPrecedence() {
+ return mPrecedence;
+ }
+
+ /**
+ * This is used for checking which session type defined in 3GPP TS 23.501 is allowed for the
+ * route in a route selection descriptor.
+ * @return the session type for this route selection descriptor.
+ */
+ @RouteSessionType
+ public int getSessionType() {
+ return mSessionType;
+ }
+
+ /**
+ * SSC mode stands for Session and Service Continuity mode (which specifies the IP continuity
+ * mode) as defined in 3GPP TS 23.501.
+ * @return the SSC mode for this route selection descriptor.
+ */
+ @RouteSscMode
+ public int getSscMode() {
+ return mSscMode;
+ }
+
+ /**
+ * This is the list of all the slices available in the route selection descriptor as indicated
+ * by the network. These are the slices that can be used by the device if this route selection
+ * descriptor is used based the traffic (see 3GPP TS 23.501 for details).
+ * @return the list of all the slices available in the route selection descriptor.
+ */
+ public @NonNull List<NetworkSliceInfo> getSliceInfo() {
+ return mSliceInfo;
+ }
+
+ /**
+ * DNN stands for Data Network Name and represents an APN as defined in 3GPP TS 23.003. There
+ * can be 0 or more DNNs specified in a route selection descriptor.
+ * @return the list of DNN for this route selection descriptor.
+ */
+ public @NonNull List<String> getDataNetworkName() {
+ return mDnn;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mPrecedence);
+ dest.writeInt(mSessionType);
+ dest.writeInt(mSscMode);
+ dest.writeTypedList(mSliceInfo, flags);
+ dest.writeStringList(mDnn);
+ }
+
+ public static final @NonNull Parcelable.Creator<RouteSelectionDescriptor> CREATOR =
+ new Parcelable.Creator<RouteSelectionDescriptor>() {
+ @Override
+ public RouteSelectionDescriptor createFromParcel(Parcel source) {
+ return new RouteSelectionDescriptor(source);
+ }
+
+ @Override
+ public RouteSelectionDescriptor[] newArray(int size) {
+ return new RouteSelectionDescriptor[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RouteSelectionDescriptor that = (RouteSelectionDescriptor) o;
+ return mPrecedence == that.mPrecedence
+ && mSessionType == that.mSessionType
+ && mSscMode == that.mSscMode
+ && mSliceInfo.size() == that.mSliceInfo.size()
+ && mSliceInfo.containsAll(that.mSliceInfo)
+ && mDnn.size() == that.mDnn.size()
+ && mDnn.containsAll(that.mDnn);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mPrecedence, mSessionType, mSscMode, mSliceInfo, mDnn);
+ }
+
+ @Override
+ public String toString() {
+ return "{.precedence = " + mPrecedence + ", .sessionType = " + mSessionType
+ + ", .sscMode = " + mSscMode + ", .sliceInfo = " + mSliceInfo
+ + ", .dnn = " + mDnn + "}";
+ }
+}
diff --git a/telephony/java/android/telephony/data/SliceInfo.aidl b/telephony/java/android/telephony/data/SlicingConfig.aidl
similarity index 87%
copy from telephony/java/android/telephony/data/SliceInfo.aidl
copy to telephony/java/android/telephony/data/SlicingConfig.aidl
index 286ea5e..ad93d8c 100644
--- a/telephony/java/android/telephony/data/SliceInfo.aidl
+++ b/telephony/java/android/telephony/data/SlicingConfig.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-/** @hide */
package android.telephony.data;
-parcelable SliceInfo;
+parcelable SlicingConfig;
diff --git a/telephony/java/android/telephony/data/SlicingConfig.java b/telephony/java/android/telephony/data/SlicingConfig.java
new file mode 100644
index 0000000..990e4d2
--- /dev/null
+++ b/telephony/java/android/telephony/data/SlicingConfig.java
@@ -0,0 +1,137 @@
+/**
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.data;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a slicing configuration
+ */
+public final class SlicingConfig implements Parcelable {
+ private final List<UrspRule> mUrspRules;
+ private final List<NetworkSliceInfo> mSliceInfo;
+
+ public SlicingConfig() {
+ mUrspRules = new ArrayList<UrspRule>();
+ mSliceInfo = new ArrayList<NetworkSliceInfo>();
+ }
+
+ /** @hide */
+ public SlicingConfig(android.hardware.radio.V1_6.SlicingConfig sc) {
+ this(sc.urspRules, sc.sliceInfo);
+ }
+
+ /** @hide */
+ public SlicingConfig(List<android.hardware.radio.V1_6.UrspRule> urspRules,
+ List<android.hardware.radio.V1_6.SliceInfo> sliceInfo) {
+ mUrspRules = new ArrayList<UrspRule>();
+ for (android.hardware.radio.V1_6.UrspRule ur : urspRules) {
+ mUrspRules.add(new UrspRule(ur.precedence, ur.trafficDescriptors,
+ ur.routeSelectionDescriptor));
+ }
+ mSliceInfo = new ArrayList<NetworkSliceInfo>();
+ for (android.hardware.radio.V1_6.SliceInfo si : sliceInfo) {
+ mSliceInfo.add(sliceInfoBuilder(si));
+ }
+ }
+
+ private NetworkSliceInfo sliceInfoBuilder(android.hardware.radio.V1_6.SliceInfo si) {
+ NetworkSliceInfo.Builder builder = new NetworkSliceInfo.Builder()
+ .setSliceServiceType(si.sst)
+ .setMappedHplmnSliceServiceType(si.mappedHplmnSst);
+ if (si.sliceDifferentiator != NetworkSliceInfo.SLICE_DIFFERENTIATOR_NO_SLICE) {
+ builder
+ .setSliceDifferentiator(si.sliceDifferentiator)
+ .setMappedHplmnSliceDifferentiator(si.mappedHplmnSD);
+ }
+ return builder.build();
+ }
+
+ /** @hide */
+ public SlicingConfig(Parcel p) {
+ mUrspRules = p.createTypedArrayList(UrspRule.CREATOR);
+ mSliceInfo = p.createTypedArrayList(NetworkSliceInfo.CREATOR);
+ }
+
+ /**
+ * This list contains the current URSP rules. Empty list represents that no rules are
+ * configured.
+ * @return the current URSP rules for this slicing configuration.
+ */
+ public @NonNull List<UrspRule> getUrspRules() {
+ return mUrspRules;
+ }
+
+ /**
+ * @return the list of all slices for this slicing configuration.
+ */
+ public @NonNull List<NetworkSliceInfo> getSliceInfo() {
+ return mSliceInfo;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeTypedList(mUrspRules, flags);
+ dest.writeTypedList(mSliceInfo, flags);
+ }
+
+ public static final @NonNull Parcelable.Creator<SlicingConfig> CREATOR =
+ new Parcelable.Creator<SlicingConfig>() {
+ @Override
+ public SlicingConfig createFromParcel(Parcel source) {
+ return new SlicingConfig(source);
+ }
+
+ @Override
+ public SlicingConfig[] newArray(int size) {
+ return new SlicingConfig[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SlicingConfig that = (SlicingConfig) o;
+ return mUrspRules.size() == that.mUrspRules.size()
+ && mUrspRules.containsAll(that.mUrspRules)
+ && mSliceInfo.size() == that.mSliceInfo.size()
+ && mSliceInfo.containsAll(that.mSliceInfo);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mUrspRules, mSliceInfo);
+ }
+
+ @Override
+ public String toString() {
+ return "{.urspRules = " + mUrspRules + ", .sliceInfo = " + mSliceInfo + "}";
+ }
+}
diff --git a/telephony/java/android/telephony/data/TrafficDescriptor.java b/telephony/java/android/telephony/data/TrafficDescriptor.java
index 480379d..d813bc5 100644
--- a/telephony/java/android/telephony/data/TrafficDescriptor.java
+++ b/telephony/java/android/telephony/data/TrafficDescriptor.java
@@ -18,20 +18,17 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
/**
- * A traffic descriptor, as defined in 3GPP TS 24.526 Section 5.2. It is used for URSP traffic
- * matching as described in 3GPP TS 24.526 Section 4.2.2. It includes an optional DNN, which,
- * if present, must be used for traffic matching; it does not specify the end point to be used for
- * the data call.
- * @hide
+ * A traffic descriptor, as defined in 3GPP TS 24.526 Section 5.2. It is used for UE Route Selection
+ * Policy(URSP) traffic matching as described in 3GPP TS 24.526 Section 4.2.2. It includes an
+ * optional Data Network Name(DNN), which, if present, must be used for traffic matching; it does
+ * not specify the end point to be used for the data call.
*/
-@SystemApi
public final class TrafficDescriptor implements Parcelable {
private final String mDnn;
private final String mOsAppId;
@@ -45,8 +42,10 @@
* Create a traffic descriptor, as defined in 3GPP TS 24.526 Section 5.2
* @param dnn optional DNN, which must be used for traffic matching, if present
* @param osAppId OsId + osAppId of the traffic descriptor
+ *
+ * @hide
*/
- public TrafficDescriptor(@Nullable String dnn, @Nullable String osAppId) {
+ public TrafficDescriptor(String dnn, String osAppId) {
mDnn = dnn;
mOsAppId = osAppId;
}
@@ -55,12 +54,13 @@
* DNN stands for Data Network Name and represents an APN as defined in 3GPP TS 23.003.
* @return the DNN of this traffic descriptor.
*/
- public @Nullable String getDnn() {
+ public @Nullable String getDataNetworkName() {
return mDnn;
}
/**
- * OsAppId represents the OsId + OsAppId as defined in 3GPP TS 24.526 Section 5.2.
+ * OsAppId is the app id as defined in 3GPP TS 24.526 Section 5.2, and it identifies a traffic
+ * category.
* @return the OS App ID of this traffic descriptor.
*/
public @Nullable String getOsAppId() {
@@ -108,4 +108,65 @@
public int hashCode() {
return Objects.hash(mDnn, mOsAppId);
}
+
+ /**
+ * Provides a convenient way to set the fields of a {@link TrafficDescriptor} when creating a
+ * new instance.
+ *
+ * <p>The example below shows how you might create a new {@code TrafficDescriptor}:
+ *
+ * <pre><code>
+ *
+ * TrafficDescriptor response = new TrafficDescriptor.Builder()
+ * .setDnn("")
+ * .build();
+ * </code></pre>
+ */
+ public static final class Builder {
+ private String mDnn = null;
+ private String mOsAppId = null;
+
+ /**
+ * Default constructor for Builder.
+ */
+ public Builder() {
+ }
+
+ /**
+ * Set the Data Network Name(DNN).
+ *
+ * @return The same instance of the builder.
+ */
+ @NonNull
+ public Builder setDataNetworkName(@NonNull String dnn) {
+ this.mDnn = dnn;
+ return this;
+ }
+
+ /**
+ * Set the OS App ID.
+ *
+ * @return The same instance of the builder.
+ */
+ @NonNull
+ public Builder setOsAppId(@NonNull String osAppId) {
+ this.mOsAppId = osAppId;
+ return this;
+ }
+
+ /**
+ * Build the {@link TrafficDescriptor}.
+ *
+ * @throws IllegalArgumentException if DNN and OS App ID are null.
+ *
+ * @return the {@link TrafficDescriptor} object.
+ */
+ @NonNull
+ public TrafficDescriptor build() {
+ if (this.mDnn == null && this.mOsAppId == null) {
+ throw new IllegalArgumentException("DNN and OS App ID are null");
+ }
+ return new TrafficDescriptor(this.mDnn, this.mOsAppId);
+ }
+ }
}
diff --git a/telephony/java/android/telephony/data/SliceInfo.aidl b/telephony/java/android/telephony/data/UrspRule.aidl
similarity index 87%
copy from telephony/java/android/telephony/data/SliceInfo.aidl
copy to telephony/java/android/telephony/data/UrspRule.aidl
index 286ea5e..2bed583 100644
--- a/telephony/java/android/telephony/data/SliceInfo.aidl
+++ b/telephony/java/android/telephony/data/UrspRule.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-/** @hide */
package android.telephony.data;
-parcelable SliceInfo;
+parcelable UrspRule;
diff --git a/telephony/java/android/telephony/data/UrspRule.java b/telephony/java/android/telephony/data/UrspRule.java
new file mode 100644
index 0000000..e2c47fd
--- /dev/null
+++ b/telephony/java/android/telephony/data/UrspRule.java
@@ -0,0 +1,178 @@
+/**
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.data;
+
+import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.hardware.radio.V1_6.OptionalDnn;
+import android.hardware.radio.V1_6.OptionalOsAppId;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a single URSP rule as defined in 3GPP TS 24.526. URSP stands for UE Route Selection
+ * Policy. In 5G, network can provide URSP information to devices which provides information on
+ * what connection parameters should be used for what traffic.
+ */
+public final class UrspRule implements Parcelable {
+ /**
+ * The min acceptable value for the precedence of a URSP rule.
+ * @hide
+ */
+ public static final int MIN_URSP_PRECEDENCE = 0;
+
+ /**
+ * The max acceptable value for the precedence of a URSP rule.
+ * @hide
+ */
+ public static final int MAX_URSP_PRECEDENCE = 255;
+
+ @IntRange(from = MIN_URSP_PRECEDENCE, to = MAX_URSP_PRECEDENCE)
+ private final int mPrecedence;
+ private final List<TrafficDescriptor> mTrafficDescriptors;
+ private final List<RouteSelectionDescriptor> mRouteSelectionDescriptor;
+
+ UrspRule(android.hardware.radio.V1_6.UrspRule ur) {
+ this(ur.precedence, ur.trafficDescriptors, ur.routeSelectionDescriptor);
+ }
+
+ /** @hide */
+ public UrspRule(int precedence,
+ List<android.hardware.radio.V1_6.TrafficDescriptor> trafficDescriptors,
+ List<android.hardware.radio.V1_6.RouteSelectionDescriptor> routeSelectionDescriptor) {
+ mPrecedence = precedence;
+ mTrafficDescriptors = new ArrayList<TrafficDescriptor>();
+ for (android.hardware.radio.V1_6.TrafficDescriptor td : trafficDescriptors) {
+ mTrafficDescriptors.add(convertToTrafficDescriptor(td));
+ }
+ mRouteSelectionDescriptor = new ArrayList<RouteSelectionDescriptor>();
+ for (android.hardware.radio.V1_6.RouteSelectionDescriptor rsd : routeSelectionDescriptor) {
+ mRouteSelectionDescriptor.add(new RouteSelectionDescriptor(rsd));
+ }
+ }
+
+ /** Convert an ArrayList of Bytes to an exactly-sized primitive array */
+ private byte[] arrayListToPrimitiveArray(ArrayList<Byte> bytes) {
+ byte[] ret = new byte[bytes.size()];
+ for (int i = 0; i < ret.length; i++) {
+ ret[i] = bytes.get(i);
+ }
+ return ret;
+ }
+
+ private TrafficDescriptor convertToTrafficDescriptor(
+ android.hardware.radio.V1_6.TrafficDescriptor td) {
+ String dnn = td.dnn.getDiscriminator() == OptionalDnn.hidl_discriminator.noinit
+ ? null : td.dnn.value();
+ String osAppId = td.osAppId.getDiscriminator() == OptionalOsAppId.hidl_discriminator.noinit
+ ? null : new String(arrayListToPrimitiveArray(td.osAppId.value().osAppId));
+ TrafficDescriptor.Builder builder = new TrafficDescriptor.Builder();
+ if (dnn != null) {
+ builder.setDataNetworkName(dnn);
+ }
+ if (osAppId != null) {
+ builder.setOsAppId(osAppId);
+ }
+ return builder.build();
+ }
+
+ private UrspRule(Parcel p) {
+ mPrecedence = p.readInt();
+ mTrafficDescriptors = p.createTypedArrayList(TrafficDescriptor.CREATOR);
+ mRouteSelectionDescriptor = p.createTypedArrayList(RouteSelectionDescriptor.CREATOR);
+ }
+
+ /**
+ * Precedence value in the range of 0 to 255. Higher value has lower precedence.
+ * @return the precedence value for this URSP rule.
+ */
+ @IntRange(from = MIN_URSP_PRECEDENCE, to = MAX_URSP_PRECEDENCE)
+ public int getPrecedence() {
+ return mPrecedence;
+ }
+
+ /**
+ * These traffic descriptors are used as a matcher for network requests.
+ * @return the traffic descriptors which are associated to this URSP rule.
+ */
+ public @NonNull List<TrafficDescriptor> getTrafficDescriptors() {
+ return mTrafficDescriptors;
+ }
+
+ /**
+ * List of routes (connection parameters) that must be used by the device for requests matching
+ * a traffic descriptor.
+ * @return the route selection descriptors which are associated to this URSP rule.
+ */
+ public @NonNull List<RouteSelectionDescriptor> getRouteSelectionDescriptor() {
+ return mRouteSelectionDescriptor;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mPrecedence);
+ dest.writeTypedList(mTrafficDescriptors, flags);
+ dest.writeTypedList(mRouteSelectionDescriptor, flags);
+ }
+
+ public static final @NonNull Parcelable.Creator<UrspRule> CREATOR =
+ new Parcelable.Creator<UrspRule>() {
+ @Override
+ public UrspRule createFromParcel(Parcel source) {
+ return new UrspRule(source);
+ }
+
+ @Override
+ public UrspRule[] newArray(int size) {
+ return new UrspRule[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ UrspRule that = (UrspRule) o;
+ return mPrecedence == that.mPrecedence
+ && mTrafficDescriptors.size() == that.mTrafficDescriptors.size()
+ && mTrafficDescriptors.containsAll(that.mTrafficDescriptors)
+ && mRouteSelectionDescriptor.size() == that.mRouteSelectionDescriptor.size()
+ && mRouteSelectionDescriptor.containsAll(that.mRouteSelectionDescriptor);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mPrecedence, mTrafficDescriptors, mRouteSelectionDescriptor);
+ }
+
+ @Override
+ public String toString() {
+ return "{.precedence = " + mPrecedence + ", .trafficDescriptors = " + mTrafficDescriptors
+ + ", .routeSelectionDescriptor = " + mRouteSelectionDescriptor + "}";
+ }
+}
diff --git a/telephony/java/android/telephony/ims/ImsCallSession.java b/telephony/java/android/telephony/ims/ImsCallSession.java
index 0aff997..dfe5e6c9 100755
--- a/telephony/java/android/telephony/ims/ImsCallSession.java
+++ b/telephony/java/android/telephony/ims/ImsCallSession.java
@@ -766,7 +766,10 @@
* The method is only valid to call when the session state is in
* {@link ImsCallSession.State#IDLE}.
*
- * @param callee dialed string to make the call to
+ * @param callee dial string to make the call to. The platform passes the dialed number
+ * entered by the user as-is. The {@link ImsService} should ensure that the
+ * number is formatted in SIP messages appropriately (e.g. using
+ * {@link android.telephony.PhoneNumberUtils#formatNumberToE164(String, String)}).
* @param profile call profile to make the call with the specified service type,
* call type and media information
* @see Listener#callSessionStarted, Listener#callSessionStartFailed
@@ -788,7 +791,10 @@
* The method is only valid to call when the session state is in
* {@link ImsCallSession.State#IDLE}.
*
- * @param participants participant list to initiate an IMS conference call
+ * @param participants participant list to initiate an IMS conference call. The platform passes
+ * the dialed numbers entered by the user as-is. The {@link ImsService} should
+ * ensure that the number is formatted in SIP messages appropriately (e.g. using
+ * {@link android.telephony.PhoneNumberUtils#formatNumberToE164(String, String)}).
* @param profile call profile to make the call with the specified service type,
* call type and media information
* @see Listener#callSessionStarted, Listener#callSessionStartFailed
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index ae5f997..d812b46 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -2447,4 +2447,10 @@
* Gets the current phone capability.
*/
PhoneCapability getPhoneCapability();
+
+ /**
+ * Request to get the current slicing configuration including URSP rules and
+ * NSSAIs (configured, allowed and rejected).
+ */
+ void getSlicingConfig(in ResultReceiver callback);
}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 822fc44..fe8e671 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -527,6 +527,7 @@
int RIL_REQUEST_SET_DATA_THROTTLING = 221;
int RIL_REQUEST_SET_ALLOWED_NETWORK_TYPES_BITMAP = 222;
int RIL_REQUEST_GET_ALLOWED_NETWORK_TYPES_BITMAP = 223;
+ int RIL_REQUEST_GET_SLICING_CONFIG = 224;
/* Responses begin */
int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;