diff options
19 files changed, 245 insertions, 62 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java index 84d05c8b4144..0f2ce0175a9e 100644 --- a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +++ b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java @@ -3302,7 +3302,7 @@ public class DeviceIdleController extends SystemService if (DEBUG) Slog.d(TAG, "Moved from LIGHT_STATE_ACTIVE to LIGHT_STATE_INACTIVE"); resetLightIdleManagementLocked(); scheduleLightAlarmLocked(mConstants.LIGHT_IDLE_AFTER_INACTIVE_TIMEOUT, - mConstants.FLEX_TIME_SHORT); + mConstants.FLEX_TIME_SHORT, true); EventLogTags.writeDeviceIdleLight(mLightState, "no activity"); } } @@ -3377,7 +3377,7 @@ public class DeviceIdleController extends SystemService mLightState = LIGHT_STATE_PRE_IDLE; EventLogTags.writeDeviceIdleLight(mLightState, reason); scheduleLightAlarmLocked(mConstants.LIGHT_PRE_IDLE_TIMEOUT, - mConstants.FLEX_TIME_SHORT); + mConstants.FLEX_TIME_SHORT, true); break; } // Nothing active, fall through to immediately idle. @@ -3396,7 +3396,7 @@ public class DeviceIdleController extends SystemService } } mMaintenanceStartTime = 0; - scheduleLightAlarmLocked(mNextLightIdleDelay, mNextLightIdleDelayFlex); + scheduleLightAlarmLocked(mNextLightIdleDelay, mNextLightIdleDelayFlex, false); mNextLightIdleDelay = Math.min(mConstants.LIGHT_MAX_IDLE_TIMEOUT, (long) (mNextLightIdleDelay * mConstants.LIGHT_IDLE_FACTOR)); mNextLightIdleDelayFlex = Math.min(mConstants.LIGHT_MAX_IDLE_TIMEOUT_FLEX, @@ -3420,7 +3420,7 @@ public class DeviceIdleController extends SystemService } else if (mCurLightIdleBudget > mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET) { mCurLightIdleBudget = mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET; } - scheduleLightAlarmLocked(mCurLightIdleBudget, mConstants.FLEX_TIME_SHORT); + scheduleLightAlarmLocked(mCurLightIdleBudget, mConstants.FLEX_TIME_SHORT, true); if (DEBUG) Slog.d(TAG, "Moved from LIGHT_STATE_IDLE to LIGHT_STATE_IDLE_MAINTENANCE."); mLightState = LIGHT_STATE_IDLE_MAINTENANCE; @@ -3431,7 +3431,8 @@ public class DeviceIdleController extends SystemService // We'd like to do maintenance, but currently don't have network // connectivity... let's try to wait until the network comes back. // We'll only wait for another full idle period, however, and then give up. - scheduleLightAlarmLocked(mNextLightIdleDelay, mNextLightIdleDelayFlex / 2); + scheduleLightAlarmLocked(mNextLightIdleDelay, + mNextLightIdleDelayFlex / 2, true); if (DEBUG) Slog.d(TAG, "Moved to LIGHT_WAITING_FOR_NETWORK."); mLightState = LIGHT_STATE_WAITING_FOR_NETWORK; EventLogTags.writeDeviceIdleLight(mLightState, reason); @@ -3964,18 +3965,23 @@ public class DeviceIdleController extends SystemService } } - void scheduleLightAlarmLocked(long delay, long flex) { + @GuardedBy("this") + void scheduleLightAlarmLocked(long delay, long flex, boolean wakeup) { if (DEBUG) { - Slog.d(TAG, "scheduleLightAlarmLocked(" + delay + Slog.d(TAG, "scheduleLightAlarmLocked(wakeup=" + wakeup + ", " + delay + (mConstants.USE_WINDOW_ALARMS ? "/" + flex : "") + ")"); } mNextLightAlarmTime = SystemClock.elapsedRealtime() + delay; if (mConstants.USE_WINDOW_ALARMS) { - mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, mNextLightAlarmTime, flex, - "DeviceIdleController.light", mLightAlarmListener, mHandler); + mAlarmManager.setWindow(wakeup ? AlarmManager.ELAPSED_REALTIME_WAKEUP : + AlarmManager.ELAPSED_REALTIME, + mNextLightAlarmTime, flex, "DeviceIdleController.light", mLightAlarmListener, + mHandler); } else { - mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, mNextLightAlarmTime, - "DeviceIdleController.light", mLightAlarmListener, mHandler); + mAlarmManager.set(wakeup ? AlarmManager.ELAPSED_REALTIME_WAKEUP : + AlarmManager.ELAPSED_REALTIME, + mNextLightAlarmTime, "DeviceIdleController.light", mLightAlarmListener, + mHandler); } } diff --git a/core/api/current.txt b/core/api/current.txt index c3b5b943477f..6aeed38e0adb 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -38281,7 +38281,8 @@ package android.service.carrier { public abstract class CarrierService extends android.app.Service { ctor public CarrierService(); - method public final void notifyCarrierNetworkChange(boolean); + method @Deprecated public final void notifyCarrierNetworkChange(boolean); + method public final void notifyCarrierNetworkChange(int, boolean); method @CallSuper public android.os.IBinder onBind(android.content.Intent); method public abstract android.os.PersistableBundle onLoadConfig(android.service.carrier.CarrierIdentifier); field public static final String CARRIER_SERVICE_INTERFACE = "android.service.carrier.CarrierService"; diff --git a/core/api/system-current.txt b/core/api/system-current.txt index d8f5d9e34ee6..da9a4c50d3cb 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -11698,6 +11698,14 @@ package android.telephony { field public static final int ROAMING_TYPE_UNKNOWN = 1; // 0x1 } + public final class SignalStrengthUpdateRequest implements android.os.Parcelable { + method public boolean isSystemThresholdReportingRequestedWhileIdle(); + } + + public static final class SignalStrengthUpdateRequest.Builder { + method @NonNull @RequiresPermission("android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH") public android.telephony.SignalStrengthUpdateRequest.Builder setSystemThresholdReportingRequestedWhileIdle(boolean); + } + public final class SmsCbCmasInfo implements android.os.Parcelable { ctor public SmsCbCmasInfo(int, int, int, int, int, int); method public int describeContents(); diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index b23c3eb0ceae..5612e7cf56ce 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -56,7 +56,7 @@ import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; -import android.os.SystemProperties; +import android.sysprop.BluetoothProperties; import android.util.Log; import android.util.Pair; @@ -1337,7 +1337,7 @@ public final class BluetoothAdapter { return true; } Log.e(TAG, "factoryReset(): Setting persist.bluetooth.factoryreset to retry later"); - SystemProperties.set("persist.bluetooth.factoryreset", "true"); + BluetoothProperties.factory_reset(true); } catch (RemoteException e) { Log.e(TAG, "", e); } finally { diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java index ddb6533547bb..d974e0c0713a 100644 --- a/core/java/android/os/Trace.java +++ b/core/java/android/os/Trace.java @@ -131,6 +131,10 @@ public final class Trace { private static native void nativeAsyncTraceBegin(long tag, String name, int cookie); @FastNative private static native void nativeAsyncTraceEnd(long tag, String name, int cookie); + @FastNative + private static native void nativeInstant(long tag, String name); + @FastNative + private static native void nativeInstantForTrack(long tag, String trackName, String name); private Trace() { } @@ -258,6 +262,42 @@ public final class Trace { } /** + * Writes a trace message to indicate that a given section of code was invoked. + * + * @param traceTag The trace tag. + * @param methodName The method name to appear in the trace. + * @hide + */ + public static void instant(long traceTag, String methodName) { + if (methodName == null) { + throw new IllegalArgumentException("methodName cannot be null"); + } + if (isTagEnabled(traceTag)) { + nativeInstant(traceTag, methodName); + } + } + + /** + * Writes a trace message to indicate that a given section of code was invoked. + * + * @param traceTag The trace tag. + * @param trackName The track where the event should appear in the trace. + * @param methodName The method name to appear in the trace. + * @hide + */ + public static void instantForTrack(long traceTag, String trackName, String methodName) { + if (trackName == null) { + throw new IllegalArgumentException("trackName cannot be null"); + } + if (methodName == null) { + throw new IllegalArgumentException("methodName cannot be null"); + } + if (isTagEnabled(traceTag)) { + nativeInstantForTrack(traceTag, trackName, methodName); + } + } + + /** * Checks whether or not tracing is currently enabled. This is useful to avoid intermediate * string creation for trace sections that require formatting. It is not necessary * to guard all Trace method calls as they internally already check this. However it is diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 9f3a847e12eb..0adc00e56bf1 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -5374,5 +5374,21 @@ public final class Telephony { */ public static final String COLUMN_NR_ADVANCED_CALLING_ENABLED = "nr_advanced_calling_enabled"; + + /** + * TelephonyProvider column name for the phone number from source CARRIER + * + * @hide + */ + public static final String COLUMN_PHONE_NUMBER_SOURCE_CARRIER = + "phone_number_source_carrier"; + + /** + * TelephonyProvider column name for the phone number from source IMS + * + * @hide + */ + public static final String COLUMN_PHONE_NUMBER_SOURCE_IMS = + "phone_number_source_ims"; } } diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 859fd804dea5..e7f89204c1ec 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -285,6 +285,8 @@ public class TelephonyRegistryManager { * UI. There is no timeout associated with showing this UX, so a carrier app must be sure to * call with active set to false sometime after calling with it set to {@code true}. * <p> + * This will apply to all subscriptions the carrier app has carrier privileges on. + * <p> * Requires Permission: calling app has carrier privileges. * * @param active Whether the carrier network change is or shortly will be @@ -300,6 +302,31 @@ public class TelephonyRegistryManager { } /** + * Informs the system of an intentional upcoming carrier network change by a carrier app on the + * given {@code subscriptionId}. This call only used to allow the system to provide alternative + * UI while telephony is performing an action that may result in intentional, temporary network + * lack of connectivity. + * <p> + * Based on the active parameter passed in, this method will either show or hide the + * alternative UI. There is no timeout associated with showing this UX, so a carrier app must be + * sure to call with active set to false sometime after calling with it set to {@code true}. + * <p> + * Requires Permission: calling app has carrier privileges. + * + * @param subscriptionId the subscription of the carrier network. + * @param active whether the carrier network change is or shortly will be active. Set this value + * to true to begin showing alternative UI and false to stop. + * @see TelephonyManager#hasCarrierPrivileges + */ + public void notifyCarrierNetworkChange(int subscriptionId, boolean active) { + try { + sRegistry.notifyCarrierNetworkChangeWithSubId(subscriptionId, active); + } catch (RemoteException ex) { + // system server crash + } + } + + /** * Notify call state changed on certain subscription. * * @param slotIndex for which call state changed. Can be derived from subId except when subId is diff --git a/core/java/android/view/inputmethod/InputConnection.java b/core/java/android/view/inputmethod/InputConnection.java index 5f036a348808..4d7d182f0013 100644 --- a/core/java/android/view/inputmethod/InputConnection.java +++ b/core/java/android/view/inputmethod/InputConnection.java @@ -770,20 +770,25 @@ public interface InputConnection { boolean beginBatchEdit(); /** - * Tell the editor that you are done with a batch edit previously - * initiated with {@link #beginBatchEdit}. This ends the latest - * batch only. - * - * <p><strong>IME authors:</strong> make sure you call this - * exactly once for each call to {@link #beginBatchEdit}.</p> - * - * <p><strong>Editor authors:</strong> please be careful about - * batch edit nesting. Updates still to be held back until the end - * of the last batch edit.</p> + * Tell the editor that you are done with a batch edit previously initiated with + * {@link #beginBatchEdit()}. This ends the latest batch only. + * + * <p><strong>IME authors:</strong> make sure you call this exactly once for each call to + * {@link #beginBatchEdit()}.</p> + * + * <p><strong>Editor authors:</strong> please be careful about batch edit nesting. Updates still + * to be held back until the end of the last batch edit. In case you are delegating this API + * call to the one obtained from + * {@link android.widget.EditText#onCreateInputConnection(EditorInfo)}, there was an off-by-one + * that had returned {@code true} when its nested batch edit count becomes {@code 0} as a result + * of invoking this API. This bug is fixed in {@link android.os.Build.VERSION_CODES#TIRAMISU}. + * </p> * - * @return true if there is still a batch edit in progress after closing - * the latest one (in other words, if the nesting count is > 0), false - * otherwise or if the input connection is no longer valid. + * @return For editor authors, you must return {@code true} if a batch edit is still in progress + * after closing the latest one (in other words, if the nesting count is still a + * positive number). Return {@code false} otherwise. For IME authors, you will + * always receive {@code true} as long as the request was sent to the editor, and + * receive {@code false} only if the input connection is no longer valid. */ boolean endBatchEdit(); diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 6ba0279313b1..15d4246e302a 100644 --- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -77,6 +77,7 @@ interface ITelephonyRegistry { void notifySubscriptionInfoChanged(); void notifyOpportunisticSubscriptionInfoChanged(); void notifyCarrierNetworkChange(in boolean active); + void notifyCarrierNetworkChangeWithSubId(in int subId, in boolean active); void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state); void notifyDisplayInfoChanged(int slotIndex, int subId, in TelephonyDisplayInfo telephonyDisplayInfo); void notifyPhoneCapabilityChanged(in PhoneCapability capability); diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java index 02ffe8c5268e..040d78b65afa 100644 --- a/core/java/com/android/internal/widget/EditableInputConnection.java +++ b/core/java/com/android/internal/widget/EditableInputConnection.java @@ -92,7 +92,7 @@ public class EditableInputConnection extends BaseInputConnection // contribution to mTextView's nested batch edit count is zero. mTextView.endBatchEdit(); mBatchEditNesting--; - return true; + return mBatchEditNesting > 0; } } return false; diff --git a/core/jni/android_os_Trace.cpp b/core/jni/android_os_Trace.cpp index f67007cda209..85fd5d99e473 100644 --- a/core/jni/android_os_Trace.cpp +++ b/core/jni/android_os_Trace.cpp @@ -90,6 +90,22 @@ static void android_os_Trace_nativeSetTracingEnabled(JNIEnv*, jclass, jboolean e atrace_set_tracing_enabled(enabled); } +static void android_os_Trace_nativeInstant(JNIEnv* env, jclass, + jlong tag, jstring nameStr) { + withString(env, nameStr, [tag](char* str) { + atrace_instant(tag, str); + }); +} + +static void android_os_Trace_nativeInstantForTrack(JNIEnv* env, jclass, + jlong tag, jstring trackStr, jstring nameStr) { + withString(env, trackStr, [env, tag, nameStr](char* track) { + withString(env, nameStr, [tag, track](char* name) { + atrace_instant_for_track(tag, track, name); + }); + }); +} + static const JNINativeMethod gTraceMethods[] = { /* name, signature, funcPtr */ { "nativeSetAppTracingAllowed", @@ -116,6 +132,12 @@ static const JNINativeMethod gTraceMethods[] = { { "nativeAsyncTraceEnd", "(JLjava/lang/String;I)V", (void*)android_os_Trace_nativeAsyncTraceEnd }, + { "nativeInstant", + "(JLjava/lang/String;)V", + (void*)android_os_Trace_nativeInstant }, + { "nativeInstantForTrack", + "(JLjava/lang/String;Ljava/lang/String;)V", + (void*)android_os_Trace_nativeInstantForTrack }, // ----------- @CriticalNative ---------------- { "nativeGetEnabledTags", diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index a699f912806d..7d0f60adeb5c 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -447,10 +447,6 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, skipCallbacks = true; } } - - if (skipCallbacks) { - mInputConsumer.sendFinishedSignal(seq, false); - } } } diff --git a/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt b/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt index c1db8edf4119..90064172dd36 100644 --- a/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt +++ b/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt @@ -16,6 +16,7 @@ package com.android.systemui.log +import android.os.Trace import android.util.Log import com.android.systemui.log.dagger.LogModule import java.io.PrintWriter @@ -169,7 +170,7 @@ class LogBuffer( buffer.add(message as LogMessageImpl) if (logcatEchoTracker.isBufferLoggable(name, message.level) || logcatEchoTracker.isTagLoggable(message.tag, message.level)) { - echoToLogcat(message) + echo(message) } } @@ -219,7 +220,7 @@ class LogBuffer( pw.println(message.printer(message)) } - private fun echoToLogcat(message: LogMessage) { + private fun echo(message: LogMessage) { val strMessage = message.printer(message) when (message.level) { LogLevel.VERBOSE -> Log.v(message.tag, strMessage) @@ -229,6 +230,7 @@ class LogBuffer( LogLevel.ERROR -> Log.e(message.tag, strMessage) LogLevel.WTF -> Log.wtf(message.tag, strMessage) } + Trace.instantForTrack(Trace.TRACE_TAG_APP, "UI Events", strMessage) } } diff --git a/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt index 142628cff448..c0f79d575dc6 100644 --- a/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt @@ -21,7 +21,6 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView -import androidx.annotation.IntegerRes import com.android.systemui.R import com.android.systemui.util.animation.TransitionLayout @@ -47,14 +46,14 @@ class RecommendationViewHolder private constructor(itemView: View) { itemView.requireViewById(R.id.media_cover4_container), itemView.requireViewById(R.id.media_cover5_container), itemView.requireViewById(R.id.media_cover6_container)) - val mediaCoverItemsResIds = listOf<@IntegerRes Int>( + val mediaCoverItemsResIds = listOf<Int>( R.id.media_cover1, R.id.media_cover2, R.id.media_cover3, R.id.media_cover4, R.id.media_cover5, R.id.media_cover6) - val mediaCoverContainersResIds = listOf<@IntegerRes Int>( + val mediaCoverContainersResIds = listOf<Int>( R.id.media_cover1_container, R.id.media_cover2_container, R.id.media_cover3_container, diff --git a/services/art-profile b/services/art-profile index af58bca129f8..2d9e95eebdc5 100644 --- a/services/art-profile +++ b/services/art-profile @@ -1464,7 +1464,7 @@ HSPLcom/android/server/DeviceIdleController;->reportTempWhitelistChangedLocked(I HPLcom/android/server/DeviceIdleController;->resetIdleManagementLocked()V+]Lcom/android/server/AnyMotionDetector;Lcom/android/server/AnyMotionDetector;]Lcom/android/server/DeviceIdleController;Lcom/android/server/DeviceIdleController; HPLcom/android/server/DeviceIdleController;->resetLightIdleManagementLocked()V+]Lcom/android/server/DeviceIdleController;Lcom/android/server/DeviceIdleController; HPLcom/android/server/DeviceIdleController;->scheduleAlarmLocked(JZ)V+]Landroid/app/AlarmManager;Landroid/app/AlarmManager; -HPLcom/android/server/DeviceIdleController;->scheduleLightAlarmLocked(JJ)V+]Landroid/app/AlarmManager;Landroid/app/AlarmManager; +HPLcom/android/server/DeviceIdleController;->scheduleLightAlarmLocked(JJZ)V+]Landroid/app/AlarmManager;Landroid/app/AlarmManager; HPLcom/android/server/DeviceIdleController;->scheduleMotionRegistrationAlarmLocked()V+]Lcom/android/server/DeviceIdleController$Injector;Lcom/android/server/DeviceIdleController$Injector;]Landroid/app/AlarmManager;Landroid/app/AlarmManager; HSPLcom/android/server/DeviceIdleController;->scheduleMotionTimeoutAlarmLocked()V+]Landroid/app/AlarmManager;Landroid/app/AlarmManager;]Lcom/android/server/DeviceIdleController$Injector;Lcom/android/server/DeviceIdleController$Injector; HPLcom/android/server/DeviceIdleController;->scheduleReportActiveLocked(Ljava/lang/String;I)V+]Lcom/android/server/DeviceIdleController$MyHandler;Lcom/android/server/DeviceIdleController$MyHandler; diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 91cd2f6ad676..d7c1cfb7d1ed 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -366,7 +366,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private List<BarringInfo> mBarringInfo = null; - private boolean mCarrierNetworkChangeState = false; + private boolean[] mCarrierNetworkChangeState = null; private PhoneCapability mPhoneCapability = null; @@ -675,6 +675,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones); mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones); mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones); + mCarrierNetworkChangeState = copyOf(mCarrierNetworkChangeState, mNumPhones); mIsDataEnabled= copyOf(mIsDataEnabled, mNumPhones); mDataEnabledReason = copyOf(mDataEnabledReason, mNumPhones); mAllowedNetworkTypeReason = copyOf(mAllowedNetworkTypeReason, mNumPhones); @@ -720,6 +721,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; mPreciseDataConnectionStates.add(new ArrayMap<>()); mBarringInfo.add(i, new BarringInfo()); + mCarrierNetworkChangeState[i] = false; mTelephonyDisplayInfos[i] = null; mIsDataEnabled[i] = false; mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER; @@ -784,6 +786,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones]; mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones]; mBarringInfo = new ArrayList<>(); + mCarrierNetworkChangeState = new boolean[numPhones]; mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones]; mPhysicalChannelConfigs = new ArrayList<>(); mAllowedNetworkTypeReason = new int[numPhones]; @@ -820,6 +823,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; mPreciseDataConnectionStates.add(new ArrayMap<>()); mBarringInfo.add(i, new BarringInfo()); + mCarrierNetworkChangeState[i] = false; mTelephonyDisplayInfos[i] = null; mIsDataEnabled[i] = false; mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER; @@ -1230,7 +1234,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } if (events.contains(TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED)) { try { - r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState); + r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState[r.phoneId]); } catch (RemoteException ex) { remove(r.binder); } @@ -1724,23 +1728,37 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { throw new SecurityException("notifyCarrierNetworkChange without carrier privilege"); } + for (int subId : subIds) { + notifyCarrierNetworkChangeWithPermission(subId, active); + } + } + + @Override + public void notifyCarrierNetworkChangeWithSubId(int subId, boolean active) { + if (!TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, subId)) { + throw new SecurityException( + "notifyCarrierNetworkChange without carrier privilege on subId " + subId); + } + + notifyCarrierNetworkChangeWithPermission(subId, active); + } + + private void notifyCarrierNetworkChangeWithPermission(int subId, boolean active) { synchronized (mRecords) { - mCarrierNetworkChangeState = active; - for (int subId : subIds) { - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = getPhoneIdFromSubId(subId); + mCarrierNetworkChangeState[phoneId] = active; - if (VDBG) { - log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId); - } - for (Record r : mRecords) { - if (r.matchTelephonyCallbackEvent( - TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED) - && idMatch(r, subId, phoneId)) { - try { - r.callback.onCarrierNetworkChange(active); - } catch (RemoteException ex) { - mRemoveList.add(r.binder); - } + if (VDBG) { + log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId); + } + for (Record r : mRecords) { + if (r.matchTelephonyCallbackEvent( + TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED) + && idMatch(r, subId, phoneId)) { + try { + r.callback.onCarrierNetworkChange(active); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); } } } @@ -2788,6 +2806,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mOutgoingCallEmergencyNumber=" + mOutgoingCallEmergencyNumber[i]); pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]); pw.println("mBarringInfo=" + mBarringInfo.get(i)); + pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState[i]); pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]); pw.println("mIsDataEnabled=" + mIsDataEnabled); pw.println("mDataEnabledReason=" + mDataEnabledReason); @@ -2797,7 +2816,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mLinkCapacityEstimateList=" + mLinkCapacityEstimateLists.get(i)); pw.decreaseIndent(); } - pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState); + pw.println("mPhoneCapability=" + mPhoneCapability); pw.println("mActiveDataSubId=" + mActiveDataSubId); pw.println("mRadioPowerState=" + mRadioPowerState); diff --git a/services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java index e472b062388e..d71030802c2b 100644 --- a/services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java @@ -1047,7 +1047,8 @@ public class DeviceIdleControllerTest { verifyLightStateConditions(LIGHT_STATE_IDLE); inOrder.verify(mDeviceIdleController).scheduleLightAlarmLocked( longThat(l -> l == mConstants.LIGHT_IDLE_TIMEOUT), - longThat(l -> l == mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX)); + longThat(l -> l == mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX), + eq(false)); // Should just alternate between IDLE and IDLE_MAINTENANCE now. @@ -1055,19 +1056,22 @@ public class DeviceIdleControllerTest { verifyLightStateConditions(LIGHT_STATE_IDLE_MAINTENANCE); inOrder.verify(mDeviceIdleController).scheduleLightAlarmLocked( longThat(l -> l >= mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET), - longThat(l -> l == mConstants.FLEX_TIME_SHORT)); + longThat(l -> l == mConstants.FLEX_TIME_SHORT), + eq(true)); mDeviceIdleController.stepLightIdleStateLocked("testing"); verifyLightStateConditions(LIGHT_STATE_IDLE); inOrder.verify(mDeviceIdleController).scheduleLightAlarmLocked( longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT), - longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX)); + longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX), + eq(false)); mDeviceIdleController.stepLightIdleStateLocked("testing"); verifyLightStateConditions(LIGHT_STATE_IDLE_MAINTENANCE); inOrder.verify(mDeviceIdleController).scheduleLightAlarmLocked( longThat(l -> l >= mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET), - longThat(l -> l == mConstants.FLEX_TIME_SHORT)); + longThat(l -> l == mConstants.FLEX_TIME_SHORT), + eq(true)); // Test that motion doesn't reset the idle timeout. mDeviceIdleController.handleMotionDetectedLocked(50, "test"); @@ -1076,7 +1080,8 @@ public class DeviceIdleControllerTest { verifyLightStateConditions(LIGHT_STATE_IDLE); inOrder.verify(mDeviceIdleController).scheduleLightAlarmLocked( longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT), - longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX)); + longThat(l -> l > mConstants.LIGHT_IDLE_TIMEOUT_INITIAL_FLEX), + eq(false)); } ///////////////// EXIT conditions /////////////////// diff --git a/telephony/java/android/service/carrier/CarrierService.java b/telephony/java/android/service/carrier/CarrierService.java index d06ec11f3e61..ca27998ec8a8 100644 --- a/telephony/java/android/service/carrier/CarrierService.java +++ b/telephony/java/android/service/carrier/CarrierService.java @@ -115,7 +115,12 @@ public abstract class CarrierService extends Service { * active. Set this value to true to begin showing * alternative UI and false to stop. * @see android.telephony.TelephonyManager#hasCarrierPrivileges + * @deprecated use {@link #notifyCarrierNetworkChange(int, boolean)} instead. + * With no parameter to specify the subscription, this API will + * apply to all subscriptions that the carrier app has carrier + * privileges on. */ + @Deprecated public final void notifyCarrierNetworkChange(boolean active) { TelephonyRegistryManager telephonyRegistryMgr = (TelephonyRegistryManager) this.getSystemService( @@ -126,6 +131,31 @@ public abstract class CarrierService extends Service { } /** + * Informs the system of an intentional upcoming carrier network change by a carrier app on the + * given {@code subscriptionId}. This call is optional and is only used to allow the system to + * provide alternative UI while telephony is performing an action that may result in + * intentional, temporary network lack of connectivity. + * + * <p>Based on the active parameter passed in, this method will either show or hide the + * alternative UI. There is no timeout associated with showing this UX, so a carrier app must + * be sure to call with active set to false sometime after calling with it set to true. + * + * <p>Requires Permission: calling app has carrier privileges. + * + * @param subscriptionId the subscription of the carrier network that trigger the change. + * @param active whether the carrier network change is or shortly will be active. Set this + * value to true to begin showing alternative UI and false to stop. + * @see android.telephony.TelephonyManager#hasCarrierPrivileges + */ + public final void notifyCarrierNetworkChange(int subscriptionId, boolean active) { + TelephonyRegistryManager telephonyRegistryMgr = this.getSystemService( + TelephonyRegistryManager.class); + if (telephonyRegistryMgr != null) { + telephonyRegistryMgr.notifyCarrierNetworkChange(subscriptionId, active); + } + } + + /** * If overriding this method, call through to the super method for any unknown actions. * {@inheritDoc} */ diff --git a/telephony/java/android/telephony/SignalStrengthUpdateRequest.java b/telephony/java/android/telephony/SignalStrengthUpdateRequest.java index 9cb80f1814f9..4884d549e2e0 100644 --- a/telephony/java/android/telephony/SignalStrengthUpdateRequest.java +++ b/telephony/java/android/telephony/SignalStrengthUpdateRequest.java @@ -19,6 +19,7 @@ package android.telephony; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; +import android.annotation.SystemApi; import android.os.Binder; import android.os.IBinder; import android.os.Parcel; @@ -130,7 +131,10 @@ public final class SignalStrengthUpdateRequest implements Parcelable { /** * Set the builder object if require reporting on the system thresholds when device is idle. * - * <p>This can only used by the system caller. Requires permission + * <p>This is intended to be used by the system privileged caller only. When setting to + * {@code true}, signal strength update request through + * {@link TelephonyManager#setSignalStrengthUpdateRequest(SignalStrengthUpdateRequest)} + * will require permission * {@link android.Manifest.permission#LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH}. * * @param isSystemThresholdReportingRequestedWhileIdle true if request reporting on the @@ -138,6 +142,7 @@ public final class SignalStrengthUpdateRequest implements Parcelable { * @return the builder to facilitate the chaining * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) public @NonNull Builder setSystemThresholdReportingRequestedWhileIdle( boolean isSystemThresholdReportingRequestedWhileIdle) { @@ -191,6 +196,7 @@ public final class SignalStrengthUpdateRequest implements Parcelable { * * @hide */ + @SystemApi public boolean isSystemThresholdReportingRequestedWhileIdle() { return mIsSystemThresholdReportingRequestedWhileIdle; } |