Merge "MediaCodec: Pass missing C2Info for MediaCodecLinearBlock."
diff --git a/StubLibraries.bp b/StubLibraries.bp
index 90bac37..2f3945f 100644
--- a/StubLibraries.bp
+++ b/StubLibraries.bp
@@ -68,6 +68,7 @@
"android.hardware.cas-V1.2-java",
"android.hardware.health-V1.0-java-constants",
"android.hardware.radio-V1.5-java",
+ "android.hardware.radio-V1.6-java",
"android.hardware.thermal-V1.0-java-constants",
"android.hardware.thermal-V2.0-java",
"android.hardware.tv.input-V1.0-java-constants",
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 44917df..d36bb9c 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -9616,6 +9616,25 @@
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DataSpecificRegistrationInfo> CREATOR;
}
+ public final class DataThrottlingRequest implements android.os.Parcelable {
+ method public int describeContents();
+ method public long getCompletionDurationMillis();
+ method public int getDataThrottlingAction();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DataThrottlingRequest> CREATOR;
+ field public static final int DATA_THROTTLING_ACTION_HOLD = 3; // 0x3
+ field public static final int DATA_THROTTLING_ACTION_NO_DATA_THROTTLING = 0; // 0x0
+ field public static final int DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER = 2; // 0x2
+ field public static final int DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER = 1; // 0x1
+ }
+
+ public static final class DataThrottlingRequest.Builder {
+ ctor public DataThrottlingRequest.Builder();
+ method @NonNull public android.telephony.DataThrottlingRequest build();
+ method @NonNull public android.telephony.DataThrottlingRequest.Builder setCompletionDurationMillis(long);
+ method @NonNull public android.telephony.DataThrottlingRequest.Builder setDataThrottlingAction(int);
+ }
+
public final class ImsiEncryptionInfo implements android.os.Parcelable {
method public int describeContents();
method @Nullable public String getKeyIdentifier();
@@ -10197,6 +10216,7 @@
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void resetOtaEmergencyNumberDbFilePath();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean resetRadioConfig();
method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int sendThermalMitigationRequest(@NonNull android.telephony.ThermalMitigationRequest);
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallForwarding(@NonNull android.telephony.CallForwardingInfo, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
@@ -10314,6 +10334,11 @@
field public static final int SRVCC_STATE_HANDOVER_FAILED = 2; // 0x2
field public static final int SRVCC_STATE_HANDOVER_NONE = -1; // 0xffffffff
field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
+ field public static final int THERMAL_MITIGATION_RESULT_INVALID_STATE = 3; // 0x3
+ field public static final int THERMAL_MITIGATION_RESULT_MODEM_ERROR = 1; // 0x1
+ field public static final int THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE = 2; // 0x2
+ field public static final int THERMAL_MITIGATION_RESULT_SUCCESS = 0; // 0x0
+ field public static final int THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR = 4; // 0x4
}
public static interface TelephonyManager.CallForwardingInfoCallback {
@@ -10325,6 +10350,24 @@
field public static final int RESULT_SUCCESS = 0; // 0x0
}
+ public final class ThermalMitigationRequest implements android.os.Parcelable {
+ method public int describeContents();
+ method @Nullable public android.telephony.DataThrottlingRequest getDataThrottlingRequest();
+ method public int getThermalMitigationAction();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ThermalMitigationRequest> CREATOR;
+ field public static final int THERMAL_MITIGATION_ACTION_DATA_THROTTLING = 0; // 0x0
+ field public static final int THERMAL_MITIGATION_ACTION_RADIO_OFF = 2; // 0x2
+ field public static final int THERMAL_MITIGATION_ACTION_VOICE_ONLY = 1; // 0x1
+ }
+
+ public static final class ThermalMitigationRequest.Builder {
+ ctor public ThermalMitigationRequest.Builder();
+ method @NonNull public android.telephony.ThermalMitigationRequest build();
+ method @NonNull public android.telephony.ThermalMitigationRequest.Builder setDataThrottlingRequest(@NonNull android.telephony.DataThrottlingRequest);
+ method @NonNull public android.telephony.ThermalMitigationRequest.Builder setThermalMitigationAction(int);
+ }
+
public final class UiccAccessRule implements android.os.Parcelable {
ctor public UiccAccessRule(byte[], @Nullable String, long);
method public int describeContents();
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index d10e33f..496ac3b 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -189,6 +189,7 @@
import android.util.ArrayMap;
import android.util.Log;
import android.util.Slog;
+import android.uwb.UwbManager;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.WindowManager;
@@ -719,6 +720,14 @@
return new SerialManager(ctx, ISerialManager.Stub.asInterface(b));
}});
+ registerService(Context.UWB_SERVICE, UwbManager.class,
+ new CachedServiceFetcher<UwbManager>() {
+ @Override
+ public UwbManager createService(ContextImpl ctx) {
+ return UwbManager.getInstance();
+ }
+ });
+
registerService(Context.VIBRATOR_SERVICE, Vibrator.class,
new CachedServiceFetcher<Vibrator>() {
@Override
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 7ffcead..92ede1c 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3513,6 +3513,7 @@
//@hide: TIME_ZONE_DETECTOR_SERVICE,
PERMISSION_SERVICE,
LIGHTS_SERVICE,
+ UWB_SERVICE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ServiceName {}
@@ -5179,6 +5180,15 @@
/**
* Use with {@link #getSystemService(String)} to retrieve a
+ * {@link android.uwb.UwbManager}.
+ *
+ * @see #getSystemService(String)
+ * @hide
+ */
+ public static final String UWB_SERVICE = "uwb";
+
+ /**
+ * Use with {@link #getSystemService(String)} to retrieve a
* {@link android.app.DreamManager} for controlling Dream states.
*
* @see #getSystemService(String)
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 74463fd..50ef08a 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2500,6 +2500,15 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device is capable of communicating with
+ * other devices via ultra wideband.
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_UWB = "android.hardware.uwb";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
* {@link #hasSystemFeature}: The device supports connecting to USB devices
* as the USB host.
*/
diff --git a/core/java/android/uwb/AdapterStateListener.java b/core/java/android/uwb/AdapterStateListener.java
new file mode 100644
index 0000000..8875af3
--- /dev/null
+++ b/core/java/android/uwb/AdapterStateListener.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 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.uwb;
+
+import android.annotation.NonNull;
+import android.os.Binder;
+import android.os.RemoteException;
+import android.util.Log;
+import android.uwb.UwbManager.AdapterStateCallback;
+import android.uwb.UwbManager.AdapterStateCallback.StateChangedReason;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+/**
+ * @hide
+ */
+public class AdapterStateListener extends IUwbAdapterStateCallbacks.Stub {
+ private static final String TAG = "Uwb.StateListener";
+
+ private final IUwbAdapter mAdapter;
+ private boolean mIsRegistered = false;
+
+ private final Map<AdapterStateCallback, Executor> mCallbackMap = new HashMap<>();
+
+ @StateChangedReason
+ private int mAdapterStateChangeReason = AdapterStateCallback.STATE_CHANGED_REASON_ERROR_UNKNOWN;
+ private boolean mAdapterEnabledState = false;
+
+ public AdapterStateListener(@NonNull IUwbAdapter adapter) {
+ mAdapter = adapter;
+ }
+
+ /**
+ * Register an {@link AdapterStateCallback} with this {@link AdapterStateListener}
+ *
+ * @param executor an {@link Executor} to execute given callback
+ * @param callback user implementation of the {@link AdapterStateCallback}
+ */
+ public void register(@NonNull Executor executor, @NonNull AdapterStateCallback callback) {
+ synchronized (this) {
+ if (mCallbackMap.containsKey(callback)) {
+ return;
+ }
+
+ mCallbackMap.put(callback, executor);
+
+ if (!mIsRegistered) {
+ try {
+ mAdapter.registerAdapterStateCallbacks(this);
+ mIsRegistered = true;
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to register adapter state callback");
+ executor.execute(() -> callback.onStateChanged(false,
+ AdapterStateCallback.STATE_CHANGED_REASON_ERROR_UNKNOWN));
+ }
+ } else {
+ sendCurrentState(callback);
+ }
+ }
+ }
+
+ /**
+ * Unregister the specified {@link AdapterStateCallback}
+ *
+ * @param callback user implementation of the {@link AdapterStateCallback}
+ */
+ public void unregister(@NonNull AdapterStateCallback callback) {
+ synchronized (this) {
+ if (!mCallbackMap.containsKey(callback)) {
+ return;
+ }
+
+ mCallbackMap.remove(callback);
+
+ if (mCallbackMap.isEmpty() && mIsRegistered) {
+ try {
+ mAdapter.unregisterAdapterStateCallbacks(this);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to unregister AdapterStateCallback with service");
+ }
+ mIsRegistered = false;
+ }
+ }
+ }
+
+ private void sendCurrentState(@NonNull AdapterStateCallback callback) {
+ synchronized (this) {
+ Executor executor = mCallbackMap.get(callback);
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ executor.execute(() -> callback.onStateChanged(
+ mAdapterEnabledState, mAdapterStateChangeReason));
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+ }
+
+ @Override
+ public void onAdapterStateChanged(boolean isEnabled, int reason) {
+ synchronized (this) {
+ @StateChangedReason int localReason =
+ convertToStateChangedReason(reason);
+ mAdapterEnabledState = isEnabled;
+ mAdapterStateChangeReason = localReason;
+ for (AdapterStateCallback cb : mCallbackMap.keySet()) {
+ sendCurrentState(cb);
+ }
+ }
+ }
+
+ private static @StateChangedReason int convertToStateChangedReason(
+ @StateChangeReason int reason) {
+ switch (reason) {
+ case StateChangeReason.ALL_SESSIONS_CLOSED:
+ return AdapterStateCallback.STATE_CHANGED_REASON_ALL_SESSIONS_CLOSED;
+
+ case StateChangeReason.SESSION_STARTED:
+ return AdapterStateCallback.STATE_CHANGED_REASON_SESSION_STARTED;
+
+ case StateChangeReason.SYSTEM_POLICY:
+ return AdapterStateCallback.STATE_CHANGED_REASON_SYSTEM_POLICY;
+
+ case StateChangeReason.SYSTEM_BOOT:
+ return AdapterStateCallback.STATE_CHANGED_REASON_SYSTEM_BOOT;
+
+ case StateChangeReason.UNKNOWN:
+ default:
+ return AdapterStateCallback.STATE_CHANGED_REASON_ERROR_UNKNOWN;
+ }
+ }
+}
diff --git a/core/java/android/uwb/IUwbAdapter.aidl b/core/java/android/uwb/IUwbAdapter.aidl
index d29ed34..2c8b2e4 100644
--- a/core/java/android/uwb/IUwbAdapter.aidl
+++ b/core/java/android/uwb/IUwbAdapter.aidl
@@ -98,11 +98,18 @@
int getMaxSimultaneousSessions();
/**
- * Get the maximum number of remote devices per session
+ * Get the maximum number of remote devices per session when local device is initiator
*
* @return the maximum number of remote devices supported in a single session
*/
- int getMaxRemoteDevicesPerSession();
+ int getMaxRemoteDevicesPerInitiatorSession();
+
+ /**
+ * Get the maximum number of remote devices per session when local device is responder
+ *
+ * @return the maximum number of remote devices supported in a single session
+ */
+ int getMaxRemoteDevicesPerResponderSession();
/**
* Provides the capabilities and features of the device
diff --git a/core/java/android/uwb/StateChangeReason.aidl b/core/java/android/uwb/StateChangeReason.aidl
index 46a6e2e..28eaf9f 100644
--- a/core/java/android/uwb/StateChangeReason.aidl
+++ b/core/java/android/uwb/StateChangeReason.aidl
@@ -41,5 +41,10 @@
* The adapter state changed because of a device system change.
*/
SYSTEM_POLICY,
+
+ /**
+ * Used to signal the first adapter state message after boot
+ */
+ SYSTEM_BOOT,
}
diff --git a/core/java/android/uwb/UwbManager.java b/core/java/android/uwb/UwbManager.java
index 2f1e2de..ed5cf36 100644
--- a/core/java/android/uwb/UwbManager.java
+++ b/core/java/android/uwb/UwbManager.java
@@ -16,13 +16,21 @@
package android.uwb;
+import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
+import android.annotation.SystemService;
+import android.content.Context;
+import android.os.IBinder;
import android.os.PersistableBundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -36,7 +44,13 @@
*
* @hide
*/
+@SystemService(Context.UWB_SERVICE)
public final class UwbManager {
+ private IUwbAdapter mUwbAdapter;
+ private static final String SERVICE_NAME = "uwb";
+
+ private AdapterStateListener mAdapterStateListener;
+
/**
* Interface for receiving UWB adapter state changes
*/
@@ -96,10 +110,31 @@
/**
* Use <code>Context.getSystemService(UwbManager.class)</code> to get an instance.
+ *
+ * @param adapter an instance of an {@link android.uwb.IUwbAdapter}
*/
- private UwbManager() {
- throw new UnsupportedOperationException();
+ private UwbManager(IUwbAdapter adapter) {
+ mUwbAdapter = adapter;
+ mAdapterStateListener = new AdapterStateListener(adapter);
}
+
+ /**
+ * @hide
+ */
+ public static UwbManager getInstance() {
+ IBinder b = ServiceManager.getService(SERVICE_NAME);
+ if (b == null) {
+ return null;
+ }
+
+ IUwbAdapter adapter = IUwbAdapter.Stub.asInterface(b);
+ if (adapter == null) {
+ return null;
+ }
+
+ return new UwbManager(adapter);
+ }
+
/**
* Register an {@link AdapterStateCallback} to listen for UWB adapter state changes
* <p>The provided callback will be invoked by the given {@link Executor}.
@@ -112,8 +147,9 @@
* @param executor an {@link Executor} to execute given callback
* @param callback user implementation of the {@link AdapterStateCallback}
*/
- public void registerAdapterStateCallback(Executor executor, AdapterStateCallback callback) {
- throw new UnsupportedOperationException();
+ public void registerAdapterStateCallback(@NonNull @CallbackExecutor Executor executor,
+ @NonNull AdapterStateCallback callback) {
+ mAdapterStateListener.register(executor, callback);
}
/**
@@ -125,8 +161,8 @@
*
* @param callback user implementation of the {@link AdapterStateCallback}
*/
- public void unregisterAdapterStateCallback(AdapterStateCallback callback) {
- throw new UnsupportedOperationException();
+ public void unregisterAdapterStateCallback(@NonNull AdapterStateCallback callback) {
+ mAdapterStateListener.unregister(callback);
}
/**
@@ -139,7 +175,11 @@
*/
@NonNull
public PersistableBundle getSpecificationInfo() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.getSpecificationInfo();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -148,7 +188,11 @@
* @return true if ranging is supported
*/
public boolean isRangingSupported() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.isRangingSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
@Retention(RetentionPolicy.SOURCE)
@@ -197,7 +241,24 @@
*/
@AngleOfArrivalSupportType
public int getAngleOfArrivalSupport() {
- throw new UnsupportedOperationException();
+ try {
+ switch (mUwbAdapter.getAngleOfArrivalSupport()) {
+ case AngleOfArrivalSupport.TWO_DIMENSIONAL:
+ return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D;
+
+ case AngleOfArrivalSupport.THREE_DIMENSIONAL_HEMISPHERICAL:
+ return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL;
+
+ case AngleOfArrivalSupport.THREE_DIMENSIONAL_SPHERICAL:
+ return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL;
+
+ case AngleOfArrivalSupport.NONE:
+ default:
+ return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE;
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -211,7 +272,15 @@
*/
@NonNull
public List<Integer> getSupportedChannelNumbers() {
- throw new UnsupportedOperationException();
+ List<Integer> channels = new ArrayList<>();
+ try {
+ for (int channel : mUwbAdapter.getSupportedChannels()) {
+ channels.add(channel);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ return channels;
}
/**
@@ -222,7 +291,15 @@
*/
@NonNull
public Set<Integer> getSupportedPreambleCodeIndices() {
- throw new UnsupportedOperationException();
+ Set<Integer> preambles = new HashSet<>();
+ try {
+ for (int preamble : mUwbAdapter.getSupportedPreambleCodes()) {
+ preambles.add(preamble);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ return preambles;
}
/**
@@ -234,7 +311,11 @@
*/
@SuppressLint("MethodNameUnits")
public long elapsedRealtimeResolutionNanos() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.getTimestampResolutionNanos();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -243,7 +324,11 @@
* @return the maximum allowed number of simultaneously open {@link RangingSession} instances.
*/
public int getMaxSimultaneousSessions() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.getMaxSimultaneousSessions();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -253,7 +338,11 @@
* @return the maximum number of remote devices per {@link RangingSession}
*/
public int getMaxRemoteDevicesPerInitiatorSession() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.getMaxRemoteDevicesPerInitiatorSession();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -263,7 +352,11 @@
* @return the maximum number of remote devices per {@link RangingSession}
*/
public int getMaxRemoteDevicesPerResponderSession() {
- throw new UnsupportedOperationException();
+ try {
+ return mUwbAdapter.getMaxRemoteDevicesPerResponderSession();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
diff --git a/core/java/com/android/internal/os/KernelWakelockReader.java b/core/java/com/android/internal/os/KernelWakelockReader.java
index f668bba..e595db3 100644
--- a/core/java/com/android/internal/os/KernelWakelockReader.java
+++ b/core/java/com/android/internal/os/KernelWakelockReader.java
@@ -184,6 +184,7 @@
try {
wlStats = mSuspendControlService.getWakeLockStats();
+ Slog.i(TAG, "Number of wakelock obtained from SystemSuspend: " + wlStats.length);
updateWakelockStats(wlStats, staleStats);
} catch (RemoteException e) {
Slog.wtf(TAG, "Failed to obtain wakelock stats from ISuspendControlService", e);
diff --git a/core/tests/overlaytests/remount/TEST_MAPPING b/core/tests/overlaytests/remount/TEST_MAPPING
index 54dd431..22b28b5 100644
--- a/core/tests/overlaytests/remount/TEST_MAPPING
+++ b/core/tests/overlaytests/remount/TEST_MAPPING
@@ -1,7 +1,7 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name" : "OverlayRemountedTest"
}
]
-}
\ No newline at end of file
+}
diff --git a/core/tests/uwbtests/Android.bp b/core/tests/uwbtests/Android.bp
index c41c346..8ee86f4 100644
--- a/core/tests/uwbtests/Android.bp
+++ b/core/tests/uwbtests/Android.bp
@@ -17,6 +17,7 @@
static_libs: [
"androidx.test.ext.junit",
"androidx.test.rules",
+ "mockito-target-minus-junit4",
],
libs: [
"android.test.runner",
diff --git a/core/tests/uwbtests/src/android/uwb/AdapterStateListenerTest.java b/core/tests/uwbtests/src/android/uwb/AdapterStateListenerTest.java
new file mode 100644
index 0000000..ce67ef7
--- /dev/null
+++ b/core/tests/uwbtests/src/android/uwb/AdapterStateListenerTest.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright 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.uwb;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+
+import android.os.RemoteException;
+import android.uwb.UwbManager.AdapterStateCallback;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
+
+/**
+ * Test of {@link AdapterStateListener}.
+ */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class AdapterStateListenerTest {
+
+ IUwbAdapter mUwbAdapter = mock(IUwbAdapter.class);
+
+ Answer mRegisterSuccessAnswer = new Answer() {
+ public Object answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ IUwbAdapterStateCallbacks cb = (IUwbAdapterStateCallbacks) args[0];
+ try {
+ cb.onAdapterStateChanged(false, StateChangeReason.UNKNOWN);
+ } catch (RemoteException e) {
+ // Nothing to do
+ }
+ return new Object();
+ }
+ };
+
+ Throwable mThrowRemoteException = new RemoteException("RemoteException");
+
+ private static Executor getExecutor() {
+ return new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ }
+
+ private static void verifyCallbackStateChangedInvoked(
+ AdapterStateCallback callback, int numTimes) {
+ verify(callback, times(numTimes)).onStateChanged(anyBoolean(), anyInt());
+ }
+
+ @Test
+ public void testRegister_RegisterUnregister() throws RemoteException {
+ doAnswer(mRegisterSuccessAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback1 = mock(AdapterStateCallback.class);
+ AdapterStateCallback callback2 = mock(AdapterStateCallback.class);
+
+ // Verify that the adapter state listener registered with the UWB Adapter
+ adapterStateListener.register(getExecutor(), callback1);
+ verify(mUwbAdapter, times(1)).registerAdapterStateCallbacks(any());
+ verifyCallbackStateChangedInvoked(callback1, 1);
+ verifyCallbackStateChangedInvoked(callback2, 0);
+
+ // Register a second client and no new call to UWB Adapter
+ adapterStateListener.register(getExecutor(), callback2);
+ verify(mUwbAdapter, times(1)).registerAdapterStateCallbacks(any());
+ verifyCallbackStateChangedInvoked(callback1, 1);
+ verifyCallbackStateChangedInvoked(callback2, 1);
+
+ // Unregister first callback
+ adapterStateListener.unregister(callback1);
+ verify(mUwbAdapter, times(1)).registerAdapterStateCallbacks(any());
+ verify(mUwbAdapter, times(0)).unregisterAdapterStateCallbacks(any());
+ verifyCallbackStateChangedInvoked(callback1, 1);
+ verifyCallbackStateChangedInvoked(callback2, 1);
+
+ // Unregister second callback
+ adapterStateListener.unregister(callback2);
+ verify(mUwbAdapter, times(1)).registerAdapterStateCallbacks(any());
+ verify(mUwbAdapter, times(1)).unregisterAdapterStateCallbacks(any());
+ verifyCallbackStateChangedInvoked(callback1, 1);
+ verifyCallbackStateChangedInvoked(callback2, 1);
+ }
+
+ @Test
+ public void testRegister_FirstRegisterFails() throws RemoteException {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback1 = mock(AdapterStateCallback.class);
+ AdapterStateCallback callback2 = mock(AdapterStateCallback.class);
+
+ // Throw a remote exception whenever first registering
+ doThrow(mThrowRemoteException).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ adapterStateListener.register(getExecutor(), callback1);
+ verify(mUwbAdapter, times(1)).registerAdapterStateCallbacks(any());
+
+ // No longer throw an exception, instead succeed
+ doAnswer(mRegisterSuccessAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ // Register a different callback
+ adapterStateListener.register(getExecutor(), callback2);
+ verify(mUwbAdapter, times(2)).registerAdapterStateCallbacks(any());
+
+ // Ensure first callback was invoked again
+ verifyCallbackStateChangedInvoked(callback1, 2);
+ verifyCallbackStateChangedInvoked(callback2, 1);
+ }
+
+ @Test
+ public void testRegister_RegisterSameCallbackTwice() throws RemoteException {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+ doAnswer(mRegisterSuccessAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ adapterStateListener.register(getExecutor(), callback);
+ verifyCallbackStateChangedInvoked(callback, 1);
+
+ adapterStateListener.register(getExecutor(), callback);
+ verifyCallbackStateChangedInvoked(callback, 1);
+
+ // Invoke a state change and ensure the callback is only called once
+ adapterStateListener.onAdapterStateChanged(false, StateChangeReason.UNKNOWN);
+ verifyCallbackStateChangedInvoked(callback, 2);
+ }
+
+ @Test
+ public void testCallback_RunViaExecutor_Success() throws RemoteException {
+ // Verify that the callbacks are invoked on the executor when successful
+ doAnswer(mRegisterSuccessAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+ runViaExecutor();
+ }
+
+ @Test
+ public void testCallback_RunViaExecutor_Failure() throws RemoteException {
+ // Verify that the callbacks are invoked on the executor when there is a remote exception
+ doThrow(mThrowRemoteException).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+ runViaExecutor();
+ }
+
+ private void runViaExecutor() {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+
+ Executor executor = mock(Executor.class);
+
+ // Do not run commands received and ensure that the callback is not invoked
+ doAnswer(new ExecutorAnswer(false)).when(executor).execute(any());
+ adapterStateListener.register(executor, callback);
+ verify(executor, times(1)).execute(any());
+ verifyCallbackStateChangedInvoked(callback, 0);
+
+ // Manually invoke the callback and ensure callback is not invoked
+ adapterStateListener.onAdapterStateChanged(false, StateChangeReason.UNKNOWN);
+ verify(executor, times(2)).execute(any());
+ verifyCallbackStateChangedInvoked(callback, 0);
+
+ // Run the command that the executor receives
+ doAnswer(new ExecutorAnswer(true)).when(executor).execute(any());
+ adapterStateListener.onAdapterStateChanged(false, StateChangeReason.UNKNOWN);
+ verify(executor, times(3)).execute(any());
+ verifyCallbackStateChangedInvoked(callback, 1);
+ }
+
+ class ExecutorAnswer implements Answer {
+
+ final boolean mShouldRun;
+ ExecutorAnswer(boolean shouldRun) {
+ mShouldRun = shouldRun;
+ }
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ if (mShouldRun) {
+ ((Runnable) invocation.getArgument(0)).run();
+ }
+ return null;
+ }
+ }
+
+ @Test
+ public void testNotify_AllCallbacksNotified() throws RemoteException {
+ doAnswer(mRegisterSuccessAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ List<AdapterStateCallback> callbacks = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+ adapterStateListener.register(getExecutor(), callback);
+ callbacks.add(callback);
+ }
+
+ // Ensure every callback got the initial state
+ for (AdapterStateCallback callback : callbacks) {
+ verifyCallbackStateChangedInvoked(callback, 1);
+ }
+
+ // Invoke a state change and ensure all callbacks are invoked
+ adapterStateListener.onAdapterStateChanged(true, StateChangeReason.ALL_SESSIONS_CLOSED);
+ for (AdapterStateCallback callback : callbacks) {
+ verifyCallbackStateChangedInvoked(callback, 2);
+ }
+ }
+
+ @Test
+ public void testStateChange_CorrectValue() {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+
+ adapterStateListener.register(getExecutor(), callback);
+
+ runStateChangeValue(StateChangeReason.ALL_SESSIONS_CLOSED,
+ AdapterStateCallback.STATE_CHANGED_REASON_ALL_SESSIONS_CLOSED);
+
+ runStateChangeValue(StateChangeReason.SESSION_STARTED,
+ AdapterStateCallback.STATE_CHANGED_REASON_SESSION_STARTED);
+
+ runStateChangeValue(StateChangeReason.SYSTEM_BOOT,
+ AdapterStateCallback.STATE_CHANGED_REASON_SYSTEM_BOOT);
+
+ runStateChangeValue(StateChangeReason.SYSTEM_POLICY,
+ AdapterStateCallback.STATE_CHANGED_REASON_SYSTEM_POLICY);
+
+ runStateChangeValue(StateChangeReason.UNKNOWN,
+ AdapterStateCallback.STATE_CHANGED_REASON_ERROR_UNKNOWN);
+ }
+
+ private void runStateChangeValue(@StateChangeReason int reasonIn,
+ @AdapterStateCallback.StateChangedReason int reasonOut) {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+ adapterStateListener.register(getExecutor(), callback);
+
+ adapterStateListener.onAdapterStateChanged(false, reasonIn);
+ verify(callback, times(1)).onStateChanged(false, reasonOut);
+
+ adapterStateListener.onAdapterStateChanged(true, reasonIn);
+ verify(callback, times(1)).onStateChanged(true, reasonOut);
+ }
+
+ @Test
+ public void testStateChange_FirstRegisterGetsCorrectState() throws RemoteException {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback = mock(AdapterStateCallback.class);
+
+ Answer registerAnswer = new Answer() {
+ public Object answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ IUwbAdapterStateCallbacks cb = (IUwbAdapterStateCallbacks) args[0];
+ try {
+ cb.onAdapterStateChanged(true, StateChangeReason.SESSION_STARTED);
+ } catch (RemoteException e) {
+ // Nothing to do
+ }
+ return new Object();
+ }
+ };
+
+ doAnswer(registerAnswer).when(mUwbAdapter).registerAdapterStateCallbacks(any());
+
+ adapterStateListener.register(getExecutor(), callback);
+ verify(callback).onStateChanged(true,
+ AdapterStateCallback.STATE_CHANGED_REASON_SESSION_STARTED);
+ }
+
+ @Test
+ public void testStateChange_SecondRegisterGetsCorrectState() {
+ AdapterStateListener adapterStateListener = new AdapterStateListener(mUwbAdapter);
+ AdapterStateCallback callback1 = mock(AdapterStateCallback.class);
+ AdapterStateCallback callback2 = mock(AdapterStateCallback.class);
+
+ adapterStateListener.register(getExecutor(), callback1);
+ adapterStateListener.onAdapterStateChanged(true, StateChangeReason.SYSTEM_BOOT);
+
+ adapterStateListener.register(getExecutor(), callback2);
+ verify(callback2).onStateChanged(true,
+ AdapterStateCallback.STATE_CHANGED_REASON_SYSTEM_BOOT);
+ }
+}
diff --git a/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java b/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java
new file mode 100644
index 0000000..4983bed
--- /dev/null
+++ b/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 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.uwb;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import android.content.Context;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test of {@link UwbManager}.
+ */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class UwbManagerTest {
+
+ public final Context mContext = InstrumentationRegistry.getContext();
+
+ @Test
+ public void testServiceAvailable() {
+ UwbManager manager = mContext.getSystemService(UwbManager.class);
+ if (UwbTestUtils.isUwbSupported(mContext)) {
+ assertNotNull(manager);
+ } else {
+ assertNull(manager);
+ }
+ }
+}
diff --git a/core/tests/uwbtests/src/android/uwb/UwbTestUtils.java b/core/tests/uwbtests/src/android/uwb/UwbTestUtils.java
index 62e0b62..fb75092 100644
--- a/core/tests/uwbtests/src/android/uwb/UwbTestUtils.java
+++ b/core/tests/uwbtests/src/android/uwb/UwbTestUtils.java
@@ -16,6 +16,8 @@
package android.uwb;
+import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.SystemClock;
import java.util.ArrayList;
@@ -24,6 +26,11 @@
public class UwbTestUtils {
private UwbTestUtils() {}
+ public static boolean isUwbSupported(Context context) {
+ PackageManager packageManager = context.getPackageManager();
+ return packageManager.hasSystemFeature(PackageManager.FEATURE_UWB);
+ }
+
public static AngleMeasurement getAngleMeasurement() {
return new AngleMeasurement.Builder()
.setRadians(getDoubleInRange(-Math.PI, Math.PI))
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index e0a484f..58f1db3 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -8200,8 +8200,10 @@
final NetworkRequestInfo nri = cbInfo.mRequestInfo;
- if (uid != nri.mUid) {
- if (VDBG) loge("Different uid than registrant attempting to unregister cb");
+ // Caller's UID must either be the registrants (if they are unregistering) or the System's
+ // (if the Binder died)
+ if (uid != nri.mUid && uid != Process.SYSTEM_UID) {
+ if (DBG) loge("Uid(" + uid + ") not registrant's (" + nri.mUid + ") or System's");
return;
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 8be24a6..bd7f9df 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -539,7 +539,6 @@
AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET,
AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET,
AudioSystem.DEVICE_OUT_HDMI_ARC,
- AudioSystem.DEVICE_OUT_SPDIF,
AudioSystem.DEVICE_OUT_AUX_LINE));
// Devices for which the volume is always max, no volume panel
Set<Integer> mFullVolumeDevices = new HashSet<>();
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 179118c..9127620 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -6964,15 +6964,15 @@
if (record.getSbn().isGroup() && record.getNotification().suppressAlertingDueToGrouping()) {
return false;
}
- // not if in call or the screen's on
- if (isInCall() || mScreenOn) {
+ // not if in call
+ if (isInCall()) {
return false;
}
// check current user
if (!isNotificationForCurrentUser(record)) {
return false;
}
-
+ // Light, but only when the screen is off
return true;
}
diff --git a/services/core/java/com/android/server/om/TEST_MAPPING b/services/core/java/com/android/server/om/TEST_MAPPING
index 6edd76f..e8a2a02 100644
--- a/services/core/java/com/android/server/om/TEST_MAPPING
+++ b/services/core/java/com/android/server/om/TEST_MAPPING
@@ -15,9 +15,6 @@
"name": "OverlayHostTests"
},
{
- "name": "OverlayRemountedTest"
- },
- {
"name": "CtsAppSecurityHostTestCases",
"options": [
{
@@ -25,5 +22,10 @@
}
]
}
+ ],
+ "presubmit-large": [
+ {
+ "name": "OverlayRemountedTest"
+ }
]
}
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java
index 63d7dbd..24a01003 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java
@@ -56,6 +56,30 @@
}
@Test
+ public void isValid_unregisteredSource() {
+ // Message invokes a broadcast response
+ // <Get Menu Language>
+ assertMessageValidity("F4:91").isEqualTo(OK);
+ // <Request Active Source>
+ assertMessageValidity("FF:85").isEqualTo(OK);
+
+ // Message by CEC Switch
+ // <Routing Change>
+ assertMessageValidity("FF:80:00:00:10:00").isEqualTo(OK);
+
+ // <Routing Information>
+ assertMessageValidity("FF:81:10:00").isEqualTo(OK);
+
+ // Standby
+ assertMessageValidity("F4:36").isEqualTo(OK);
+ assertMessageValidity("FF:36").isEqualTo(OK);
+
+ // <Report Physical Address> / <Active Source>
+ assertMessageValidity("FF:84:10:00:04").isEqualTo(OK);
+ assertMessageValidity("FF:82:10:00").isEqualTo(OK);
+ }
+
+ @Test
public void isValid_giveDevicePowerStatus() {
assertMessageValidity("04:8F").isEqualTo(OK);
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 abcc14c..078832d 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -1185,7 +1185,7 @@
NotificationRecord r = getLightsNotification();
mService.buzzBeepBlinkLocked(r);
verifyNeverLights();
- assertFalse(r.isInterruptive());
+ assertTrue(r.isInterruptive());
assertEquals(-1, r.getLastAudiblyAlertedMs());
}
diff --git a/telecomm/TEST_MAPPING b/telecomm/TEST_MAPPING
index c9903f9..1963ff3 100644
--- a/telecomm/TEST_MAPPING
+++ b/telecomm/TEST_MAPPING
@@ -23,7 +23,9 @@
"exclude-annotation": "androidx.test.filters.FlakyTest"
}
]
- },
+ }
+ ],
+ "presubmit-large": [
{
"name": "CtsTelecomTestCases",
"options": [
diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java
index 031c337..f900c38 100644
--- a/telephony/java/android/telephony/Annotation.java
+++ b/telephony/java/android/telephony/Annotation.java
@@ -634,4 +634,15 @@
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA,
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE})
public @interface OverrideNetworkType {}
+
+ /**
+ * Result of a thermal mitigation request.
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "THERMAL_MITIGATION_RESULT_" }, value = {
+ TelephonyManager.THERMAL_MITIGATION_RESULT_SUCCESS,
+ TelephonyManager.THERMAL_MITIGATION_RESULT_MODEM_ERROR,
+ TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE,
+ TelephonyManager.THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR})
+ public @interface ThermalMitigationResult {}
}
diff --git a/telephony/java/android/telephony/DataThrottlingRequest.aidl b/telephony/java/android/telephony/DataThrottlingRequest.aidl
new file mode 100644
index 0000000..e1a3b66
--- /dev/null
+++ b/telephony/java/android/telephony/DataThrottlingRequest.aidl
@@ -0,0 +1,19 @@
+/*
+* 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.telephony;
+
+parcelable DataThrottlingRequest;
\ No newline at end of file
diff --git a/telephony/java/android/telephony/DataThrottlingRequest.java b/telephony/java/android/telephony/DataThrottlingRequest.java
new file mode 100644
index 0000000..f50bb58
--- /dev/null
+++ b/telephony/java/android/telephony/DataThrottlingRequest.java
@@ -0,0 +1,244 @@
+/*
+ * 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.telephony;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+
+/**
+ * Class stores information related to the type of data throttling request. Must be populated as
+ * field in {@link ThermalMitigationRequest} for sending of thermal mitigation request at {@link
+ * TelephonyManager#sendThermalMitigationRequest(ThermalMitigationResult)}.
+ * @hide
+ */
+@SystemApi
+public final class DataThrottlingRequest implements Parcelable {
+ /**
+ * Clear all existing data throttling, enable data, and attempt to enable radio for thermal
+ * mitigation all within the requested completion window. Note that attempting to enable radio
+ * will not guarantee that radio will actually be enabled.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int DATA_THROTTLING_ACTION_NO_DATA_THROTTLING = 0;
+
+ /**
+ * Enact secondary carrier data throttling within specified completion window. This also
+ * attempts to enables radio if currently disabled for thermal mitigation, enables data, and
+ * removes any existing data throttling on primary carrier. Note that attempting to enable radio
+ * will not guarantee that radio will actually be enabled.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER = 1;
+
+ /**
+ * Enact primary carrier data throttling within specified completion window. This also attempts
+ * to enable radio if currently disabled for thermal mitigation and disables data on secondary
+ * carrier if currently enabled. Note that attempting to enable radio will not guarantee that
+ * radio will actually be enabled.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER = 2;
+
+ /**
+ * Immediately hold on to the current level of data throttling indicating that the current level
+ * of data throttling has alleviated the thermal concerns which caused the original data
+ * throttling request. A thermal module should remain actively monitoring the temperature levels
+ * and request an appropriate thermal mitigation action. {@link
+ * #THERMAL_MITIGATION_RESULT_INVALID_PARAMETERS} will be returned if completion window is not
+ * 0.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int DATA_THROTTLING_ACTION_HOLD = 3;
+
+ /**
+ * Type of data throttling action to carry out.
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "DATA_THROTTLING_ACTION_" }, value = {
+ DATA_THROTTLING_ACTION_NO_DATA_THROTTLING,
+ DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER,
+ DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER,
+ DATA_THROTTLING_ACTION_HOLD})
+ public @interface DataThrottlingAction {}
+
+ /**
+ * Represents the data throttling action that will be requested. See {@link
+ * DATA_THROTTLING_ACTION_NO_DATA_THROTTLING}, {@link
+ * #DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER}, {@link
+ * #DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER}, and {@link
+ * #DATA_THROTTLING_ACTION_HOLD} for more details.
+ **/
+ private @DataThrottlingAction int mDataThrottlingAction;
+ /**
+ * Represents the time over which modem should gradually execute the data thorttling request.
+ */
+ private long mCompletionDurationMillis;
+
+ private DataThrottlingRequest(@NonNull int dataThrottlingAction,
+ long completionDurationMillis) {
+ mDataThrottlingAction = dataThrottlingAction;
+ mCompletionDurationMillis = completionDurationMillis;
+ }
+
+ private DataThrottlingRequest(Parcel in) {
+ mDataThrottlingAction = in.readInt();
+ mCompletionDurationMillis = in.readLong();
+ }
+
+ /**
+ * Implement the Parcelable interface
+ */
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mDataThrottlingAction);
+ dest.writeLong(mCompletionDurationMillis);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "[DataThrottlingRequest "
+ + ", DataThrottlingAction=" + mDataThrottlingAction
+ + ", completionDurationMillis=" + mCompletionDurationMillis
+ + "]";
+ }
+
+ /**
+ * @return the dataThrottlingAction.
+ */
+ public @DataThrottlingAction int getDataThrottlingAction() {
+ return mDataThrottlingAction;
+ }
+
+ /**
+ * @return the completionDurationMillis which represents the time over which modem should
+ * gradually execute the data thorttling request.
+ */
+ public long getCompletionDurationMillis() {
+ return mCompletionDurationMillis;
+ }
+
+ public static final @NonNull Parcelable.Creator<DataThrottlingRequest> CREATOR =
+ new Parcelable.Creator<DataThrottlingRequest>() {
+
+ @Override
+ public DataThrottlingRequest createFromParcel(Parcel in) {
+ return new DataThrottlingRequest(in);
+ }
+
+ @Override
+ public DataThrottlingRequest[] newArray(int size) {
+ return new DataThrottlingRequest[size];
+ }
+ };
+
+ /**
+ * Provides a convenient way to set the fields of a {@link DataThrottlingRequest} when creating
+ * a new instance.
+ *
+ * <p>The example below shows how you might create a new {@code DataThrottlingRequest}:
+ *
+ * <pre><code>
+ *
+ * DataThrottlingRequest dp = new DataThrottlingRequest.Builder()
+ * .setDataThrottlingAction(
+ * DataThrottlingRequest.DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER)
+ * .setCompletionDurationMillis(10000L)
+ * .build();
+ * </code></pre>
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final class Builder {
+ private @DataThrottlingAction int mDataThrottlingAction;
+ private long mCompletionDurationMillis;
+
+ /**
+ * Default constructor for Builder.
+ */
+ public Builder() {}
+
+ /**
+ * Set the data throttling action.
+ *
+ * @param dataThrottlingAction data throttling action.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setDataThrottlingAction(
+ @DataThrottlingAction int dataThrottlingAction) {
+ mDataThrottlingAction = dataThrottlingAction;
+ return this;
+ }
+
+ /**
+ * Set the completion duration.
+ *
+ * @param completionDurationMillis completion duration in millis which represents the time
+ * over which modem should gradually execute the data thorttling request. This can
+ * never be a negative number and must be 0 for {@link #DATA_THROTTLING_ACTION_HOLD}.
+ * Otherwise, an IllegalArgumentException will be thrown.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setCompletionDurationMillis(long completionDurationMillis) {
+ mCompletionDurationMillis = completionDurationMillis;
+ return this;
+ }
+
+ /**
+ * Build the DataThrottlingRequest.
+ *
+ * @return the DataThrottlingRequest object.
+ */
+ public @NonNull DataThrottlingRequest build() {
+ if (mCompletionDurationMillis < 0) {
+ throw new IllegalArgumentException("completionDurationMillis cannot be a negative "
+ + "number");
+ }
+
+ if (mDataThrottlingAction == DataThrottlingRequest.DATA_THROTTLING_ACTION_HOLD
+ && mCompletionDurationMillis != 0) {
+ throw new IllegalArgumentException("completionDurationMillis must be 0 for "
+ + "DataThrottlingRequest.DATA_THROTTLING_ACTION_HOLD");
+ }
+
+ return new DataThrottlingRequest(mDataThrottlingAction, mCompletionDurationMillis);
+ }
+ }
+
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index d156907..718676c 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -76,6 +76,7 @@
import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SimActivationState;
+import android.telephony.Annotation.ThermalMitigationResult;
import android.telephony.Annotation.UiccAppType;
import android.telephony.CallForwardingInfo.CallForwardingReason;
import android.telephony.VisualVoicemailService.VisualVoicemailTask;
@@ -11543,18 +11544,6 @@
}
/**
- * In this mode, modem will not send specified indications when screen is off.
- * @hide
- */
- public static final int INDICATION_UPDATE_MODE_NORMAL = 1;
-
- /**
- * In this mode, modem will still send specified indications when screen is off.
- * @hide
- */
- public static final int INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF = 2;
-
- /**
* The indication for signal strength update.
* @hide
*/
@@ -14043,4 +14032,106 @@
return Collections.emptyList();
}
+
+ /**
+ * Indicates that the thermal mitigation request was completed successfully.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_RESULT_SUCCESS = 0;
+
+ /**
+ * Indicates that the thermal mitigation request was not completed because of a modem error.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_RESULT_MODEM_ERROR = 1;
+
+ /**
+ * Indicates that the thermal mitigation request was not completed because the modem is not
+ * available.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE = 2;
+
+ /**
+ * Indicates that the thermal mitigation request could not power off the radio due to the device
+ * either being in an active voice call, device pending an emergency call, or any other state
+ * that would dissallow powering off of radio.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_RESULT_INVALID_STATE = 3;
+
+ /**
+ * Indicates that the thermal mitigation request resulted an unknown error.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR = 4;
+
+ /**
+ * Thermal mitigation request to control functionalities at modem. Thermal mitigation is done
+ * per-subscription. Caller must be sure to bind the TelephonyManager instance to subId by
+ * calling {@link #createForSubscriptionId(int)} if they want thermal mitigation on a specific
+ * subscription Id. Otherwise, TelephonyManager will use the default subscription.
+ *
+ * Calling this does not guarantee that the thermal mitigation action requested was done to
+ * completion. A thermal module should actively monitor the temperature levels and request an
+ * appropriate thermal mitigation action. Every action is assumed to be done 'on top of' the
+ * previous action, where the order of actions from least thermal mitigation to most is as
+ * follows:
+ * <ol>
+ * <li>{@link ThermalMitigationRequest#THERMAL_MITIGATION_ACTION_DATA_THROTTLING}</li>
+ * <ol>
+ * <li>{@link DataThrottlingRequest#DATA_THROTTLING_ACTION_NO_DATA_THROTTLING}</li>
+ * <li>{@link DataThrottlingRequest#DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER}</li>
+ * <li>{@link DataThrottlingRequest#DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER}</li>
+ * </ol>
+ * <li>{@link ThermalMitigationRequest#THERMAL_MITIGATION_ACTION_VOICE_ONLY}</li>
+ * <li>{@link ThermalMitigationRequest#THERMAL_MITIGATION_ACTION_RADIO_OFF}</li>
+ * </ol>
+ *
+ * So, for example, requesting {@link
+ * DataThrottlingRequest#DATA_THROTTLING_ACTION_THROTTLE_PRIMARY_CARRIER} will ensure that the
+ * data on secondary carrier has been disabled before throttling on primary carrier. {@link
+ * ThermalMitigationRequest#THERMAL_MITIGATION_ACTION_VOICE_ONLY} will ensure that data on both
+ * primary and secondary have been disabled. {@link
+ * ThermalMitigationRequest#THERMAL_MITIGATION_ACTION_RADIO_OFF} will ensure that voice is
+ * disabled and that data on both primary and secondary carriers are disabled before turning
+ * radio off. {@link DataThrottlingRequest#DATA_THROTTLING_ACTION_HOLD} is not part of the order
+ * and can be used at any time during data throttling to hold onto the current level of data
+ * throttling.
+ *
+ * @param thermalMitigationRequest Thermal mitigation request. See {@link
+ * ThermalMitigationRequest} for details.
+ *
+ * @throws IllegalStateException if the Telephony process is not currently available.
+ * @throws IllegalArgumentException if the thermalMitigationRequest had invalid parameters.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ @ThermalMitigationResult
+ public int sendThermalMitigationRequest(
+ @NonNull ThermalMitigationRequest thermalMitigationRequest) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.sendThermalMitigationRequest(getSubId(), thermalMitigationRequest);
+ }
+ throw new IllegalStateException("telephony service is null.");
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Telephony#thermalMitigationRequest RemoteException", ex);
+ ex.rethrowFromSystemServer();
+ }
+ return THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR;
+ }
}
diff --git a/telephony/java/android/telephony/ThermalMitigationRequest.aidl b/telephony/java/android/telephony/ThermalMitigationRequest.aidl
new file mode 100644
index 0000000..a912f77
--- /dev/null
+++ b/telephony/java/android/telephony/ThermalMitigationRequest.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright 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.telephony;
+
+parcelable ThermalMitigationRequest;
\ No newline at end of file
diff --git a/telephony/java/android/telephony/ThermalMitigationRequest.java b/telephony/java/android/telephony/ThermalMitigationRequest.java
new file mode 100644
index 0000000..91ad9c3
--- /dev/null
+++ b/telephony/java/android/telephony/ThermalMitigationRequest.java
@@ -0,0 +1,248 @@
+/*
+ * 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.telephony;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+
+/**
+ * Class stores information related to the type of data throttling request to be sent to {@link
+ * TelephonyManager#sendThermalMitigationRequest(ThermalMitigationResult)}.
+ * @hide
+ */
+@SystemApi
+public final class ThermalMitigationRequest implements Parcelable {
+ /**
+ * Sent as a thermal mititgation action to {@link
+ * TelephonyManager#sendThermalMitigationRequest(ThermalMitigationResult)} to start data
+ * throttling. {@link TelephonyManager#InvalidThermalMitigationRequestException} will be thrown
+ * if dataThrottlingRequest is {@code null} or if completion duration is < 0.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_ACTION_DATA_THROTTLING = 0;
+
+ /**
+ * Sent as a thermal mititgation action to {@link
+ * TelephonyManager#sendThermalMitigationRequest(ThermalMitigationResult)} to allow only voice
+ * calls and internet data will not be available. This attempts to enable radio if currently
+ * disabled for thermal mitigation with no guarantee of it actually turning on.
+ * dataThrottlingRequest must be {@code null} or {@link
+ * TelephonyManager#InvalidThermalMitigationRequestException} will be thrown.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_ACTION_VOICE_ONLY = 1;
+
+ /**
+ * Sent as a thermal mititgation action to {@link'
+ * TelephonyManager#sendThermalMitigationRequest(ThermalMitigationResult)} to turn radio off. If
+ * radio is not able to be powered off because of an ongoing voice call, pending emergency call,
+ * or any other state that wouldn't allow radio off, {@link
+ * TelephonyManager#THERMAL_MITIGATION_RESULT_INVALID_STATE}.
+ * dataThrottlingRequest must be {@code null} or
+ * {@link TelephonyManager#InvalidThermalMitigationRequestException} will be returned.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int THERMAL_MITIGATION_ACTION_RADIO_OFF = 2;
+
+ /**
+ * Type of thermal mitigation action.
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "THERMAL_MITIGATION_ACTION_" }, value = {
+ THERMAL_MITIGATION_ACTION_DATA_THROTTLING,
+ THERMAL_MITIGATION_ACTION_VOICE_ONLY,
+ THERMAL_MITIGATION_ACTION_RADIO_OFF})
+ public @interface ThermalMitigationAction {}
+
+ private @ThermalMitigationAction int mThermalMitigationAction;
+ private DataThrottlingRequest mDataThrottlingRequest;
+
+ /**
+ * @param thermalMitigationAction thermal mitigation action.
+ * @param dataThrottlingRequest is the parameters for more fine-controlled data throttling. This
+ * is only applicable if thermalMitigationAction is
+ * {@link #THERMAL_MITIGATION_ACTION_DATA_THROTTLING}. Otherwise, it must be set to
+ * {@code null}. See {@link DataThrottlingRequest} for more details.
+ */
+ private ThermalMitigationRequest(@ThermalMitigationAction int thermalMitigationAction,
+ @Nullable DataThrottlingRequest dataThrottlingRequest) {
+ mThermalMitigationAction = thermalMitigationAction;
+ mDataThrottlingRequest = dataThrottlingRequest;
+ }
+
+ private ThermalMitigationRequest(Parcel in) {
+ mThermalMitigationAction = in.readInt();
+ mDataThrottlingRequest = in.readParcelable(DataThrottlingRequest.class.getClassLoader());
+ }
+
+ /**
+ * Implement the Parcelable interface
+ */
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mThermalMitigationAction);
+ dest.writeParcelable(mDataThrottlingRequest, 0);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "[ThermalMitigationRequest "
+ + ", thermalMitigationAction=" + mThermalMitigationAction
+ + ", dataThrottlingRequest=" + mDataThrottlingRequest
+ + "]";
+ }
+
+ /**
+ * @return the thermal mitigation action.
+ */
+ public @ThermalMitigationAction int getThermalMitigationAction() {
+ return mThermalMitigationAction;
+ }
+
+ /**
+ * @return the data throttling request.
+ */
+ @Nullable
+ public DataThrottlingRequest getDataThrottlingRequest() {
+ return mDataThrottlingRequest;
+ }
+
+ public static final @NonNull Parcelable.Creator<ThermalMitigationRequest> CREATOR =
+ new Parcelable.Creator<ThermalMitigationRequest>() {
+
+ @Override
+ public ThermalMitigationRequest createFromParcel(Parcel in) {
+ return new ThermalMitigationRequest(in);
+ }
+
+ @Override
+ public ThermalMitigationRequest[] newArray(int size) {
+ return new ThermalMitigationRequest[size];
+ }
+ };
+
+ /**
+ * Provides a convenient way to set the fields of a {@link ThermalMitigationRequest} when
+ * creating a new instance.
+ *
+ * <p>The example below shows how you might create a new {@code ThermalMitigationRequest}:
+ *
+ * <pre><code>
+ *
+ * ThermalMitigationRequest dp = new ThermalMitigationRequest.Builder()
+ * .setThermalMitigationAction(
+ * ThermalMitigationRequest.THERMAL_MITIGATION_ACTION_DATA_THROTTLING)
+ * .setDataThrottlingRequest(new DataThrottlingRequest.Builder()
+ * .setDataThrottlingAction(
+ * DataThrottlingRequest.DATA_THROTTLING_ACTION_THROTTLE_SECONDARY_CARRIER)
+ * .setCompletionDurationMillis(10000L)
+ * .build())
+ * .build();
+ * </code></pre>
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final class Builder {
+ private @ThermalMitigationAction int mThermalMitigationAction = -1;
+ private DataThrottlingRequest mDataThrottlingRequest;
+
+ /**
+ * Default constructor for Builder.
+ */
+ public Builder() {}
+
+ /**
+ * Set the thermal mitigation action.
+ *
+ * @param thermalMitigationAction thermal mitigation action. See {@link
+ * #THERMAL_MITIGATION_ACTION_DATA_THROTTLING}, {@link
+ * #THERMAL_MITIGATION_ACTION_VOICE_ONLY}, and {@link
+ * #THERMAL_MITIGATION_ACTION_RADIO_OFF} for more details.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setThermalMitigationAction(
+ @ThermalMitigationAction int thermalMitigationAction) {
+ mThermalMitigationAction = thermalMitigationAction;
+ return this;
+ }
+
+ /**
+ * Set the data throttling request.
+ *
+ * @param dataThrottlingRequest is the parameters for more fine-controlled data throttling.
+ * This is only applicable if thermalMitigationAction is {@link
+ * #THERMAL_MITIGATION_ACTION_DATA_THROTTLING}. Otherwise, it should not be set and
+ * will throw an IllegalArgumentException if it is. See {@link DataThrottlingRequest}
+ * for more details.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setDataThrottlingRequest(
+ @NonNull DataThrottlingRequest dataThrottlingRequest) {
+ mDataThrottlingRequest = dataThrottlingRequest;
+ return this;
+ }
+
+ /**
+ * Build the ThermalMitigationRequest.
+ *
+ * @return the ThermalMitigationRequest object.
+ */
+ public @NonNull ThermalMitigationRequest build() {
+ if (mThermalMitigationAction < 0) {
+ throw new IllegalArgumentException("thermalMitigationAction was "
+ + " not set");
+ }
+
+ if (mThermalMitigationAction == THERMAL_MITIGATION_ACTION_DATA_THROTTLING) {
+ if (mDataThrottlingRequest == null) {
+ throw new IllegalArgumentException("dataThrottlingRequest cannot be null for "
+ + "THERMAL_MITIGATION_ACTION_DATA_THROTTLING");
+ }
+
+
+ } else if (mDataThrottlingRequest != null) {
+ throw new IllegalArgumentException("dataThrottlingRequest must be null for "
+ + "THERMAL_MITIGATION_ACTION_VOICE_ONLY and "
+ + "THERMAL_MITIGATION_ACTION_RADIO_OFF");
+ }
+
+ return new ThermalMitigationRequest(mThermalMitigationAction, mDataThrottlingRequest);
+ }
+ }
+}
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
index ca9bf3c..f0088b9 100644
--- a/telephony/java/android/telephony/data/DataCallResponse.java
+++ b/telephony/java/android/telephony/data/DataCallResponse.java
@@ -134,6 +134,8 @@
private final int mMtuV6;
private final @HandoverFailureMode int mHandoverFailureMode;
private final int mPduSessionId;
+ private final Qos mDefaultQos;
+ private final List<QosSession> mQosSessions;
/**
* @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -182,6 +184,8 @@
mMtu = mMtuV4 = mMtuV6 = mtu;
mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
mPduSessionId = PDU_SESSION_ID_NOT_SET;
+ mDefaultQos = null;
+ mQosSessions = new ArrayList<>();
}
private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id,
@@ -189,7 +193,8 @@
@Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
@Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
@Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6,
- @HandoverFailureMode int handoverFailureMode, int pduSessionId) {
+ @HandoverFailureMode int handoverFailureMode, int pduSessionId,
+ @Nullable Qos defaultQos, @Nullable List<QosSession> qosSessions) {
mCause = cause;
mSuggestedRetryTime = suggestedRetryTime;
mId = id;
@@ -209,6 +214,8 @@
mMtuV6 = mtuV6;
mHandoverFailureMode = handoverFailureMode;
mPduSessionId = pduSessionId;
+ mDefaultQos = defaultQos;
+ mQosSessions = qosSessions;
}
/** @hide */
@@ -233,6 +240,9 @@
mMtuV6 = source.readInt();
mHandoverFailureMode = source.readInt();
mPduSessionId = source.readInt();
+ mDefaultQos = source.readParcelable(Qos.class.getClassLoader());
+ mQosSessions = new ArrayList<>();
+ source.readList(mQosSessions, QosSession.class.getClassLoader());
}
/**
@@ -350,6 +360,28 @@
return mPduSessionId;
}
+ /**
+ * @return default QOS of the data call received from the network
+ *
+ * @hide
+ */
+
+ @Nullable
+ public Qos getDefaultQos() {
+ return mDefaultQos;
+ }
+
+ /**
+ * @return All the dedicated bearer QOS sessions of the data call received from the network
+ *
+ * @hide
+ */
+
+ @NonNull
+ public List<QosSession> getQosSessions() {
+ return mQosSessions;
+ }
+
@NonNull
@Override
public String toString() {
@@ -370,6 +402,8 @@
.append(" mtuV6=").append(getMtuV6())
.append(" handoverFailureMode=").append(getHandoverFailureMode())
.append(" pduSessionId=").append(getPduSessionId())
+ .append(" defaultQos=").append(mDefaultQos)
+ .append(" qosSessions=").append(mQosSessions)
.append("}");
return sb.toString();
}
@@ -383,12 +417,22 @@
}
DataCallResponse other = (DataCallResponse) o;
- return this.mCause == other.mCause
- && this.mSuggestedRetryTime == other.mSuggestedRetryTime
- && this.mId == other.mId
- && this.mLinkStatus == other.mLinkStatus
- && this.mProtocolType == other.mProtocolType
- && this.mInterfaceName.equals(other.mInterfaceName)
+
+ final boolean isQosSame = (mDefaultQos == null || other.mDefaultQos == null) ?
+ mDefaultQos == other.mDefaultQos :
+ mDefaultQos.equals(other.mDefaultQos);
+
+ final boolean isQosSessionsSame = (mQosSessions == null || mQosSessions == null) ?
+ mQosSessions == other.mQosSessions :
+ mQosSessions.size() == other.mQosSessions.size()
+ && mQosSessions.containsAll(other.mQosSessions);
+
+ return mCause == other.mCause
+ && mSuggestedRetryTime == other.mSuggestedRetryTime
+ && mId == other.mId
+ && mLinkStatus == other.mLinkStatus
+ && mProtocolType == other.mProtocolType
+ && mInterfaceName.equals(other.mInterfaceName)
&& mAddresses.size() == other.mAddresses.size()
&& mAddresses.containsAll(other.mAddresses)
&& mDnsAddresses.size() == other.mDnsAddresses.size()
@@ -401,14 +445,17 @@
&& mMtuV4 == other.mMtuV4
&& mMtuV6 == other.mMtuV6
&& mHandoverFailureMode == other.mHandoverFailureMode
- && mPduSessionId == other.mPduSessionId;
+ && mPduSessionId == other.mPduSessionId
+ && isQosSame
+ && isQosSessionsSame;
}
@Override
public int hashCode() {
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
- mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
+ mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId, mDefaultQos,
+ mQosSessions);
}
@Override
@@ -433,6 +480,12 @@
dest.writeInt(mMtuV6);
dest.writeInt(mHandoverFailureMode);
dest.writeInt(mPduSessionId);
+ if (mDefaultQos.getType() == Qos.QOS_TYPE_EPS) {
+ dest.writeParcelable((EpsQos)mDefaultQos, flags);
+ } else {
+ dest.writeParcelable((NrQos)mDefaultQos, flags);
+ }
+ dest.writeList(mQosSessions);
}
public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -512,6 +565,10 @@
private int mPduSessionId = PDU_SESSION_ID_NOT_SET;
+ private Qos mDefaultQos;
+
+ private List<QosSession> mQosSessions = new ArrayList<>();
+
/**
* Default constructor for Builder.
*/
@@ -706,6 +763,35 @@
}
/**
+ * Set the default QOS for this data connection.
+ *
+ * @param defaultQos QOS (Quality Of Service) received from network.
+ *
+ * @return The same instance of the builder.
+ *
+ * @hide
+ */
+ public @NonNull Builder setDefaultQos(@Nullable Qos defaultQos) {
+ mDefaultQos = defaultQos;
+ return this;
+ }
+
+ /**
+ * Set the dedicated bearer QOS sessions for this data connection.
+ *
+ * @param qosSessions Dedicated bearer QOS (Quality Of Service) sessions received
+ * from network.
+ *
+ * @return The same instance of the builder.
+ *
+ * @hide
+ */
+ public @NonNull Builder setQosSessions(@NonNull List<QosSession> qosSessions) {
+ mQosSessions = qosSessions;
+ return this;
+ }
+
+ /**
* Build the DataCallResponse.
*
* @return the DataCallResponse object.
@@ -713,7 +799,8 @@
public @NonNull DataCallResponse build() {
return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
- mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
+ mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId,
+ mDefaultQos, mQosSessions);
}
}
}
diff --git a/telephony/java/android/telephony/data/EpsQos.java b/telephony/java/android/telephony/data/EpsQos.java
new file mode 100644
index 0000000..ad43068
--- /dev/null
+++ b/telephony/java/android/telephony/data/EpsQos.java
@@ -0,0 +1,105 @@
+/**
+ * Copyright 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.telephony.data;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+
+/**
+ * Class that stores information specific to NR QOS.
+ *
+ * @hide
+ */
+public final class EpsQos extends Qos implements Parcelable {
+
+ int qosClassId;
+
+ public EpsQos() {
+ super(Qos.QOS_TYPE_EPS,
+ new android.hardware.radio.V1_6.QosBandwidth(),
+ new android.hardware.radio.V1_6.QosBandwidth());
+ }
+
+ public EpsQos(@NonNull android.hardware.radio.V1_6.EpsQos qos) {
+ super(Qos.QOS_TYPE_EPS, qos.downlink, qos.uplink);
+ qosClassId = qos.qci;
+ }
+
+ private EpsQos(Parcel source) {
+ super(source);
+ qosClassId = source.readInt();
+ }
+
+ public static @NonNull EpsQos createFromParcelBody(@NonNull Parcel in) {
+ return new EpsQos(in);
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ super.writeToParcel(Qos.QOS_TYPE_EPS, dest, flags);
+ dest.writeInt(qosClassId);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), qosClassId);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof EpsQos)) {
+ return false;
+ }
+
+ EpsQos other = (EpsQos) o;
+
+ return this.qosClassId == other.qosClassId
+ && super.equals(other);
+ }
+
+ @Override
+ public String toString() {
+ return "EpsQos {"
+ + " qosClassId=" + qosClassId
+ + " downlink=" + downlink
+ + " uplink=" + uplink + "}";
+ }
+
+ public static final @NonNull Parcelable.Creator<EpsQos> CREATOR =
+ new Parcelable.Creator<EpsQos>() {
+ @Override
+ public EpsQos createFromParcel(Parcel source) {
+ return new EpsQos(source);
+ }
+
+ @Override
+ public EpsQos[] newArray(int size) {
+ return new EpsQos[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/data/NrQos.java b/telephony/java/android/telephony/data/NrQos.java
new file mode 100644
index 0000000..2011eed
--- /dev/null
+++ b/telephony/java/android/telephony/data/NrQos.java
@@ -0,0 +1,112 @@
+/**
+ * Copyright 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.telephony.data;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Class that stores information specific to NR QOS.
+ *
+ * @hide
+ */
+public final class NrQos extends Qos implements Parcelable {
+ int qosFlowId;
+ int fiveQi;
+ int averagingWindowMs;
+
+ public NrQos(@NonNull android.hardware.radio.V1_6.NrQos qos) {
+ super(Qos.QOS_TYPE_NR, qos.downlink, qos.uplink);
+ fiveQi = qos.fiveQi;
+ qosFlowId = qos.qfi;
+ averagingWindowMs = qos.averagingWindowMs;
+ }
+
+ private NrQos(Parcel source) {
+ super(source);
+ this.qosFlowId = source.readInt();
+ this.fiveQi = source.readInt();
+ this.averagingWindowMs = source.readInt();
+ }
+
+ public static @NonNull NrQos createFromParcelBody(@NonNull Parcel in) {
+ return new NrQos(in);
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ super.writeToParcel(Qos.QOS_TYPE_NR, dest, flags);
+ dest.writeInt(qosFlowId);
+ dest.writeInt(fiveQi);
+ dest.writeInt(averagingWindowMs);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), qosFlowId, fiveQi, averagingWindowMs);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof NrQos)) {
+ return false;
+ }
+
+ NrQos other = (NrQos) o;
+
+ if (!super.equals(other)) {
+ return false;
+ }
+
+ return this.qosFlowId == other.qosFlowId
+ && this.fiveQi == other.fiveQi
+ && this.averagingWindowMs == other.averagingWindowMs;
+ }
+
+ @Override
+ public String toString() {
+ return "NrQos {"
+ + " fiveQi=" + fiveQi
+ + " downlink=" + downlink
+ + " uplink=" + uplink
+ + " qosFlowId=" + qosFlowId
+ + " averagingWindowMs=" + averagingWindowMs + "}";
+ }
+
+ public static final @NonNull Parcelable.Creator<NrQos> CREATOR =
+ new Parcelable.Creator<NrQos>() {
+ @Override
+ public NrQos createFromParcel(Parcel source) {
+ return new NrQos(source);
+ }
+
+ @Override
+ public NrQos[] newArray(int size) {
+ return new NrQos[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/data/Qos.java b/telephony/java/android/telephony/data/Qos.java
new file mode 100644
index 0000000..c8bb91e
--- /dev/null
+++ b/telephony/java/android/telephony/data/Qos.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright 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.telephony.data;
+
+import android.annotation.CallSuper;
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
+
+/**
+ * Class that stores information specific to QOS.
+ *
+ * @hide
+ */
+public abstract class Qos {
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "QOS_TYPE_",
+ value = {QOS_TYPE_EPS, QOS_TYPE_NR})
+ public @interface QosType {}
+
+ @QosType
+ final int type;
+
+ static final int QOS_TYPE_EPS = 1;
+ static final int QOS_TYPE_NR = 2;
+
+ final QosBandwidth downlink;
+ final QosBandwidth uplink;
+
+ Qos(int type,
+ @NonNull android.hardware.radio.V1_6.QosBandwidth downlink,
+ @NonNull android.hardware.radio.V1_6.QosBandwidth uplink) {
+ this.type = type;
+ this.downlink = new QosBandwidth(downlink.maxBitrateKbps, downlink.guaranteedBitrateKbps);
+ this.uplink = new QosBandwidth(uplink.maxBitrateKbps, uplink.guaranteedBitrateKbps);
+ }
+
+ static class QosBandwidth implements Parcelable {
+ int maxBitrateKbps;
+ int guaranteedBitrateKbps;
+
+ QosBandwidth() {
+ }
+
+ QosBandwidth(int maxBitrateKbps, int guaranteedBitrateKbps) {
+ this.maxBitrateKbps = maxBitrateKbps;
+ this.guaranteedBitrateKbps = guaranteedBitrateKbps;
+ }
+
+ private QosBandwidth(Parcel source) {
+ maxBitrateKbps = source.readInt();
+ guaranteedBitrateKbps = source.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(maxBitrateKbps);
+ dest.writeInt(guaranteedBitrateKbps);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(maxBitrateKbps, guaranteedBitrateKbps);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof QosBandwidth)) {
+ return false;
+ }
+
+ QosBandwidth other = (QosBandwidth) o;
+ return maxBitrateKbps == other.maxBitrateKbps
+ && guaranteedBitrateKbps == other.guaranteedBitrateKbps;
+ }
+
+ @Override
+ public String toString() {
+ return "Bandwidth {"
+ + " maxBitrateKbps=" + maxBitrateKbps
+ + " guaranteedBitrateKbps=" + guaranteedBitrateKbps + "}";
+ }
+
+ public static final @NonNull Parcelable.Creator<QosBandwidth> CREATOR =
+ new Parcelable.Creator<QosBandwidth>() {
+ @Override
+ public QosBandwidth createFromParcel(Parcel source) {
+ return new QosBandwidth(source);
+ }
+
+ @Override
+ public QosBandwidth[] newArray(int size) {
+ return new QosBandwidth[size];
+ }
+ };
+ };
+
+ protected Qos(@NonNull Parcel source) {
+ type = source.readInt();
+ downlink = source.readParcelable(QosBandwidth.class.getClassLoader());
+ uplink = source.readParcelable(QosBandwidth.class.getClassLoader());
+ }
+
+ /**
+ * Used by child classes for parceling.
+ *
+ * @hide
+ */
+ @CallSuper
+ public void writeToParcel(@QosType int type, Parcel dest, int flags) {
+ dest.writeInt(type);
+ dest.writeParcelable(downlink, flags);
+ dest.writeParcelable(uplink, flags);
+ }
+
+ /** @hide */
+ public static @NonNull Qos create(@NonNull android.hardware.radio.V1_6.Qos qos) {
+ switch (qos.getDiscriminator()) {
+ case android.hardware.radio.V1_6.Qos.hidl_discriminator.eps:
+ return new EpsQos(qos.eps());
+ case android.hardware.radio.V1_6.Qos.hidl_discriminator.nr:
+ return new NrQos(qos.nr());
+ default:
+ return null;
+ }
+ }
+
+ /** @hide */
+ public @QosType int getType() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(downlink, uplink);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ Qos other = (Qos) o;
+ return type == other.type
+ && downlink.equals(other.downlink)
+ && uplink.equals(other.uplink);
+ }
+}
diff --git a/telephony/java/android/telephony/data/QosFilter.java b/telephony/java/android/telephony/data/QosFilter.java
new file mode 100644
index 0000000..6927744
--- /dev/null
+++ b/telephony/java/android/telephony/data/QosFilter.java
@@ -0,0 +1,373 @@
+/**
+ * Copyright 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.telephony.data;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.net.InetAddresses;
+import android.net.LinkAddress;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.net.InetAddress;
+import java.net.Inet4Address;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+
+/**
+ * Class that stores QOS filter parameters as defined in
+ * 3gpp 24.008 10.5.6.12 and 3gpp 24.501 9.11.4.13.
+ *
+ * @hide
+ */
+public final class QosFilter implements Parcelable {
+
+ private List<LinkAddress> localAddresses;
+ private List<LinkAddress> remoteAddresses;
+ private PortRange localPort;
+ private PortRange remotePort;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "QOS_PROTOCOL_",
+ value = {QOS_PROTOCOL_UNSPECIFIED, QOS_PROTOCOL_TCP, QOS_PROTOCOL_UDP,
+ QOS_PROTOCOL_ESP, QOS_PROTOCOL_AH})
+ public @interface QosProtocol {}
+
+ public static final int QOS_PROTOCOL_UNSPECIFIED =
+ android.hardware.radio.V1_6.QosProtocol.UNSPECIFIED;
+ public static final int QOS_PROTOCOL_TCP = android.hardware.radio.V1_6.QosProtocol.TCP;
+ public static final int QOS_PROTOCOL_UDP = android.hardware.radio.V1_6.QosProtocol.UDP;
+ public static final int QOS_PROTOCOL_ESP = android.hardware.radio.V1_6.QosProtocol.ESP;
+ public static final int QOS_PROTOCOL_AH = android.hardware.radio.V1_6.QosProtocol.AH;
+
+ @QosProtocol
+ private int protocol;
+
+ private int typeOfServiceMask;
+
+ private long flowLabel;
+
+ /** IPSec security parameter index */
+ private long securityParameterIndex;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "QOS_FILTER_DIRECTION_",
+ value = {QOS_FILTER_DIRECTION_DOWNLINK, QOS_FILTER_DIRECTION_UPLINK,
+ QOS_FILTER_DIRECTION_BIDIRECTIONAL})
+ public @interface QosFilterDirection {}
+
+ public static final int QOS_FILTER_DIRECTION_DOWNLINK =
+ android.hardware.radio.V1_6.QosFilterDirection.DOWNLINK;
+ public static final int QOS_FILTER_DIRECTION_UPLINK =
+ android.hardware.radio.V1_6.QosFilterDirection.UPLINK;
+ public static final int QOS_FILTER_DIRECTION_BIDIRECTIONAL =
+ android.hardware.radio.V1_6.QosFilterDirection.BIDIRECTIONAL;
+
+ @QosFilterDirection
+ private int filterDirection;
+
+ /**
+ * Specified the order in which the filter needs to be matched.
+ * A Lower numerical value has a higher precedence.
+ */
+ private int precedence;
+
+ QosFilter() {
+ localAddresses = new ArrayList<>();
+ remoteAddresses = new ArrayList<>();
+ localPort = new PortRange();
+ remotePort = new PortRange();
+ protocol = QOS_PROTOCOL_UNSPECIFIED;
+ filterDirection = QOS_FILTER_DIRECTION_BIDIRECTIONAL;
+ }
+
+ public QosFilter(List<LinkAddress> localAddresses, List<LinkAddress> remoteAddresses,
+ PortRange localPort, PortRange remotePort, int protocol, int tos,
+ long flowLabel, long spi, int direction, int precedence) {
+ this.localAddresses = localAddresses;
+ this.remoteAddresses = remoteAddresses;
+ this.localPort = localPort;
+ this.remotePort = remotePort;
+ this.protocol = protocol;
+ this.typeOfServiceMask = tos;
+ this.flowLabel = flowLabel;
+ this.securityParameterIndex = spi;
+ this.filterDirection = direction;
+ this.precedence = precedence;
+ }
+
+ /** @hide */
+ public static @NonNull QosFilter create(
+ @NonNull android.hardware.radio.V1_6.QosFilter qosFilter) {
+ QosFilter ret = new QosFilter();
+
+ String[] localAddresses = qosFilter.localAddresses.stream().toArray(String[]::new);
+ if (localAddresses != null) {
+ for (String address : localAddresses) {
+ ret.localAddresses.add(createLinkAddressFromString(address));
+ }
+ }
+
+ String[] remoteAddresses = qosFilter.remoteAddresses.stream().toArray(String[]::new);
+ if (remoteAddresses != null) {
+ for (String address : remoteAddresses) {
+ ret.remoteAddresses.add(createLinkAddressFromString(address));
+ }
+ }
+
+ if (qosFilter.localPort != null) {
+ if (qosFilter.localPort.getDiscriminator()
+ == android.hardware.radio.V1_6.MaybePort.hidl_discriminator.range) {
+ final android.hardware.radio.V1_6.PortRange portRange = qosFilter.localPort.range();
+ ret.localPort.start = portRange.start;
+ ret.localPort.end = portRange.end;
+ }
+ }
+
+ if (qosFilter.remotePort != null) {
+ if (qosFilter.remotePort.getDiscriminator()
+ == android.hardware.radio.V1_6.MaybePort.hidl_discriminator.range) {
+ final android.hardware.radio.V1_6.PortRange portRange
+ = qosFilter.remotePort.range();
+ ret.remotePort.start = portRange.start;
+ ret.remotePort.end = portRange.end;
+ }
+ }
+
+ ret.protocol = qosFilter.protocol;
+
+ if (qosFilter.tos != null) {
+ if (qosFilter.tos.getDiscriminator()
+ == android.hardware.radio.V1_6.QosFilter.TypeOfService.hidl_discriminator.value) {
+ ret.typeOfServiceMask = qosFilter.tos.value();
+ }
+ }
+
+ if (qosFilter.flowLabel != null) {
+ if (qosFilter.flowLabel.getDiscriminator()
+ == android.hardware.radio.V1_6.QosFilter.Ipv6FlowLabel.hidl_discriminator.value) {
+ ret.flowLabel = qosFilter.flowLabel.value();
+ }
+ }
+
+ if (qosFilter.spi != null) {
+ if (qosFilter.spi.getDiscriminator()
+ == android.hardware.radio.V1_6.QosFilter.IpsecSpi.hidl_discriminator.value) {
+ ret.securityParameterIndex = qosFilter.spi.value();
+ }
+ }
+
+ ret.filterDirection = qosFilter.direction;
+ ret.precedence = qosFilter.precedence;
+
+ return ret;
+ }
+
+ public static class PortRange implements Parcelable {
+ int start;
+ int end;
+
+ PortRange() {
+ start = -1;
+ end = -1;
+ }
+
+ private PortRange(Parcel source) {
+ start = source.readInt();
+ end = source.readInt();
+ }
+
+ public PortRange(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(start);
+ dest.writeInt(end);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final @NonNull Parcelable.Creator<PortRange> CREATOR =
+ new Parcelable.Creator<PortRange>() {
+ @Override
+ public PortRange createFromParcel(Parcel source) {
+ return new PortRange(source);
+ }
+
+ @Override
+ public PortRange[] newArray(int size) {
+ return new PortRange[size];
+ }
+ };
+
+ @Override
+ public String toString() {
+ return "PortRange {"
+ + " start=" + start
+ + " end=" + end + "}";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof PortRange)) {
+ return false;
+ }
+
+ PortRange other = (PortRange) o;
+ return start == other.start
+ && end == other.end;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(start, end);
+ }
+ };
+
+ @Override
+ public String toString() {
+ return "QosFilter {"
+ + " localAddresses=" + localAddresses
+ + " remoteAddresses=" + remoteAddresses
+ + " localPort=" + localPort
+ + " remotePort=" + remotePort
+ + " protocol=" + protocol
+ + " typeOfServiceMask=" + typeOfServiceMask
+ + " flowLabel=" + flowLabel
+ + " securityParameterIndex=" + securityParameterIndex
+ + " filterDirection=" + filterDirection
+ + " precedence=" + precedence + "}";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localAddresses, remoteAddresses, localPort,
+ remotePort, protocol, typeOfServiceMask, flowLabel,
+ securityParameterIndex, filterDirection, precedence);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof QosFilter)) {
+ return false;
+ }
+
+ QosFilter other = (QosFilter) o;
+
+ return localAddresses.size() == other.localAddresses.size()
+ && localAddresses.containsAll(other.localAddresses)
+ && remoteAddresses.size() == other.remoteAddresses.size()
+ && remoteAddresses.containsAll(other.remoteAddresses)
+ && localPort.equals(other.localPort)
+ && remotePort.equals(other.remotePort)
+ && protocol == other.protocol
+ && typeOfServiceMask == other.typeOfServiceMask
+ && flowLabel == other.flowLabel
+ && securityParameterIndex == other.securityParameterIndex
+ && filterDirection == other.filterDirection
+ && precedence == other.precedence;
+ }
+
+ private static LinkAddress createLinkAddressFromString(String addressString) {
+ addressString = addressString.trim();
+ InetAddress address = null;
+ int prefixLength = -1;
+ try {
+ String[] pieces = addressString.split("/", 2);
+ address = InetAddresses.parseNumericAddress(pieces[0]);
+ if (pieces.length == 1) {
+ prefixLength = (address instanceof Inet4Address) ? 32 : 128;
+ } else if (pieces.length == 2) {
+ prefixLength = Integer.parseInt(pieces[1]);
+ }
+ } catch (NullPointerException e) { // Null string.
+ } catch (ArrayIndexOutOfBoundsException e) { // No prefix length.
+ } catch (NumberFormatException e) { // Non-numeric prefix.
+ } catch (IllegalArgumentException e) { // Invalid IP address.
+ }
+
+ if (address == null || prefixLength == -1) {
+ throw new IllegalArgumentException("Invalid link address " + addressString);
+ }
+
+ return new LinkAddress(address, prefixLength, 0, 0,
+ LinkAddress.LIFETIME_UNKNOWN, LinkAddress.LIFETIME_UNKNOWN);
+ }
+
+ private QosFilter(Parcel source) {
+ localAddresses = new ArrayList<>();
+ source.readList(localAddresses, LinkAddress.class.getClassLoader());
+ remoteAddresses = new ArrayList<>();
+ source.readList(remoteAddresses, LinkAddress.class.getClassLoader());
+ localPort = source.readParcelable(PortRange.class.getClassLoader());
+ remotePort = source.readParcelable(PortRange.class.getClassLoader());
+ protocol = source.readInt();
+ typeOfServiceMask = source.readInt();
+ flowLabel = source.readLong();
+ securityParameterIndex = source.readLong();
+ filterDirection = source.readInt();
+ precedence = source.readInt();
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeList(localAddresses);
+ dest.writeList(remoteAddresses);
+ dest.writeParcelable(localPort, flags);
+ dest.writeParcelable(remotePort, flags);
+ dest.writeInt(protocol);
+ dest.writeInt(typeOfServiceMask);
+ dest.writeLong(flowLabel);
+ dest.writeLong(securityParameterIndex);
+ dest.writeInt(filterDirection);
+ dest.writeInt(precedence);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final @NonNull Parcelable.Creator<QosFilter> CREATOR =
+ new Parcelable.Creator<QosFilter>() {
+ @Override
+ public QosFilter createFromParcel(Parcel source) {
+ return new QosFilter(source);
+ }
+
+ @Override
+ public QosFilter[] newArray(int size) {
+ return new QosFilter[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/data/QosSession.java b/telephony/java/android/telephony/data/QosSession.java
new file mode 100644
index 0000000..f07b6a9
--- /dev/null
+++ b/telephony/java/android/telephony/data/QosSession.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 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.telephony.data;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+
+/**
+ * Class that stores information specific to QOS session.
+ *
+ * @hide
+ */
+public final class QosSession implements Parcelable{
+
+ final int qosSessionId;
+ final Qos qos;
+ final List<QosFilter> qosFilterList;
+
+ public QosSession(int qosSessionId, @NonNull Qos qos, @NonNull List<QosFilter> qosFilterList) {
+ this.qosSessionId = qosSessionId;
+ this.qos = qos;
+ this.qosFilterList = qosFilterList;
+ }
+
+ private QosSession(Parcel source) {
+ qosSessionId = source.readInt();
+ qos = source.readParcelable(Qos.class.getClassLoader());
+ qosFilterList = new ArrayList<>();
+ source.readList(qosFilterList, QosFilter.class.getClassLoader());
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(qosSessionId);
+ if (qos.getType() == Qos.QOS_TYPE_EPS) {
+ dest.writeParcelable((EpsQos)qos, flags);
+ } else {
+ dest.writeParcelable((NrQos)qos, flags);
+ }
+ dest.writeList(qosFilterList);
+ }
+
+ public static @NonNull QosSession create(
+ @NonNull android.hardware.radio.V1_6.QosSession qosSession) {
+ List<QosFilter> qosFilters = new ArrayList<>();
+
+ if (qosSession.qosFilters != null) {
+ for (android.hardware.radio.V1_6.QosFilter filter : qosSession.qosFilters) {
+ qosFilters.add(QosFilter.create(filter));
+ }
+ }
+
+ return new QosSession(
+ qosSession.qosSessionId,
+ Qos.create(qosSession.qos),
+ qosFilters);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "QosSession {"
+ + " qosSessionId=" + qosSessionId
+ + " qos=" + qos
+ + " qosFilterList=" + qosFilterList + "}";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(qosSessionId, qos, qosFilterList);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || !(o instanceof QosSession)) {
+ return false;
+ }
+
+ QosSession other = (QosSession) o;
+ return this.qosSessionId == other.qosSessionId
+ && this.qos.equals(other.qos)
+ && this.qosFilterList.size() == other.qosFilterList.size()
+ && this.qosFilterList.containsAll(other.qosFilterList);
+ }
+
+
+ public static final @NonNull Parcelable.Creator<QosSession> CREATOR =
+ new Parcelable.Creator<QosSession>() {
+ @Override
+ public QosSession createFromParcel(Parcel source) {
+ return new QosSession(source);
+ }
+
+ @Override
+ public QosSession[] newArray(int size) {
+ return new QosSession[size];
+ }
+ };
+}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 69525a8..7e1aee7 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -36,6 +36,7 @@
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.ClientRequestStats;
+import android.telephony.ThermalMitigationRequest;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.ICellInfoCallback;
import android.telephony.ModemActivityInfo;
@@ -2254,4 +2255,14 @@
* @return CarrierBandwidth with bandwidth of both primary and secondary carrier.
*/
CarrierBandwidth getCarrierBandwidth(int subId);
+
+ /**
+ * Thermal mitigation request to control functionalities at modem.
+ *
+ * @param subId the id of the subscription
+ * @param thermalMitigationRequest holds the parameters necessary for the request.
+ * @throws InvalidThermalMitigationRequestException if the parametes are invalid.
+ */
+ int sendThermalMitigationRequest(int subId,
+ in ThermalMitigationRequest thermalMitigationRequest);
}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index a2361a7..21cca4c 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -520,6 +520,7 @@
int RIL_REQUEST_START_HANDOVER = 217;
int RIL_REQUEST_CANCEL_HANDOVER = 218;
int RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS = 219;
+ int RIL_REQUEST_SET_DATA_THROTTLING = 221;
/* Responses begin */
int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;
diff --git a/tests/RollbackTest/TEST_MAPPING b/tests/RollbackTest/TEST_MAPPING
index 0f4c460..7f9f2dc 100644
--- a/tests/RollbackTest/TEST_MAPPING
+++ b/tests/RollbackTest/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "RollbackTest"
},