diff options
33 files changed, 729 insertions, 536 deletions
diff --git a/Android.bp b/Android.bp index 81d6dab8ac17..4f2e6d0dbf42 100644 --- a/Android.bp +++ b/Android.bp @@ -12,6 +12,44 @@ // See the License for the specific language governing permissions and // limitations under the License. +// ==== c++ proto device library ============================== +cc_library { + name: "libplatformprotos", + host_supported: true, + // b/34740546, work around clang-tidy segmentation fault. + tidy_checks: ["-modernize*"], + proto: { + export_proto_headers: true, + include_dirs: ["external/protobuf/src"], + }, + + target: { + host: { + proto: { + type: "full", + }, + }, + android: { + proto: { + type: "lite", + }, + shared: { + // The proto files generate full protos, but we only use + // them as lite on device. This works fine for a static + // library, where the unused full symbols are stripped, + // but fails if it is linked as a standalone shared + // library because it is missing the full runtime. + enabled: false, + }, + }, + }, + + srcs: [ + "core/proto/**/*.proto", + "libs/incident/**/*.proto", + ], +} + subdirs = [ "libs/*", "tools/*", diff --git a/Android.mk b/Android.mk index c3ac9b3e0215..ea4713c34e61 100644 --- a/Android.mk +++ b/Android.mk @@ -1466,35 +1466,6 @@ endif include $(BUILD_JAVA_LIBRARY) -# ==== c++ proto device library ============================== -include $(CLEAR_VARS) -LOCAL_MODULE := libplatformprotos -# b/34740546, work around clang-tidy segmentation fault. -LOCAL_TIDY_CHECKS := -modernize* -LOCAL_PROTOC_OPTIMIZE_TYPE := lite -LOCAL_PROTOC_FLAGS := \ - --include_source_info \ - -Iexternal/protobuf/src -LOCAL_SRC_FILES := \ - $(call all-proto-files-under, core/proto) \ - $(call all-proto-files-under, libs/incident/proto) -include $(BUILD_STATIC_LIBRARY) - -# ==== c++ proto host library ============================== -include $(CLEAR_VARS) -LOCAL_MODULE := libplatformprotos -# b/34740546, work around clang-tidy segmentation fault. -LOCAL_TIDY_CHECKS := -modernize* -LOCAL_PROTOC_OPTIMIZE_TYPE := full -LOCAL_PROTOC_FLAGS := \ - --include_source_info \ - -Iexternal/protobuf/src -LOCAL_SRC_FILES := \ - $(call all-proto-files-under, core/proto) \ - $(call all-proto-files-under, libs/incident/proto) -include $(BUILD_HOST_SHARED_LIBRARY) - - # ==== java proto host library ============================== include $(CLEAR_VARS) LOCAL_MODULE := platformprotos diff --git a/core/java/android/app/ITaskStackListener.aidl b/core/java/android/app/ITaskStackListener.aidl index f369955cdc31..4994fbb0da3a 100644 --- a/core/java/android/app/ITaskStackListener.aidl +++ b/core/java/android/app/ITaskStackListener.aidl @@ -39,8 +39,11 @@ oneway interface ITaskStackListener { * Called whenever IActivityManager.startActivity is called on an activity that is already * running in the pinned stack and the activity is not actually started, but the task is either * brought to the front or a new Intent is delivered to it. + * + * @param clearedTask whether or not the launch activity also cleared the task as a part of + * starting */ - void onPinnedActivityRestartAttempt(); + void onPinnedActivityRestartAttempt(boolean clearedTask); /** * Called whenever the pinned stack is starting animating a resize. diff --git a/core/java/android/app/TaskStackListener.java b/core/java/android/app/TaskStackListener.java index 307fc9128ed2..2df011fb856e 100644 --- a/core/java/android/app/TaskStackListener.java +++ b/core/java/android/app/TaskStackListener.java @@ -39,7 +39,7 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub { } @Override - public void onPinnedActivityRestartAttempt() throws RemoteException { + public void onPinnedActivityRestartAttempt(boolean clearedTask) throws RemoteException { } @Override diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index ad3a99d3610f..b0d63951971b 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -1404,6 +1404,11 @@ public class Editor { // or double-clicks that could "dismiss" the floating toolbar. int delay = ViewConfiguration.getDoubleTapTimeout(); mTextView.postDelayed(mShowFloatingToolbar, delay); + + // This classifies the text and most likely returns before the toolbar is actually + // shown. If not, it will update the toolbar with the result when classification + // returns. We would rather not wait for a long running classification process. + invalidateActionModeAsync(); } } @@ -1853,7 +1858,7 @@ public class Editor { mInsertionPointCursorController.invalidateHandle(); } if (mTextActionMode != null) { - invalidateActionModeAsync(); + invalidateActionMode(); } } @@ -1945,12 +1950,12 @@ public class Editor { if (mRestartActionModeOnNextRefresh) { // To avoid distraction, newly start action mode only when selection action // mode is being restarted. - startSelectionActionMode(); + startSelectionActionModeAsync(false); } } else if (selectionController == null || !selectionController.isActive()) { // Insertion action mode is active. Avoid dismissing the selection. stopTextActionModeWithPreservingSelection(); - startSelectionActionMode(); + startSelectionActionModeAsync(false); } else { mTextActionMode.invalidateContentRect(); } @@ -2004,22 +2009,24 @@ public class Editor { /** * Asynchronously starts a selection action mode using the TextClassifier. */ - void startSelectionActionModeAsync() { - getSelectionActionModeHelper().startActionModeAsync(); + void startSelectionActionModeAsync(boolean adjustSelection) { + getSelectionActionModeHelper().startActionModeAsync(adjustSelection); } /** - * Synchronously starts a selection action mode without the TextClassifier. + * Asynchronously invalidates an action mode using the TextClassifier. */ - void startSelectionActionMode() { - getSelectionActionModeHelper().startActionMode(); + private void invalidateActionModeAsync() { + getSelectionActionModeHelper().invalidateActionModeAsync(); } /** - * Asynchronously invalidates an action mode using the TextClassifier. + * Synchronously invalidates an action mode without the TextClassifier. */ - private void invalidateActionModeAsync() { - getSelectionActionModeHelper().invalidateActionModeAsync(); + private void invalidateActionMode() { + if (mTextActionMode != null) { + mTextActionMode.invalidate(); + } } private SelectionActionModeHelper getSelectionActionModeHelper() { @@ -2075,7 +2082,7 @@ public class Editor { } if (mTextActionMode != null) { // Text action mode is already started - invalidateActionModeAsync(); + invalidateActionMode(); return false; } @@ -4703,7 +4710,7 @@ public class Editor { } positionAtCursorOffset(offset, false); if (mTextActionMode != null) { - invalidateActionModeAsync(); + invalidateActionMode(); } } @@ -4787,7 +4794,7 @@ public class Editor { } updateDrawable(); if (mTextActionMode != null) { - invalidateActionModeAsync(); + invalidateActionMode(); } } @@ -5414,13 +5421,8 @@ public class Editor { resetDragAcceleratorState(); if (mTextView.hasSelection()) { - // Do not invoke the text assistant if this was a drag selection. - if (mHaventMovedEnoughToStartDrag) { - startSelectionActionModeAsync(); - } else { - startSelectionActionMode(); - } - + // Drag selection should not be adjusted by the text classifier. + startSelectionActionModeAsync(mHaventMovedEnoughToStartDrag); } break; } diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java index c9d172fa78b5..16a1087510d3 100644 --- a/core/java/android/widget/SelectionActionModeHelper.java +++ b/core/java/android/widget/SelectionActionModeHelper.java @@ -65,7 +65,7 @@ final class SelectionActionModeHelper { textView.getTextClassifier(), textView.getText(), 0, 1, textView.getTextLocales()); } - public void startActionModeAsync() { + public void startActionModeAsync(boolean adjustSelection) { cancelAsyncTask(); if (isNoOpTextClassifier() || !hasSelection()) { // No need to make an async call for a no-op TextClassifier. @@ -74,16 +74,16 @@ final class SelectionActionModeHelper { } else { resetTextClassificationHelper(); mTextClassificationAsyncTask = new TextClassificationAsyncTask( - mEditor.getTextView(), TIMEOUT_DURATION, - mTextClassificationHelper::suggestSelection, this::startActionMode) + mEditor.getTextView(), + TIMEOUT_DURATION, + adjustSelection + ? mTextClassificationHelper::suggestSelection + : mTextClassificationHelper::classifyText, + this::startActionMode) .execute(); } } - public void startActionMode() { - startActionMode(null); - } - public void invalidateActionModeAsync() { cancelAsyncTask(); if (isNoOpTextClassifier() || !hasSelection()) { diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 242dcf535d32..eaf111521574 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -10579,7 +10579,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Selection.setSelection((Spannable) text, start, end); // Make sure selection mode is engaged. if (mEditor != null) { - mEditor.startSelectionActionMode(); + mEditor.startSelectionActionModeAsync(false); } return true; } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 8006f786d4a8..aeb564b49ea8 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1299,9 +1299,9 @@ * Include a Service for the android.net.scoring.RECOMMEND_NETWORKS action protected by the BIND_NETWORK_RECOMMENDATION_SERVICE permission. - This must be set to a valid network recommendation app. + This must be set to a valid network recommendation app or empty. --> - <string name="config_defaultNetworkRecommendationProviderPackage" translatable="false">com.android.networkrecommendation</string> + <string name="config_defaultNetworkRecommendationProviderPackage" translatable="false"></string> <!-- Whether to enable Hardware FLP overlay which allows Hardware FLP to be replaced by an app at run-time. When disabled, only the diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp new file mode 100644 index 000000000000..8dc8a001a138 --- /dev/null +++ b/libs/hwui/Android.bp @@ -0,0 +1,385 @@ +cc_defaults { + name: "hwui_defaults", + defaults: [ + "hwui_static_deps", + + //"hwui_bugreport_font_cache_usage", + //"hwui_compile_for_perf", + + // Enables fine-grained GLES error checking + // If enabled, every GLES call is wrapped & error checked + // Has moderate overhead + //"hwui_enable_opengl-validation", + ], + + cflags: [ + "-DEGL_EGLEXT_PROTOTYPES", + "-DGL_GLEXT_PROTOTYPES", + "-DATRACE_TAG=ATRACE_TAG_VIEW", + "-DLOG_TAG=\"OpenGLRenderer\"", + "-Wall", + "-Wno-unused-parameter", + "-Wunreachable-code", + "-Werror", + "-fvisibility=hidden", + + // GCC false-positives on this warning, and since we -Werror that's + // a problem + "-Wno-free-nonheap-object", + + // clang's warning is broken, see: https://llvm.org/bugs/show_bug.cgi?id=21629 + "-Wno-missing-braces", + + // TODO: Linear blending should be enabled by default, but we are + // TODO: making it an opt-in while it's a work in progress + //"-DANDROID_ENABLE_LINEAR_BLENDING", + ], + + include_dirs: [ + "external/skia/include/private", + "external/skia/src/core", + "external/skia/src/effects", + "external/skia/src/image", + "external/skia/src/utils", + ], + + product_variables: { + device_uses_hwc2: { + cflags: ["-DUSE_HWC2"], + }, + }, +} + +cc_defaults { + name: "hwui_static_deps", + shared_libs: [ + "liblog", + "libcutils", + "libutils", + "libEGL", + "libGLESv2", + "libvulkan", + "libskia", + "libui", + "libgui", + "libprotobuf-cpp-full", + "libharfbuzz_ng", + "libft2", + "libminikin", + "libandroidfw", + "libRScpp", + ], + static_libs: [ + "libplatformprotos", + ], +} + +cc_defaults { + name: "hwui_bugreport_font_cache_usage", + srcs: ["font/FontCacheHistoryTracker.cpp"], + cflags: ["-DBUGREPORT_FONT_CACHE_USAGE"], +} + +cc_defaults { + name: "hwui_compile_for_perf", + // TODO: Non-arm? + cflags: [ + "-fno-omit-frame-pointer", + "-marm", + "-mapcs", + ], +} + +cc_defaults { + name: "hwui_debug", + cflags: ["-include debug/wrap_gles.h"], + srcs: [ + "debug/wrap_gles.cpp", + "debug/DefaultGlesDriver.cpp", + "debug/GlesErrorCheckWrapper.cpp", + "debug/GlesDriver.cpp", + "debug/FatalBaseDriver.cpp", + "debug/NullGlesDriver.cpp", + ], + include_dirs: ["frameworks/native/opengl/libs/GLES2"], +} + +cc_defaults { + name: "hwui_enable_opengl_validation", + defaults: ["hwui_debug"], + cflags: ["-DDEBUG_OPENGL=3"], + srcs: ["debug/wrap_gles.cpp"], + include_dirs: ["frameworks/native/opengl/libs/GLES2"], +} + +// ------------------------ +// library +// ------------------------ + +cc_defaults { + name: "libhwui_defaults", + defaults: ["hwui_defaults"], + srcs: [ + "hwui/Bitmap.cpp", + "font/CacheTexture.cpp", + "font/Font.cpp", + "hwui/Canvas.cpp", + "hwui/MinikinSkia.cpp", + "hwui/MinikinUtils.cpp", + "hwui/PaintImpl.cpp", + "hwui/Typeface.cpp", + "pipeline/skia/GLFunctorDrawable.cpp", + "pipeline/skia/LayerDrawable.cpp", + "pipeline/skia/RenderNodeDrawable.cpp", + "pipeline/skia/ReorderBarrierDrawables.cpp", + "pipeline/skia/SkiaDisplayList.cpp", + "pipeline/skia/SkiaOpenGLPipeline.cpp", + "pipeline/skia/SkiaOpenGLReadback.cpp", + "pipeline/skia/SkiaPipeline.cpp", + "pipeline/skia/SkiaProfileRenderer.cpp", + "pipeline/skia/SkiaRecordingCanvas.cpp", + "pipeline/skia/SkiaVulkanPipeline.cpp", + "renderstate/Blend.cpp", + "renderstate/MeshState.cpp", + "renderstate/OffscreenBufferPool.cpp", + "renderstate/PixelBufferState.cpp", + "renderstate/RenderState.cpp", + "renderstate/Scissor.cpp", + "renderstate/Stencil.cpp", + "renderstate/TextureState.cpp", + "renderthread/CanvasContext.cpp", + "renderthread/OpenGLPipeline.cpp", + "renderthread/DrawFrameTask.cpp", + "renderthread/EglManager.cpp", + "renderthread/VulkanManager.cpp", + "renderthread/RenderProxy.cpp", + "renderthread/RenderTask.cpp", + "renderthread/RenderThread.cpp", + "renderthread/TimeLord.cpp", + "renderthread/Frame.cpp", + "service/GraphicsStatsService.cpp", + "thread/TaskManager.cpp", + "utils/Blur.cpp", + "utils/Color.cpp", + "utils/GLUtils.cpp", + "utils/LinearAllocator.cpp", + "utils/StringUtils.cpp", + "utils/TestWindowContext.cpp", + "utils/VectorDrawableUtils.cpp", + "AmbientShadow.cpp", + "AnimationContext.cpp", + "Animator.cpp", + "AnimatorManager.cpp", + "BakedOpDispatcher.cpp", + "BakedOpRenderer.cpp", + "BakedOpState.cpp", + "Caches.cpp", + "CanvasState.cpp", + "ClipArea.cpp", + "DamageAccumulator.cpp", + "DeferredLayerUpdater.cpp", + "DeviceInfo.cpp", + "DisplayList.cpp", + "Extensions.cpp", + "FboCache.cpp", + "FontRenderer.cpp", + "FrameBuilder.cpp", + "FrameInfo.cpp", + "FrameInfoVisualizer.cpp", + "GammaFontRenderer.cpp", + "GlLayer.cpp", + "GlopBuilder.cpp", + "GpuMemoryTracker.cpp", + "GradientCache.cpp", + "Image.cpp", + "Interpolator.cpp", + "JankTracker.cpp", + "Layer.cpp", + "LayerBuilder.cpp", + "LayerUpdateQueue.cpp", + "Matrix.cpp", + "OpDumper.cpp", + "OpenGLReadback.cpp", + "Patch.cpp", + "PatchCache.cpp", + "PathCache.cpp", + "PathParser.cpp", + "PathTessellator.cpp", + "PixelBuffer.cpp", + "ProfileRenderer.cpp", + "Program.cpp", + "ProgramCache.cpp", + "Properties.cpp", + "PropertyValuesAnimatorSet.cpp", + "PropertyValuesHolder.cpp", + "RecordingCanvas.cpp", + "RenderBufferCache.cpp", + "RenderNode.cpp", + "RenderProperties.cpp", + "ResourceCache.cpp", + "ShadowTessellator.cpp", + "SkiaCanvas.cpp", + "SkiaCanvasProxy.cpp", + "SkiaShader.cpp", + "Snapshot.cpp", + "SpotShadow.cpp", + "TessellationCache.cpp", + "TextDropShadowCache.cpp", + "Texture.cpp", + "TextureCache.cpp", + "VectorDrawable.cpp", + "VkLayer.cpp", + "protos/hwui.proto", + ], + + proto: { + export_proto_headers: true, + }, + + export_include_dirs: ["."], +} + +cc_library { + name: "libhwui", + defaults: ["libhwui_defaults"], +} + +// ------------------------ +// static library null gpu +// ------------------------ + +cc_library_static { + name: "libhwui_static_debug", + defaults: [ + "libhwui_defaults", + "hwui_debug", + ], + cflags: ["-DHWUI_NULL_GPU"], + srcs: [ + "debug/nullegl.cpp", + ], + export_include_dirs: ["."], +} + +cc_defaults { + name: "hwui_test_defaults", + defaults: ["hwui_defaults"], + srcs: [ + "tests/common/scenes/*.cpp", + "tests/common/LeakChecker.cpp", + "tests/common/TestListViewSceneBase.cpp", + "tests/common/TestContext.cpp", + "tests/common/TestScene.cpp", + "tests/common/TestUtils.cpp", + ], +} + +// ------------------------ +// unit tests +// ------------------------ + +cc_test { + name: "hwui_unit_tests", + defaults: ["hwui_test_defaults"], + + static_libs: [ + "libgmock", + "libhwui_static_debug", + ], + shared_libs: ["libmemunreachable"], + cflags: [ + "-include debug/wrap_gles.h", + "-DHWUI_NULL_GPU", + ], + + srcs: [ + "tests/unit/main.cpp", + "tests/unit/BakedOpDispatcherTests.cpp", + "tests/unit/BakedOpRendererTests.cpp", + "tests/unit/BakedOpStateTests.cpp", + "tests/unit/BitmapTests.cpp", + "tests/unit/CanvasContextTests.cpp", + "tests/unit/CanvasStateTests.cpp", + "tests/unit/ClipAreaTests.cpp", + "tests/unit/DamageAccumulatorTests.cpp", + "tests/unit/DeferredLayerUpdaterTests.cpp", + "tests/unit/DeviceInfoTests.cpp", + "tests/unit/FatVectorTests.cpp", + "tests/unit/FontRendererTests.cpp", + "tests/unit/FrameBuilderTests.cpp", + "tests/unit/GlopBuilderTests.cpp", + "tests/unit/GpuMemoryTrackerTests.cpp", + "tests/unit/GradientCacheTests.cpp", + "tests/unit/GraphicsStatsServiceTests.cpp", + "tests/unit/LayerUpdateQueueTests.cpp", + "tests/unit/LeakCheckTests.cpp", + "tests/unit/LinearAllocatorTests.cpp", + "tests/unit/MatrixTests.cpp", + "tests/unit/MeshStateTests.cpp", + "tests/unit/OffscreenBufferPoolTests.cpp", + "tests/unit/OpDumperTests.cpp", + "tests/unit/PathInterpolatorTests.cpp", + "tests/unit/RenderNodeDrawableTests.cpp", + "tests/unit/RecordingCanvasTests.cpp", + "tests/unit/RenderNodeTests.cpp", + "tests/unit/RenderPropertiesTests.cpp", + "tests/unit/SkiaBehaviorTests.cpp", + "tests/unit/SkiaDisplayListTests.cpp", + "tests/unit/SkiaPipelineTests.cpp", + "tests/unit/SkiaRenderPropertiesTests.cpp", + "tests/unit/SkiaCanvasTests.cpp", + "tests/unit/SnapshotTests.cpp", + "tests/unit/StringUtilsTests.cpp", + "tests/unit/TestUtilsTests.cpp", + "tests/unit/TextDropShadowCacheTests.cpp", + "tests/unit/TextureCacheTests.cpp", + "tests/unit/VectorDrawableTests.cpp", + ], +} + +// ------------------------ +// Macro-bench app +// ------------------------ + +cc_benchmark { + name: "hwuimacro", + defaults: ["hwui_test_defaults"], + + // set to libhwui_static_debug to skip actual GL commands + whole_static_libs: ["libhwui"], + shared_libs: ["libmemunreachable"], + + srcs: [ + "tests/macrobench/TestSceneRunner.cpp", + "tests/macrobench/main.cpp", + ], +} + +// ------------------------ +// Micro-bench app +// --------------------- + +cc_benchmark { + name: "hwuimicro", + defaults: ["hwui_test_defaults"], + + cflags: [ + "-include debug/wrap_gles.h", + "-DHWUI_NULL_GPU", + ], + + whole_static_libs: ["libhwui_static_debug"], + shared_libs: ["libmemunreachable"], + + srcs: [ + "tests/microbench/main.cpp", + "tests/microbench/DisplayListCanvasBench.cpp", + "tests/microbench/FontBench.cpp", + "tests/microbench/FrameBuilderBench.cpp", + "tests/microbench/LinearAllocatorBench.cpp", + "tests/microbench/PathParserBench.cpp", + "tests/microbench/RenderNodeBench.cpp", + "tests/microbench/ShadowBench.cpp", + "tests/microbench/TaskManagerBench.cpp", + ], +} diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk deleted file mode 100644 index 5ef49dc5fecd..000000000000 --- a/libs/hwui/Android.mk +++ /dev/null @@ -1,383 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk - -BUGREPORT_FONT_CACHE_USAGE := false - -# Enables fine-grained GLES error checking -# If set to true, every GLES call is wrapped & error checked -# Has moderate overhead -HWUI_ENABLE_OPENGL_VALIDATION := false - -hwui_src_files := \ - hwui/Bitmap.cpp \ - font/CacheTexture.cpp \ - font/Font.cpp \ - hwui/Canvas.cpp \ - hwui/MinikinSkia.cpp \ - hwui/MinikinUtils.cpp \ - hwui/PaintImpl.cpp \ - hwui/Typeface.cpp \ - pipeline/skia/GLFunctorDrawable.cpp \ - pipeline/skia/LayerDrawable.cpp \ - pipeline/skia/RenderNodeDrawable.cpp \ - pipeline/skia/ReorderBarrierDrawables.cpp \ - pipeline/skia/SkiaDisplayList.cpp \ - pipeline/skia/SkiaOpenGLPipeline.cpp \ - pipeline/skia/SkiaOpenGLReadback.cpp \ - pipeline/skia/SkiaPipeline.cpp \ - pipeline/skia/SkiaProfileRenderer.cpp \ - pipeline/skia/SkiaRecordingCanvas.cpp \ - pipeline/skia/SkiaVulkanPipeline.cpp \ - renderstate/Blend.cpp \ - renderstate/MeshState.cpp \ - renderstate/OffscreenBufferPool.cpp \ - renderstate/PixelBufferState.cpp \ - renderstate/RenderState.cpp \ - renderstate/Scissor.cpp \ - renderstate/Stencil.cpp \ - renderstate/TextureState.cpp \ - renderthread/CanvasContext.cpp \ - renderthread/OpenGLPipeline.cpp \ - renderthread/DrawFrameTask.cpp \ - renderthread/EglManager.cpp \ - renderthread/VulkanManager.cpp \ - renderthread/RenderProxy.cpp \ - renderthread/RenderTask.cpp \ - renderthread/RenderThread.cpp \ - renderthread/TimeLord.cpp \ - renderthread/Frame.cpp \ - service/GraphicsStatsService.cpp \ - thread/TaskManager.cpp \ - utils/Blur.cpp \ - utils/Color.cpp \ - utils/GLUtils.cpp \ - utils/LinearAllocator.cpp \ - utils/StringUtils.cpp \ - utils/TestWindowContext.cpp \ - utils/VectorDrawableUtils.cpp \ - AmbientShadow.cpp \ - AnimationContext.cpp \ - Animator.cpp \ - AnimatorManager.cpp \ - BakedOpDispatcher.cpp \ - BakedOpRenderer.cpp \ - BakedOpState.cpp \ - Caches.cpp \ - CanvasState.cpp \ - ClipArea.cpp \ - DamageAccumulator.cpp \ - DeferredLayerUpdater.cpp \ - DeviceInfo.cpp \ - DisplayList.cpp \ - Extensions.cpp \ - FboCache.cpp \ - FontRenderer.cpp \ - FrameBuilder.cpp \ - FrameInfo.cpp \ - FrameInfoVisualizer.cpp \ - GammaFontRenderer.cpp \ - GlLayer.cpp \ - GlopBuilder.cpp \ - GpuMemoryTracker.cpp \ - GradientCache.cpp \ - Image.cpp \ - Interpolator.cpp \ - JankTracker.cpp \ - Layer.cpp \ - LayerBuilder.cpp \ - LayerUpdateQueue.cpp \ - Matrix.cpp \ - OpDumper.cpp \ - OpenGLReadback.cpp \ - Patch.cpp \ - PatchCache.cpp \ - PathCache.cpp \ - PathParser.cpp \ - PathTessellator.cpp \ - PixelBuffer.cpp \ - ProfileRenderer.cpp \ - Program.cpp \ - ProgramCache.cpp \ - Properties.cpp \ - PropertyValuesAnimatorSet.cpp \ - PropertyValuesHolder.cpp \ - RecordingCanvas.cpp \ - RenderBufferCache.cpp \ - RenderNode.cpp \ - RenderProperties.cpp \ - ResourceCache.cpp \ - ShadowTessellator.cpp \ - SkiaCanvas.cpp \ - SkiaCanvasProxy.cpp \ - SkiaShader.cpp \ - Snapshot.cpp \ - SpotShadow.cpp \ - TessellationCache.cpp \ - TextDropShadowCache.cpp \ - Texture.cpp \ - TextureCache.cpp \ - VectorDrawable.cpp \ - VkLayer.cpp \ - protos/hwui.proto - -hwui_test_common_src_files := \ - $(call all-cpp-files-under, tests/common/scenes) \ - tests/common/LeakChecker.cpp \ - tests/common/TestListViewSceneBase.cpp \ - tests/common/TestContext.cpp \ - tests/common/TestScene.cpp \ - tests/common/TestUtils.cpp - -hwui_debug_common_src_files := \ - debug/wrap_gles.cpp \ - debug/DefaultGlesDriver.cpp \ - debug/GlesErrorCheckWrapper.cpp \ - debug/GlesDriver.cpp \ - debug/FatalBaseDriver.cpp \ - debug/NullGlesDriver.cpp - -hwui_cflags := \ - -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES \ - -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" \ - -Wall -Wno-unused-parameter -Wunreachable-code -Werror - -ifeq ($(TARGET_USES_HWC2),true) - hwui_cflags += -DUSE_HWC2 -endif - -# TODO: Linear blending should be enabled by default, but we are -# TODO: making it an opt-in while it's a work in progress -# TODO: The final test should be: -# TODO: ifneq ($(TARGET_ENABLE_LINEAR_BLENDING),false) -ifeq ($(TARGET_ENABLE_LINEAR_BLENDING),true) - hwui_cflags += -DANDROID_ENABLE_LINEAR_BLENDING -endif - -# GCC false-positives on this warning, and since we -Werror that's -# a problem -hwui_cflags += -Wno-free-nonheap-object - -# clang's warning is broken, see: https://llvm.org/bugs/show_bug.cgi?id=21629 -hwui_cflags += -Wno-missing-braces - -ifeq (true, $(BUGREPORT_FONT_CACHE_USAGE)) - hwui_src_files += \ - font/FontCacheHistoryTracker.cpp - hwui_cflags += -DBUGREPORT_FONT_CACHE_USAGE -endif - -ifndef HWUI_COMPILE_SYMBOLS - hwui_cflags += -fvisibility=hidden -endif - -ifdef HWUI_COMPILE_FOR_PERF - # TODO: Non-arm? - hwui_cflags += -fno-omit-frame-pointer -marm -mapcs -endif - -# This has to be lazy-resolved because it depends on the LOCAL_MODULE_CLASS -# which varies depending on what is being built -define hwui_proto_include -$(call local-generated-sources-dir)/proto/$(LOCAL_PATH) -endef - -hwui_c_includes += \ - external/skia/include/private \ - external/skia/src/core \ - external/skia/src/effects \ - external/skia/src/image \ - external/skia/src/utils \ - external/icu/icu4c/source/common \ - external/harfbuzz_ng/src \ - external/freetype/include - -# enable RENDERSCRIPT -hwui_c_includes += \ - $(call intermediates-dir-for,STATIC_LIBRARIES,TARGET,) \ - frameworks/rs/cpp \ - frameworks/rs - -# ------------------------ -# static library -# ------------------------ - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libhwui_static -LOCAL_CFLAGS := $(hwui_cflags) -LOCAL_SRC_FILES := $(hwui_src_files) - -ifeq (true, $(HWUI_ENABLE_OPENGL_VALIDATION)) - LOCAL_CFLAGS += -include debug/wrap_gles.h - LOCAL_CFLAGS += -DDEBUG_OPENGL=3 - LOCAL_SRC_FILES += $(hwui_debug_common_src_files) -endif - -LOCAL_C_INCLUDES := $(hwui_c_includes) $(call hwui_proto_include) -LOCAL_EXPORT_C_INCLUDE_DIRS := \ - $(LOCAL_PATH) \ - $(call hwui_proto_include) - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_STATIC_LIBRARY) - -# ------------------------ -# static library null gpu -# ------------------------ - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libhwui_static_debug -LOCAL_CFLAGS := \ - $(hwui_cflags) \ - -include debug/wrap_gles.h \ - -DHWUI_NULL_GPU -LOCAL_SRC_FILES := \ - $(hwui_src_files) \ - $(hwui_debug_common_src_files) \ - debug/nullegl.cpp -LOCAL_C_INCLUDES := $(hwui_c_includes) $(call hwui_proto_include) -LOCAL_EXPORT_C_INCLUDE_DIRS := \ - $(LOCAL_PATH) \ - $(call hwui_proto_include) - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_STATIC_LIBRARY) - -# ------------------------ -# shared library -# ------------------------ - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := SHARED_LIBRARIES -LOCAL_MODULE := libhwui -LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_SHARED_LIBRARY) - -# ------------------------ -# unit tests -# ------------------------ - -include $(CLEAR_VARS) - -LOCAL_MODULE := hwui_unit_tests -LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_LIBRARIES := libgmock libhwui_static_debug -LOCAL_SHARED_LIBRARIES := libmemunreachable -LOCAL_CFLAGS := \ - $(hwui_cflags) \ - -include debug/wrap_gles.h \ - -DHWUI_NULL_GPU -LOCAL_C_INCLUDES := $(hwui_c_includes) - -LOCAL_SRC_FILES += \ - $(hwui_test_common_src_files) \ - tests/unit/main.cpp \ - tests/unit/BakedOpDispatcherTests.cpp \ - tests/unit/BakedOpRendererTests.cpp \ - tests/unit/BakedOpStateTests.cpp \ - tests/unit/BitmapTests.cpp \ - tests/unit/CanvasContextTests.cpp \ - tests/unit/CanvasStateTests.cpp \ - tests/unit/ClipAreaTests.cpp \ - tests/unit/DamageAccumulatorTests.cpp \ - tests/unit/DeferredLayerUpdaterTests.cpp \ - tests/unit/DeviceInfoTests.cpp \ - tests/unit/FatVectorTests.cpp \ - tests/unit/FontRendererTests.cpp \ - tests/unit/FrameBuilderTests.cpp \ - tests/unit/GlopBuilderTests.cpp \ - tests/unit/GpuMemoryTrackerTests.cpp \ - tests/unit/GradientCacheTests.cpp \ - tests/unit/GraphicsStatsServiceTests.cpp \ - tests/unit/LayerUpdateQueueTests.cpp \ - tests/unit/LeakCheckTests.cpp \ - tests/unit/LinearAllocatorTests.cpp \ - tests/unit/MatrixTests.cpp \ - tests/unit/MeshStateTests.cpp \ - tests/unit/OffscreenBufferPoolTests.cpp \ - tests/unit/OpDumperTests.cpp \ - tests/unit/PathInterpolatorTests.cpp \ - tests/unit/RenderNodeDrawableTests.cpp \ - tests/unit/RecordingCanvasTests.cpp \ - tests/unit/RenderNodeTests.cpp \ - tests/unit/RenderPropertiesTests.cpp \ - tests/unit/SkiaBehaviorTests.cpp \ - tests/unit/SkiaDisplayListTests.cpp \ - tests/unit/SkiaPipelineTests.cpp \ - tests/unit/SkiaRenderPropertiesTests.cpp \ - tests/unit/SkiaCanvasTests.cpp \ - tests/unit/SnapshotTests.cpp \ - tests/unit/StringUtilsTests.cpp \ - tests/unit/TestUtilsTests.cpp \ - tests/unit/TextDropShadowCacheTests.cpp \ - tests/unit/TextureCacheTests.cpp \ - tests/unit/VectorDrawableTests.cpp \ - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_NATIVE_TEST) - -# ------------------------ -# Macro-bench app -# ------------------------ - -include $(CLEAR_VARS) - -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/local/tmp -LOCAL_MODULE:= hwuimacro -LOCAL_MODULE_TAGS := tests -LOCAL_MULTILIB := both -LOCAL_CFLAGS := $(hwui_cflags) -LOCAL_C_INCLUDES := $(hwui_c_includes) - -# set to libhwui_static_debug to skip actual GL commands -LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static -LOCAL_SHARED_LIBRARIES := libmemunreachable - -LOCAL_SRC_FILES += \ - $(hwui_test_common_src_files) \ - tests/macrobench/TestSceneRunner.cpp \ - tests/macrobench/main.cpp - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_NATIVE_BENCHMARK) - -# ------------------------ -# Micro-bench app -# --------------------- -include $(CLEAR_VARS) - -LOCAL_MODULE:= hwuimicro -LOCAL_MODULE_TAGS := tests -LOCAL_CFLAGS := \ - $(hwui_cflags) \ - -include debug/wrap_gles.h \ - -DHWUI_NULL_GPU - -LOCAL_C_INCLUDES := $(hwui_c_includes) - -LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static_debug -LOCAL_SHARED_LIBRARIES := libmemunreachable - -LOCAL_SRC_FILES += \ - $(hwui_test_common_src_files) \ - tests/microbench/main.cpp \ - tests/microbench/DisplayListCanvasBench.cpp \ - tests/microbench/FontBench.cpp \ - tests/microbench/FrameBuilderBench.cpp \ - tests/microbench/LinearAllocatorBench.cpp \ - tests/microbench/PathParserBench.cpp \ - tests/microbench/RenderNodeBench.cpp \ - tests/microbench/ShadowBench.cpp \ - tests/microbench/TaskManagerBench.cpp - - -include $(LOCAL_PATH)/hwui_static_deps.mk -include $(BUILD_NATIVE_BENCHMARK) diff --git a/libs/hwui/hwui_static_deps.mk b/libs/hwui/hwui_static_deps.mk deleted file mode 100644 index 8826cfcc3100..000000000000 --- a/libs/hwui/hwui_static_deps.mk +++ /dev/null @@ -1,33 +0,0 @@ -############################################################################### -# -# -# This file contains the shared and static dependencies needed by any target -# that attempts to statically link HWUI (i.e. libhwui_static build target). This -# file should be included by any target that lists libhwui_static as a -# dependency. -# -# This is a workaround for the fact that the build system does not add these -# transitive dependencies when it attempts to link libhwui_static into another -# library. -# -############################################################################### - -LOCAL_SHARED_LIBRARIES += \ - liblog \ - libcutils \ - libutils \ - libEGL \ - libGLESv2 \ - libvulkan \ - libskia \ - libui \ - libgui \ - libprotobuf-cpp-full \ - libharfbuzz_ng \ - libft2 \ - libminikin \ - libandroidfw \ - libRScpp - -LOCAL_STATIC_LIBRARIES += \ - libplatformprotos diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index 5a178a50408b..eb513e170286 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -998,7 +998,8 @@ public class AccessPoint implements Comparable<AccessPoint> { if (mRssi != info.getRssi()) { mRssi = info.getRssi(); updated = true; - } else if (mNetworkInfo.getDetailedState() != networkInfo.getDetailedState()) { + } else if (mNetworkInfo != null && networkInfo != null + && mNetworkInfo.getDetailedState() != networkInfo.getDetailedState()) { updated = true; } mInfo = info; diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java index f519a906eab5..d4ce40c7c0a8 100644 --- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java +++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java @@ -465,9 +465,9 @@ public class WifiTrackerTest { private void updateScoresAndWaitForAccessPointsChangedCallback() throws InterruptedException { // Updating scores can happen together or one after the other, so the latch countdown is set // to 2. - mAccessPointsChangedLatch = new CountDownLatch(3); + mAccessPointsChangedLatch = new CountDownLatch(2); updateScores(); - assertTrue("onAccessPointChanged was not called three times", + assertTrue("onAccessPointChanged was not called twice", mAccessPointsChangedLatch.await(LATCH_TIMEOUT, TimeUnit.MILLISECONDS)); } diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java index df03fdc46d06..bdc08718d37f 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java @@ -107,12 +107,12 @@ public class PipManager implements BasePipManager { } @Override - public void onPinnedActivityRestartAttempt() { + public void onPinnedActivityRestartAttempt(boolean clearedTask) { if (!checkCurrentUserId(false /* debug */)) { return; } - mTouchHandler.getMotionHelper().expandPip(); + mTouchHandler.getMotionHelper().expandPip(clearedTask /* skipAnimation */); } }; diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java index fc52a2ec5994..5121c8d0a375 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java @@ -140,14 +140,25 @@ public class PipMotionHelper { * Resizes the pinned stack back to fullscreen. */ void expandPip() { + expandPip(false /* skipAnimation */); + } + + /** + * Resizes the pinned stack back to fullscreen. + */ + void expandPip(boolean skipAnimation) { cancelAnimations(); mHandler.post(() -> { try { - mActivityManager.resizeStack(PINNED_STACK_ID, null /* bounds */, - true /* allowResizeInDockedMode */, true /* preserveWindows */, - true /* animate */, EXPAND_STACK_TO_FULLSCREEN_DURATION); + if (skipAnimation) { + mActivityManager.moveTasksToFullscreenStack(PINNED_STACK_ID, true /* onTop */); + } else { + mActivityManager.resizeStack(PINNED_STACK_ID, null /* bounds */, + true /* allowResizeInDockedMode */, true /* preserveWindows */, + true /* animate */, EXPAND_STACK_TO_FULLSCREEN_DURATION); + } } catch (RemoteException e) { - Log.e(TAG, "Error showing PiP menu activity", e); + Log.e(TAG, "Error expanding PiP activity", e); } }); } diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java index 657f08be8b52..9735bfc666d7 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java @@ -625,7 +625,7 @@ public class PipManager implements BasePipManager { } @Override - public void onPinnedActivityRestartAttempt() { + public void onPinnedActivityRestartAttempt(boolean clearedTask) { if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()"); if (!checkCurrentUserId(DEBUG)) { return; diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index a9e1f61b7d47..f431517cfe77 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -158,7 +158,7 @@ public class SystemServicesProxy { public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) { } public void onActivityPinned(String packageName) { } public void onActivityUnpinned() { } - public void onPinnedActivityRestartAttempt() { } + public void onPinnedActivityRestartAttempt(boolean clearedTask) { } public void onPinnedStackAnimationStarted() { } public void onPinnedStackAnimationEnded() { } public void onActivityForcedResizable(String packageName, int taskId, int reason) { } @@ -223,10 +223,11 @@ public class SystemServicesProxy { } @Override - public void onPinnedActivityRestartAttempt() + public void onPinnedActivityRestartAttempt(boolean clearedTask) throws RemoteException{ mHandler.removeMessages(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT); - mHandler.sendEmptyMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT); + mHandler.obtainMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT, clearedTask ? 1 : 0, 0) + .sendToTarget(); } @Override @@ -1294,7 +1295,8 @@ public class SystemServicesProxy { } case ON_PINNED_ACTIVITY_RESTART_ATTEMPT: { for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) { - mTaskStackListeners.get(i).onPinnedActivityRestartAttempt(); + mTaskStackListeners.get(i).onPinnedActivityRestartAttempt( + msg.arg1 != 0); } break; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java index d57f81399efd..8934460c380e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java @@ -28,17 +28,22 @@ import android.content.Context; import android.os.Handler; import android.os.Looper; import android.support.test.InstrumentationRegistry; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; import com.android.internal.hardware.AmbientDisplayConfiguration; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.wakelock.WakeLock; import com.android.systemui.util.wakelock.WakeLockFake; +import com.android.systemui.utils.hardware.FakeSensorManager; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +@SmallTest +@RunWith(AndroidJUnit4.class) public class DozeTriggersTest { private Context mContext; private DozeTriggers mTriggers; @@ -46,7 +51,7 @@ public class DozeTriggersTest { private DozeHostFake mHost; private AmbientDisplayConfiguration mConfig; private DozeParameters mParameters; - private SensorManagerFake mSensors; + private FakeSensorManager mSensors; private Handler mHandler; private WakeLock mWakeLock; private Instrumentation mInstrumentation; @@ -65,7 +70,7 @@ public class DozeTriggersTest { mHost = new DozeHostFake(); mConfig = DozeConfigurationUtil.createMockConfig(); mParameters = DozeConfigurationUtil.createMockParameters(); - mSensors = new SensorManagerFake(mContext); + mSensors = new FakeSensorManager(mContext); mHandler = new Handler(Looper.getMainLooper()); mWakeLock = new WakeLockFake(); @@ -76,29 +81,29 @@ public class DozeTriggersTest { } @Test - @Ignore("setup crashes on virtual devices") public void testOnNotification_stillWorksAfterOneFailedProxCheck() throws Exception { when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE); mInstrumentation.runOnMainSync(()->{ mTriggers.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED); - mTriggers.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.DOZE); + mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE); mHost.callback.onNotificationHeadsUp(); }); mInstrumentation.runOnMainSync(() -> { - mSensors.PROXIMITY.sendProximityResult(false); /* Near */ + mSensors.getMockProximitySensor().sendProximityResult(false); /* Near */ }); verify(mMachine, never()).requestState(any()); + verify(mMachine, never()).requestPulse(anyInt()); mInstrumentation.runOnMainSync(()->{ mHost.callback.onNotificationHeadsUp(); }); mInstrumentation.runOnMainSync(() -> { - mSensors.PROXIMITY.sendProximityResult(true); /* Far */ + mSensors.getMockProximitySensor().sendProximityResult(true); /* Far */ }); verify(mMachine).requestPulse(anyInt()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/SensorManagerFake.java b/packages/SystemUI/tests/src/com/android/systemui/utils/hardware/FakeSensorManager.java index 5b4b8917d8d1..30be6658d4b6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/SensorManagerFake.java +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/hardware/FakeSensorManager.java @@ -11,10 +11,10 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License */ -package com.android.systemui.doze; +package com.android.systemui.utils.hardware; import android.content.Context; import android.hardware.HardwareBuffer; @@ -33,6 +33,8 @@ import android.util.ArraySet; import com.google.android.collect.Lists; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -44,18 +46,38 @@ import java.util.List; * Note that this class ignores the "Handler" argument, so the test is responsible for calling the * listener on the right thread. */ -public class SensorManagerFake extends SensorManager { +public class FakeSensorManager extends SensorManager { - public MockSensor PROXIMITY; + private final MockProximitySensor mMockProximitySensor; - public SensorManagerFake(Context context) { - PROXIMITY = new MockSensor(context.getSystemService(SensorManager.class) - .getDefaultSensor(Sensor.TYPE_PROXIMITY)); + public FakeSensorManager(Context context) throws Exception { + Sensor proxSensor = context.getSystemService(SensorManager.class) + .getDefaultSensor(Sensor.TYPE_PROXIMITY); + if (proxSensor == null) { + // No prox? Let's create a fake one! + proxSensor = createSensor(Sensor.TYPE_PROXIMITY); + } + mMockProximitySensor = new MockProximitySensor(proxSensor); + } + + public MockProximitySensor getMockProximitySensor() { + return mMockProximitySensor; + } + + @Override + public Sensor getDefaultSensor(int type) { + Sensor s = super.getDefaultSensor(type); + if (s != null) { + return s; + } + // Our mock sensors aren't wakeup, and it's a pain to create them that way. Instead, just + // return non-wakeup sensors if we can't find a wakeup sensor. + return getDefaultSensor(type, false /* wakeup */); } @Override protected List<Sensor> getFullSensorList() { - return Lists.newArrayList(PROXIMITY.sensor); + return Lists.newArrayList(mMockProximitySensor.sensor); } @Override @@ -65,8 +87,8 @@ public class SensorManagerFake extends SensorManager { @Override protected void unregisterListenerImpl(SensorEventListener listener, Sensor sensor) { - if (sensor == PROXIMITY.sensor || sensor == null) { - PROXIMITY.listeners.remove(listener); + if (sensor == mMockProximitySensor.sensor || sensor == null) { + mMockProximitySensor.listeners.remove(listener); } } @@ -74,8 +96,8 @@ public class SensorManagerFake extends SensorManager { protected boolean registerListenerImpl(SensorEventListener listener, Sensor sensor, int delayUs, Handler handler, int maxReportLatencyUs, int reservedFlags) { - if (sensor == PROXIMITY.sensor) { - PROXIMITY.listeners.add(listener); + if (sensor == mMockProximitySensor.sensor) { + mMockProximitySensor.listeners.add(listener); return true; } return false; @@ -141,11 +163,44 @@ public class SensorManagerFake extends SensorManager { return false; } - public class MockSensor { + private Sensor createSensor(int type) throws Exception { + Constructor<Sensor> constr = Sensor.class.getDeclaredConstructor(); + constr.setAccessible(true); + Sensor sensor = constr.newInstance(); + + setSensorType(sensor, type); + setSensorField(sensor, "mName", "Mock " + sensor.getStringType() + "/" + type); + setSensorField(sensor, "mVendor", "Mock Vendor"); + setSensorField(sensor, "mVersion", 1); + setSensorField(sensor, "mHandle", -1); + setSensorField(sensor, "mMaxRange", 10); + setSensorField(sensor, "mResolution", 1); + setSensorField(sensor, "mPower", 1); + setSensorField(sensor, "mMinDelay", 1000); + setSensorField(sensor, "mMaxDelay", 1000000000); + setSensorField(sensor, "mFlags", 0); + setSensorField(sensor, "mId", -1); + + return sensor; + } + + private void setSensorField(Sensor sensor, String fieldName, Object value) throws Exception { + Field field = Sensor.class.getDeclaredField(fieldName); + field.setAccessible(true); + field.set(sensor, value); + } + + private void setSensorType(Sensor sensor, int type) throws Exception { + Method setter = Sensor.class.getDeclaredMethod("setType", Integer.TYPE); + setter.setAccessible(true); + setter.invoke(sensor, type); + } + + public class MockProximitySensor { final Sensor sensor; final ArraySet<SensorEventListener> listeners = new ArraySet<>(); - private MockSensor(Sensor sensor) { + private MockProximitySensor(Sensor sensor) { this.sensor = sensor; } diff --git a/rs/java/android/renderscript/ScriptIntrinsicLUT.java b/rs/java/android/renderscript/ScriptIntrinsicLUT.java index 69ff64acdf90..e90462d11124 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicLUT.java +++ b/rs/java/android/renderscript/ScriptIntrinsicLUT.java @@ -56,6 +56,10 @@ public final class ScriptIntrinsicLUT extends ScriptIntrinsic { } + public void destroy() { + mTables.destroy(); + super.destroy(); + } private void validate(int index, int value) { if (index < 0 || index > 255) { diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 43135334ba74..a5615a9c56fe 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -166,8 +166,11 @@ public final class ActiveServices { */ static final class ActiveForegroundApp { String mPackageName; + int mUid; CharSequence mLabel; boolean mShownWhileScreenOn; + boolean mAppOnTop; + boolean mShownWhileTop; long mStartTime; long mStartVisibleTime; long mEndTime; @@ -728,11 +731,12 @@ public final class ActiveServices { synchronized (mAm) { final long now = SystemClock.elapsedRealtime(); final long nowPlusMin = now + mAm.mConstants.FOREGROUND_SERVICE_UI_MIN_TIME; + long nextUpdateTime = Long.MAX_VALUE; if (smap != null) { for (int i = smap.mActiveForegroundApps.size()-1; i >= 0; i--) { ActiveForegroundApp aa = smap.mActiveForegroundApps.valueAt(i); if (aa.mEndTime != 0 && (mScreenOn || aa.mShownWhileScreenOn)) { - if (aa.mEndTime < (aa.mStartVisibleTime + if (!aa.mShownWhileTop && aa.mEndTime < (aa.mStartVisibleTime + mAm.mConstants.FOREGROUND_SERVICE_UI_MIN_TIME)) { // Check to see if this should still be displayed... we continue // until it has been shown for at least the timeout duration. @@ -741,6 +745,12 @@ public final class ActiveServices { smap.mActiveForegroundApps.removeAt(i); smap.mActiveForegroundAppsChanged = true; continue; + } else { + long hideTime = aa.mStartVisibleTime + + mAm.mConstants.FOREGROUND_SERVICE_UI_MIN_TIME; + if (hideTime < nextUpdateTime) { + nextUpdateTime = hideTime; + } } } else { // This was up for longer than the timeout, so just remove immediately. @@ -749,10 +759,17 @@ public final class ActiveServices { continue; } } - if (active == null) { - active = new ArrayList<>(); + if (!aa.mAppOnTop) { + if (active == null) { + active = new ArrayList<>(); + } + active.add(aa); } - active.add(aa); + } + smap.removeMessages(ServiceMap.MSG_UPDATE_FOREGROUND_APPS); + if (nextUpdateTime < Long.MAX_VALUE) { + Message msg = smap.obtainMessage(); + smap.sendMessageAtTime(msg, nextUpdateTime); } } if (!smap.mActiveForegroundAppsChanged) { @@ -842,7 +859,7 @@ public final class ActiveServices { active.mNumActive--; if (active.mNumActive <= 0) { active.mEndTime = SystemClock.elapsedRealtime(); - if (active.mEndTime >= (active.mStartVisibleTime + if (active.mShownWhileTop || active.mEndTime >= (active.mStartVisibleTime + mAm.mConstants.FOREGROUND_SERVICE_UI_MIN_TIME)) { // Have been active for long enough that we will remove it immediately. smap.mActiveForegroundApps.remove(r.packageName); @@ -887,6 +904,31 @@ public final class ActiveServices { } } + void foregroundServiceProcStateChangedLocked(UidRecord uidRec) { + ServiceMap smap = mServiceMap.get(UserHandle.getUserId(uidRec.uid)); + if (smap != null) { + boolean changed = false; + for (int j = smap.mActiveForegroundApps.size()-1; j >= 0; j--) { + ActiveForegroundApp active = smap.mActiveForegroundApps.valueAt(j); + if (active.mUid == uidRec.uid) { + if (uidRec.curProcState <= ActivityManager.PROCESS_STATE_TOP) { + if (!active.mAppOnTop) { + active.mAppOnTop = true; + changed = true; + } + active.mShownWhileTop = true; + } else if (active.mAppOnTop) { + active.mAppOnTop = false; + changed = true; + } + } + } + if (changed) { + requestUpdateActiveForegroundAppsLocked(smap, 0); + } + } + } + private void setServiceForegroundInnerLocked(ServiceRecord r, int id, Notification notification, int flags) { if (id != 0) { @@ -948,7 +990,13 @@ public final class ActiveServices { if (active == null) { active = new ActiveForegroundApp(); active.mPackageName = r.packageName; + active.mUid = r.appInfo.uid; active.mShownWhileScreenOn = mScreenOn; + if (r.app != null) { + active.mAppOnTop = active.mShownWhileTop = + r.app.uidRecord.curProcState + <= ActivityManager.PROCESS_STATE_TOP; + } active.mStartTime = active.mStartVisibleTime = SystemClock.elapsedRealtime(); smap.mActiveForegroundApps.put(r.packageName, active); @@ -2790,6 +2838,9 @@ public final class ActiveServices { if (!doit && didSomething) { return true; } + if (doit && filterByClasses == null) { + forceStopPackageLocked(packageName, mServiceMap.valueAt(i).mUserId); + } } } else { ServiceMap smap = mServiceMap.get(userId); @@ -2798,6 +2849,9 @@ public final class ActiveServices { didSomething = collectPackageServicesLocked(packageName, filterByClasses, evenPersistent, doit, killProcess, items); } + if (doit && filterByClasses == null) { + forceStopPackageLocked(packageName, userId); + } } if (mTmpCollectionResults != null) { @@ -2806,10 +2860,11 @@ public final class ActiveServices { } mTmpCollectionResults.clear(); } + return didSomething; } - void removeUninstalledPackageLocked(String packageName, int userId) { + void forceStopPackageLocked(String packageName, int userId) { ServiceMap smap = mServiceMap.get(userId); if (smap != null && smap.mActiveForegroundApps.size() > 0) { for (int i = smap.mActiveForegroundApps.size()-1; i >= 0; i--) { @@ -3640,6 +3695,10 @@ public final class ActiveServices { } pw.print(" mNumActive="); pw.print(aa.mNumActive); + pw.print(" mAppOnTop="); + pw.print(aa.mAppOnTop); + pw.print(" mShownWhileTop="); + pw.print(aa.mShownWhileTop); pw.print(" mShownWhileScreenOn="); pw.println(aa.mShownWhileScreenOn); pw.print(" mStartTime="); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 1098a82bde27..420510951416 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -120,7 +120,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_NETWORK; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_OOM_ADJ; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PERMISSIONS_REVIEW; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_POWER; -import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_POWER_QUICK; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROCESSES; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROCESS_OBSERVERS; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROVIDER; @@ -19008,7 +19007,7 @@ public class ActivityManagerService extends IActivityManager.Stub removeTasksByPackageNameLocked(ssp, userId); - mServices.removeUninstalledPackageLocked(ssp, userId); + mServices.forceStopPackageLocked(ssp, userId); // Hide the "unsupported display" dialog if necessary. if (mUnsupportedDisplaySizeDialog != null && ssp.equals( @@ -19891,8 +19890,9 @@ public class ActivityManagerService extends IActivityManager.Stub } /** - * NOTE: For the pinned stack, this method is only called after the bounds animation has - * animated the stack to the fullscreen. + * NOTE: For the pinned stack, this method is usually called after the bounds animation has + * animated the stack to the fullscreen, but can also be called if we are relaunching an + * activity and clearing the task at the same time. */ @Override public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) { @@ -22278,6 +22278,9 @@ public class ActivityManagerService extends IActivityManager.Stub if (uidRec.curProcState > app.curProcState) { uidRec.curProcState = app.curProcState; } + if (app.foregroundServices) { + uidRec.foregroundServices = true; + } } } @@ -22519,6 +22522,9 @@ public class ActivityManagerService extends IActivityManager.Stub uidRec.setWhitelist = uidRec.curWhitelist; enqueueUidChangeLocked(uidRec, -1, uidChange); noteUidProcessState(uidRec.uid, uidRec.curProcState); + if (uidRec.foregroundServices) { + mServices.foregroundServiceProcStateChangedLocked(uidRec); + } } } if (mLocalPowerManager != null) { diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 86a3103ac244..1f1aa8e8cdd9 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -575,12 +575,15 @@ class ActivityStarter { return; } - if (startedActivityStackId == PINNED_STACK_ID - && (result == START_TASK_TO_FRONT || result == START_DELIVERED_TO_TOP)) { + boolean clearedTask = (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) + == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); + if (startedActivityStackId == PINNED_STACK_ID && (result == START_TASK_TO_FRONT + || result == START_DELIVERED_TO_TOP || clearedTask)) { // The activity was already running in the pinned stack so it wasn't started, but either // brought to the front or the new intent was delivered to it since it was already in // front. Notify anyone interested in this piece of information. - mService.mTaskChangeNotificationController.notifyPinnedActivityRestartAttempt(); + mService.mTaskChangeNotificationController.notifyPinnedActivityRestartAttempt( + clearedTask); return; } } diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java index b025385413ea..fbc2bd270a75 100644 --- a/services/core/java/com/android/server/am/ProcessRecord.java +++ b/services/core/java/com/android/server/am/ProcessRecord.java @@ -103,7 +103,6 @@ final class ProcessRecord { int renderThreadTid; // TID for RenderThread boolean serviceb; // Process currently is on the service B list boolean serviceHighRam; // We are forcing to service B list due to its RAM use - boolean setIsForeground; // Running foreground UI when last set? boolean notCachedSinceIdle; // Has this process not been in a cached state since last idle? boolean hasClientActivities; // Are there any client services with activities? boolean hasStartedServices; // Are there any started services running in this process? @@ -303,9 +302,8 @@ final class ProcessRecord { pw.print(" hasAboveClient="); pw.print(hasAboveClient); pw.print(" treatLikeActivity="); pw.println(treatLikeActivity); } - if (setIsForeground || foregroundServices || forcingToForeground != null) { - pw.print(prefix); pw.print("setIsForeground="); pw.print(setIsForeground); - pw.print(" foregroundServices="); pw.print(foregroundServices); + if (foregroundServices || forcingToForeground != null) { + pw.print(prefix); pw.print("foregroundServices="); pw.print(foregroundServices); pw.print(" forcingToForeground="); pw.println(forcingToForeground); } if (reportedInteraction || fgInteractionTime != 0) { diff --git a/services/core/java/com/android/server/am/TaskChangeNotificationController.java b/services/core/java/com/android/server/am/TaskChangeNotificationController.java index 7d2bc5b51c2e..f5d7b6858b83 100644 --- a/services/core/java/com/android/server/am/TaskChangeNotificationController.java +++ b/services/core/java/com/android/server/am/TaskChangeNotificationController.java @@ -104,7 +104,7 @@ class TaskChangeNotificationController { }; private final TaskStackConsumer mNotifyPinnedActivityRestartAttempt = (l, m) -> { - l.onPinnedActivityRestartAttempt(); + l.onPinnedActivityRestartAttempt(m.arg1 != 0); }; private final TaskStackConsumer mNotifyPinnedStackAnimationStarted = (l, m) -> { @@ -300,10 +300,11 @@ class TaskChangeNotificationController { * running in the pinned stack and the activity was not actually started, but the task is * either brought to the front or a new Intent is delivered to it. */ - void notifyPinnedActivityRestartAttempt() { + void notifyPinnedActivityRestartAttempt(boolean clearedTask) { mHandler.removeMessages(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG); final Message msg = - mHandler.obtainMessage(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG); + mHandler.obtainMessage(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG, + clearedTask ? 1 : 0, 0); forAllLocalListeners(mNotifyPinnedActivityRestartAttempt, msg); msg.sendToTarget(); } diff --git a/services/core/java/com/android/server/am/UidRecord.java b/services/core/java/com/android/server/am/UidRecord.java index c0fb77f08647..c411bcec4540 100644 --- a/services/core/java/com/android/server/am/UidRecord.java +++ b/services/core/java/com/android/server/am/UidRecord.java @@ -35,6 +35,7 @@ public final class UidRecord { int setProcState = ActivityManager.PROCESS_STATE_NONEXISTENT; long lastBackgroundTime; boolean ephemeral; + boolean foregroundServices; boolean curWhitelist; boolean setWhitelist; boolean idle; @@ -102,6 +103,7 @@ public final class UidRecord { public void reset() { curProcState = ActivityManager.PROCESS_STATE_CACHED_EMPTY; + foregroundServices = false; } public void updateHasInternetPermission() { @@ -131,6 +133,9 @@ public final class UidRecord { if (ephemeral) { sb.append(" ephemeral"); } + if (foregroundServices) { + sb.append(" fgServices"); + } if (curWhitelist) { sb.append(" whitelist"); } diff --git a/services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java b/services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java index f92bf3dd4427..4981d5c5731f 100644 --- a/services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java +++ b/services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java @@ -66,7 +66,11 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt @Override public void applyChangesLocked(NotificationRecord record) { - record.setRecentlyIntrusive(false); + // there will be another reconsideration in the message queue HANG_TIME_MS + // from each time this record alerts, which can finally clear this flag. + if ((System.currentTimeMillis() - record.getLastIntrusive()) >= HANG_TIME_MS) { + record.setRecentlyIntrusive(false); + } } }; } diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index a4eccbf3f1dd..1d843c1cabf8 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -884,6 +884,8 @@ public class NotificationManagerService extends SystemService { } else if (action.equals(Intent.ACTION_USER_REMOVED)) { final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); mZenModeHelper.onUserRemoved(user); + mRankingHelper.onUserRemoved(user); + savePolicyFile(); } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) { final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); mConditionProviders.onUserUnlocked(user); diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java index 90257daae453..f019a5ce00ea 100644 --- a/services/core/java/com/android/server/notification/NotificationRecord.java +++ b/services/core/java/com/android/server/notification/NotificationRecord.java @@ -85,6 +85,7 @@ public final class NotificationRecord { // to communicate with the ranking module. private float mContactAffinity; private boolean mRecentlyIntrusive; + private long mLastIntrusive; // is this notification currently being intercepted by Zen Mode? private boolean mIntercept; @@ -515,12 +516,19 @@ public final class NotificationRecord { public void setRecentlyIntrusive(boolean recentlyIntrusive) { mRecentlyIntrusive = recentlyIntrusive; + if (recentlyIntrusive) { + mLastIntrusive = System.currentTimeMillis(); + } } public boolean isRecentlyIntrusive() { return mRecentlyIntrusive; } + public long getLastIntrusive() { + return mLastIntrusive; + } + public void setPackagePriority(int packagePriority) { mPackagePriority = packagePriority; } diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java index 3481556ddb8f..1e741de5f269 100644 --- a/services/core/java/com/android/server/notification/RankingHelper.java +++ b/services/core/java/com/android/server/notification/RankingHelper.java @@ -1040,6 +1040,18 @@ public class RankingHelper implements RankingConfig { return packageChannels; } + public void onUserRemoved(int userId) { + synchronized (mRecords) { + int N = mRecords.size(); + for (int i = N - 1; i >= 0 ; i--) { + Record record = mRecords.valueAt(i); + if (UserHandle.getUserId(record.uid) == userId) { + mRecords.removeAt(i); + } + } + } + } + public void onPackagesChanged(boolean removingPackage, int changeUserId, String[] pkgList, int[] uidList) { if (pkgList == null || pkgList.length == 0) { diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java index f4f7e2403f0c..8e06a51238ee 100644 --- a/services/core/java/com/android/server/trust/TrustManagerService.java +++ b/services/core/java/com/android/server/trust/TrustManagerService.java @@ -325,8 +325,6 @@ public class TrustManagerService extends SystemService { agentInfo.label = resolveInfo.loadLabel(pm); agentInfo.icon = resolveInfo.loadIcon(pm); agentInfo.settings = getSettingsAttrs(pm, resolveInfo); - agentInfo.agent = new TrustAgentWrapper(mContext, this, - new Intent().setComponent(name), userInfo.getUserHandle()); } else { int index = mActiveAgents.indexOf(agentInfo); agentInfo = mActiveAgents.valueAt(index); @@ -363,6 +361,11 @@ public class TrustManagerService extends SystemService { } } + if (agentInfo.agent == null) { + agentInfo.agent = new TrustAgentWrapper(mContext, this, + new Intent().setComponent(name), userInfo.getUserHandle()); + } + if (!mActiveAgents.contains(agentInfo)) { mActiveAgents.add(agentInfo); } else { diff --git a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java index e2428b908f41..8ab6d08c3e4f 100644 --- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java @@ -843,6 +843,36 @@ public class RankingHelperTest { } @Test + public void testOnUserRemoved() throws Exception { + int[] user0Uids = {98, 235, 16, 3782}; + int[] user1Uids = new int[user0Uids.length]; + for (int i = 0; i < user0Uids.length; i++) { + user1Uids[i] = UserHandle.PER_USER_RANGE + user0Uids[i]; + + final ApplicationInfo legacy = new ApplicationInfo(); + legacy.targetSdkVersion = Build.VERSION_CODES.N_MR1; + when(mPm.getApplicationInfoAsUser(eq(PKG), anyInt(), anyInt())).thenReturn(legacy); + + // create records with the default channel for all user 0 and user 1 uids + mHelper.getImportance(PKG, user0Uids[i]); + mHelper.getImportance(PKG, user1Uids[i]); + } + + mHelper.onUserRemoved(1); + + // user 0 records remain + for (int i = 0; i < user0Uids.length; i++) { + assertEquals(1, + mHelper.getNotificationChannels(PKG, user0Uids[i], false).getList().size()); + } + // user 1 records are gone + for (int i = 0; i < user1Uids.length; i++) { + assertEquals(0, + mHelper.getNotificationChannels(PKG, user1Uids[i], false).getList().size()); + } + } + + @Test public void testOnPackageChanged_packageRemoval() throws Exception { // Deleted NotificationChannel channel1 = diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java index f01e4c0a8c69..256e13b57d61 100644 --- a/telephony/java/com/android/internal/telephony/DctConstants.java +++ b/telephony/java/com/android/internal/telephony/DctConstants.java @@ -106,6 +106,7 @@ public class DctConstants { public static final int EVENT_REDIRECTION_DETECTED = BASE + 44; public static final int EVENT_PCO_DATA_RECEIVED = BASE + 45; public static final int EVENT_SET_CARRIER_DATA_ENABLED = BASE + 46; + public static final int EVENT_DATA_RECONNECT = BASE + 47; /***** Constants *****/ |