Merge "Fix issue where launch transition would never end"
diff --git a/api/current.txt b/api/current.txt
index e3e30c1..15c4fdf 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -55771,6 +55771,7 @@
method public int getDropDownVerticalOffset();
method public int getDropDownWidth();
method protected android.widget.Filter getFilter();
+ method public int getInputMethodMode();
method @Deprecated public android.widget.AdapterView.OnItemClickListener getItemClickListener();
method @Deprecated public android.widget.AdapterView.OnItemSelectedListener getItemSelectedListener();
method public int getListSelection();
@@ -55795,6 +55796,7 @@
method public void setDropDownHorizontalOffset(int);
method public void setDropDownVerticalOffset(int);
method public void setDropDownWidth(int);
+ method public void setInputMethodMode(int);
method public void setListSelection(int);
method public void setOnDismissListener(android.widget.AutoCompleteTextView.OnDismissListener);
method public void setOnItemClickListener(android.widget.AdapterView.OnItemClickListener);
diff --git a/api/system-current.txt b/api/system-current.txt
index 357f6a4..bfffb41 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6350,7 +6350,8 @@
method public void onDestroyContentCaptureSession(@NonNull android.view.contentcapture.ContentCaptureSessionId);
method public void onDisconnected();
method public void onUserDataRemovalRequest(@NonNull android.view.contentcapture.UserDataRemovalRequest);
- method public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method @Deprecated public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method public final void setContentCaptureWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
field public static final String SERVICE_INTERFACE = "android.service.contentcapture.ContentCaptureService";
}
@@ -9307,7 +9308,8 @@
package android.view.autofill {
public final class AutofillManager {
- method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method @Deprecated public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method public void setAugmentedAutofillWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
}
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 47d38a7..4dd1cd8 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -2103,7 +2103,8 @@
method public void onDestroyContentCaptureSession(@NonNull android.view.contentcapture.ContentCaptureSessionId);
method public void onDisconnected();
method public void onUserDataRemovalRequest(@NonNull android.view.contentcapture.UserDataRemovalRequest);
- method public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method @Deprecated public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method public final void setContentCaptureWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
field public static final String SERVICE_INTERFACE = "android.service.contentcapture.ContentCaptureService";
}
@@ -2692,7 +2693,8 @@
}
public final class AutofillManager {
- method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method @Deprecated public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
+ method public void setAugmentedAutofillWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
field public static final String DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES = "smart_suggestion_supported_modes";
field public static final int FLAG_SMART_SUGGESTION_OFF = 0; // 0x0
field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 46917e4..a6c7cae 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -110,13 +110,30 @@
} else {
mShuttingDown = true;
}
+ ALOGD("%sAnimationStartTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot",
+ elapsedRealtime());
+}
+
+BootAnimation::~BootAnimation() {
+ if (mAnimation != nullptr) {
+ releaseAnimation(mAnimation);
+ mAnimation = nullptr;
+ }
+ ALOGD("%sAnimationStopTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot",
+ elapsedRealtime());
}
void BootAnimation::onFirstRef() {
status_t err = mSession->linkToComposerDeath(this);
SLOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err));
if (err == NO_ERROR) {
- run("BootAnimation", PRIORITY_DISPLAY);
+ // Load the animation content -- this can be slow (eg 200ms)
+ // called before waitForSurfaceFlinger() in main() to avoid wait
+ ALOGD("%sAnimationPreloadTiming start time: %" PRId64 "ms",
+ mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime());
+ preloadAnimation();
+ ALOGD("%sAnimationPreloadStopTiming start time: %" PRId64 "ms",
+ mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime());
}
}
@@ -306,6 +323,20 @@
mFlingerSurface = s;
mTargetInset = -1;
+ return NO_ERROR;
+}
+
+bool BootAnimation::preloadAnimation() {
+ findBootAnimationFile();
+ if (!mZipFileName.isEmpty()) {
+ mAnimation = loadAnimation(mZipFileName);
+ return (mAnimation != nullptr);
+ }
+
+ return false;
+}
+
+void BootAnimation::findBootAnimationFile() {
// If the device has encryption turned on or is in process
// of being encrypted we show the encrypted boot animation.
char decrypt[PROPERTY_VALUE_MAX];
@@ -320,7 +351,7 @@
for (const char* f : encryptedBootFiles) {
if (access(f, R_OK) == 0) {
mZipFileName = f;
- return NO_ERROR;
+ return;
}
}
}
@@ -332,10 +363,9 @@
for (const char* f : (!mShuttingDown ? bootFiles : shutdownFiles)) {
if (access(f, R_OK) == 0) {
mZipFileName = f;
- return NO_ERROR;
+ return;
}
}
- return NO_ERROR;
}
bool BootAnimation::threadLoop()
@@ -790,8 +820,6 @@
}
}
- mCallbacks->init(animation.parts);
-
zip->endIteration(cookie);
return true;
@@ -799,13 +827,25 @@
bool BootAnimation::movie()
{
- Animation* animation = loadAnimation(mZipFileName);
- if (animation == NULL)
+ if (mAnimation == nullptr) {
+ mAnimation = loadAnimation(mZipFileName);
+ }
+
+ if (mAnimation == nullptr)
return false;
+ // mCallbacks->init() may get called recursively,
+ // this loop is needed to get the same results
+ for (const Animation::Part& part : mAnimation->parts) {
+ if (part.animation != nullptr) {
+ mCallbacks->init(part.animation->parts);
+ }
+ }
+ mCallbacks->init(mAnimation->parts);
+
bool anyPartHasClock = false;
- for (size_t i=0; i < animation->parts.size(); i++) {
- if(validClock(animation->parts[i])) {
+ for (size_t i=0; i < mAnimation->parts.size(); i++) {
+ if(validClock(mAnimation->parts[i])) {
anyPartHasClock = true;
break;
}
@@ -846,7 +886,7 @@
bool clockFontInitialized = false;
if (mClockEnabled) {
clockFontInitialized =
- (initFont(&animation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR);
+ (initFont(&mAnimation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR);
mClockEnabled = clockFontInitialized;
}
@@ -855,7 +895,7 @@
mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL);
}
- playAnimation(*animation);
+ playAnimation(*mAnimation);
if (mTimeCheckThread != nullptr) {
mTimeCheckThread->requestExit();
@@ -863,10 +903,11 @@
}
if (clockFontInitialized) {
- glDeleteTextures(1, &animation->clockFont.texture.name);
+ glDeleteTextures(1, &mAnimation->clockFont.texture.name);
}
- releaseAnimation(animation);
+ releaseAnimation(mAnimation);
+ mAnimation = nullptr;
return false;
}
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h
index 19616cb..dc19fb0 100644
--- a/cmds/bootanimation/BootAnimation.h
+++ b/cmds/bootanimation/BootAnimation.h
@@ -115,6 +115,7 @@
};
explicit BootAnimation(sp<Callbacks> callbacks);
+ virtual ~BootAnimation();
sp<SurfaceComposerClient> session() const;
@@ -155,6 +156,8 @@
void releaseAnimation(Animation*) const;
bool parseAnimationDesc(Animation&);
bool preloadZip(Animation &animation);
+ void findBootAnimationFile();
+ bool preloadAnimation();
void checkExit();
@@ -182,6 +185,7 @@
SortedVector<String8> mLoadedFiles;
sp<TimeCheckThread> mTimeCheckThread = nullptr;
sp<Callbacks> mCallbacks;
+ Animation* mAnimation = nullptr;
};
// ---------------------------------------------------------------------------
diff --git a/cmds/bootanimation/bootanimation_main.cpp b/cmds/bootanimation/bootanimation_main.cpp
index a52a5e9..6c7b3e5 100644
--- a/cmds/bootanimation/bootanimation_main.cpp
+++ b/cmds/bootanimation/bootanimation_main.cpp
@@ -44,14 +44,16 @@
sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();
+ // create the boot animation object (may take up to 200ms for 2MB zip)
+ sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks());
+
waitForSurfaceFlinger();
- // create the boot animation object
- sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks());
+ boot->run("BootAnimation", PRIORITY_DISPLAY);
+
ALOGV("Boot animation set up. Joining pool.");
IPCThreadState::self()->joinThreadPool();
}
- ALOGV("Boot animation exit");
return 0;
}
diff --git a/core/java/android/service/contentcapture/ContentCaptureService.java b/core/java/android/service/contentcapture/ContentCaptureService.java
index d2f9859..ae70775 100644
--- a/core/java/android/service/contentcapture/ContentCaptureService.java
+++ b/core/java/android/service/contentcapture/ContentCaptureService.java
@@ -49,7 +49,9 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
* A service used to capture the content of the screen to provide contextual data in other areas of
@@ -164,17 +166,9 @@
}
/**
- * Explicitly limits content capture to the given packages and activities.
- *
- * <p>To reset the whitelist, call it passing {@code null} to both arguments.
- *
- * <p>Useful when the service wants to restrict content capture to a category of apps, like
- * chat apps. For example, if the service wants to support view captures on all activities of
- * app {@code ChatApp1} and just activities {@code act1} and {@code act2} of {@code ChatApp2},
- * it would call: {@code setContentCaptureWhitelist(Arrays.asList("ChatApp1"),
- * Arrays.asList(new ComponentName("ChatApp2", "act1"),
- * new ComponentName("ChatApp2", "act2")));}
+ * @deprecated use {@link #setContentCaptureWhitelist(Set, Set)} instead
*/
+ @Deprecated
public final void setContentCaptureWhitelist(@Nullable List<String> packages,
@Nullable List<ComponentName> activities) {
final IContentCaptureServiceCallback callback = mCallback;
@@ -190,6 +184,27 @@
}
/**
+ * Explicitly limits content capture to the given packages and activities.
+ *
+ * <p>To reset the whitelist, call it passing {@code null} to both arguments.
+ *
+ * <p>Useful when the service wants to restrict content capture to a category of apps, like
+ * chat apps. For example, if the service wants to support view captures on all activities of
+ * app {@code ChatApp1} and just activities {@code act1} and {@code act2} of {@code ChatApp2},
+ * it would call: {@code setContentCaptureWhitelist(Sets.newArraySet("ChatApp1"),
+ * Sets.newArraySet(new ComponentName("ChatApp2", "act1"),
+ * new ComponentName("ChatApp2", "act2")));}
+ */
+ public final void setContentCaptureWhitelist(@Nullable Set<String> packages,
+ @Nullable Set<ComponentName> activities) {
+ setContentCaptureWhitelist(toList(packages), toList(activities));
+ }
+
+ private <T> ArrayList<T> toList(@Nullable Set<T> set) {
+ return set == null ? null : new ArrayList<T>(set);
+ }
+
+ /**
* Called when the Android system connects to service.
*
* <p>You should generally do initialization here rather than in {@link #onCreate}.
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index f93ac4c..a6b40ed 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -78,6 +78,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
//TODO: use java.lang.ref.Cleaner once Android supports Java 9
import sun.misc.Cleaner;
@@ -1780,6 +1781,18 @@
}
/**
+ * @deprecated use {@link #setAugmentedAutofillWhitelist(Set, Set)} instead.
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ @Deprecated
+ public void setAugmentedAutofillWhitelist(@Nullable List<String> packages,
+ @Nullable List<ComponentName> activities) {
+ // TODO(b/123100824): implement
+ }
+
+ /**
* Explicitly limits augmented autofill to the given packages and activities.
*
* <p>To reset the whitelist, call it passing {@code null} to both arguments.
@@ -1799,8 +1812,8 @@
*/
@SystemApi
@TestApi
- public void setAugmentedAutofillWhitelist(@Nullable List<String> packages,
- @Nullable List<ComponentName> activities) {
+ public void setAugmentedAutofillWhitelist(@Nullable Set<String> packages,
+ @Nullable Set<ComponentName> activities) {
// TODO(b/123100824): implement
}
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 904a862..89e205c 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -1230,9 +1230,16 @@
* Ensures that the drop down is not obscuring the IME.
* @param visible whether the ime should be in front. If false, the ime is pushed to
* the background.
+ *
+ * This method is deprecated. Please use the following methods instead.
+ * Use {@link #setInputMethodMode} to ensure that the drop down is not obscuring the IME.
+ * Use {@link #showDropDown()} to show the drop down immediately
+ * A combination of {@link #isDropDownAlwaysVisible()} and {@link #enoughToFilter()} to decide
+ * whether to manually trigger {@link #showDropDown()} or not.
+ *
* @hide internal used only here and SearchDialog
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768913)
public void ensureImeVisible(boolean visible) {
mPopup.setInputMethodMode(visible
? ListPopupWindow.INPUT_METHOD_NEEDED : ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
@@ -1242,14 +1249,39 @@
}
/**
- * @hide internal used only here and SearchDialog
+ * This method is deprecated. Please use {@link #getInputMethodMode()} instead.
+ *
+ * @hide This API is not being used and can be removed.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public boolean isInputMethodNotNeeded() {
return mPopup.getInputMethodMode() == ListPopupWindow.INPUT_METHOD_NOT_NEEDED;
}
/**
+ * Returns the input method mode used by the auto complete dropdown.
+ */
+ public int getInputMethodMode() {
+ return mPopup.getInputMethodMode();
+ }
+
+ /**
+ * Use this method to specify when the IME should be displayed. This function can be used to
+ * prevent the dropdown from obscuring the IME.
+ *
+ * @param mode speficies the input method mode. use one of the following values:
+ *
+ * {@link ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE} IME Displayed if the auto-complete box is
+ * focusable.
+ * {@link ListPopupWindow#INPUT_METHOD_NEEDED} Always display the IME.
+ * {@link ListPopupWindow#INPUT_METHOD_NOT_NEEDED}. The auto-complete suggestions are always
+ * displayed, even if the suggestions cover/hide the input method.
+ */
+ public void setInputMethodMode(int mode) {
+ mPopup.setInputMethodMode(mode);
+ }
+
+ /**
* <p>Displays the drop down on screen.</p>
*/
public void showDropDown() {
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 585a1f1..fbf8091 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -46,6 +46,7 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
+import android.content.res.Configuration;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.graphics.Bitmap;
@@ -486,6 +487,27 @@
}
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ int width = -1;
+ if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ width = getResources().getDimensionPixelSize(R.dimen.chooser_preview_width);
+ }
+
+ updateLayoutWidth(R.id.content_preview_text_layout, width);
+ updateLayoutWidth(R.id.content_preview_title_layout, width);
+ updateLayoutWidth(R.id.content_preview_file_layout, width);
+ }
+
+ private void updateLayoutWidth(int layoutResourceId, int width) {
+ View view = findViewById(layoutResourceId);
+ LayoutParams params = view.getLayoutParams();
+ params.width = width;
+ view.setLayoutParams(params);
+ }
+
private void displayContentPreview(@ContentPreviewType int previewType, Intent targetIntent) {
switch (previewType) {
case CONTENT_PREVIEW_TEXT:
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index 774c224..7ff15f2 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -6,4 +6,4 @@
per-file android_net_* = codewiz@google.com, jchalard@google.com, lorenzo@google.com, reminv@google.com, satk@google.com
# Zygote
-per-file com_android_inernal_os_Zygote.*,fd_utils.* = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
+per-file com_android_internal_os_Zygote.*,fd_utils.* = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/res/res/layout/chooser_grid.xml b/core/res/res/layout/chooser_grid.xml
index 3683bfd..10798ad 100644
--- a/core/res/res/layout/chooser_grid.xml
+++ b/core/res/res/layout/chooser_grid.xml
@@ -20,12 +20,10 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:maxWidth="@dimen/resolver_max_width"
android:maxCollapsedHeight="288dp"
android:maxCollapsedHeightSmall="56dp"
android:id="@id/contentPanel">
-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -153,8 +151,9 @@
android:background="?attr/colorBackgroundFloating">
<LinearLayout
- android:layout_width="match_parent"
+ android:layout_width="@dimen/chooser_preview_width"
android:layout_height="wrap_content"
+ android:layout_gravity="center"
android:orientation="horizontal"
android:paddingLeft="@dimen/chooser_edge_margin_normal"
android:paddingRight="@dimen/chooser_edge_margin_normal"
@@ -182,8 +181,9 @@
<!-- Required sub-layout so we can get the nice rounded corners-->
<!-- around this section -->
<LinearLayout
- android:layout_width="match_parent"
+ android:layout_width="@dimen/chooser_preview_width"
android:layout_height="wrap_content"
+ android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginLeft="@dimen/chooser_edge_margin_thin"
android:layout_marginRight="@dimen/chooser_edge_margin_thin"
@@ -224,8 +224,9 @@
android:background="?attr/colorBackgroundFloating">
<LinearLayout
- android:layout_width="match_parent"
+ android:layout_width="@dimen/chooser_preview_width"
android:layout_height="wrap_content"
+ android:layout_gravity="center"
android:orientation="horizontal"
android:paddingLeft="@dimen/chooser_edge_margin_normal"
android:paddingRight="@dimen/chooser_edge_margin_normal"
diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml
index 351bd81..9e87a47 100644
--- a/core/res/res/values-land/dimens.xml
+++ b/core/res/res/values-land/dimens.xml
@@ -76,4 +76,6 @@
<!-- Floating toolbar dimensions -->
<dimen name="floating_toolbar_preferred_width">544dp</dimen>
+ <dimen name="chooser_preview_width">480dp</dimen>
+
</resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 9f86f84..39cbd26 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -721,4 +721,5 @@
<dimen name="chooser_edge_margin_thin">16dp</dimen>
<dimen name="chooser_edge_margin_normal">24dp</dimen>
<dimen name="chooser_preview_image_font_size">20sp</dimen>
+ <dimen name="chooser_preview_width">-1px</dimen>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 01abffe..08fc36d 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2756,6 +2756,7 @@
<java-symbol type="dimen" name="chooser_edge_margin_thin" />
<java-symbol type="dimen" name="chooser_edge_margin_normal" />
<java-symbol type="dimen" name="chooser_preview_image_font_size"/>
+ <java-symbol type="dimen" name="chooser_preview_width" />
<java-symbol type="layout" name="chooser_grid" />
<java-symbol type="layout" name="resolve_grid_item" />
<java-symbol type="id" name="day_picker_view_pager" />
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index bdb6364..8135671 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -1509,6 +1509,9 @@
* Convenience method that returns the width of this bitmap divided
* by the density scale factor.
*
+ * Returns the bitmap's width multiplied by the ratio of the target density to the bitmap's
+ * source density
+ *
* @param targetDensity The density of the target canvas of the bitmap.
* @return The scaled width of this bitmap, according to the density scale factor.
*/
@@ -1520,6 +1523,9 @@
* Convenience method that returns the height of this bitmap divided
* by the density scale factor.
*
+ * Returns the bitmap's height multiplied by the ratio of the target density to the bitmap's
+ * source density
+ *
* @param targetDensity The density of the target canvas of the bitmap.
* @return The scaled height of this bitmap, according to the density scale factor.
*/
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 3778a9c..4a5388b 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -126,6 +126,7 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC_INTERNAL" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.RESET_FINGERPRINT_LOCKOUT" />
+ <uses-permission android:name="android.permission.MANAGE_BIOMETRIC" />
<uses-permission android:name="android.permission.MANAGE_SLICE_PERMISSIONS" />
<uses-permission android:name="android.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS" />
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 62cc889..ed9b38b 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -58,7 +58,7 @@
/**
* Renders bubbles in a stack and handles animating expanded and collapsed states.
*/
-public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.FloatingView {
+public class BubbleStackView extends FrameLayout {
private static final String TAG = "BubbleStackView";
/**
@@ -146,8 +146,9 @@
mBubbleData = data;
mInflater = LayoutInflater.from(context);
- mTouchHandler = new BubbleTouchHandler(context);
+ mTouchHandler = new BubbleTouchHandler(context, this);
setOnTouchListener(mTouchHandler);
+ mInflater = LayoutInflater.from(context);
Resources res = getResources();
mBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
@@ -199,6 +200,8 @@
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY));
setClipChildren(false);
+
+ mBubbleContainer.bringToFront();
}
@Override
@@ -484,9 +487,10 @@
if (shouldExpand) {
mBubbleContainer.setController(mExpandedAnimationController);
mExpandedAnimationController.expandFromStack(
- mStackAnimationController.getStackPosition(), () -> {
- updatePointerPosition();
- updateAfter.run();
+ mStackAnimationController.getStackPosition(),
+ () -> {
+ updatePointerPosition();
+ updateAfter.run();
});
} else {
mBubbleContainer.cancelAllAnimations();
@@ -544,55 +548,49 @@
: null;
}
- @Override
- public void setPosition(float x, float y) {
- mStackAnimationController.moveFirstBubbleWithStackFollowing(x, y);
- }
-
- @Override
- public void setPositionX(float x) {
- // Unsupported, use setPosition(x, y).
- }
-
- @Override
- public void setPositionY(float y) {
- // Unsupported, use setPosition(x, y).
- }
-
- @Override
- public PointF getPosition() {
+ public PointF getStackPosition() {
return mStackAnimationController.getStackPosition();
}
/** Called when a drag operation on an individual bubble has started. */
- public void onBubbleDragStart(BubbleView bubble) {
- // TODO: Save position and snap back if not dismissed.
+ public void onBubbleDragStart(View bubble) {
+ mExpandedAnimationController.prepareForBubbleDrag(bubble);
}
/** Called with the coordinates to which an individual bubble has been dragged. */
- public void onBubbleDragged(BubbleView bubble, float x, float y) {
- bubble.setTranslationX(x);
- bubble.setTranslationY(y);
+ public void onBubbleDragged(View bubble, float x, float y) {
+ if (!mIsExpanded || mIsAnimating) {
+ return;
+ }
+
+ mExpandedAnimationController.dragBubbleOut(bubble, x, y);
}
/** Called when a drag operation on an individual bubble has finished. */
- public void onBubbleDragFinish(BubbleView bubble, float x, float y, float velX, float velY) {
- // TODO: Add fling to bottom to dismiss.
+ public void onBubbleDragFinish(
+ View bubble, float x, float y, float velX, float velY, boolean dismissed) {
+ if (!mIsExpanded || mIsAnimating) {
+ return;
+ }
+
+ if (dismissed) {
+ mExpandedAnimationController.prepareForDismissalWithVelocity(bubble, velX, velY);
+ } else {
+ mExpandedAnimationController.snapBubbleBack(bubble, velX, velY);
+ }
}
void onDragStart() {
- if (mIsExpanded) {
+ if (mIsExpanded || mIsAnimating) {
return;
}
mStackAnimationController.cancelStackPositionAnimations();
mBubbleContainer.setController(mStackAnimationController);
- mIsAnimating = false;
}
void onDragged(float x, float y) {
- // TODO: We can drag if animating - just need to reroute inflight anims to drag point.
- if (mIsExpanded) {
+ if (mIsExpanded || mIsAnimating) {
return;
}
@@ -744,9 +742,9 @@
private void updatePointerPosition() {
if (mExpandedBubble != null) {
- float pointerPosition = mExpandedBubble.iconView.getPosition().x
+ float pointerPosition = mExpandedBubble.iconView.getTranslationX()
+ (mExpandedBubble.iconView.getWidth() / 2f);
- mExpandedBubble.expandedView.setPointerPosition(pointerPosition);
+ mExpandedBubble.expandedView.setPointerPosition((int) pointerPosition);
}
}
@@ -772,7 +770,7 @@
* @return the normalized x-axis position of the bubble stack rounded to 4 decimal places.
*/
public float getNormalizedXPosition() {
- return new BigDecimal(getPosition().x / mDisplaySize.x)
+ return new BigDecimal(getStackPosition().x / mDisplaySize.x)
.setScale(4, RoundingMode.CEILING.HALF_UP)
.floatValue();
}
@@ -781,7 +779,7 @@
* @return the normalized y-axis position of the bubble stack rounded to 4 decimal places.
*/
public float getNormalizedYPosition() {
- return new BigDecimal(getPosition().y / mDisplaySize.y)
+ return new BigDecimal(getStackPosition().y / mDisplaySize.y)
.setScale(4, RoundingMode.CEILING.HALF_UP)
.floatValue();
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
index 7d3c0f8..165eb1d 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
@@ -34,17 +34,16 @@
* dismissing, and flings.
*/
class BubbleTouchHandler implements View.OnTouchListener {
+ /** Velocity required to dismiss a bubble without dragging it into the dismiss target. */
+ private static final float DISMISS_MIN_VELOCITY = 4000f;
+
+ private final PointF mTouchDown = new PointF();
+ private final PointF mViewPositionOnTouchDown = new PointF();
+ private final BubbleStackView mStack;
private BubbleController mController = Dependency.get(BubbleController.class);
private PipDismissViewController mDismissViewController;
- // The position of the bubble on down event
- private float mBubbleDownPosX;
- private float mBubbleDownPosY;
- // The touch position on down event
- private float mDownX = -1;
- private float mDownY = -1;
-
private boolean mMovedEnough;
private int mTouchSlopSquared;
private VelocityTracker mVelocityTracker;
@@ -58,65 +57,42 @@
}
};
- // Bubble being dragged from the row of bubbles when the stack is expanded
- private BubbleView mBubbleDraggingOut;
+ /** View that was initially touched, when we received the first ACTION_DOWN event. */
+ private View mTouchedView;
- /**
- * Views movable by this touch handler should implement this interface.
- */
- public interface FloatingView {
-
- /**
- * Sets the position of the view.
- */
- void setPosition(float x, float y);
-
- /**
- * Sets the x position of the view.
- */
- void setPositionX(float x);
-
- /**
- * Sets the y position of the view.
- */
- void setPositionY(float y);
-
- /**
- * @return the position of the view.
- */
- PointF getPosition();
- }
-
- public BubbleTouchHandler(Context context) {
+ BubbleTouchHandler(Context context, BubbleStackView stackView) {
final int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mTouchSlopSquared = touchSlop * touchSlop;
mDismissViewController = new PipDismissViewController(context);
+ mStack = stackView;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
- int action = event.getActionMasked();
+ final int action = event.getActionMasked();
- BubbleStackView stack = (BubbleStackView) v;
- View targetView = mBubbleDraggingOut != null
- ? mBubbleDraggingOut
- : stack.getTargetView(event);
- boolean isFloating = targetView instanceof FloatingView;
- if (!isFloating || targetView == null || action == MotionEvent.ACTION_OUTSIDE) {
- stack.collapseStack();
+ // If we aren't currently in the process of touching a view, figure out what we're touching.
+ // It'll be the stack, an individual bubble, or nothing.
+ if (mTouchedView == null) {
+ mTouchedView = mStack.getTargetView(event);
+ }
+
+ // If this is an ACTION_OUTSIDE event, or the stack reported that we aren't touching
+ // anything, collapse the stack.
+ if (action == MotionEvent.ACTION_OUTSIDE || mTouchedView == null) {
+ mStack.collapseStack();
cleanUpDismissTarget();
- resetTouches();
+ mTouchedView = null;
return false;
}
- FloatingView floatingView = (FloatingView) targetView;
- boolean isBubbleStack = floatingView instanceof BubbleStackView;
+ final boolean isStack = mStack.equals(mTouchedView);
+ final float rawX = event.getRawX();
+ final float rawY = event.getRawY();
- PointF startPos = floatingView.getPosition();
- float rawX = event.getRawX();
- float rawY = event.getRawY();
- float x = mBubbleDownPosX + rawX - mDownX;
- float y = mBubbleDownPosY + rawY - mDownY;
+ // The coordinates of the touch event, in terms of the touched view's position.
+ final float viewX = mViewPositionOnTouchDown.x + rawX - mTouchDown.x;
+ final float viewY = mViewPositionOnTouchDown.y + rawY - mTouchDown.y;
switch (action) {
case MotionEvent.ACTION_DOWN:
trackMovement(event);
@@ -124,87 +100,83 @@
mDismissViewController.createDismissTarget();
mHandler.postDelayed(mShowDismissAffordance, SHOW_TARGET_DELAY);
- mBubbleDownPosX = startPos.x;
- mBubbleDownPosY = startPos.y;
- mDownX = rawX;
- mDownY = rawY;
- mMovedEnough = false;
+ mTouchDown.set(rawX, rawY);
- if (isBubbleStack) {
- stack.onDragStart();
+ if (isStack) {
+ mViewPositionOnTouchDown.set(mStack.getStackPosition());
+ mStack.onDragStart();
} else {
- stack.onBubbleDragStart((BubbleView) floatingView);
+ mViewPositionOnTouchDown.set(
+ mTouchedView.getTranslationX(), mTouchedView.getTranslationY());
+ mStack.onBubbleDragStart(mTouchedView);
}
break;
-
case MotionEvent.ACTION_MOVE:
trackMovement(event);
+ final float deltaX = rawX - mTouchDown.x;
+ final float deltaY = rawY - mTouchDown.y;
- if (mBubbleDownPosX == -1 || mDownX == -1) {
- mBubbleDownPosX = startPos.x;
- mBubbleDownPosY = startPos.y;
- mDownX = rawX;
- mDownY = rawY;
- }
- final float deltaX = rawX - mDownX;
- final float deltaY = rawY - mDownY;
if ((deltaX * deltaX) + (deltaY * deltaY) > mTouchSlopSquared && !mMovedEnough) {
mMovedEnough = true;
}
if (mMovedEnough) {
- if (floatingView instanceof BubbleView) {
- mBubbleDraggingOut = ((BubbleView) floatingView);
- stack.onBubbleDragged(mBubbleDraggingOut, x, y);
+ if (isStack) {
+ mStack.onDragged(viewX, viewY);
} else {
- stack.onDragged(x, y);
+ mStack.onBubbleDragged(mTouchedView, viewX, viewY);
}
}
+
// TODO - when we're in the target stick to it / animate in some way?
mInDismissTarget = mDismissViewController.updateTarget(
- isBubbleStack ? stack.getBubbleAt(0) : (View) floatingView);
+ isStack ? mStack.getBubbleAt(0) : mTouchedView);
break;
case MotionEvent.ACTION_CANCEL:
- resetTouches();
+ mTouchedView = null;
cleanUpDismissTarget();
break;
case MotionEvent.ACTION_UP:
trackMovement(event);
- if (mInDismissTarget) {
- if (isBubbleStack) {
- mController.dismissStack();
- } else {
- mController.removeBubble(((BubbleView) floatingView).getKey());
- }
+ if (mInDismissTarget && isStack) {
+ mController.dismissStack();
} else if (mMovedEnough) {
mVelocityTracker.computeCurrentVelocity(1000);
final float velX = mVelocityTracker.getXVelocity();
final float velY = mVelocityTracker.getYVelocity();
- if (isBubbleStack) {
- stack.onDragFinish(x, y, velX, velY);
+ if (isStack) {
+ mStack.onDragFinish(viewX, viewY, velX, velY);
} else {
- stack.onBubbleDragFinish(mBubbleDraggingOut, x, y, velX, velY);
+ final boolean dismissed = mInDismissTarget || velY > DISMISS_MIN_VELOCITY;
+ mStack.onBubbleDragFinish(
+ mTouchedView, viewX, viewY, velX, velY, /* dismissed */ dismissed);
+ if (dismissed) {
+ mController.removeBubble(((BubbleView) mTouchedView).getKey());
+ }
}
- } else if (floatingView.equals(stack.getExpandedBubbleView())) {
- stack.collapseStack();
- } else if (isBubbleStack) {
- if (stack.isExpanded()) {
- stack.collapseStack();
+ } else if (mTouchedView.equals(mStack.getExpandedBubbleView())) {
+ mStack.collapseStack();
+ } else if (isStack) {
+ if (mStack.isExpanded()) {
+ mStack.collapseStack();
} else {
- stack.expandStack();
+ mStack.expandStack();
}
} else {
- stack.setExpandedBubble(((BubbleView) floatingView).getKey());
+ mStack.setExpandedBubble(((BubbleView) mTouchedView).getKey());
}
+
cleanUpDismissTarget();
mVelocityTracker.recycle();
mVelocityTracker = null;
- resetTouches();
+ mTouchedView = null;
+ mMovedEnough = false;
break;
}
+
return true;
}
@@ -216,16 +188,6 @@
mDismissViewController.destroyDismissTarget();
}
- /**
- * Resets anything we care about after a gesture is complete.
- */
- private void resetTouches() {
- mDownX = -1;
- mDownY = -1;
- mBubbleDownPosX = -1;
- mBubbleDownPosY = -1;
- mBubbleDraggingOut = null;
- }
private void trackMovement(MotionEvent event) {
if (mVelocityTracker == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
index 1a4b1994..b409a31 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
@@ -20,7 +20,6 @@
import android.app.Notification;
import android.content.Context;
import android.graphics.Color;
-import android.graphics.PointF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
@@ -39,7 +38,7 @@
/**
* A floating object on the screen that can post message updates.
*/
-public class BubbleView extends FrameLayout implements BubbleTouchHandler.FloatingView {
+public class BubbleView extends FrameLayout {
private static final String TAG = "BubbleView";
// Same value as Launcher3 badge code
@@ -217,25 +216,4 @@
// XXX: should we pull from the drawable, app icon, notif tint?
return ColorUtils.blendARGB(defaultTint, Color.WHITE, WHITE_SCRIM_ALPHA);
}
-
- @Override
- public void setPosition(float x, float y) {
- setPositionX(x);
- setPositionY(y);
- }
-
- @Override
- public void setPositionX(float x) {
- setTranslationX(x);
- }
-
- @Override
- public void setPositionY(float y) {
- setTranslationY(y);
- }
-
- @Override
- public PointF getPosition() {
- return new PointF(getTranslationX(), getTranslationY());
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
index 5b158e9..9fd26b8 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
@@ -44,6 +44,9 @@
*/
private static final int ANIMATE_TRANSLATION_FACTOR = 4;
+ /** How much to scale down bubbles when they're animating in/out. */
+ private static final float ANIMATE_SCALE_PERCENT = 0.5f;
+
/**
* The stack position from which the bubbles were expanded. Saved in {@link #expandFromStack}
* and used to return to stack form in {@link #collapseBackToStack}.
@@ -59,6 +62,22 @@
/** Height of the status bar. */
private float mStatusBarHeight;
+ /**
+ * Whether the individual bubble has been dragged out of the row of bubbles far enough to cause
+ * the rest of the bubbles to animate to fill the gap.
+ */
+ private boolean mBubbleDraggedOutEnough = false;
+
+ /** The bubble currently being dragged out of the row (to potentially be dismissed). */
+ private View mBubbleDraggingOut;
+
+ /**
+ * Drag velocities for the dragging-out bubble when the drag finished. These are used by
+ * {@link #onChildRemoved} to animate out the bubble while respecting touch velocity.
+ */
+ private float mBubbleDraggingOutVelX;
+ private float mBubbleDraggingOutVelY;
+
@Override
protected void setLayout(PhysicsAnimationLayout layout) {
super.setLayout(layout);
@@ -102,6 +121,87 @@
runAfterTranslationsEnd(after);
}
+ /** Prepares the given bubble to be dragged out. */
+ public void prepareForBubbleDrag(View bubble) {
+ mLayout.cancelAnimationsOnView(bubble);
+
+ mBubbleDraggingOut = bubble;
+ mBubbleDraggingOut.setTranslationZ(Short.MAX_VALUE);
+ }
+
+ /**
+ * Drags an individual bubble to the given coordinates. Bubbles to the right will animate to
+ * take its place once it's dragged out of the row of bubbles, and animate out of the way if the
+ * bubble is dragged back into the row.
+ */
+ public void dragBubbleOut(View bubbleView, float x, float y) {
+ bubbleView.setTranslationX(x);
+ bubbleView.setTranslationY(y);
+
+ final boolean draggedOutEnough =
+ y > getExpandedY() + mBubbleSizePx || y < getExpandedY() - mBubbleSizePx;
+ if (draggedOutEnough != mBubbleDraggedOutEnough) {
+ animateStackByBubbleWidthsStartingFrom(
+ /* numBubbleWidths */ draggedOutEnough ? -1 : 0,
+ /* startIndex */ mLayout.indexOfChild(bubbleView) + 1);
+ mBubbleDraggedOutEnough = draggedOutEnough;
+ }
+ }
+
+ /**
+ * Snaps a bubble back to its position within the bubble row, and animates the rest of the
+ * bubbles to accommodate it if it was previously dragged out past the threshold.
+ */
+ public void snapBubbleBack(View bubbleView, float velX, float velY) {
+ final int index = mLayout.indexOfChild(bubbleView);
+
+ // Snap the bubble back, respecting its current velocity.
+ mLayout.animateValueForChildAtIndex(
+ DynamicAnimation.TRANSLATION_X, index, getXForChildAtIndex(index), velX);
+ mLayout.animateValueForChildAtIndex(
+ DynamicAnimation.TRANSLATION_Y, index, getExpandedY(), velY);
+ mLayout.setEndListenerForProperties(
+ mLayout.new OneTimeMultiplePropertyEndListener() {
+ @Override
+ void onAllAnimationsForPropertiesEnd() {
+ // Reset Z translation once the bubble is done snapping back.
+ bubbleView.setTranslationZ(0f);
+ }
+ },
+ DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
+
+ animateStackByBubbleWidthsStartingFrom(
+ /* numBubbleWidths */ 0, /* startIndex */ index + 1);
+
+ mBubbleDraggingOut = null;
+ mBubbleDraggedOutEnough = false;
+ }
+
+ /**
+ * Sets configuration variables so that when the given bubble is removed, the animations are
+ * started with the given velocities.
+ */
+ public void prepareForDismissalWithVelocity(View bubbleView, float velX, float velY) {
+ mBubbleDraggingOut = bubbleView;
+ mBubbleDraggingOutVelX = velX;
+ mBubbleDraggingOutVelY = velY;
+ mBubbleDraggedOutEnough = false;
+ }
+
+ /**
+ * Animates the bubbles, starting at the given index, to the left or right by the given number
+ * of bubble widths. Passing zero for numBubbleWidths will animate the bubbles to their normal
+ * positions.
+ */
+ private void animateStackByBubbleWidthsStartingFrom(int numBubbleWidths, int startIndex) {
+ for (int i = startIndex; i < mLayout.getChildCount(); i++) {
+ mLayout.animateValueForChildAtIndex(
+ DynamicAnimation.TRANSLATION_X,
+ i,
+ getXForChildAtIndex(i + numBubbleWidths));
+ }
+ }
+
/** The Y value of the row of expanded bubbles. */
private float getExpandedY() {
final WindowInsets insets = mLayout.getRootWindowInsets();
@@ -165,12 +265,7 @@
child.setTranslationX(getXForChildAtIndex(index));
child.setTranslationY(getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR);
mLayout.animateValueForChild(DynamicAnimation.TRANSLATION_Y, child, getExpandedY());
-
- // Animate the remaining bubbles to the correct X position.
- for (int i = index + 1; i < mLayout.getChildCount(); i++) {
- mLayout.animateValueForChildAtIndex(
- DynamicAnimation.TRANSLATION_X, i, getXForChildAtIndex(i));
- }
+ animateBubblesAfterIndexToCorrectX(index);
}
@Override
@@ -179,16 +274,36 @@
// TODO: Reverse this when bubbles are at the bottom.
mLayout.animateValueForChild(
DynamicAnimation.ALPHA, child, 0f, finishRemoval);
- mLayout.animateValueForChild(
- DynamicAnimation.TRANSLATION_Y,
- child,
- getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR);
- // Animate the remaining bubbles to the correct X position.
- for (int i = index; i < mLayout.getChildCount(); i++) {
- mLayout.animateValueForChildAtIndex(
- DynamicAnimation.TRANSLATION_X, i, getXForChildAtIndex(i));
+ // If we're removing the dragged-out bubble, that means it got dismissed.
+ if (child.equals(mBubbleDraggingOut)) {
+ // Throw it to the bottom of the screen, towards the center horizontally.
+ mLayout.animateValueForChild(
+ DynamicAnimation.TRANSLATION_X,
+ child,
+ mLayout.getWidth() / 2f - mBubbleSizePx / 2f,
+ mBubbleDraggingOutVelX);
+ mLayout.animateValueForChild(
+ DynamicAnimation.TRANSLATION_Y,
+ child,
+ mLayout.getHeight() + mBubbleSizePx,
+ mBubbleDraggingOutVelY);
+
+ // Scale it down a bit so it looks like it's disappearing.
+ mLayout.animateValueForChild(DynamicAnimation.SCALE_X, child, ANIMATE_SCALE_PERCENT);
+ mLayout.animateValueForChild(DynamicAnimation.SCALE_Y, child, ANIMATE_SCALE_PERCENT);
+
+ mBubbleDraggingOut = null;
+ } else {
+ // If we're removing some random bubble just throw it off the top.
+ mLayout.animateValueForChild(
+ DynamicAnimation.TRANSLATION_Y,
+ child,
+ getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR);
}
+
+ // Animate all the other bubbles to their new positions sans this bubble.
+ animateBubblesAfterIndexToCorrectX(index);
}
@Override
@@ -207,6 +322,23 @@
() -> super.setChildVisibility(child, index, visibility));
}
+ /**
+ * Animates the bubbles after the given index to the X position they should be in according to
+ * {@link #getXForChildAtIndex}.
+ */
+ private void animateBubblesAfterIndexToCorrectX(int start) {
+ for (int i = start; i < mLayout.getChildCount(); i++) {
+ final View bubble = mLayout.getChildAt(i);
+
+ // Don't animate the dragging out bubble, or it'll jump around while being dragged. It
+ // will be snapped to the correct X value after the drag (if it's not dismissed).
+ if (!bubble.equals(mBubbleDraggingOut)) {
+ mLayout.animateValueForChild(
+ DynamicAnimation.TRANSLATION_X, bubble, getXForChildAtIndex(i));
+ }
+ }
+ }
+
/** Returns the appropriate X translation value for a bubble at the given index. */
private float getXForChildAtIndex(int index) {
return mBubblePaddingPx + (mBubbleSizePx + mBubblePaddingPx) * index;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
index a4ddbf7..dfdcfc9 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
@@ -187,6 +187,20 @@
}
/**
+ * Sets an end listener that will be called whenever any of the given properties' animations
+ * end. For example, setting a listener for TRANSLATION_X and TRANSLATION_Y will result in that
+ * listener being called twice - once when all TRANSLATION_X animations end, and again when all
+ * TRANSLATION_Y animations end.
+ */
+ public void setEndListenerForProperties(
+ DynamicAnimation.OnAnimationEndListener endListener,
+ DynamicAnimation.ViewProperty... properties) {
+ for (DynamicAnimation.ViewProperty property : properties) {
+ setEndListenerForProperty(endListener, property);
+ }
+ }
+
+ /**
* Removes the end listener that would have been called when all child animations for a given
* property stopped running.
*/
@@ -197,7 +211,6 @@
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
- setChildrenVisibility();
// Set up animations for the new view, if the controller is set. If it isn't set, we'll be
// setting up animations for all children when setController is called.
@@ -208,6 +221,8 @@
mController.onChildAdded(child, index);
}
+
+ setChildrenVisibility();
}
@Override
@@ -294,6 +309,13 @@
}
}
+ /** Cancels all of the physics animations running on the given view. */
+ public void cancelAnimationsOnView(View view) {
+ for (DynamicAnimation.ViewProperty property : mController.getAnimatedProperties()) {
+ getAnimationFromView(property, view).cancel();
+ }
+ }
+
/**
* Animates the property of the given child view, then runs the callback provided when the
* animation ends.
@@ -318,6 +340,11 @@
});
}
+ // Set the start velocity if it's something other than the not-set value.
+ if (startVel != Float.MAX_VALUE) {
+ animation.setStartVelocity(startVel);
+ }
+
animation.animateToFinalPosition(value);
}
}
@@ -337,6 +364,14 @@
animateValueForChild(property, view, value, Float.MAX_VALUE, /* after */ null);
}
+ protected void animateValueForChild(
+ DynamicAnimation.ViewProperty property,
+ View view,
+ float value,
+ float startVel) {
+ animateValueForChild(property, view, value, startVel, /* after */ null);
+ }
+
/**
* Animates the property of the child at the given index to the given value, then runs the
* callback provided when the animation ends.
@@ -414,7 +449,13 @@
*/
private SpringAnimation getAnimationAtIndex(
DynamicAnimation.ViewProperty property, int index) {
- return (SpringAnimation) getChildAt(index).getTag(getTagIdForProperty(property));
+ return getAnimationFromView(property, getChildAt(index));
+ }
+
+ /** Retrieves the animation of the given property from the view via the view tag system. */
+ private SpringAnimation getAnimationFromView(
+ DynamicAnimation.ViewProperty property, View view) {
+ return (SpringAnimation) view.getTag(getTagIdForProperty(property));
}
/** Sets up SpringAnimations of the given property for each child view in the layout. */
@@ -528,4 +569,33 @@
}
}
}
+
+ /**
+ * One time end listener that waits for every animation on every given property to finish. At
+ * that point, it calls {@link #onAllAnimationsForPropertiesEnd} and then removes itself as an
+ * end listener from each property.
+ */
+ public abstract class OneTimeMultiplePropertyEndListener
+ implements DynamicAnimation.OnAnimationEndListener {
+ final DynamicAnimation.ViewProperty[] mViewProperties;
+
+ OneTimeMultiplePropertyEndListener(DynamicAnimation.ViewProperty... properties) {
+ mViewProperties = properties;
+ }
+
+ @Override
+ public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value,
+ float velocity) {
+ if (!arePropertiesAnimating(mViewProperties)) {
+ onAllAnimationsForPropertiesEnd();
+
+ for (DynamicAnimation.ViewProperty property : mViewProperties) {
+ removeEndListenerForProperty(property);
+ }
+ }
+ }
+
+ /** Called when every animation for every property has finished. */
+ abstract void onAllAnimationsForPropertiesEnd();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
index 4944732..52b8cc2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
@@ -49,7 +49,7 @@
context.display.getSize(mTmpSize)
val renderScript = RenderScript.create(context)
- val rect = Rect(0, 0,artwork.width, artwork.height)
+ val rect = Rect(0, 0, artwork.width, artwork.height)
MathUtils.fitRect(rect, Math.max(mTmpSize.x / DOWNSAMPLE, mTmpSize.y / DOWNSAMPLE))
val inBitmap = Bitmap.createScaledBitmap(artwork, rect.width(), rect.height(),
true /* filter */)
@@ -67,6 +67,7 @@
input.destroy()
output.destroy()
inBitmap.recycle()
+ blur.destroy()
val canvas = Canvas(outBitmap)
canvas.drawColor(ColorUtils.setAlphaComponent(color, COLOR_ALPHA))
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
index 4c06ff6..3808702 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
@@ -26,12 +26,15 @@
import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.notification.TransformState;
@@ -108,6 +111,11 @@
return false;
}
+ // Apps targeting Q should fix their dark mode bugs.
+ if (mRow.getEntry().targetSdk >= Build.VERSION_CODES.Q) {
+ return false;
+ }
+
int background = getBackgroundColor(view);
if (background == Color.TRANSPARENT) {
background = defaultBackgroundColor;
@@ -138,17 +146,19 @@
}
}
- private boolean childrenNeedInversion(@ColorInt int parentBackground, ViewGroup viewGroup) {
+ @VisibleForTesting
+ boolean childrenNeedInversion(@ColorInt int parentBackground, ViewGroup viewGroup) {
if (viewGroup == null) {
return false;
}
+ int backgroundColor = getBackgroundColor(viewGroup);
+ if (Color.alpha(backgroundColor) != 255) {
+ backgroundColor = ContrastColorUtil.compositeColors(backgroundColor, parentBackground);
+ backgroundColor = ColorUtils.setAlphaComponent(backgroundColor, 255);
+ }
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
- int backgroundColor = getBackgroundColor(viewGroup);
- if (backgroundColor == Color.TRANSPARENT) {
- backgroundColor = parentBackground;
- }
if (child instanceof TextView) {
int foreground = ((TextView) child).getCurrentTextColor();
if (ColorUtils.calculateContrast(foreground, backgroundColor) < 3) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 18d5bfa..30d5b65 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1881,6 +1881,8 @@
mStatusBarWindow.cancelExpandHelper();
mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor);
+ } else {
+ mBubbleController.collapseStack();
}
}
@@ -2521,6 +2523,9 @@
if (mRemoteInputManager.getController() != null) {
mRemoteInputManager.getController().closeRemoteInputs();
}
+ if (mBubbleController.isStackExpanded()) {
+ mBubbleController.collapseStack();
+ }
if (mLockscreenUserManager.isCurrentProfile(getSendingUserId())) {
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
String reason = intent.getStringExtra("reason");
@@ -2534,6 +2539,9 @@
if (mStatusBarWindowController != null) {
mStatusBarWindowController.setNotTouchable(false);
}
+ if (mBubbleController.isStackExpanded()) {
+ mBubbleController.collapseStack();
+ }
finishBarAnimations();
resetUserExpandedStates();
}
diff --git a/packages/SystemUI/tests/AndroidManifest.xml b/packages/SystemUI/tests/AndroidManifest.xml
index e73c70b..efb4ff0 100644
--- a/packages/SystemUI/tests/AndroidManifest.xml
+++ b/packages/SystemUI/tests/AndroidManifest.xml
@@ -68,6 +68,13 @@
</intent-filter>
</receiver>
+ <activity android:name="com.android.systemui.bubbles.BubblesTestActivity"
+ android:allowEmbedded="true"
+ android:documentLaunchMode="always"
+ android:excludeFromRecents="true"
+ android:exported="false"
+ android:resizeableActivity="true" />
+
<provider
android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
tools:replace="android:authorities"
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java
new file mode 100644
index 0000000..ea472da
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * 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.
+ */
+
+package com.android.systemui.bubbles;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import com.android.systemui.R;
+
+/**
+ * Referenced by NotificationTestHelper#makeBubbleMetadata
+ */
+public class BubblesTestActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
index c0aac7e..3bd582f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
@@ -22,6 +22,8 @@
import android.graphics.PointF;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
+import android.view.View;
+import android.widget.FrameLayout;
import androidx.dynamicanimation.animation.DynamicAnimation;
@@ -63,15 +65,13 @@
public void testExpansionAndCollapse() throws InterruptedException {
Runnable afterExpand = Mockito.mock(Runnable.class);
mExpandedController.expandFromStack(mExpansionPoint, afterExpand);
-
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
- testExpanded();
+ testBubblesInCorrectExpandedPositions();
Mockito.verify(afterExpand).run();
Runnable afterCollapse = Mockito.mock(Runnable.class);
mExpandedController.collapseBackToStack(afterCollapse);
-
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
testStackedAtPosition(mExpansionPoint.x, mExpansionPoint.y, -1);
@@ -79,17 +79,70 @@
}
@Test
- public void testOnChildRemoved() throws InterruptedException {
- Runnable afterExpand = Mockito.mock(Runnable.class);
- mExpandedController.expandFromStack(mExpansionPoint, afterExpand);
+ public void testOnChildAdded() throws InterruptedException {
+ expand();
+
+ // Add another new view and wait for its animation.
+ final View newView = new FrameLayout(getContext());
+ mLayout.addView(newView, 0);
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
- testExpanded();
+
+ testBubblesInCorrectExpandedPositions();
+ }
+
+ @Test
+ public void testOnChildRemoved() throws InterruptedException {
+ expand();
// Remove some views and see if the remaining child views still pass the expansion test.
mLayout.removeView(mViews.get(0));
mLayout.removeView(mViews.get(3));
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
- testExpanded();
+ testBubblesInCorrectExpandedPositions();
+ }
+
+ @Test
+ public void testBubbleDraggedNotDismissedSnapsBack() throws InterruptedException {
+ expand();
+
+ final View draggedBubble = mViews.get(0);
+ mExpandedController.prepareForBubbleDrag(draggedBubble);
+ mExpandedController.dragBubbleOut(draggedBubble, 500f, 500f);
+
+ assertEquals(500f, draggedBubble.getTranslationX(), 1f);
+ assertEquals(500f, draggedBubble.getTranslationY(), 1f);
+
+ // Snap it back and make sure it made it back correctly.
+ mExpandedController.snapBubbleBack(draggedBubble, 0f, 0f);
+ waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
+ testBubblesInCorrectExpandedPositions();
+ }
+
+ @Test
+ public void testBubbleDismissed() throws InterruptedException {
+ expand();
+
+ final View draggedBubble = mViews.get(0);
+ mExpandedController.prepareForBubbleDrag(draggedBubble);
+ mExpandedController.dragBubbleOut(draggedBubble, 500f, 500f);
+
+ assertEquals(500f, draggedBubble.getTranslationX(), 1f);
+ assertEquals(500f, draggedBubble.getTranslationY(), 1f);
+
+ // Snap it back and make sure it made it back correctly.
+ mExpandedController.prepareForDismissalWithVelocity(draggedBubble, 0f, 0f);
+ mLayout.removeView(draggedBubble);
+ waitForLayoutMessageQueue();
+ waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
+
+ assertEquals(-1, mLayout.indexOfChild(draggedBubble));
+ testBubblesInCorrectExpandedPositions();
+ }
+
+ /** Expand the stack and wait for animations to finish. */
+ private void expand() throws InterruptedException {
+ mExpandedController.expandFromStack(mExpansionPoint, Mockito.mock(Runnable.class));
+ waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
}
/** Check that children are in the correct positions for being stacked. */
@@ -108,7 +161,7 @@
}
/** Check that children are in the correct positions for being expanded. */
- private void testExpanded() {
+ private void testBubblesInCorrectExpandedPositions() {
// Check all the visible bubbles to see if they're in the right place.
for (int i = 0; i < Math.min(mLayout.getChildCount(), mMaxRenderedBubbles); i++) {
assertEquals(mBubblePadding + (i * (mBubbleSize + mBubblePadding)),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
index 31e44d7..d94b669 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
@@ -155,6 +155,11 @@
}
@Override
+ public void cancelAnimationsOnView(View view) {
+ mMainThreadHandler.post(() -> super.cancelAnimationsOnView(view));
+ }
+
+ @Override
protected void animateValueForChildAtIndex(DynamicAnimation.ViewProperty property,
int index, float value, float startVel, Runnable after) {
mMainThreadHandler.post(() ->
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index 0b24c21..a2c880a5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -36,6 +36,7 @@
import android.widget.RemoteViews;
import com.android.systemui.R;
+import com.android.systemui.bubbles.BubblesTestActivity;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;
@@ -290,7 +291,8 @@
}
private Notification.BubbleMetadata makeBubbleMetadata() {
- PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0);
+ Intent target = new Intent(mContext, BubblesTestActivity.class);
+ PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, 0);
return new Notification.BubbleMetadata.Builder()
.setIntent(bubbleIntent)
.setTitle("bubble title")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
similarity index 63%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
rename to packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
index 24aa772..637b30c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
@@ -14,7 +14,9 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.notification;
+package com.android.systemui.statusbar.notification.row.wrapper;
+
+import static org.mockito.Mockito.mock;
import android.content.Context;
import android.support.test.filters.SmallTest;
@@ -22,13 +24,15 @@
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.NotificationTestHelper;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
-import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.util.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,12 +41,26 @@
@RunWithLooper
public class NotificationViewWrapperTest extends SysuiTestCase {
- @Test
- public void constructor_doesntUseViewContext() throws Exception {
+ private View mView;
+ private ExpandableNotificationRow mRow;
+ private TestableNotificationViewWrapper mNotificationViewWrapper;
+
+ @Before
+ public void setup() throws Exception {
Assert.sMainLooper = TestableLooper.get(this).getLooper();
- new TestableNotificationViewWrapper(mContext,
- new View(mContext),
- new NotificationTestHelper(getContext()).createRow());
+ mView = mock(View.class);
+ mRow = new NotificationTestHelper(getContext()).createRow();
+ mNotificationViewWrapper = new TestableNotificationViewWrapper(mContext, mView, mRow);
+ }
+
+ @Test
+ public void childrenNeedInversion_doesntCrash_whenOpacity() {
+ LinearLayout viewGroup = new LinearLayout(mContext);
+ TextView textView = new TextView(mContext);
+ textView.setTextColor(0xcc000000);
+ viewGroup.addView(textView);
+
+ mNotificationViewWrapper.childrenNeedInversion(0xcc000000, viewGroup);
}
static class TestableNotificationViewWrapper extends NotificationViewWrapper {
diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java
index 9a1d7bf..f293328 100644
--- a/services/core/java/com/android/server/attention/AttentionManagerService.java
+++ b/services/core/java/com/android/server/attention/AttentionManagerService.java
@@ -201,11 +201,6 @@
StatsLog.write(StatsLog.ATTENTION_MANAGER_SERVICE_RESULT_REPORTED,
error);
}
-
- @Override
- public IBinder asBinder() {
- return null;
- }
});
} catch (RemoteException e) {
Slog.e(LOG_TAG, "Cannot call into the AttentionService");
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index c33a2c1..d40948b 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -830,12 +830,25 @@
new String[]{resolvedType}, PendingIntent.FLAG_CANCEL_CURRENT
| PendingIntent.FLAG_ONE_SHOT, null);
- final int flags = intent.getFlags();
Intent newIntent = new Intent(Intent.ACTION_REVIEW_PERMISSIONS);
- newIntent.setFlags(flags
- | FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+
+ int flags = intent.getFlags();
+ flags |= Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
+
+ /*
+ * Prevent reuse of review activity: Each app needs their own review activity. By
+ * default activities launched with NEW_TASK or NEW_DOCUMENT try to reuse activities
+ * with the same launch parameters (extras are ignored). Hence to avoid possible
+ * reuse force a new activity via the MULTIPLE_TASK flag.
+ *
+ * Activities that are not launched with NEW_TASK or NEW_DOCUMENT are not re-used,
+ * hence no need to add the flag in this case.
+ */
+ if ((flags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_NEW_DOCUMENT)) != 0) {
+ flags |= Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
+ }
+ newIntent.setFlags(flags);
+
newIntent.putExtra(Intent.EXTRA_PACKAGE_NAME, aInfo.packageName);
newIntent.putExtra(Intent.EXTRA_INTENT, new IntentSender(target));
if (resultRecord != null) {
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 836a50b..94f26a8 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1236,7 +1236,7 @@
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public List<SubscriptionInfo> getActiveSubscriptionInfoList() {
- return getActiveSubscriptionInfoList(false);
+ return getActiveSubscriptionInfoList(/* userVisibleonly */true);
}
/**
@@ -2858,15 +2858,24 @@
/**
* Whether system UI should hide a subscription. If it's a bundled opportunistic
* subscription, it shouldn't show up in anywhere in Settings app, dialer app,
- * or status bar.
+ * or status bar. Exception is if caller is carrier app, in which case they will
+ * want to see their own hidden subscriptions.
*
* @param info the subscriptionInfo to check against.
* @return true if this subscription should be hidden.
*
* @hide
*/
- public static boolean shouldHideSubscription(SubscriptionInfo info) {
- return (info != null && !TextUtils.isEmpty(info.getGroupUuid()) && info.isOpportunistic());
+ private boolean shouldHideSubscription(SubscriptionInfo info) {
+ if (info == null) return false;
+
+ // If hasCarrierPrivileges or canManageSubscription returns true, it means caller
+ // has carrier privilege.
+ boolean hasCarrierPrivilegePermission = (info.isEmbedded() && canManageSubscription(info))
+ || TelephonyManager.from(mContext).hasCarrierPrivileges(info.getSubscriptionId());
+
+ return (!TextUtils.isEmpty(info.getGroupUuid()) && info.isOpportunistic()
+ && !hasCarrierPrivilegePermission);
}
/**
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java b/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
index 72e57a1..8a1b21c 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
@@ -67,7 +67,7 @@
/** The network id in the wpa_supplicant */
private int mNetId;
- /** The frequency used by this group */
+ /** The frequency (in MHz) used by this group */
private int mFrequency;
/** P2P group started string pattern */
@@ -273,7 +273,7 @@
this.mNetId = netId;
}
- /** Get the operating frequency of the p2p group */
+ /** Get the operating frequency (in MHz) of the p2p group */
public int getFrequency() {
return mFrequency;
}