diff options
50 files changed, 471 insertions, 300 deletions
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt index 13a48993f68f..6a4c67b71250 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -90,6 +90,7 @@ package android.content { public abstract class Context { method @NonNull public android.os.UserHandle getUser(); field public static final String PAC_PROXY_SERVICE = "pac_proxy"; + field public static final String REMOTE_AUTH_SERVICE = "remote_auth"; field public static final String TEST_NETWORK_SERVICE = "test_network"; } diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 7de7c676706b..21d4b6461214 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -6059,6 +6059,18 @@ public abstract class Context { /** * Use with {@link #getSystemService(String)} to retrieve a + * {@link android.remoteauth.RemoteAuthManager} to discover, + * register and authenticate via remote authenticator devices. + * + * @see #getSystemService(String) + * @see android.remoteauth.RemoteAuthManager + * @hide + */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + public static final String REMOTE_AUTH_SERVICE = "remote_auth"; + + /** + * Use with {@link #getSystemService(String)} to retrieve a * {@link android.app.ambientcontext.AmbientContextManager}. * * @see #getSystemService(String) diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 809dc3c41188..4549c30b8c5d 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4479,8 +4479,8 @@ public class Intent implements Parcelable, Cloneable { * @see #EXTRA_SIM_LOCKED_REASON * @see #EXTRA_REBROADCAST_ON_UNLOCK * - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or - * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} * * @hide */ @@ -4503,42 +4503,42 @@ public class Intent implements Parcelable, Cloneable { * @see #SIM_STATE_IMSI * @see #SIM_STATE_LOADED * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String EXTRA_SIM_STATE = "ss"; /** * The intent value UNKNOWN represents the SIM state unknown * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; /** * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_NOT_READY = "NOT_READY"; /** * The intent value ABSENT means the SIM card is missing * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_ABSENT = "ABSENT"; /** * The intent value PRESENT means the device has a SIM card inserted * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_PRESENT = "PRESENT"; /** * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; @@ -4546,35 +4546,35 @@ public class Intent implements Parcelable, Cloneable { * The intent value CARD_RESTRICTED means card is present but not usable due to carrier * restrictions * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; /** * The intent value LOCKED means the SIM is locked by PIN or by network * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_LOCKED = "LOCKED"; /** * The intent value READY means the SIM is ready to be accessed * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_READY = "READY"; /** * The intent value IMSI means the SIM IMSI is ready in property * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_IMSI = "IMSI"; /** * The intent value LOADED means all SIM records, including IMSI, are loaded * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} */ public static final String SIM_STATE_LOADED = "LOADED"; @@ -4588,21 +4588,24 @@ public class Intent implements Parcelable, Cloneable { * @see #SIM_ABSENT_ON_PERM_DISABLED * * @hide - * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ public static final String EXTRA_SIM_LOCKED_REASON = "reason"; /** * The intent value PIN means the SIM is locked on PIN1 * @hide - * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ public static final String SIM_LOCKED_ON_PIN = "PIN"; /** * The intent value PUK means the SIM is locked on PUK1 * @hide - * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ /* PUK means ICC is locked on PUK1 */ public static final String SIM_LOCKED_ON_PUK = "PUK"; @@ -4610,14 +4613,16 @@ public class Intent implements Parcelable, Cloneable { /** * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION * @hide - * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ public static final String SIM_LOCKED_NETWORK = "NETWORK"; /** * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails * @hide - * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; @@ -4626,8 +4631,8 @@ public class Intent implements Parcelable, Cloneable { * is a rebroadcast on unlock. Defaults to {@code false} if not specified. * * @hide - * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or - * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} + * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or + * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} */ public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index d738d9eec4cb..db4a684b667e 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -1561,6 +1561,14 @@ public abstract class PackageManager { */ public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000; + /** + * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is + * a development-only feature and should not be used on end user devices. + * + * @hide + */ + public static final int INSTALL_FORCE_NON_STAGED_APEX_UPDATE = 0x02000000; + /** @hide */ @IntDef(flag = true, value = { DONT_KILL_APP, diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 9b169499b41f..c8dbfc914847 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -53,6 +53,7 @@ import android.graphics.drawable.Drawable.ConstantState; import android.graphics.drawable.DrawableInflater; import android.os.Build; import android.os.Bundle; +import android.os.SystemClock; import android.util.ArrayMap; import android.util.ArraySet; import android.util.AttributeSet; @@ -132,6 +133,11 @@ public class Resources { private static final Object sSync = new Object(); private final Object mUpdateLock = new Object(); + /** + * Controls whether we should preload resources during zygote init. + */ + private static final boolean PRELOAD_RESOURCES = true; + // Used by BridgeResources in layoutlib @UnsupportedAppUsage static Resources mSystem = null; @@ -2666,6 +2672,98 @@ public class Resources { } } + /** + * Load in commonly used resources, so they can be shared across processes. + * + * These tend to be a few Kbytes, but are frequently in the 20-40K range, and occasionally even + * larger. + * @hide + */ + @UnsupportedAppUsage + public static void preloadResources() { + try { + final Resources sysRes = Resources.getSystem(); + sysRes.startPreloading(); + if (PRELOAD_RESOURCES) { + Log.i(TAG, "Preloading resources..."); + + long startTime = SystemClock.uptimeMillis(); + TypedArray ar = sysRes.obtainTypedArray( + com.android.internal.R.array.preloaded_drawables); + int numberOfEntries = preloadDrawables(sysRes, ar); + ar.recycle(); + Log.i(TAG, "...preloaded " + numberOfEntries + " resources in " + + (SystemClock.uptimeMillis() - startTime) + "ms."); + + startTime = SystemClock.uptimeMillis(); + ar = sysRes.obtainTypedArray( + com.android.internal.R.array.preloaded_color_state_lists); + numberOfEntries = preloadColorStateLists(sysRes, ar); + ar.recycle(); + Log.i(TAG, "...preloaded " + numberOfEntries + " resources in " + + (SystemClock.uptimeMillis() - startTime) + "ms."); + + if (sysRes.getBoolean( + com.android.internal.R.bool.config_freeformWindowManagement)) { + startTime = SystemClock.uptimeMillis(); + ar = sysRes.obtainTypedArray( + com.android.internal.R.array.preloaded_freeform_multi_window_drawables); + numberOfEntries = preloadDrawables(sysRes, ar); + ar.recycle(); + Log.i(TAG, "...preloaded " + numberOfEntries + " resource in " + + (SystemClock.uptimeMillis() - startTime) + "ms."); + } + } + sysRes.finishPreloading(); + } catch (RuntimeException e) { + Log.w(TAG, "Failure preloading resources", e); + } + } + + private static int preloadColorStateLists(Resources resources, TypedArray ar) { + final int numberOfEntries = ar.length(); + for (int i = 0; i < numberOfEntries; i++) { + int id = ar.getResourceId(i, 0); + + if (id != 0) { + if (resources.getColorStateList(id, null) == null) { + throw new IllegalArgumentException( + "Unable to find preloaded color resource #0x" + + Integer.toHexString(id) + + " (" + ar.getString(i) + ")"); + } + } + } + return numberOfEntries; + } + + private static int preloadDrawables(Resources resources, TypedArray ar) { + final int numberOfEntries = ar.length(); + for (int i = 0; i < numberOfEntries; i++) { + int id = ar.getResourceId(i, 0); + + if (id != 0) { + if (resources.getDrawable(id, null) == null) { + throw new IllegalArgumentException( + "Unable to find preloaded drawable resource #0x" + + Integer.toHexString(id) + + " (" + ar.getString(i) + ")"); + } + } + } + return numberOfEntries; + } + + /** + * Clear the cache when the framework resources packages is changed. + * @hide + */ + @VisibleForTesting + public static void resetPreloadDrawableStateCache() { + ResourcesImpl.resetDrawableStateCache(); + preloadResources(); + } + /** @hide */ public void dump(PrintWriter pw, String prefix) { pw.println(prefix + "class=" + getClass()); diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java index 3bb237ac1228..480e43e2f5d1 100644 --- a/core/java/android/content/res/ResourcesImpl.java +++ b/core/java/android/content/res/ResourcesImpl.java @@ -52,6 +52,7 @@ import android.util.TypedValue; import android.util.Xml; import android.view.DisplayAdjustments; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.GrowingArrayUtils; import libcore.util.NativeAllocationRegistry; @@ -159,6 +160,23 @@ public class ResourcesImpl { } /** + * Clear the cache when the framework resources packages is changed. + * + * It's only used in the test initial function instead of regular app behaviors. It doesn't + * guarantee the thread-safety so mark this with @VisibleForTesting. + */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + static void resetDrawableStateCache() { + synchronized (sSync) { + sPreloadedDrawables[0].clear(); + sPreloadedDrawables[1].clear(); + sPreloadedColorDrawables.clear(); + sPreloadedComplexColors.clear(); + sPreloaded = false; + } + } + + /** * Creates a new ResourcesImpl object with CompatibilityInfo. * * @param assets Previously created AssetManager. diff --git a/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java index 02e7f6036b34..c8e2cccfd2f6 100644 --- a/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java @@ -221,7 +221,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes List<CameraOutputConfig> outputConfigs = sessionConfig.outputConfigs; ArrayList<OutputConfiguration> outputList = new ArrayList<>(); for (CameraOutputConfig output : outputConfigs) { - Surface outputSurface = initializeSurfrace(output); + Surface outputSurface = initializeSurface(output); if (outputSurface == null) { continue; } @@ -234,7 +234,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes if ((output.sharedSurfaceConfigs != null) && !output.sharedSurfaceConfigs.isEmpty()) { cameraOutput.enableSurfaceSharing(); for (CameraOutputConfig sharedOutputConfig : output.sharedSurfaceConfigs) { - Surface sharedSurface = initializeSurfrace(sharedOutputConfig); + Surface sharedSurface = initializeSurface(sharedOutputConfig); if (sharedSurface == null) { continue; } @@ -989,7 +989,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes return ret; } - private Surface initializeSurfrace(CameraOutputConfig output) { + private Surface initializeSurface(CameraOutputConfig output) { switch(output.type) { case CameraOutputConfig.TYPE_SURFACE: if (output.surface == null) { diff --git a/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java index 2156c1220a52..efb3510dfebf 100644 --- a/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java @@ -1942,10 +1942,10 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession { HashMap<Integer, Pair<Image, TotalCaptureResult>> captureMap, Integer jpegOrientation, Byte jpegQuality) { ArrayList<CaptureBundle> ret = new ArrayList<>(); - for (Integer stagetId : captureMap.keySet()) { - Pair<Image, TotalCaptureResult> entry = captureMap.get(stagetId); + for (Integer stageId : captureMap.keySet()) { + Pair<Image, TotalCaptureResult> entry = captureMap.get(stageId); CaptureBundle bundle = new CaptureBundle(); - bundle.stage = stagetId; + bundle.stage = stageId; bundle.captureImage = initializeParcelImage(entry.first); bundle.sequenceId = entry.second.getSequenceId(); bundle.captureResult = entry.second.getNativeMetadata(); diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index 0786d6f87b67..26c5b874cd97 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -196,7 +196,8 @@ public final class Zygote { public static final int PROFILEABLE = 1 << 24; /** - * Enable ptrace. This is enabled on eng or userdebug builds, or if the app is debuggable. + * Enable ptrace. This is enabled on eng, if the app is debuggable, or if + * the persist.debug.ptrace.enabled property is set. */ public static final int DEBUG_ENABLE_PTRACE = 1 << 25; @@ -1020,20 +1021,35 @@ public final class Zygote { "persist.debug.dalvik.vm.jdwp.enabled").equals("1"); /** + * This will enable ptrace by default for all apps. It is OK to cache this property + * because we expect to reboot the system whenever this property changes + */ + private static final boolean ENABLE_PTRACE = SystemProperties.get( + "persist.debug.ptrace.enabled").equals("1"); + + /** * Applies debugger system properties to the zygote arguments. * - * For eng builds all apps are debuggable. On userdebug and user builds - * if persist.debug.dalvik.vm.jdwp.enabled is 1 all apps are - * debuggable. Otherwise, the debugger state is specified via the - * "--enable-jdwp" flag in the spawn request. + * For eng builds all apps are debuggable with JDWP and ptrace. + * + * On userdebug builds if persist.debug.dalvik.vm.jdwp.enabled + * is 1 all apps are debuggable with JDWP and ptrace. Otherwise, the + * debugger state is specified via the "--enable-jdwp" flag in the + * spawn request. + * + * On userdebug builds if persist.debug.ptrace.enabled is 1 all + * apps are debuggable with ptrace. * * @param args non-null; zygote spawner args */ static void applyDebuggerSystemProperty(ZygoteArguments args) { - if (Build.IS_ENG || ENABLE_JDWP) { + if (Build.IS_ENG || (Build.IS_USERDEBUG && ENABLE_JDWP)) { args.mRuntimeFlags |= Zygote.DEBUG_ENABLE_JDWP; + // Also enable ptrace when JDWP is enabled for consistency with + // before persist.debug.ptrace.enabled existed. + args.mRuntimeFlags |= Zygote.DEBUG_ENABLE_PTRACE; } - if (RoSystemProperties.DEBUGGABLE) { + if (Build.IS_ENG || (Build.IS_USERDEBUG && ENABLE_PTRACE)) { args.mRuntimeFlags |= Zygote.DEBUG_ENABLE_PTRACE; } } @@ -1057,7 +1073,8 @@ public final class Zygote { int peerUid = peer.getUid(); if (args.mInvokeWith != null && peerUid != 0 - && (args.mRuntimeFlags & Zygote.DEBUG_ENABLE_JDWP) == 0) { + && (args.mRuntimeFlags + & (Zygote.DEBUG_ENABLE_JDWP | Zygote.DEBUG_ENABLE_PTRACE)) == 0) { throw new ZygoteSecurityException("Peer is permitted to specify an " + "explicit invoke-with wrapper command only for debuggable " + "applications."); diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 85cb15bdd906..b3938b4b33fb 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -26,7 +26,6 @@ import android.app.ApplicationLoaders; import android.compat.annotation.UnsupportedAppUsage; import android.content.pm.SharedLibraryInfo; import android.content.res.Resources; -import android.content.res.TypedArray; import android.os.Build; import android.os.Environment; import android.os.IInstalld; @@ -102,21 +101,10 @@ public class ZygoteInit { private static final String SOCKET_NAME_ARG = "--socket-name="; /** - * Used to pre-load resources. - */ - @UnsupportedAppUsage - private static Resources mResources; - - /** * The path of a file that contains classes to preload. */ private static final String PRELOADED_CLASSES = "/system/etc/preloaded-classes"; - /** - * Controls whether we should preload resources during zygote init. - */ - private static final boolean PRELOAD_RESOURCES = true; - private static final int UNPRIVILEGED_UID = 9999; private static final int UNPRIVILEGED_GID = 9999; @@ -143,7 +131,7 @@ public class ZygoteInit { cacheNonBootClasspathClassLoaders(); bootTimingsTraceLog.traceEnd(); // CacheNonBootClasspathClassLoaders bootTimingsTraceLog.traceBegin("PreloadResources"); - preloadResources(); + Resources.preloadResources(); bootTimingsTraceLog.traceEnd(); // PreloadResources Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadAppProcessHALs"); nativePreloadAppProcessHALs(); @@ -414,87 +402,6 @@ public class ZygoteInit { } /** - * Load in commonly used resources, so they can be shared across processes. - * - * These tend to be a few Kbytes, but are frequently in the 20-40K range, and occasionally even - * larger. - */ - private static void preloadResources() { - try { - mResources = Resources.getSystem(); - mResources.startPreloading(); - if (PRELOAD_RESOURCES) { - Log.i(TAG, "Preloading resources..."); - - long startTime = SystemClock.uptimeMillis(); - TypedArray ar = mResources.obtainTypedArray( - com.android.internal.R.array.preloaded_drawables); - int N = preloadDrawables(ar); - ar.recycle(); - Log.i(TAG, "...preloaded " + N + " resources in " - + (SystemClock.uptimeMillis() - startTime) + "ms."); - - startTime = SystemClock.uptimeMillis(); - ar = mResources.obtainTypedArray( - com.android.internal.R.array.preloaded_color_state_lists); - N = preloadColorStateLists(ar); - ar.recycle(); - Log.i(TAG, "...preloaded " + N + " resources in " - + (SystemClock.uptimeMillis() - startTime) + "ms."); - - if (mResources.getBoolean( - com.android.internal.R.bool.config_freeformWindowManagement)) { - startTime = SystemClock.uptimeMillis(); - ar = mResources.obtainTypedArray( - com.android.internal.R.array.preloaded_freeform_multi_window_drawables); - N = preloadDrawables(ar); - ar.recycle(); - Log.i(TAG, "...preloaded " + N + " resource in " - + (SystemClock.uptimeMillis() - startTime) + "ms."); - } - } - mResources.finishPreloading(); - } catch (RuntimeException e) { - Log.w(TAG, "Failure preloading resources", e); - } - } - - private static int preloadColorStateLists(TypedArray ar) { - int N = ar.length(); - for (int i = 0; i < N; i++) { - int id = ar.getResourceId(i, 0); - - if (id != 0) { - if (mResources.getColorStateList(id, null) == null) { - throw new IllegalArgumentException( - "Unable to find preloaded color resource #0x" - + Integer.toHexString(id) - + " (" + ar.getString(i) + ")"); - } - } - } - return N; - } - - - private static int preloadDrawables(TypedArray ar) { - int N = ar.length(); - for (int i = 0; i < N; i++) { - int id = ar.getResourceId(i, 0); - - if (id != 0) { - if (mResources.getDrawable(id, null) == null) { - throw new IllegalArgumentException( - "Unable to find preloaded drawable resource #0x" - + Integer.toHexString(id) - + " (" + ar.getString(i) + ")"); - } - } - } - return N; - } - - /** * Runs several special GCs to try to clean up a few generations of softly- and final-reachable * objects, along with any other garbage. This is only useful just before a fork(). */ diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index c19879713f2f..9dce5e3a10f3 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -40,7 +40,6 @@ #include <binder/Stability.h> #include <binderthreadstate/CallerUtils.h> #include <cutils/atomic.h> -#include <cutils/threads.h> #include <log/log.h> #include <utils/KeyedVector.h> #include <utils/List.h> diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index eb30ad9ce60b..71bd6391f02f 100644 --- a/packages/SystemUI/Android.bp +++ b/packages/SystemUI/Android.bp @@ -134,6 +134,7 @@ android_library { "res-keyguard", "res", ], + use_resource_processor: true, static_libs: [ "WifiTrackerLib", "WindowManager-Shell", @@ -452,6 +453,7 @@ android_app { ], resource_dirs: [], + use_resource_processor: true, platform_apis: true, system_ext_specific: true, certificate: "platform", diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index 3b9060ad0ac3..d2e46401f6d5 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -30,7 +30,7 @@ import android.widget.FrameLayout import androidx.annotation.VisibleForTesting import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.systemui.R +import com.android.systemui.customization.R import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index 0326b6d3edca..bc45e31434fe 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -52,7 +52,9 @@ public class KeyguardClockSwitch extends RelativeLayout { int largeClockTopMargin = parent.getResources() .getDimensionPixelSize(R.dimen.keyguard_large_clock_top_margin); int targetHeight = parent.getResources() - .getDimensionPixelSize(R.dimen.large_clock_text_size) * 2; + .getDimensionPixelSize( + com.android.systemui.customization.R.dimen.large_clock_text_size) + * 2; int top = parent.getHeight() / 2 - targetHeight / 2 + largeClockTopMargin / 2; return new Rect( @@ -152,7 +154,8 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mClock != null) { if (mSmallClockFrame.isLaidOut()) { int targetHeight = getResources() - .getDimensionPixelSize(R.dimen.small_clock_text_size); + .getDimensionPixelSize( + com.android.systemui.customization.R.dimen.small_clock_text_size); mClock.getSmallClock().getEvents().onTargetRegionChanged(new Rect( mSmallClockFrame.getLeft(), mSmallClockFrame.getTop(), diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index ba5a8c94dc23..ccc1e4534c0a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -1150,7 +1150,8 @@ public class KeyguardSecurityContainer extends ConstraintLayout { } drawable.setTint(iconColor); - Drawable bg = context.getDrawable(R.drawable.user_avatar_bg); + Drawable bg = context.getDrawable( + com.android.settingslib.R.drawable.user_avatar_bg); bg.setTintBlendMode(BlendMode.DST); bg.setTint(Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorSurfaceVariant)); diff --git a/packages/SystemUI/src/com/android/systemui/GuestSessionNotification.java b/packages/SystemUI/src/com/android/systemui/GuestSessionNotification.java index fa9a83ec9913..7a6b1c372a24 100644 --- a/packages/SystemUI/src/com/android/systemui/GuestSessionNotification.java +++ b/packages/SystemUI/src/com/android/systemui/GuestSessionNotification.java @@ -64,12 +64,15 @@ public final class GuestSessionNotification { } String contentText; if (userInfo.isEphemeral()) { - contentText = mContext.getString(R.string.guest_notification_ephemeral); + contentText = mContext.getString( + com.android.settingslib.R.string.guest_notification_ephemeral); } else if (isGuestFirstLogin) { - contentText = mContext.getString(R.string.guest_notification_non_ephemeral); + contentText = mContext.getString( + com.android.settingslib.R.string.guest_notification_non_ephemeral); } else { contentText = mContext.getString( - R.string.guest_notification_non_ephemeral_non_first_login); + com.android.settingslib.R.string + .guest_notification_non_ephemeral_non_first_login); } final Intent guestExitIntent = new Intent( @@ -89,7 +92,7 @@ public final class GuestSessionNotification { Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.ALERTS) - .setSmallIcon(R.drawable.ic_account_circle) + .setSmallIcon(com.android.settingslib.R.drawable.ic_account_circle) .setContentTitle(mContext.getString(R.string.guest_notification_session_active)) .setContentText(contentText) .setPriority(Notification.PRIORITY_DEFAULT) diff --git a/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java index 370628c0b09b..eb004fb4d4b2 100644 --- a/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java @@ -106,7 +106,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { TypedArray atts = context.obtainStyledAttributes(attrs, R.styleable.BatteryMeterView, defStyle, 0); final int frameColor = atts.getColor(R.styleable.BatteryMeterView_frameColor, - context.getColor(R.color.meter_background_color)); + context.getColor(com.android.settingslib.R.color.meter_background_color)); mPercentageStyleId = atts.getResourceId(R.styleable.BatteryMeterView_textAppearance, 0); mDrawable = new AccessorizedBatteryDrawable(context, frameColor); atts.recycle(); diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt index c98a62f36656..2bf8050379d3 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt @@ -460,7 +460,7 @@ private fun LottieAnimationView.addOverlayDynamicColor( for (key in listOf(".blue600", ".blue400")) { addValueCallback(KeyPath(key, "**"), LottieProperty.COLOR_FILTER) { PorterDuffColorFilter( - context.getColor(R.color.settingslib_color_blue400), + context.getColor(com.android.settingslib.R.color.settingslib_color_blue400), PorterDuff.Mode.SRC_ATOP ) } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/ColorSchemeTransition.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/ColorSchemeTransition.kt index 2b42604e7160..14d4b6800b0a 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/ColorSchemeTransition.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/ColorSchemeTransition.kt @@ -119,7 +119,7 @@ internal constructor( ::AnimatingColorTransition ) - val bgColor = context.getColor(com.android.systemui.R.color.material_dynamic_secondary95) + val bgColor = context.getColor(com.google.android.material.R.color.material_dynamic_secondary95) val surfaceColor = animatingColorTransitionFactory(bgColor, ::surfaceFromScheme) { surfaceColor -> val colorList = ColorStateList.valueOf(surfaceColor) diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleStoryIconFactory.java b/packages/SystemUI/src/com/android/systemui/people/PeopleStoryIconFactory.java index 58e700f81388..25965fc86370 100644 --- a/packages/SystemUI/src/com/android/systemui/people/PeopleStoryIconFactory.java +++ b/packages/SystemUI/src/com/android/systemui/people/PeopleStoryIconFactory.java @@ -33,7 +33,6 @@ import android.view.ContextThemeWrapper; import androidx.core.graphics.drawable.RoundedBitmapDrawable; import com.android.settingslib.Utils; -import com.android.systemui.R; class PeopleStoryIconFactory implements AutoCloseable { @@ -59,7 +58,8 @@ class PeopleStoryIconFactory implements AutoCloseable { mIconSize = mDensity * iconSizeDp; mPackageManager = pm; mIconDrawableFactory = iconDrawableFactory; - mImportantConversationColor = mContext.getColor(R.color.important_conversation); + mImportantConversationColor = mContext.getColor( + com.android.launcher3.icons.R.color.important_conversation); mAccentColor = Utils.getColorAttr(mContext, com.android.internal.R.attr.colorAccentPrimaryVariant).getDefaultColor(); } @@ -224,4 +224,4 @@ class PeopleStoryIconFactory implements AutoCloseable { @Override public void close() { } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 6bf8b7666054..30bfd6dbb788 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -178,7 +178,8 @@ public class HotspotTile extends QSTileImpl<BooleanState> { private String getSecondaryLabel(boolean isActive, boolean isTransient, boolean isDataSaverEnabled, int numConnectedDevices, boolean isWifiTetheringAllowed) { if (!isWifiTetheringAllowed) { - return mContext.getString(R.string.wifitrackerlib_admin_restricted_network); + return mContext.getString( + com.android.wifitrackerlib.R.string.wifitrackerlib_admin_restricted_network); } else if (isTransient) { return mContext.getString(R.string.quick_settings_hotspot_secondary_label_transient); } else if (isDataSaverEnabled) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 87d54a495d8b..3130f7f12d23 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1394,8 +1394,8 @@ public class NotificationContentView extends FrameLayout implements Notification if (shouldShowBubbleButton(entry)) { // explicitly resolve drawable resource using SystemUI's theme Drawable d = mContext.getDrawable(entry.isBubble() - ? R.drawable.bubble_ic_stop_bubble - : R.drawable.bubble_ic_create_bubble); + ? com.android.wm.shell.R.drawable.bubble_ic_stop_bubble + : com.android.wm.shell.R.drawable.bubble_ic_create_bubble); String contentDescription = mContext.getResources().getString(entry.isBubble() ? R.string.notification_conversation_unbubble diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DarkIconDispatcherImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DarkIconDispatcherImpl.java index 2677c3f2a8bd..bb64beb1ad5f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DarkIconDispatcherImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DarkIconDispatcherImpl.java @@ -23,7 +23,6 @@ import android.graphics.Rect; import android.util.ArrayMap; import android.widget.ImageView; -import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dump.DumpManager; @@ -54,8 +53,10 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher, Context context, LightBarTransitionsController.Factory lightBarTransitionsControllerFactory, DumpManager dumpManager) { - mDarkModeIconColorSingleTone = context.getColor(R.color.dark_mode_icon_color_single_tone); - mLightModeIconColorSingleTone = context.getColor(R.color.light_mode_icon_color_single_tone); + mDarkModeIconColorSingleTone = context.getColor( + com.android.settingslib.R.color.dark_mode_icon_color_single_tone); + mLightModeIconColorSingleTone = context.getColor( + com.android.settingslib.R.color.light_mode_icon_color_single_tone); mTransitionsController = lightBarTransitionsControllerFactory.create(this); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 13566ef8c630..feace126be91 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -458,8 +458,9 @@ public class KeyguardStatusBarView extends RelativeLayout { @ColorInt int textColor = Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor); @ColorInt int iconColor = Utils.getColorStateListDefaultColor(mContext, - Color.luminance(textColor) < 0.5 ? R.color.dark_mode_icon_color_single_tone : - R.color.light_mode_icon_color_single_tone); + Color.luminance(textColor) < 0.5 + ? com.android.settingslib.R.color.dark_mode_icon_color_single_tone + : com.android.settingslib.R.color.light_mode_icon_color_single_tone); float intensity = textColor == Color.WHITE ? 0 : 1; mCarrierLabel.setTextColor(iconColor); @@ -467,7 +468,7 @@ public class KeyguardStatusBarView extends RelativeLayout { if (userSwitcherName != null) { userSwitcherName.setTextColor(Utils.getColorStateListDefaultColor( mContext, - R.color.light_mode_icon_color_single_tone)); + com.android.settingslib.R.color.light_mode_icon_color_single_tone)); } if (iconManager != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java index fe2a9137c1a9..9a7be10c5207 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java @@ -32,7 +32,6 @@ import android.view.WindowInsetsController.Appearance; import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.view.AppearanceRegion; import com.android.systemui.Dumpable; -import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dump.DumpManager; import com.android.systemui.navigationbar.NavigationModeController; @@ -96,8 +95,10 @@ public class LightBarController implements BatteryController.BatteryStateChangeC NavigationModeController navModeController, DumpManager dumpManager, DisplayTracker displayTracker) { - mDarkIconColor = ctx.getColor(R.color.dark_mode_icon_color_single_tone); - mLightIconColor = ctx.getColor(R.color.light_mode_icon_color_single_tone); + mDarkIconColor = ctx.getColor( + com.android.settingslib.R.color.dark_mode_icon_color_single_tone); + mLightIconColor = ctx.getColor( + com.android.settingslib.R.color.light_mode_icon_color_single_tone); mStatusBarIconController = (SysuiDarkIconDispatcher) darkIconDispatcher; mBatteryController = batteryController; mBatteryController.addCallback(this); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java index 924ae4a95fac..92e1e4ba986c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java @@ -415,7 +415,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh // We first look for the background on the dialogContentWithBackground added by // DialogLaunchAnimator. If it's not there, we use the background of the DecorView. View viewWithBackground = decorView.findViewByPredicate( - view -> view.getTag(R.id.tag_dialog_background) != null); + view -> view.getTag( + com.android.systemui.animation.R.id.tag_dialog_background) != null); Drawable background = viewWithBackground != null ? viewWithBackground.getBackground() : decorView.getBackground(); Insets insets = background != null ? background.getOpticalInsets() : Insets.NONE; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java index c8ee647cf8a8..880e0d2eef31 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java @@ -319,7 +319,7 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> drawable = new CircleFramedDrawable(mCurrentUser.picture, avatarSize); } - Drawable bg = mContext.getDrawable(R.drawable.user_avatar_bg); + Drawable bg = mContext.getDrawable(com.android.settingslib.R.drawable.user_avatar_bg); drawable = new LayerDrawable(new Drawable[]{bg, drawable}); return drawable; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java index e9f0dcb4eb51..9a6e71c1382c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java @@ -533,7 +533,7 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS } drawable.setTint(mResources.getColor(iconColorRes, mContext.getTheme())); - Drawable bg = mContext.getDrawable(R.drawable.user_avatar_bg); + Drawable bg = mContext.getDrawable(com.android.settingslib.R.drawable.user_avatar_bg); drawable = new LayerDrawable(new Drawable[]{bg, drawable}); return drawable; } diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java index 32ecb6786a51..ecaf7921a4df 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java @@ -61,7 +61,7 @@ public class TunerActivity extends Activity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setTheme(R.style.Theme_AppCompat_DayNight); + setTheme(androidx.appcompat.R.style.Theme_AppCompat_DayNight); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); requestWindowFeature(Window.FEATURE_NO_TITLE); diff --git a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt index 667a3ca8f9d2..83b272e74222 100644 --- a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt @@ -747,7 +747,9 @@ constructor( userId: Int, ): Drawable { if (isGuest) { - return checkNotNull(applicationContext.getDrawable(R.drawable.ic_account_circle)) + return checkNotNull( + applicationContext.getDrawable(com.android.settingslib.R.drawable.ic_account_circle) + ) } // TODO(b/246631653): cache the bitmaps to avoid the background work to fetch them. diff --git a/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt b/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt index e74232df3ac3..00ca92dacee1 100644 --- a/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt @@ -42,13 +42,13 @@ object LegacyUserUiHelper { isManageUsers: Boolean, ): Int { return if (isAddUser && isTablet) { - R.drawable.ic_account_circle_filled + com.android.settingslib.R.drawable.ic_account_circle_filled } else if (isAddUser) { R.drawable.ic_add } else if (isGuest) { - R.drawable.ic_account_circle + com.android.settingslib.R.drawable.ic_account_circle } else if (isAddSupervisedUser) { - R.drawable.ic_add_supervised_user + com.android.settingslib.R.drawable.ic_add_supervised_user } else if (isManageUsers) { R.drawable.ic_manage_users } else { diff --git a/packages/SystemUI/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModel.kt b/packages/SystemUI/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModel.kt index afd72e7ed1be..aeed5fc59281 100644 --- a/packages/SystemUI/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModel.kt @@ -128,7 +128,7 @@ constructor( viewKey = model.id, name = if (model.isGuest && model.isSelected) { - Text.Resource(R.string.guest_exit_quick_settings_button) + Text.Resource(com.android.settingslib.R.string.guest_exit_quick_settings_button) } else { model.name }, diff --git a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java index 2efeda932ff3..904a98b5e54d 100644 --- a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java +++ b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java @@ -112,7 +112,7 @@ public class NotificationChannels implements CoreStartable { // priority, so it can be shown in all times. nm.createNotificationChannel(new NotificationChannel( TVPIP, - context.getString(R.string.notification_channel_tv_pip), + context.getString(com.android.wm.shell.R.string.notification_channel_tv_pip), NotificationManager.IMPORTANCE_MAX)); } } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 35cb834e0005..cd0fc7924c82 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -1747,8 +1747,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, if (!ss.dynamic) continue; mDynamic.put(stream, true); if (findRow(stream) == null) { - addRow(stream, R.drawable.ic_volume_remote, R.drawable.ic_volume_remote_mute, true, - false, true); + addRow(stream, + com.android.settingslib.R.drawable.ic_volume_remote, + com.android.settingslib.R.drawable.ic_volume_remote_mute, + true, false, true); } } diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java index d2142dcfb2b4..e5c55b0a5e7f 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java @@ -48,8 +48,10 @@ final class DotIndicatorDecoration extends RecyclerView.ItemDecoration { R.dimen.card_carousel_dot_selected_radius); mDotMargin = context.getResources().getDimensionPixelSize(R.dimen.card_carousel_dot_margin); - mUnselectedColor = context.getColor(R.color.material_dynamic_neutral70); - mSelectedColor = context.getColor(R.color.material_dynamic_neutral100); + mUnselectedColor = context.getColor( + com.google.android.material.R.color.material_dynamic_neutral70); + mSelectedColor = context.getColor( + com.google.android.material.R.color.material_dynamic_neutral100); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java index d03148cee335..2491e2bdd623 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java @@ -278,7 +278,7 @@ public class WalletActivity extends ComponentActivity implements private Drawable getHomeIndicatorDrawable() { Drawable drawable = getDrawable(R.drawable.ic_close); - drawable.setTint(getColor(R.color.material_dynamic_neutral70)); + drawable.setTint(getColor(com.google.android.material.R.color.material_dynamic_neutral70)); return drawable; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt index e3b8649718c1..97377592ce24 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt @@ -633,6 +633,7 @@ class UserInteractorTest : SysuiTestCase() { val userInfos = createUserInfos(count = 2, includeGuest = false) userRepository.setUserInfos(userInfos) userRepository.setSelectedUserInfo(userInfos[0]) + runCurrent() val refreshUsersCallCount = userRepository.refreshUsersCallCount fakeBroadcastDispatcher.registeredReceivers.forEach { @@ -653,6 +654,7 @@ class UserInteractorTest : SysuiTestCase() { val userInfos = createUserInfos(count = 2, includeGuest = false) userRepository.setUserInfos(userInfos) userRepository.setSelectedUserInfo(userInfos[0]) + runCurrent() val refreshUsersCallCount = userRepository.refreshUsersCallCount fakeBroadcastDispatcher.registeredReceivers.forEach { diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java index 2cf0e3e54326..c80bed223923 100644 --- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java +++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java @@ -634,7 +634,7 @@ public class TouchExplorer extends BaseEventStreamTransformation MotionEvent event, MotionEvent rawEvent, int policyFlags) { switch (event.getActionMasked()) { case ACTION_DOWN: - // We should have already received ACTION_DOWN. Ignore. + handleActionDownStateTouchExploring(event, rawEvent, policyFlags); break; case ACTION_POINTER_DOWN: handleActionPointerDown(event, rawEvent, policyFlags); @@ -840,6 +840,15 @@ public class TouchExplorer extends BaseEventStreamTransformation } } + private void handleActionDownStateTouchExploring( + MotionEvent event, MotionEvent rawEvent, int policyFlags) { + // This is an interrupted and continued touch exploration. Maintain the consistency of the + // event stream. + mSendTouchExplorationEndDelayed.cancel(); + mSendTouchInteractionEndDelayed.cancel(); + sendTouchExplorationGestureStartAndHoverEnterIfNeeded(policyFlags); + } + /** * Handles move events while touch exploring. this is also where we drag or delegate based on * the number of fingers moving on the screen. @@ -1097,12 +1106,15 @@ public class TouchExplorer extends BaseEventStreamTransformation } /** - * Sends the enter events if needed. Such events are hover enter and touch explore - * gesture start. + * Sends the enter events if needed. Such events are hover enter and touch explore gesture + * start. * * @param policyFlags The policy flags associated with the event. */ private void sendTouchExplorationGestureStartAndHoverEnterIfNeeded(int policyFlags) { + if (!mState.isTouchExploring()) { + mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_START); + } MotionEvent event = mState.getLastInjectedHoverEvent(); if (event != null && event.getActionMasked() == ACTION_HOVER_EXIT) { final int pointerIdBits = event.getPointerIdBits(); @@ -1115,7 +1127,6 @@ public class TouchExplorer extends BaseEventStreamTransformation } } - /** * Determines whether a two pointer gesture is a dragging one. * @@ -1341,6 +1352,8 @@ public class TouchExplorer extends BaseEventStreamTransformation Slog.e(LOG_TAG, "Unable to find a valid pointer for touch exploration."); return; } + // Send hover exit if we haven't closed a previous touch exploration event stream. + sendHoverExitAndTouchExplorationGestureEndIfNeeded(pointerId); final int pointerIdBits = (1 << pointerId); final int policyFlags = mState.getLastReceivedPolicyFlags(); mSendHoverEnterAndMoveDelayed.setPointerIdBits(pointerIdBits); diff --git a/services/core/java/com/android/server/logcat/LogcatManagerService.java b/services/core/java/com/android/server/logcat/LogcatManagerService.java index 43732d473cf4..25c939ee16b4 100644 --- a/services/core/java/com/android/server/logcat/LogcatManagerService.java +++ b/services/core/java/com/android/server/logcat/LogcatManagerService.java @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; +import android.os.DeadObjectException; import android.os.Handler; import android.os.ILogd; import android.os.Looper; @@ -514,7 +515,15 @@ public final class LogcatManagerService extends SystemService { Slog.d(TAG, "Approving log access: " + request); } try { - getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); + try { + getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); + } catch (DeadObjectException e) { + // This can happen if logd restarts, so force getting a new connection + // to logd and try once more. + Slog.w(TAG, "Logd connection no longer valid while approving, trying once more."); + mLogdService = null; + getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); + } Integer activeCount = mActiveLogAccessCount.getOrDefault(client, 0); mActiveLogAccessCount.put(client, activeCount + 1); } catch (RemoteException e) { @@ -527,7 +536,15 @@ public final class LogcatManagerService extends SystemService { Slog.d(TAG, "Declining log access: " + request); } try { - getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); + try { + getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); + } catch (DeadObjectException e) { + // This can happen if logd restarts, so force getting a new connection + // to logd and try once more. + Slog.w(TAG, "Logd connection no longer valid while declining, trying once more."); + mLogdService = null; + getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); + } } catch (RemoteException e) { Slog.e(TAG, "Fails to call remote functions", e); } diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java index 1a6155b43f6b..a085b95d8e77 100644 --- a/services/core/java/com/android/server/pm/ApexManager.java +++ b/services/core/java/com/android/server/pm/ApexManager.java @@ -424,7 +424,7 @@ public abstract class ApexManager { /** * Performs a non-staged install of the given {@code apexFile}. */ - abstract void installPackage(File apexFile, PackageParser2 packageParser) + abstract void installPackage(File apexFile, PackageParser2 packageParser, boolean force) throws PackageManagerException; /** @@ -1136,7 +1136,7 @@ public abstract class ApexManager { } @Override - void installPackage(File apexFile, PackageParser2 packageParser) + void installPackage(File apexFile, PackageParser2 packageParser, boolean force) throws PackageManagerException { try { final int flags = PackageManager.GET_META_DATA @@ -1159,7 +1159,7 @@ public abstract class ApexManager { } checkApexSignature(existingApexPkg, newApexPkg); ApexInfo apexInfo = waitForApexService().installAndActivatePackage( - apexFile.getAbsolutePath()); + apexFile.getAbsolutePath(), force); final ParsedPackage parsedPackage2 = packageParser.parsePackage( new File(apexInfo.modulePath), flags, /* useCaches= */ false); final PackageInfo finalApexPkg = PackageInfoWithoutStateUtils.generate( @@ -1505,7 +1505,7 @@ public abstract class ApexManager { } @Override - void installPackage(File apexFile, PackageParser2 packageParser) { + void installPackage(File apexFile, PackageParser2 packageParser, boolean force) { throw new UnsupportedOperationException("APEX updates are not supported"); } diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 293f7e9941e3..703ae11ae99b 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -872,8 +872,10 @@ final class InstallPackageHelper { "Expected exactly one .apex file under " + dir.getAbsolutePath() + " got: " + apexes.length); } + boolean force = (request.mArgs.mInstallFlags + & PackageManager.INSTALL_FORCE_NON_STAGED_APEX_UPDATE) != 0; try (PackageParser2 packageParser = mPm.mInjector.getScanningPackageParser()) { - mApexManager.installPackage(apexes[0], packageParser); + mApexManager.installPackage(apexes[0], packageParser, force); } } catch (PackageManagerException e) { request.mInstallResult.setError("APEX installation failed", e); diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index be842b96843c..38b79e5612ef 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -86,7 +86,6 @@ import android.os.ServiceManager; import android.os.ServiceSpecificException; import android.os.ShellCommand; import android.os.SystemClock; -import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; @@ -3053,6 +3052,13 @@ class PackageManagerShellCommand extends ShellCommand { // Set package source to other by default sessionParams.setPackageSource(PackageInstaller.PACKAGE_SOURCE_OTHER); + // Encodes one of the states: + // 1. Install request explicitly specified --staged, then value will be true. + // 2. Install request explicitly specified --non-staged, then value will be false. + // 3. Install request did not specify either --staged or --non-staged, then for APEX + // installs the value will be true, and for apk installs it will be false. + Boolean staged = null; + String opt; boolean replaceExisting = true; boolean forceNonStaged = false; @@ -3151,7 +3157,6 @@ class PackageManagerShellCommand extends ShellCommand { break; case "--apex": sessionParams.setInstallAsApex(); - sessionParams.setStaged(); break; case "--force-non-staged": forceNonStaged = true; @@ -3160,7 +3165,10 @@ class PackageManagerShellCommand extends ShellCommand { sessionParams.setMultiPackage(); break; case "--staged": - sessionParams.setStaged(); + staged = true; + break; + case "--non-staged": + staged = false; break; case "--force-queryable": sessionParams.setForceQueryable(); @@ -3192,11 +3200,17 @@ class PackageManagerShellCommand extends ShellCommand { throw new IllegalArgumentException("Unknown option " + opt); } } + if (staged == null) { + staged = (sessionParams.installFlags & PackageManager.INSTALL_APEX) != 0; + } if (replaceExisting) { sessionParams.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING; } if (forceNonStaged) { sessionParams.isStaged = false; + sessionParams.installFlags |= PackageManager.INSTALL_FORCE_NON_STAGED_APEX_UPDATE; + } else if (staged) { + sessionParams.setStaged(); } return params; } @@ -3978,7 +3992,8 @@ class PackageManagerShellCommand extends ShellCommand { pw.println(" [--preload] [--instant] [--full] [--dont-kill]"); pw.println(" [--enable-rollback]"); pw.println(" [--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES]"); - pw.println(" [--apex] [--force-non-staged] [--staged-ready-timeout TIMEOUT]"); + pw.println(" [--apex] [--non-staged] [--force-non-staged]"); + pw.println(" [--staged-ready-timeout TIMEOUT]"); pw.println(" [PATH [SPLIT...]|-]"); pw.println(" Install an application. Must provide the apk data to install, either as"); pw.println(" file path(s) or '-' to read from stdin. Options are:"); @@ -4006,6 +4021,9 @@ class PackageManagerShellCommand extends ShellCommand { pw.println(" 3=device setup, 4=user request"); pw.println(" --force-uuid: force install on to disk volume with given UUID"); pw.println(" --apex: install an .apex file, not an .apk"); + pw.println(" --non-staged: explicitly set this installation to be non-staged."); + pw.println(" This flag is only useful for APEX installs that are implicitly"); + pw.println(" assumed to be staged."); pw.println(" --force-non-staged: force the installation to run under a non-staged"); pw.println(" session, which may complete without requiring a reboot"); pw.println(" --staged-ready-timeout: By default, staged sessions wait " diff --git a/services/core/java/com/android/server/vcn/TelephonySubscriptionTracker.java b/services/core/java/com/android/server/vcn/TelephonySubscriptionTracker.java index ca4a32f553ae..099c9ae33bfb 100644 --- a/services/core/java/com/android/server/vcn/TelephonySubscriptionTracker.java +++ b/services/core/java/com/android/server/vcn/TelephonySubscriptionTracker.java @@ -16,9 +16,6 @@ package com.android.server.vcn; -import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED; -import static android.telephony.CarrierConfigManager.EXTRA_SLOT_INDEX; -import static android.telephony.CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX; import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static android.telephony.TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED; @@ -48,7 +45,6 @@ import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting.Visibility; import com.android.internal.util.IndentingPrintWriter; -import com.android.server.vcn.util.PersistableBundleUtils; import com.android.server.vcn.util.PersistableBundleUtils.PersistableBundleWrapper; import java.util.ArrayList; @@ -109,6 +105,12 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { @NonNull private TelephonySubscriptionSnapshot mCurrentSnapshot; + @NonNull + private final CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener = + (int logicalSlotIndex, int subscriptionId, int carrierId, int specificCarrierId) -> + handleActionCarrierConfigChanged(logicalSlotIndex, subscriptionId); + + public TelephonySubscriptionTracker( @NonNull Context context, @NonNull Handler handler, @@ -149,13 +151,14 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { public void register() { final HandlerExecutor executor = new HandlerExecutor(mHandler); final IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_CARRIER_CONFIG_CHANGED); filter.addAction(ACTION_MULTI_SIM_CONFIG_CHANGED); mContext.registerReceiver(this, filter, null, mHandler); mSubscriptionManager.addOnSubscriptionsChangedListener( executor, mSubscriptionChangedListener); mTelephonyManager.registerTelephonyCallback(executor, mActiveDataSubIdListener); + mCarrierConfigManager.registerCarrierConfigChangeListener(executor, + mCarrierConfigChangeListener); registerCarrierPrivilegesCallbacks(); } @@ -197,6 +200,7 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { mContext.unregisterReceiver(this); mSubscriptionManager.removeOnSubscriptionsChangedListener(mSubscriptionChangedListener); mTelephonyManager.unregisterTelephonyCallback(mActiveDataSubIdListener); + mCarrierConfigManager.unregisterCarrierConfigChangeListener(mCarrierConfigChangeListener); unregisterCarrierPrivilegesCallbacks(); } @@ -273,7 +277,7 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { } /** - * Broadcast receiver for ACTION_CARRIER_CONFIG_CHANGED + * Broadcast receiver for ACTION_MULTI_SIM_CONFIG_CHANGED * * <p>The broadcast receiver is registered with mHandler, so callbacks & broadcasts are all * serialized on mHandler, avoiding the need for locking. @@ -281,9 +285,6 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { - case ACTION_CARRIER_CONFIG_CHANGED: - handleActionCarrierConfigChanged(context, intent); - break; case ACTION_MULTI_SIM_CONFIG_CHANGED: handleActionMultiSimConfigChanged(context, intent); break; @@ -310,26 +311,21 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver { handleSubscriptionsChanged(); } - private void handleActionCarrierConfigChanged(Context context, Intent intent) { - // Accept sticky broadcasts; if CARRIER_CONFIG_CHANGED was previously broadcast and it - // already was for an identified carrier, we can stop waiting for initial load to complete - final int subId = intent.getIntExtra(EXTRA_SUBSCRIPTION_INDEX, INVALID_SUBSCRIPTION_ID); - final int slotId = intent.getIntExtra(EXTRA_SLOT_INDEX, INVALID_SIM_SLOT_INDEX); - + private void handleActionCarrierConfigChanged(int slotId, int subId) { if (slotId == INVALID_SIM_SLOT_INDEX) { return; } if (SubscriptionManager.isValidSubscriptionId(subId)) { - final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId); + // Get only configs as needed to save memory. + final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId, + VcnManager.VCN_RELATED_CARRIER_CONFIG_KEYS); if (mDeps.isConfigForIdentifiedCarrier(carrierConfig)) { mReadySubIdsBySlotId.put(slotId, subId); - final PersistableBundle minimized = - PersistableBundleUtils.minimizeBundle( - carrierConfig, VcnManager.VCN_RELATED_CARRIER_CONFIG_KEYS); - if (minimized != null) { - mSubIdToCarrierConfigMap.put(subId, new PersistableBundleWrapper(minimized)); + if (!carrierConfig.isEmpty()) { + mSubIdToCarrierConfigMap.put(subId, + new PersistableBundleWrapper(carrierConfig)); } handleSubscriptionsChanged(); } diff --git a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java index ab292ab5381e..872e438c6b8d 100644 --- a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java @@ -19,6 +19,7 @@ package com.android.server.pm; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doAnswer; @@ -362,7 +363,7 @@ public class ApexManagerTest { File apex = extractResource("test.apex_rebootless_v1", "test.rebootless_apex_v1.apex"); PackageManagerException e = expectThrows(PackageManagerException.class, - () -> mApexManager.installPackage(apex, mPackageParser2)); + () -> mApexManager.installPackage(apex, mPackageParser2, /* force= */ false)); assertThat(e).hasMessageThat().contains("It is forbidden to install new APEX packages"); } @@ -378,10 +379,11 @@ public class ApexManagerTest { File finalApex = extractResource("test.rebootles_apex_v2", "test.rebootless_apex_v2.apex"); ApexInfo newApexInfo = createApexInfo("test.apex_rebootless", 2, /* isActive= */ true, /* isFactory= */ false, finalApex); - when(mApexService.installAndActivatePackage(anyString())).thenReturn(newApexInfo); + when(mApexService.installAndActivatePackage(anyString(), anyBoolean())).thenReturn( + newApexInfo); File installedApex = extractResource("installed", "test.rebootless_apex_v2.apex"); - mApexManager.installPackage(installedApex, mPackageParser2); + mApexManager.installPackage(installedApex, mPackageParser2, /* force= */ false); PackageInfo newInfo = mApexManager.getPackageInfo("test.apex.rebootless", ApexManager.MATCH_ACTIVE_PACKAGE); @@ -416,10 +418,11 @@ public class ApexManagerTest { File finalApex = extractResource("test.rebootles_apex_v2", "test.rebootless_apex_v2.apex"); ApexInfo newApexInfo = createApexInfo("test.apex_rebootless", 2, /* isActive= */ true, /* isFactory= */ false, finalApex); - when(mApexService.installAndActivatePackage(anyString())).thenReturn(newApexInfo); + when(mApexService.installAndActivatePackage(anyString(), anyBoolean())).thenReturn( + newApexInfo); File installedApex = extractResource("installed", "test.rebootless_apex_v2.apex"); - mApexManager.installPackage(installedApex, mPackageParser2); + mApexManager.installPackage(installedApex, mPackageParser2, /* force= */ false); PackageInfo newInfo = mApexManager.getPackageInfo("test.apex.rebootless", ApexManager.MATCH_ACTIVE_PACKAGE); @@ -447,13 +450,14 @@ public class ApexManagerTest { mApexManager.scanApexPackagesTraced(mPackageParser2, ParallelPackageParser.makeExecutorService()); - when(mApexService.installAndActivatePackage(anyString())).thenThrow( + when(mApexService.installAndActivatePackage(anyString(), anyBoolean())).thenThrow( new RuntimeException("install failed :(")); File installedApex = extractResource("test.apex_rebootless_v1", "test.rebootless_apex_v1.apex"); assertThrows(PackageManagerException.class, - () -> mApexManager.installPackage(installedApex, mPackageParser2)); + () -> mApexManager.installPackage(installedApex, mPackageParser2, /* force= */ + false)); } @Test @@ -468,7 +472,8 @@ public class ApexManagerTest { File installedApex = extractResource("shim_different_certificate", "com.android.apex.cts.shim.v2_different_certificate.apex"); PackageManagerException e = expectThrows(PackageManagerException.class, - () -> mApexManager.installPackage(installedApex, mPackageParser2)); + () -> mApexManager.installPackage(installedApex, mPackageParser2, /* force= */ + false)); assertThat(e).hasMessageThat().contains("APK container signature of "); assertThat(e).hasMessageThat().contains( "is not compatible with currently installed on device"); @@ -486,7 +491,8 @@ public class ApexManagerTest { File installedApex = extractResource("shim_unsigned_apk_container", "com.android.apex.cts.shim.v2_unsigned_apk_container.apex"); PackageManagerException e = expectThrows(PackageManagerException.class, - () -> mApexManager.installPackage(installedApex, mPackageParser2)); + () -> mApexManager.installPackage(installedApex, mPackageParser2, /* force= */ + false)); assertThat(e).hasMessageThat().contains("Failed to collect certificates from "); } diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 63dbeeba8e40..318b01aad076 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -9899,4 +9899,38 @@ public class CarrierConfigManager { } trm.removeCarrierConfigChangedListener(listener); } + + /** + * Get subset of specified carrier configuration if available or empty bundle, without throwing + * {@link RuntimeException} to caller. + * + * <p>This is a system internally used only utility to reduce the repetitive logic. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}, or the calling app + * has carrier privileges on the specified subscription (see + * {@link TelephonyManager#hasCarrierPrivileges()}). + * + * @param context Context used to get the CarrierConfigManager service. + * @param subId The subscription ID to get the config from. + * @param keys The config keys the client is interested in. + * @return Config bundle with key/value for the specified keys or empty bundle when failed + * @hide + */ + @RequiresPermission(anyOf = { + Manifest.permission.READ_PHONE_STATE, + "carrier privileges", + }) + @NonNull + public static PersistableBundle getCarrierConfigSubset( + @NonNull Context context, int subId, @NonNull String... keys) { + PersistableBundle configs = null; + CarrierConfigManager ccm = context.getSystemService(CarrierConfigManager.class); + try { + configs = ccm.getConfigForSubId(subId, keys); + } catch (RuntimeException exception) { + Rlog.w(TAG, "CarrierConfigLoader is not available."); + } + return configs != null ? configs : new PersistableBundle(); + } } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 81eb8365d7e0..96dc44a5f9fa 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -2218,46 +2218,46 @@ public class SubscriptionManager { } /** - * Get an array of subscription ids for specified logical SIM slot Index. + * Get an array of subscription ids for the specified logical SIM slot Index. The maximum size + * of the array is 1. This API was mistakenly designed to return multiple subscription ids, + * which is not possible in the current Android telephony architecture. * * @param slotIndex The logical SIM slot index. * - * @return subscription Ids or {@code null} if the given slot index is not valid or there are - * no active subscription in the slot. In the implementation today, there will be no more - * than one subscriptions per logical SIM slot. + * @return Subscription id of the active subscription on the specified logical SIM slot index. + * If SIM is absent on the slot, a single element array of {@link #INVALID_SUBSCRIPTION_ID} will + * be returned. {@code null} if the provided {@code slotIndex} is not valid. * * @deprecated Use {@link #getSubscriptionId(int)} instead. */ @Deprecated @Nullable public int[] getSubscriptionIds(int slotIndex) { - int subId = getSubscriptionId(slotIndex); - if (!isValidSubscriptionId(subId)) { + if (!isValidSlotIndex(slotIndex)) { return null; } return new int[]{getSubscriptionId(slotIndex)}; } - /** @hide */ - @UnsupportedAppUsage + /** + * Get an array of subscription ids for the specified logical SIM slot Index. The maximum size + * of the array is 1. This API was mistakenly designed to return multiple subscription ids, + * which is not possible in the current Android telephony architecture. + * + * @param slotIndex The logical SIM slot index. + * + * @return Subscription id of the active subscription on the specified logical SIM slot index. + * If SIM is absent on the slot, a single element array of {@link #INVALID_SUBSCRIPTION_ID} will + * be returned. {@code null} if the provided {@code slotIndex} is not valid. + * + * @deprecated Use {@link #getSubscriptionId(int)} instead. + * @hide + */ public static int[] getSubId(int slotIndex) { if (!isValidSlotIndex(slotIndex)) { - logd("[getSubId]- fail"); return null; } - - int[] subId = null; - - try { - ISub iSub = TelephonyManager.getSubscriptionService(); - if (iSub != null) { - subId = iSub.getSubIds(slotIndex); - } - } catch (RemoteException ex) { - // ignore it - } - - return subId; + return new int[]{getSubscriptionId(slotIndex)}; } /** @@ -3628,17 +3628,10 @@ public class SubscriptionManager { } /** - * Enables or disables a subscription. This is currently used in the settings page. It will - * fail and return false if operation is not supported or failed. - * - * To disable an active subscription on a physical (non-Euicc) SIM, - * {@link #canDisablePhysicalSubscription} needs to be true. - * - * <p> - * Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required + * Enable or disable a subscription. This method is same as + * {@link #setUiccApplicationsEnabled(int, boolean)}. * - * @param subscriptionId Subscription to be enabled or disabled. It could be a eSIM or pSIM - * subscription. + * @param subscriptionId Subscription to be enabled or disabled. * @param enable whether user is turning it on or off. * * @return whether the operation is successful. @@ -3648,19 +3641,15 @@ public class SubscriptionManager { @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int subscriptionId, boolean enable) { - if (VDBG) { - logd("setSubscriptionActivated subId= " + subscriptionId + " enable " + enable); - } try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { - return iSub.setSubscriptionEnabled(enable, subscriptionId); + iSub.setUiccApplicationsEnabled(enable, subscriptionId); } } catch (RemoteException ex) { - // ignore it + return false; } - - return false; + return true; } /** @@ -3683,11 +3672,7 @@ public class SubscriptionManager { logd("setUiccApplicationsEnabled subId= " + subscriptionId + " enable " + enabled); } try { - ISub iSub = ISub.Stub.asInterface( - TelephonyFrameworkInitializer - .getTelephonyServiceManager() - .getSubscriptionServiceRegisterer() - .get()); + ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { iSub.setUiccApplicationsEnabled(enabled, subscriptionId); } @@ -3715,11 +3700,7 @@ public class SubscriptionManager { logd("canDisablePhysicalSubscription"); } try { - ISub iSub = ISub.Stub.asInterface( - TelephonyFrameworkInitializer - .getTelephonyServiceManager() - .getSubscriptionServiceRegisterer() - .get()); + ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { return iSub.canDisablePhysicalSubscription(); } @@ -3843,10 +3824,15 @@ public class SubscriptionManager { } /** - * DO NOT USE. - * This API is designed for features that are not finished at this point. Do not call this API. + * Get the active subscription id by logical SIM slot index. + * + * @param slotIndex The logical SIM slot index. + * @return The active subscription id. + * + * @throws IllegalArgumentException if the provided slot index is invalid. + * @throws SecurityException if callers do not hold the required permission. + * * @hide - * TODO b/135547512: further clean up */ @SystemApi @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index af4edc443151..6a5380ddb36e 100644 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -236,8 +236,6 @@ interface ISub { int getSlotIndex(int subId); - int[] getSubIds(int slotIndex); - int getSubId(int slotIndex); int getDefaultSubId(); @@ -267,8 +265,6 @@ interface ISub { String getSubscriptionProperty(int subId, String propKey, String callingPackage, String callingFeatureId); - boolean setSubscriptionEnabled(boolean enable, int subId); - boolean isSubscriptionEnabled(int subId); int getEnabledSubscriptionId(int slotIndex); @@ -279,7 +275,7 @@ interface ISub { boolean canDisablePhysicalSubscription(); - int setUiccApplicationsEnabled(boolean enabled, int subscriptionId); + void setUiccApplicationsEnabled(boolean enabled, int subscriptionId); int setDeviceToDeviceStatusSharing(int sharing, int subId); diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index ecafe702ea4e..9d05517050e2 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1791,6 +1791,22 @@ interface ITelephony { String gid2, String plmn, String spn, String carrierPrivilegeRules, String apn); /** + * Forcibly sets a package as a carrier provisioning package. + * + * This override is ephemeral, and will disappear upon phone process restart (including + * device reboot). + * + * WARNING: This API is meant for testing purposes only. This enables automated testing for + * cases where the carrier service package is used as a permissioning gate for features such as + * restricted carrier network access (restricted APNs and Merged Carrier Wifi) + * + * @param carrierServicePackage The package that should be marked as the carrier service + * package, or {@code null} to disable the override. + */ + void setCarrierServicePackageOverride(int subId, String carrierServicePackage, + String callingPackage); + + /** * A test API to return installed carrier id list version. */ int getCarrierIdListVersion(int subId); diff --git a/tests/vcn/java/com/android/server/vcn/TelephonySubscriptionTrackerTest.java b/tests/vcn/java/com/android/server/vcn/TelephonySubscriptionTrackerTest.java index 965b073ff0db..34f884b94296 100644 --- a/tests/vcn/java/com/android/server/vcn/TelephonySubscriptionTrackerTest.java +++ b/tests/vcn/java/com/android/server/vcn/TelephonySubscriptionTrackerTest.java @@ -19,9 +19,6 @@ package com.android.server.vcn; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import static android.net.vcn.VcnManager.VCN_RESTRICTED_TRANSPORTS_INT_ARRAY_KEY; -import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED; -import static android.telephony.CarrierConfigManager.EXTRA_SLOT_INDEX; -import static android.telephony.CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX; import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static android.telephony.TelephonyCallback.ActiveDataSubscriptionIdListener; @@ -143,6 +140,8 @@ public class TelephonySubscriptionTrackerTest { @NonNull private TelephonySubscriptionTrackerCallback mCallback; @NonNull private TelephonySubscriptionTracker mTelephonySubscriptionTracker; + @NonNull private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener; + public TelephonySubscriptionTrackerTest() { mContext = mock(Context.class); mTestLooper = new TestLooper(); @@ -173,7 +172,7 @@ public class TelephonySubscriptionTrackerTest { .getSystemService(Context.CARRIER_CONFIG_SERVICE); doReturn(TEST_CARRIER_CONFIG) .when(mCarrierConfigManager) - .getConfigForSubId(eq(TEST_SUBSCRIPTION_ID_1)); + .getConfigForSubId(eq(TEST_SUBSCRIPTION_ID_1), any()); // subId 1, 2 are in same subGrp, only subId 1 is active doReturn(TEST_PARCEL_UUID).when(TEST_SUBINFO_1).getGroupUuid(); @@ -189,9 +188,15 @@ public class TelephonySubscriptionTrackerTest { doReturn(2).when(mTelephonyManager).getActiveModemCount(); mCallback = mock(TelephonySubscriptionTrackerCallback.class); + // Capture CarrierConfigChangeListener to emulate the carrier config change notification + ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = + ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class); mTelephonySubscriptionTracker = new TelephonySubscriptionTracker(mContext, mHandler, mCallback, mDeps); mTelephonySubscriptionTracker.register(); + verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(), + listenerArgumentCaptor.capture()); + mCarrierConfigChangeListener = listenerArgumentCaptor.getAllValues().get(0); doReturn(true).when(mDeps).isConfigForIdentifiedCarrier(any()); doReturn(Arrays.asList(TEST_SUBINFO_1, TEST_SUBINFO_2)) @@ -239,14 +244,11 @@ public class TelephonySubscriptionTrackerTest { return intent; } - private Intent buildTestBroadcastIntent(boolean hasValidSubscription) { - Intent intent = new Intent(ACTION_CARRIER_CONFIG_CHANGED); - intent.putExtra(EXTRA_SLOT_INDEX, TEST_SIM_SLOT_INDEX); - intent.putExtra( - EXTRA_SUBSCRIPTION_INDEX, - hasValidSubscription ? TEST_SUBSCRIPTION_ID_1 : INVALID_SUBSCRIPTION_ID); - - return intent; + private void sendCarrierConfigChange(boolean hasValidSubscription) { + mCarrierConfigChangeListener.onCarrierConfigChanged( + TEST_SIM_SLOT_INDEX, + hasValidSubscription ? TEST_SUBSCRIPTION_ID_1 : INVALID_SUBSCRIPTION_ID, + TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); } private TelephonySubscriptionSnapshot buildExpectedSnapshot( @@ -302,14 +304,15 @@ public class TelephonySubscriptionTrackerTest { any(), eq(mHandler)); final IntentFilter filter = getIntentFilter(); - assertEquals(2, filter.countActions()); - assertTrue(filter.hasAction(ACTION_CARRIER_CONFIG_CHANGED)); + assertEquals(1, filter.countActions()); assertTrue(filter.hasAction(ACTION_MULTI_SIM_CONFIG_CHANGED)); verify(mSubscriptionManager) .addOnSubscriptionsChangedListener(any(HandlerExecutor.class), any()); assertNotNull(getOnSubscriptionsChangedListener()); + verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(), any()); + verify(mTelephonyManager, times(2)) .registerCarrierPrivilegesCallback(anyInt(), any(HandlerExecutor.class), any()); verify(mTelephonyManager) @@ -442,7 +445,7 @@ public class TelephonySubscriptionTrackerTest { @Test public void testReceiveBroadcast_ConfigReadyWithSubscriptions() throws Exception { - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback).onNewSnapshot(eq(buildExpectedSnapshot(TEST_PRIVILEGED_PACKAGES))); @@ -454,7 +457,7 @@ public class TelephonySubscriptionTrackerTest { .when(mSubscriptionManager) .getAllSubscriptionInfoList(); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); // Expect an empty snapshot @@ -465,7 +468,7 @@ public class TelephonySubscriptionTrackerTest { public void testReceiveBroadcast_SlotCleared() throws Exception { setupReadySubIds(); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(false)); + sendCarrierConfigChange(false /* hasValidSubscription */); mTestLooper.dispatchAll(); verifyNoActiveSubscriptions(); @@ -476,7 +479,7 @@ public class TelephonySubscriptionTrackerTest { public void testReceiveBroadcast_ConfigNotReady() throws Exception { doReturn(false).when(mDeps).isConfigForIdentifiedCarrier(any()); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); // No interactions expected; config was not loaded @@ -485,21 +488,21 @@ public class TelephonySubscriptionTrackerTest { @Test public void testSubscriptionsClearedAfterValidTriggersCallbacks() throws Exception { - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback).onNewSnapshot(eq(buildExpectedSnapshot(TEST_PRIVILEGED_PACKAGES))); assertNotNull( mTelephonySubscriptionTracker.getReadySubIdsBySlotId().get(TEST_SIM_SLOT_INDEX)); doReturn(Collections.emptyList()).when(mSubscriptionManager).getAllSubscriptionInfoList(); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback).onNewSnapshot(eq(buildExpectedSnapshot(emptyMap(), emptyMap()))); } @Test public void testCarrierConfigUpdatedAfterValidTriggersCallbacks() throws Exception { - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback).onNewSnapshot(eq(buildExpectedSnapshot(TEST_PRIVILEGED_PACKAGES))); reset(mCallback); @@ -510,12 +513,12 @@ public class TelephonySubscriptionTrackerTest { new int[] {TRANSPORT_WIFI, TRANSPORT_CELLULAR}); doReturn(updatedConfig) .when(mCarrierConfigManager) - .getConfigForSubId(eq(TEST_SUBSCRIPTION_ID_1)); + .getConfigForSubId(eq(TEST_SUBSCRIPTION_ID_1), any()); Map<Integer, PersistableBundleWrapper> subIdToCarrierConfigMap = new HashMap<>(); subIdToCarrierConfigMap.put( TEST_SUBSCRIPTION_ID_1, new PersistableBundleWrapper(updatedConfig)); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback) @@ -530,13 +533,13 @@ public class TelephonySubscriptionTrackerTest { @Test public void testSlotClearedAfterValidTriggersCallbacks() throws Exception { - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(true)); + sendCarrierConfigChange(true /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback).onNewSnapshot(eq(buildExpectedSnapshot(TEST_PRIVILEGED_PACKAGES))); assertNotNull( mTelephonySubscriptionTracker.getReadySubIdsBySlotId().get(TEST_SIM_SLOT_INDEX)); - mTelephonySubscriptionTracker.onReceive(mContext, buildTestBroadcastIntent(false)); + sendCarrierConfigChange(false /* hasValidSubscription */); mTestLooper.dispatchAll(); verify(mCallback) .onNewSnapshot( diff --git a/tools/split-select/Android.bp b/tools/split-select/Android.bp index 540265793de6..ec9d42a2dc64 100644 --- a/tools/split-select/Android.bp +++ b/tools/split-select/Android.bp @@ -57,9 +57,6 @@ cc_defaults { // This tool is prebuilt if we're doing an app-only build. product_variables: { - pdk: { - enabled: false, - }, unbundled_build: { enabled: false, }, |