Skip to content

Commit

Permalink
Merge "qt-r1-bubbles-dev @ build 5835883" into qt-qpr1-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sliceslicebaby authored and Android (Google) Code Review committed Sep 16, 2019
2 parents 2a873c7 + a5813e0 commit fd48588
Show file tree
Hide file tree
Showing 101 changed files with 4,314 additions and 2,255 deletions.
3 changes: 2 additions & 1 deletion api/test-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2344,6 +2344,7 @@ package android.provider {
field public static final String LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST = "location_ignore_settings_package_whitelist";
field public static final String LOW_POWER_MODE = "low_power";
field public static final String LOW_POWER_MODE_STICKY = "low_power_sticky";
field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
field public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package";
}
Expand All @@ -2367,7 +2368,7 @@ package android.provider {
field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis";
field public static final String LOCATION_ACCESS_CHECK_INTERVAL_MILLIS = "location_access_check_interval_millis";
field public static final String NOTIFICATION_BADGING = "notification_badging";
field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
field public static final String USER_SETUP_COMPLETE = "user_setup_complete";
field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
Expand Down
3 changes: 2 additions & 1 deletion cmds/statsd/src/atoms.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5924,7 +5924,8 @@ message BubbleUIChanged {
optional bool is_ongoing = 10;

// Whether the bubble is produced by an app running in foreground.
optional bool is_foreground = 11;
// This is deprecated and the value should be ignored.
optional bool is_foreground = 11 [deprecated = true];
}

/**
Expand Down
7 changes: 7 additions & 0 deletions core/java/android/app/ITaskStackListener.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ oneway interface ITaskStackListener {
*/
void onSingleTaskDisplayDrawn(int displayId);

/*
* Called when the last task is removed from a display which can only contain one task.
*
* @param displayId the id of the display from which the window is removed.
*/
void onSingleTaskDisplayEmpty(int displayId);

/**
* Called when a task is reparented to a stack on a different display.
*
Expand Down
34 changes: 29 additions & 5 deletions core/java/android/app/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -8539,24 +8539,34 @@ public static final class BubbleMetadata implements Parcelable {
* If set and the app creating the bubble is in the foreground, the bubble will be posted
* in its expanded state, with the contents of {@link #getIntent()} in a floating window.
*
* <p>If the app creating the bubble is not in the foreground this flag has no effect.</p>
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
* The app is considered foreground if it is visible and on the screen, note that
* a foreground service does not qualify.
* </p>
*
* <p>Generally this flag should only be set if the user has performed an action to request
* or create a bubble.</p>
*
* @hide
*/
private static final int FLAG_AUTO_EXPAND_BUBBLE = 0x00000001;
public static final int FLAG_AUTO_EXPAND_BUBBLE = 0x00000001;

/**
* If set and the app posting the bubble is in the foreground, the bubble will
* be posted <b>without</b> the associated notification in the notification shade.
*
* <p>If the app posting the bubble is not in the foreground this flag has no effect.</p>
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
* The app is considered foreground if it is visible and on the screen, note that
* a foreground service does not qualify.
* </p>
*
* <p>Generally this flag should only be set if the user has performed an action to request
* or create a bubble, or if the user has seen the content in the notification and the
* notification is no longer relevant.</p>
*
* @hide
*/
private static final int FLAG_SUPPRESS_NOTIFICATION = 0x00000002;
public static final int FLAG_SUPPRESS_NOTIFICATION = 0x00000002;

private BubbleMetadata(PendingIntent expandIntent, PendingIntent deleteIntent,
Icon icon, int height, @DimenRes int heightResId) {
Expand Down Expand Up @@ -8672,10 +8682,20 @@ public void writeToParcel(Parcel out, int flags) {
out.writeInt(mDesiredHeightResId);
}

private void setFlags(int flags) {
/**
* @hide
*/
public void setFlags(int flags) {
mFlags = flags;
}

/**
* @hide
*/
public int getFlags() {
return mFlags;
}

/**
* Builder to construct a {@link BubbleMetadata} object.
*/
Expand Down Expand Up @@ -8792,6 +8812,8 @@ public BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int heightResId) {
* {@link #getIntent()} in a floating window).
*
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
* The app is considered foreground if it is visible and on the screen, note that
* a foreground service does not qualify.
* </p>
*
* <p>Generally, this flag should only be set if the user has performed an action to
Expand All @@ -8810,6 +8832,8 @@ public BubbleMetadata.Builder setAutoExpandBubble(boolean shouldExpand) {
* the notification shade.
*
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
* The app is considered foreground if it is visible and on the screen, note that
* a foreground service does not qualify.
* </p>
*
* <p>Generally, this flag should only be set if the user has performed an action to
Expand Down
4 changes: 4 additions & 0 deletions core/java/android/app/TaskStackListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo)
public void onSingleTaskDisplayDrawn(int displayId) throws RemoteException {
}

@Override
public void onSingleTaskDisplayEmpty(int displayId) throws RemoteException {
}

@Override
public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
}
Expand Down
19 changes: 18 additions & 1 deletion core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8697,10 +8697,16 @@ public boolean validate(@Nullable String value) {
* Whether the notification bubbles are globally enabled
* The value is boolean (1 or 0).
* @hide
* @deprecated use {@link Global#NOTIFICATION_BUBBLES} instead.
*/
@TestApi
@Deprecated
public static final String NOTIFICATION_BUBBLES = "notification_bubbles";

/**
* @deprecated use {@link Global#NOTIFICATION_BUBBLES_VALIDATOR} instead.
*/
@Deprecated
private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR;

/**
Expand Down Expand Up @@ -9025,7 +9031,6 @@ public boolean validate(@Nullable String value) {
ASSIST_GESTURE_WAKE_ENABLED,
VR_DISPLAY_MODE,
NOTIFICATION_BADGING,
NOTIFICATION_BUBBLES,
NOTIFICATION_DISMISS_RTL,
QS_AUTO_ADDED_TILES,
SCREENSAVER_ENABLED,
Expand Down Expand Up @@ -9393,6 +9398,16 @@ public static final class Global extends NameValueTable {
*/
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");

/**
* Whether the notification bubbles are globally enabled
* The value is boolean (1 or 0).
* @hide
*/
@TestApi
public static final String NOTIFICATION_BUBBLES = "notification_bubbles";

private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR;

/**
* Whether users are allowed to add more users or guest from lockscreen.
* <p>
Expand Down Expand Up @@ -13852,6 +13867,7 @@ public boolean validate(@Nullable String value) {
ZEN_DURATION,
CHARGING_VIBRATION_ENABLED,
AWARE_ALLOWED,
NOTIFICATION_BUBBLES,
};

/**
Expand Down Expand Up @@ -13918,6 +13934,7 @@ public boolean validate(@Nullable String value) {
VALIDATORS.put(AWARE_ALLOWED, AWARE_ALLOWED_VALIDATOR);
VALIDATORS.put(POWER_BUTTON_LONG_PRESS, POWER_BUTTON_LONG_PRESS_VALIDATOR);
VALIDATORS.put(POWER_BUTTON_VERY_LONG_PRESS, POWER_BUTTON_VERY_LONG_PRESS_VALIDATOR);
VALIDATORS.put(NOTIFICATION_BUBBLES, NOTIFICATION_BUBBLES_VALIDATOR);
}

/**
Expand Down
14 changes: 0 additions & 14 deletions core/java/android/view/SurfaceControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private static native long nativeCreate(SurfaceSession session, String name,
private static native long nativeCopyFromSurfaceControl(long nativeObject);
private static native void nativeWriteToParcel(long nativeObject, Parcel out);
private static native void nativeRelease(long nativeObject);
private static native void nativeDestroy(long nativeObject);
private static native void nativeDisconnect(long nativeObject);

private static native ScreenshotGraphicBuffer nativeScreenshot(IBinder displayToken,
Expand Down Expand Up @@ -929,19 +928,6 @@ public void release() {
mCloseGuard.close();
}

/**
* Release the local resources like {@link #release} but also
* remove the Surface from the screen.
* @hide
*/
public void remove() {
if (mNativeObject != 0) {
nativeDestroy(mNativeObject);
mNativeObject = 0;
}
mCloseGuard.close();
}

/**
* Disconnect any client still connected to the surface.
* @hide
Expand Down
63 changes: 24 additions & 39 deletions core/java/android/view/SurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.CompatibilityInfo.Translator;
import android.content.res.Configuration;
import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Color;
Expand Down Expand Up @@ -103,8 +102,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
private static final boolean DEBUG_POSITION = false;

@UnsupportedAppUsage
final ArrayList<SurfaceHolder.Callback> mCallbacks
= new ArrayList<SurfaceHolder.Callback>();
final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<>();

final int[] mLocation = new int[2];

Expand All @@ -129,7 +127,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
SurfaceControl mBackgroundControl;
final Object mSurfaceControlLock = new Object();
final Rect mTmpRect = new Rect();
final Configuration mConfiguration = new Configuration();

Paint mRoundedViewportPaint;

Expand All @@ -139,25 +136,16 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
boolean mIsCreating = false;
private volatile boolean mRtHandlingPositionUpdates = false;

private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener
= new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
updateSurface();
}
};
private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener =
this::updateSurface;

@UnsupportedAppUsage
private final ViewTreeObserver.OnPreDrawListener mDrawListener =
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
// reposition ourselves where the surface is
mHaveFrame = getWidth() > 0 && getHeight() > 0;
updateSurface();
return true;
}
};
private final ViewTreeObserver.OnPreDrawListener mDrawListener = () -> {
// reposition ourselves where the surface is
mHaveFrame = getWidth() > 0 && getHeight() > 0;
updateSurface();
return true;
};

boolean mRequestedVisible = false;
boolean mWindowVisibility = false;
Expand Down Expand Up @@ -195,7 +183,6 @@ public boolean onPreDraw() {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
final Rect mSurfaceFrame = new Rect();
int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1;
private Translator mTranslator;

private boolean mGlobalListenersAdded;
private boolean mAttachedToWindow;
Expand Down Expand Up @@ -702,9 +689,9 @@ protected void updateSurface() {
return;
}

mTranslator = viewRoot.mTranslator;
if (mTranslator != null) {
mSurface.setCompatibilityTranslator(mTranslator);
final Translator translator = viewRoot.mTranslator;
if (translator != null) {
mSurface.setCompatibilityTranslator(translator);
}

int myWidth = mRequestedWidth;
Expand Down Expand Up @@ -748,8 +735,8 @@ protected void updateSurface() {
mScreenRect.top = mWindowSpaceTop;
mScreenRect.right = mWindowSpaceLeft + getWidth();
mScreenRect.bottom = mWindowSpaceTop + getHeight();
if (mTranslator != null) {
mTranslator.translateRectInAppWindowToScreen(mScreenRect);
if (translator != null) {
translator.translateRectInAppWindowToScreen(mScreenRect);
}

final Rect surfaceInsets = viewRoot.mWindowAttributes.surfaceInsets;
Expand Down Expand Up @@ -839,11 +826,11 @@ protected void updateSurface() {

mSurfaceFrame.left = 0;
mSurfaceFrame.top = 0;
if (mTranslator == null) {
if (translator == null) {
mSurfaceFrame.right = mSurfaceWidth;
mSurfaceFrame.bottom = mSurfaceHeight;
} else {
float appInvertedScale = mTranslator.applicationInvertedScale;
float appInvertedScale = translator.applicationInvertedScale;
mSurfaceFrame.right = (int) (mSurfaceWidth * appInvertedScale + 0.5f);
mSurfaceFrame.bottom = (int) (mSurfaceHeight * appInvertedScale + 0.5f);
}
Expand All @@ -861,7 +848,7 @@ protected void updateSurface() {
try {
redrawNeeded |= visible && !mDrawFinished;

SurfaceHolder.Callback callbacks[] = null;
SurfaceHolder.Callback[] callbacks = null;

final boolean surfaceChanged = creating;
if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
Expand Down Expand Up @@ -976,8 +963,8 @@ protected void updateSurface() {
mScreenRect.set(mWindowSpaceLeft, mWindowSpaceTop,
mWindowSpaceLeft + mLocation[0], mWindowSpaceTop + mLocation[1]);

if (mTranslator != null) {
mTranslator.translateRectInAppWindowToScreen(mScreenRect);
if (translator != null) {
translator.translateRectInAppWindowToScreen(mScreenRect);
}

if (mSurfaceControl == null) {
Expand Down Expand Up @@ -1009,13 +996,11 @@ private void onDrawFinished() {
}

if (mDeferredDestroySurfaceControl != null) {
mDeferredDestroySurfaceControl.remove();
mTmpTransaction.remove(mDeferredDestroySurfaceControl).apply();
mDeferredDestroySurfaceControl = null;
}

runOnUiThread(() -> {
performDrawFinished();
});
runOnUiThread(this::performDrawFinished);
}

/**
Expand Down Expand Up @@ -1088,7 +1073,7 @@ public void positionChanged(long frameNumber, int left, int top, int right, int
if (DEBUG_POSITION) {
Log.d(TAG, String.format(
"%d updateSurfacePosition RenderWorker, frameNr = %d, "
+ "postion = [%d, %d, %d, %d]",
+ "position = [%d, %d, %d, %d]",
System.identityHashCode(this), frameNumber,
left, top, right, bottom));
}
Expand Down Expand Up @@ -1124,7 +1109,7 @@ public void positionLost(long frameNumber) {
};

private SurfaceHolder.Callback[] getSurfaceCallbacks() {
SurfaceHolder.Callback callbacks[];
SurfaceHolder.Callback[] callbacks;
synchronized (mCallbacks) {
callbacks = new SurfaceHolder.Callback[mCallbacks.size()];
mCallbacks.toArray(callbacks);
Expand Down Expand Up @@ -1194,7 +1179,7 @@ public void addCallback(Callback callback) {
synchronized (mCallbacks) {
// This is a linear search, but in practice we'll
// have only a couple callbacks, so it doesn't matter.
if (mCallbacks.contains(callback) == false) {
if (!mCallbacks.contains(callback)) {
mCallbacks.add(callback);
}
}
Expand Down
Loading

0 comments on commit fd48588

Please sign in to comment.