diff options
23 files changed, 195 insertions, 64 deletions
diff --git a/api/current.txt b/api/current.txt index 1a56525ab153..cf3318197097 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12244,6 +12244,7 @@ package android.graphics { field public int inTargetDensity; field public byte[] inTempStorage; field public deprecated boolean mCancel; + field public android.graphics.Bitmap.Config outConfig; field public int outHeight; field public java.lang.String outMimeType; field public int outWidth; diff --git a/api/system-current.txt b/api/system-current.txt index 06411d08dccd..251855c9da0e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -12833,6 +12833,7 @@ package android.graphics { field public int inTargetDensity; field public byte[] inTempStorage; field public deprecated boolean mCancel; + field public android.graphics.Bitmap.Config outConfig; field public int outHeight; field public java.lang.String outMimeType; field public int outWidth; diff --git a/api/test-current.txt b/api/test-current.txt index cde9bdc63faa..ba632bd8111c 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -12278,6 +12278,7 @@ package android.graphics { field public int inTargetDensity; field public byte[] inTempStorage; field public deprecated boolean mCancel; + field public android.graphics.Bitmap.Config outConfig; field public int outHeight; field public java.lang.String outMimeType; field public int outWidth; diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 3ba55ed2c4dc..83b6a52e33e8 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -339,6 +339,21 @@ public final class Display { public static final int COLOR_MODE_DISPLAY_P3 = 9; /** + * Indicates that when display is removed, all its activities will be moved to the primary + * display and the topmost activity should become focused. + * + * @hide + */ + public static final int REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY = 0; + /** + * Indicates that when display is removed, all its stacks and tasks will be removed, all + * activities will be destroyed according to the usual lifecycle. + * + * @hide + */ + public static final int REMOVE_MODE_DESTROY_CONTENT = 1; + + /** * Internal method to create a display. * Applications should use {@link android.view.WindowManager#getDefaultDisplay()} * or {@link android.hardware.display.DisplayManager#getDisplay} @@ -770,6 +785,20 @@ public final class Display { } /** + * @hide + * Get current remove mode of the display - what actions should be performed with the display's + * content when it is removed. Default behavior for public displays in this case is to move all + * activities to the primary display and make it focused. For private display - destroy all + * activities. + * + * @see #REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY + * @see #REMOVE_MODE_DESTROY_CONTENT + */ + public int getRemoveMode() { + return mDisplayInfo.removeMode; + } + + /** * Returns the display's HDR capabilities. * * @see #isHdr() diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java index f6b94af4b954..3d11dcbf14bf 100644 --- a/core/java/android/view/DisplayInfo.java +++ b/core/java/android/view/DisplayInfo.java @@ -238,6 +238,15 @@ public final class DisplayInfo implements Parcelable { */ public String ownerPackageName; + /** + * @hide + * Get current remove mode of the display - what actions should be performed with the display's + * content when it is removed. + * + * @see Display#getRemoveMode() + */ + public int removeMode = Display.REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY; + public static final Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() { @Override public DisplayInfo createFromParcel(Parcel source) { @@ -298,7 +307,8 @@ public final class DisplayInfo implements Parcelable { && presentationDeadlineNanos == other.presentationDeadlineNanos && state == other.state && ownerUid == other.ownerUid - && Objects.equal(ownerPackageName, other.ownerPackageName); + && Objects.equal(ownerPackageName, other.ownerPackageName) + && removeMode == other.removeMode; } @Override @@ -341,6 +351,7 @@ public final class DisplayInfo implements Parcelable { state = other.state; ownerUid = other.ownerUid; ownerPackageName = other.ownerPackageName; + removeMode = other.removeMode; } public void readFromParcel(Parcel source) { @@ -385,6 +396,7 @@ public final class DisplayInfo implements Parcelable { ownerUid = source.readInt(); ownerPackageName = source.readString(); uniqueId = source.readString(); + removeMode = source.readInt(); } @Override @@ -428,6 +440,7 @@ public final class DisplayInfo implements Parcelable { dest.writeInt(ownerUid); dest.writeString(ownerPackageName); dest.writeString(uniqueId); + dest.writeInt(removeMode); } @Override @@ -637,6 +650,8 @@ public final class DisplayInfo implements Parcelable { sb.append(" (uid ").append(ownerUid).append(")"); } sb.append(flagsToString(flags)); + sb.append(", removeMode "); + sb.append(removeMode); sb.append("}"); return sb.toString(); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b06c3fdb2746..d46811753e39 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -858,6 +858,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ static boolean sHasFocusableExcludeAutoFocusable; + /** + * Prior to O, auto-focusable didn't exist and views marked as clickable weren't implicitly + * made focusable by default. As a result, apps could (incorrectly) change the clickable + * setting of views off the UI thread. Now that clickable can effect the focusable state, + * changing the clickable attribute off the UI thread will cause an exception (since changing + * the focusable state checks). In order to prevent apps from crashing, we will handle this + * specific case and just not notify parents on new focusables resulting from marking views + * clickable from outside the UI thread. + */ + private static boolean sAutoFocusableOffUIThreadWontNotifyParents; + /** @hide */ @IntDef({NOT_FOCUSABLE, FOCUSABLE, FOCUSABLE_AUTO}) @Retention(RetentionPolicy.SOURCE) @@ -4182,6 +4193,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sHasFocusableExcludeAutoFocusable = targetSdkVersion < Build.VERSION_CODES.O; + sAutoFocusableOffUIThreadWontNotifyParents = targetSdkVersion < Build.VERSION_CODES.O; + sCompatibilityDone = true; } } @@ -12135,6 +12148,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, int privateFlags = mPrivateFlags; // If focusable is auto, update the FOCUSABLE bit. + int focusableChangedByAuto = 0; if (((mViewFlags & FOCUSABLE_AUTO) != 0) && (changed & (FOCUSABLE_MASK | CLICKABLE | FOCUSABLE_IN_TOUCH_MODE)) != 0) { int newFocus = NOT_FOCUSABLE; @@ -12144,8 +12158,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mViewFlags = (mViewFlags & ~FOCUSABLE_IN_TOUCH_MODE); } mViewFlags = (mViewFlags & ~FOCUSABLE) | newFocus; - int focusChanged = (old & FOCUSABLE) ^ (newFocus & FOCUSABLE); - changed = (changed & ~FOCUSABLE) | focusChanged; + focusableChangedByAuto = (old & FOCUSABLE) ^ (newFocus & FOCUSABLE); + changed = (changed & ~FOCUSABLE) | focusableChangedByAuto; } /* Check if the FOCUSABLE bit has changed */ @@ -12160,7 +12174,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Tell the view system that we are now available to take focus * if no one else already has it. */ - if (mParent != null) mParent.focusableViewAvailable(this); + if (mParent != null) { + ViewRootImpl viewRootImpl = getViewRootImpl(); + if (!sAutoFocusableOffUIThreadWontNotifyParents + || focusableChangedByAuto == 0 + || viewRootImpl == null + || viewRootImpl.mThread == Thread.currentThread()) { + mParent.focusableViewAvailable(this); + } + } } } diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 2bde9911da8e..3ca455dc24cf 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -876,9 +876,9 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { sk_sp<SkColorSpace> colorSpace; if (kRGBA_F16_SkColorType == colorType) { - colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); + colorSpace = SkColorSpace::MakeSRGBLinear(); } else { - colorSpace = isSRGB ? SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : nullptr; + colorSpace = isSRGB ? SkColorSpace::MakeSRGB() : nullptr; } if (!bitmap->setInfo(SkImageInfo::Make(width, height, colorType, alphaType, colorSpace), @@ -997,7 +997,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, auto bitmapWrapper = reinterpret_cast<BitmapWrapper*>(bitmapHandle); bitmapWrapper->getSkBitmap(&bitmap); - sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeSRGB(); bool isSRGB = bitmap.colorSpace() == sRGB.get(); p->writeInt32(isMutable); diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 19d4848e1656..2aa16b281884 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -39,6 +39,7 @@ jfieldID gOptions_targetDensityFieldID; jfieldID gOptions_widthFieldID; jfieldID gOptions_heightFieldID; jfieldID gOptions_mimeFieldID; +jfieldID gOptions_outConfigFieldID; jfieldID gOptions_mCancelID; jfieldID gOptions_bitmapFieldID; @@ -47,6 +48,9 @@ jfieldID gBitmap_ninePatchInsetsFieldID; jclass gInsetStruct_class; jmethodID gInsetStruct_constructorMethodID; +jclass gBitmapConfig_class; +jmethodID gBitmapConfig_nativeToConfigMethodID; + using namespace android; jstring encodedFormatToString(JNIEnv* env, SkEncodedImageFormat format) { @@ -298,6 +302,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding env->SetIntField(options, gOptions_widthFieldID, -1); env->SetIntField(options, gOptions_heightFieldID, -1); env->SetObjectField(options, gOptions_mimeFieldID, 0); + env->SetObjectField(options, gOptions_outConfigFieldID, 0); jobject jconfig = env->GetObjectField(options, gOptions_configFieldID); prefColorType = GraphicsJNI::getNativeBitmapColorType(env, jconfig); @@ -352,6 +357,9 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding scaledHeight = codec->getInfo().height() / sampleSize; } + // Set the decode colorType + SkColorType decodeColorType = codec->computeOutputColorType(prefColorType); + // Set the options and return if the client only wants the size. if (options != NULL) { jstring mimeType = encodedFormatToString( @@ -363,6 +371,20 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding env->SetIntField(options, gOptions_heightFieldID, scaledHeight); env->SetObjectField(options, gOptions_mimeFieldID, mimeType); + SkColorType outColorType = decodeColorType; + // Scaling can affect the output color type + if (willScale || scale != 1.0f) { + outColorType = colorTypeForScaledOutput(outColorType); + } + + jint configID = GraphicsJNI::colorTypeToLegacyBitmapConfig(outColorType); + if (isHardware) { + configID = GraphicsJNI::kHardware_LegacyBitmapConfig; + } + jobject config = env->CallStaticObjectMethod(gBitmapConfig_class, + gBitmapConfig_nativeToConfigMethodID, configID); + env->SetObjectField(options, gOptions_outConfigFieldID, config); + if (onlyDecodeSize) { return nullptr; } @@ -409,10 +431,6 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding decodeAllocator = &defaultAllocator; } - // Set the decode colorType. This is necessary because we can't always support - // the requested colorType. - SkColorType decodeColorType = codec->computeOutputColorType(prefColorType); - // Construct a color table for the decode if necessary sk_sp<SkColorTable> colorTable(nullptr); SkPMColor* colorPtr = nullptr; @@ -747,6 +765,8 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) { gOptions_widthFieldID = GetFieldIDOrDie(env, options_class, "outWidth", "I"); gOptions_heightFieldID = GetFieldIDOrDie(env, options_class, "outHeight", "I"); gOptions_mimeFieldID = GetFieldIDOrDie(env, options_class, "outMimeType", "Ljava/lang/String;"); + gOptions_outConfigFieldID = GetFieldIDOrDie(env, options_class, "outConfig", + "Landroid/graphics/Bitmap$Config;"); gOptions_mCancelID = GetFieldIDOrDie(env, options_class, "mCancel", "Z"); jclass bitmap_class = FindClassOrDie(env, "android/graphics/Bitmap"); @@ -758,6 +778,11 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) { gInsetStruct_constructorMethodID = GetMethodIDOrDie(env, gInsetStruct_class, "<init>", "(IIIIIIIIFIF)V"); + gBitmapConfig_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, + "android/graphics/Bitmap$Config")); + gBitmapConfig_nativeToConfigMethodID = GetStaticMethodIDOrDie(env, gBitmapConfig_class, + "nativeToConfig", "(I)Landroid/graphics/Bitmap$Config;"); + return android::RegisterMethodsOrDie(env, "android/graphics/BitmapFactory", gMethods, NELEM(gMethods)); } diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index d5f33cf81305..5d7310167b7c 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -287,21 +287,7 @@ void GraphicsJNI::point_to_jpointf(const SkPoint& r, JNIEnv* env, jobject obj) env->SetFloatField(obj, gPointF_yFieldID, SkScalarToFloat(r.fY)); } -// This enum must keep these int values, to match the int values -// in the java Bitmap.Config enum. -enum LegacyBitmapConfig { - kNo_LegacyBitmapConfig = 0, - kA8_LegacyBitmapConfig = 1, - kIndex8_LegacyBitmapConfig = 2, - kRGB_565_LegacyBitmapConfig = 3, - kARGB_4444_LegacyBitmapConfig = 4, - kARGB_8888_LegacyBitmapConfig = 5, - kRGBA_16F_LegacyBitmapConfig = 6, - kHardware_LegacyBitmapConfig = 7, - - kLastEnum_LegacyBitmapConfig = kHardware_LegacyBitmapConfig -}; - +// See enum values in GraphicsJNI.h jint GraphicsJNI::colorTypeToLegacyBitmapConfig(SkColorType colorType) { switch (colorType) { case kRGBA_F16_SkColorType: @@ -455,14 +441,14 @@ android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, sk_sp<SkColorSpace> GraphicsJNI::defaultColorSpace() { #ifdef ANDROID_ENABLE_LINEAR_BLENDING - return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + return SkColorSpace::MakeSRGB(); #else return nullptr; #endif } sk_sp<SkColorSpace> GraphicsJNI::linearColorSpace() { - return SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); + return SkColorSpace::MakeSRGBLinear(); } sk_sp<SkColorSpace> GraphicsJNI::colorSpaceForType(SkColorType type) { diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index e899db5592bc..8a1ef6ee5d34 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -24,6 +24,21 @@ struct Typeface; class GraphicsJNI { public: + // This enum must keep these int values, to match the int values + // in the java Bitmap.Config enum. + enum LegacyBitmapConfig { + kNo_LegacyBitmapConfig = 0, + kA8_LegacyBitmapConfig = 1, + kIndex8_LegacyBitmapConfig = 2, + kRGB_565_LegacyBitmapConfig = 3, + kARGB_4444_LegacyBitmapConfig = 4, + kARGB_8888_LegacyBitmapConfig = 5, + kRGBA_16F_LegacyBitmapConfig = 6, + kHardware_LegacyBitmapConfig = 7, + + kLastEnum_LegacyBitmapConfig = kHardware_LegacyBitmapConfig + }; + // returns true if an exception is set (and dumps it out to the Log) static bool hasException(JNIEnv*); diff --git a/core/jni/android_os_seccomp.cpp b/core/jni/android_os_seccomp.cpp index 3f021ae1378f..45d50615f232 100644 --- a/core/jni/android_os_seccomp.cpp +++ b/core/jni/android_os_seccomp.cpp @@ -148,7 +148,10 @@ bool set_seccomp_filter() { AllowSyscall(f, 128); // __NR_restart_syscall // b/35034743 - AllowSyscall(f, 267); // __NR_fstatfs64 + AllowSyscall(f, 267); // __NR_syncfs + + // b/34763393 + AllowSyscall(f, 277); // __NR_seccomp Trap(f); diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index 64a726babce0..a3c6c6edb3ad 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -350,11 +350,17 @@ public class BitmapFactory { /** * If known, this string is set to the mimetype of the decoded image. - * If not know, or there is an error, it is set to null. + * If not known, or there is an error, it is set to null. */ public String outMimeType; /** + * If known, the config the decoded bitmap will have. + * If not known, or there is an error, it is set to null. + */ + public Bitmap.Config outConfig; + + /** * Temp storage to use for decoding. Suggest 16K or so. */ public byte[] inTempStorage; diff --git a/libs/hwui/Texture.cpp b/libs/hwui/Texture.cpp index 50af9c8cd711..0dbd7674e2aa 100644 --- a/libs/hwui/Texture.cpp +++ b/libs/hwui/Texture.cpp @@ -282,7 +282,7 @@ void Texture::upload(Bitmap& bitmap) { setDefaultParams = true; } - sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeSRGB(); bool needSRGB = bitmap.info().colorSpace() == sRGB.get(); GLint internalFormat, format, type; diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp index 208107f65743..68d3dd5efb79 100644 --- a/libs/hwui/VectorDrawable.cpp +++ b/libs/hwui/VectorDrawable.cpp @@ -564,7 +564,7 @@ bool Tree::allocateBitmapIfNeeded(Cache& cache, int width, int height) { #ifndef ANDROID_ENABLE_LINEAR_BLENDING sk_sp<SkColorSpace> colorSpace = nullptr; #else - sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB(); #endif SkImageInfo info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType, colorSpace); cache.bitmap = Bitmap::allocateHeapBitmap(info); diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp index 3e10b36d921d..f9730c9ca273 100644 --- a/libs/hwui/hwui/Bitmap.cpp +++ b/libs/hwui/hwui/Bitmap.cpp @@ -232,7 +232,7 @@ sk_sp<Bitmap> Bitmap::allocateHardwareBitmap(uirenderer::renderthread::RenderThr return nullptr; } - sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> sRGB = SkColorSpace::MakeSRGB(); bool needSRGB = skBitmap.info().colorSpace() == sRGB.get(); bool hasSRGB = caches.extensions().hasSRGB(); GLint format, type, internalFormat; @@ -324,7 +324,7 @@ sk_sp<Bitmap> Bitmap::createFrom(sp<GraphicBuffer> graphicBuffer) { } SkImageInfo info = SkImageInfo::Make(graphicBuffer->getWidth(), graphicBuffer->getHeight(), kRGBA_8888_SkColorType, kPremul_SkAlphaType, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); + SkColorSpace::MakeSRGB()); return sk_sp<Bitmap>(new Bitmap(graphicBuffer.get(), info)); } diff --git a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp index f32d97a3d809..03e6b7f47999 100644 --- a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp +++ b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp @@ -93,7 +93,7 @@ TEST(SkiaBehavior, porterDuffCreateIsCached) { } TEST(SkiaBehavior, srgbColorSpaceIsSingleton) { - sk_sp<SkColorSpace> sRGB1 = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); - sk_sp<SkColorSpace> sRGB2 = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> sRGB1 = SkColorSpace::MakeSRGB(); + sk_sp<SkColorSpace> sRGB2 = SkColorSpace::MakeSRGB(); ASSERT_EQ(sRGB1.get(), sRGB2.get()); } diff --git a/libs/hwui/utils/TestWindowContext.cpp b/libs/hwui/utils/TestWindowContext.cpp index 79fc8643859c..ecad7bed296b 100644 --- a/libs/hwui/utils/TestWindowContext.cpp +++ b/libs/hwui/utils/TestWindowContext.cpp @@ -109,7 +109,7 @@ public: } bool capturePixels(SkBitmap* bmp) { - sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB(); SkImageInfo destinationConfig = SkImageInfo::Make(mSize.width(), mSize.height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType, colorSpace); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index e8eee24b8dc0..a20801368a91 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -42,7 +42,9 @@ import org.junit.Test; import org.junit.runner.RunWith; @SmallTest -@RunWith(AndroidJUnit4.class) +// @RunWith(AndroidJUnit4.class) +// TODO(gpitsch): We have seen some flakes in these tests, needs some investigation. +// Q: How is mMetricsReader being used by the tested code? public class StatusBarTest extends SysuiTestCase { StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @@ -54,7 +56,7 @@ public class StatusBarTest extends SysuiTestCase { private MetricsReader mMetricsReader; private DisplayMetrics mDisplayMetrics = new DisplayMetrics(); - @Before + // @Before public void setup() { mStatusBarKeyguardViewManager = mock(StatusBarKeyguardViewManager.class); mUnlockMethodCache = mock(UnlockMethodCache.class); @@ -87,7 +89,7 @@ public class StatusBarTest extends SysuiTestCase { } } - @Test + // @Test public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); @@ -95,7 +97,7 @@ public class StatusBarTest extends SysuiTestCase { mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); } - @Test + // @Test public void executeRunnableDismissingKeyguard_nullRunnable_showing() { when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -103,7 +105,7 @@ public class StatusBarTest extends SysuiTestCase { mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); } - @Test + // @Test public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -111,7 +113,7 @@ public class StatusBarTest extends SysuiTestCase { mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); } - @Test + // @Test public void lockscreenStateMetrics_notShowing() { // uninteresting state, except that fingerprint must be non-zero when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -129,7 +131,7 @@ public class StatusBarTest extends SysuiTestCase { .setSubtype(0)); } - @Test + // @Test public void lockscreenStateMetrics_notShowing_secure() { // uninteresting state, except that fingerprint must be non-zero when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -147,7 +149,7 @@ public class StatusBarTest extends SysuiTestCase { .setSubtype(1)); } - @Test + // @Test public void lockscreenStateMetrics_isShowing() { // uninteresting state, except that fingerprint must be non-zero when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -165,7 +167,7 @@ public class StatusBarTest extends SysuiTestCase { .setSubtype(0)); } - @Test + // @Test public void lockscreenStateMetrics_isShowing_secure() { // uninteresting state, except that fingerprint must be non-zero when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -183,7 +185,7 @@ public class StatusBarTest extends SysuiTestCase { .setSubtype(1)); } - @Test + // @Test public void lockscreenStateMetrics_isShowingBouncer() { // uninteresting state, except that fingerprint must be non-zero when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); @@ -201,7 +203,7 @@ public class StatusBarTest extends SysuiTestCase { .setSubtype(1)); } - @Test + // @Test public void onActivatedMetrics() { ActivatableNotificationView view = mock(ActivatableNotificationView.class); mStatusBar.onActivated(view); @@ -226,4 +228,4 @@ public class StatusBarTest extends SysuiTestCase { return null; } } -}
\ No newline at end of file +} diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 69a3a263bbf8..3b9426d22007 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -2328,7 +2328,8 @@ public class ActivityManagerService extends IActivityManager.Stub } } vrService.setVrMode(vrMode, requestedPackage, userId, callingPackage); - } case NOTIFY_VR_SLEEPING_MSG: { + } break; + case NOTIFY_VR_SLEEPING_MSG: { notifyVrManagerOfSleepState(msg.arg1 != 0); } break; case HANDLE_TRUST_STORAGE_UPDATE_MSG: { @@ -9916,7 +9917,7 @@ public class ActivityManagerService extends IActivityManager.Stub try { if (DEBUG_STACK) Slog.d(TAG_STACK, "moveStackToDisplay: moving stackId=" + stackId + " to displayId=" + displayId); - mStackSupervisor.moveStackToDisplayLocked(stackId, displayId); + mStackSupervisor.moveStackToDisplayLocked(stackId, displayId, ON_TOP); } finally { Binder.restoreCallingIdentity(ident); } diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 104fc6a6e565..cf0ebaf6964e 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -477,6 +477,8 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL mTmpRect2.setEmpty(); mWindowContainerController.reparent(activityDisplay.mDisplayId, mTmpRect2); postAddToDisplay(activityDisplay, mTmpRect2.isEmpty() ? null : mTmpRect2, onTop); + adjustFocusToNextFocusableStackLocked("reparent", true /* allowFocusSelf */); + mStackSupervisor.resumeFocusedStackTopActivityLocked(); } /** @@ -3179,8 +3181,18 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL mStackSupervisor.topRunningActivityLocked(), myReason); } + /** Find next proper focusable stack and make it focused. */ private boolean adjustFocusToNextFocusableStackLocked(String reason) { - final ActivityStack stack = mStackSupervisor.getNextFocusableStackLocked(this); + return adjustFocusToNextFocusableStackLocked(reason, false /* allowFocusSelf */); + } + + /** + * Find next proper focusable stack and make it focused. + * @param allowFocusSelf Is the focus allowed to remain on the same stack. + */ + private boolean adjustFocusToNextFocusableStackLocked(String reason, boolean allowFocusSelf) { + final ActivityStack stack = mStackSupervisor.getNextFocusableStackLocked( + allowFocusSelf ? null : this); final String myReason = reason + " adjustFocusToNextFocusableStack"; if (stack == null) { return false; @@ -3190,7 +3202,8 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL if (stack.isHomeOrRecentsStack() && (top == null || !top.visible)) { // If we will be focusing on the home stack next and its current top activity isn't - // visible, then use the task return to value to determine the home task to display next. + // visible, then use the task return to value to determine the home task to display + // next. return mStackSupervisor.moveHomeStackTaskToTop(reason); } diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index e954363a936b..95734a4ed782 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -40,6 +40,7 @@ import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.FLAG_PRIVATE; import static android.view.Display.INVALID_DISPLAY; +import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONTAINERS; @@ -2616,8 +2617,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D * Move stack with all its existing content to specified display. * @param stackId Id of stack to move. * @param displayId Id of display to move stack to. + * @param onTop Indicates whether container should be place on top or on bottom. */ - void moveStackToDisplayLocked(int stackId, int displayId) { + void moveStackToDisplayLocked(int stackId, int displayId, boolean onTop) { final ActivityDisplay activityDisplay = mActivityDisplays.get(displayId); if (activityDisplay == null) { throw new IllegalArgumentException("moveStackToDisplayLocked: Unknown displayId=" @@ -2631,7 +2633,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D + " to its current displayId=" + displayId); } - activityContainer.moveToDisplayLocked(activityDisplay); + activityContainer.moveToDisplayLocked(activityDisplay, onTop); } else { throw new IllegalStateException("moveStackToDisplayLocked: Stack with stackId=" + stackId + " is not attached to any display."); @@ -3777,12 +3779,16 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D synchronized (mService) { ActivityDisplay activityDisplay = mActivityDisplays.get(displayId); if (activityDisplay != null) { + final boolean destroyContentOnRemoval + = activityDisplay.shouldDestroyContentOnRemove(); ArrayList<ActivityStack> stacks = activityDisplay.mStacks; for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityStack stack = stacks.get(stackNdx); - // TODO: Implement proper stack removal and ability to choose the behavior - - // remove stack completely or move it to other display. - moveStackToDisplayLocked(stack.mStackId, DEFAULT_DISPLAY); + moveStackToDisplayLocked(stack.mStackId, DEFAULT_DISPLAY, + !destroyContentOnRemoval /* onTop */); + if (destroyContentOnRemoval) { + stack.finishAllActivitiesLocked(true /* immediately */); + } } mActivityDisplays.remove(displayId); } @@ -4451,8 +4457,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** * Move the stack to specified display. * @param activityDisplay Target display to move the stack to. + * @param onTop Indicates whether container should be place on top or on bottom. */ - void moveToDisplayLocked(ActivityDisplay activityDisplay) { + void moveToDisplayLocked(ActivityDisplay activityDisplay, boolean onTop) { if (DEBUG_STACK) Slog.d(TAG_STACK, "moveToDisplayLocked: " + this + " from display=" + mActivityDisplay + " to display=" + activityDisplay + " Callers=" + Debug.getCallers(2)); @@ -4460,7 +4467,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D removeFromDisplayLocked(); mActivityDisplay = activityDisplay; - mStack.reparent(activityDisplay, ON_TOP); + mStack.reparent(activityDisplay, onTop); } @Override @@ -4642,8 +4649,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** Actual Display this object tracks. */ int mDisplayId; Display mDisplay; - private final DisplayMetrics mRealMetrics = new DisplayMetrics(); - private final Point mRealSize = new Point(); /** All of the stacks on this display. Order matters, topmost stack is in front of all other * stacks, bottommost behind. Accessed directly by ActivityManager package classes */ @@ -4737,6 +4742,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } return mDisplayAccessUIDs; } + + boolean shouldDestroyContentOnRemove() { + return mDisplay.getRemoveMode() == REMOVE_MODE_DESTROY_CONTENT; + } } class VirtualActivityDisplay extends ActivityDisplay { diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java index 40a895210480..a947b4106794 100644 --- a/services/core/java/com/android/server/display/LogicalDisplay.java +++ b/services/core/java/com/android/server/display/LogicalDisplay.java @@ -216,6 +216,8 @@ final class LogicalDisplay { } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRIVATE) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_PRIVATE; + // For private displays by default content is destroyed on removal. + mBaseDisplayInfo.removeMode = Display.REMOVE_MODE_DESTROY_CONTENT; } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRESENTATION) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_PRESENTATION; diff --git a/wifi/java/android/net/wifi/WifiNetworkScoreCache.java b/wifi/java/android/net/wifi/WifiNetworkScoreCache.java index 04dea1b60abe..f61dfdc2f6f9 100755 --- a/wifi/java/android/net/wifi/WifiNetworkScoreCache.java +++ b/wifi/java/android/net/wifi/WifiNetworkScoreCache.java @@ -145,7 +145,7 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub { if (network != null && network.rssiCurve != null) { score = network.rssiCurve.lookupScore(result.level); if (DBG) { - Log.e(TAG, "getNetworkScore found scored network " + network.networkKey + Log.d(TAG, "getNetworkScore found scored network " + network.networkKey + " score " + Integer.toString(score) + " RSSI " + result.level); } @@ -171,7 +171,7 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub { if (network != null && network.rssiCurve != null) { score = network.rssiCurve.lookupScore(result.level, isActiveNetwork); if (DBG) { - Log.e(TAG, "getNetworkScore found scored network " + network.networkKey + Log.d(TAG, "getNetworkScore found scored network " + network.networkKey + " score " + Integer.toString(score) + " RSSI " + result.level + " isActiveNetwork " + isActiveNetwork); |