summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/SurfaceView.java6
-rw-r--r--core/res/res/values/config.xml10
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java2
-rw-r--r--services/core/java/com/android/server/am/AppRestrictionController.java42
-rw-r--r--services/core/java/com/android/server/pm/resolution/ComponentResolver.java11
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java20
10 files changed, 104 insertions, 9 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 6be6f9d110ad..96b1abb62dbf 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -1274,6 +1274,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
private class SurfaceViewPositionUpdateListener implements RenderNode.PositionUpdateListener {
private final int mRtSurfaceWidth;
private final int mRtSurfaceHeight;
+ private boolean mRtFirst = true;
private final SurfaceControl.Transaction mPositionChangedTransaction =
new SurfaceControl.Transaction();
@@ -1284,14 +1285,15 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
@Override
public void positionChanged(long frameNumber, int left, int top, int right, int bottom) {
- if (mRTLastReportedPosition.left == left
+ if (!mRtFirst && (mRTLastReportedPosition.left == left
&& mRTLastReportedPosition.top == top
&& mRTLastReportedPosition.right == right
&& mRTLastReportedPosition.bottom == bottom
&& mRTLastReportedSurfaceSize.x == mRtSurfaceWidth
- && mRTLastReportedSurfaceSize.y == mRtSurfaceHeight) {
+ && mRTLastReportedSurfaceSize.y == mRtSurfaceHeight)) {
return;
}
+ mRtFirst = false;
try {
if (DEBUG_POSITION) {
Log.d(TAG, String.format(
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 4284e7e4bfe1..757f40963bf7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -5682,8 +5682,8 @@
restricted level.
-->
<array name="config_bg_current_drain_threshold_to_bg_restricted">
- <item>10.0</item> <!-- regular device -->
- <item>20.0</item> <!-- low ram device -->
+ <item>4.0</item> <!-- regular device -->
+ <item>8.0</item> <!-- low ram device -->
</array>
<!-- The background current drain monitoring window size. -->
@@ -5744,6 +5744,12 @@
-->
<bool name="config_bg_prompt_fgs_with_noti_to_bg_restricted">false</bool>
+ <!-- The behavior when the system detects it's abusive, should the system prompt the user
+ to put it into the bg restricted level.
+ True - we'll show the prompt to user, False - we'll not show it.
+ -->
+ <bool name="config_bg_prompt_abusive_apps_to_bg_restricted">false</bool>
+
<!-- The types of state where we'll exempt its battery usage during that state.
The state here must be one or a combination of STATE_TYPE_* in BaseAppStateTracker.
-->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 41d340fd1f88..333482272789 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -4765,6 +4765,7 @@
<java-symbol type="integer" name="config_bg_current_drain_media_playback_min_duration" />
<java-symbol type="integer" name="config_bg_current_drain_location_min_duration" />
<java-symbol type="bool" name="config_bg_prompt_fgs_with_noti_to_bg_restricted" />
+ <java-symbol type="bool" name="config_bg_prompt_abusive_apps_to_bg_restricted" />
<java-symbol type="integer" name="config_bg_current_drain_exempted_types" />
<java-symbol type="bool" name="config_bg_current_drain_high_threshold_by_bg_location" />
<java-symbol type="drawable" name="ic_swap_horiz" />
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index b6fb82852c2f..5ef24133ca11 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -385,7 +385,9 @@ public class BubbleController {
mMainExecutor.execute(() -> {
int expandedId = INVALID_TASK_ID;
if (mStackView != null && mStackView.getExpandedBubble() != null
- && isStackExpanded() && !mStackView.isExpansionAnimating()) {
+ && isStackExpanded()
+ && !mStackView.isExpansionAnimating()
+ && !mStackView.isSwitchAnimating()) {
expandedId = mStackView.getExpandedBubble().getTaskId();
}
if (expandedId != INVALID_TASK_ID && expandedId != taskId) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
index cb88203349fa..b7c5eb06fbfa 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
@@ -1608,6 +1608,13 @@ public class BubbleStackView extends FrameLayout
}
/**
+ * Whether the stack of bubbles is animating a switch between bubbles.
+ */
+ public boolean isSwitchAnimating() {
+ return mIsBubbleSwitchAnimating;
+ }
+
+ /**
* The {@link Bubble} that is expanded, null if one does not exist.
*/
@VisibleForTesting
@@ -2467,6 +2474,10 @@ public class BubbleStackView extends FrameLayout
private void dismissBubbleIfExists(@Nullable BubbleViewProvider bubble) {
if (bubble != null && mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) {
+ if (mIsExpanded && mBubbleData.getBubbles().size() > 1) {
+ // If we have more than 1 bubble we will perform the switch animation
+ mIsBubbleSwitchAnimating = true;
+ }
mBubbleData.dismissBubbleWithKey(bubble.getKey(), Bubbles.DISMISS_USER_GESTURE);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
index 9b2702ff7bf2..1243c4718229 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
@@ -215,6 +215,7 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard
logoView.setImageDrawable(mContext.getDrawable(R.drawable.ic_qs_plus));
mEmptyStateView.<TextView>requireViewById(R.id.empty_state_title).setText(label);
mEmptyStateView.setOnClickListener(clickListener);
+ mAppButton.setOnClickListener(clickListener);
}
void showErrorMessage(@Nullable CharSequence message) {
@@ -256,6 +257,11 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard
}
@VisibleForTesting
+ Button getAppButton() {
+ return mAppButton;
+ }
+
+ @VisibleForTesting
TextView getErrorView() {
return mErrorView;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
index 01769e52c8d3..b1950eac9846 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
@@ -20,6 +20,7 @@ import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -323,6 +324,7 @@ public class WalletScreenControllerTest extends SysuiTestCase {
assertEquals(GONE, mWalletView.getCardCarousel().getVisibility());
assertEquals(VISIBLE, mWalletView.getEmptyStateView().getVisibility());
assertEquals(GONE, mWalletView.getErrorView().getVisibility());
+ assertTrue(mWalletView.getAppButton().hasOnClickListeners());
}
@Test
diff --git a/services/core/java/com/android/server/am/AppRestrictionController.java b/services/core/java/com/android/server/am/AppRestrictionController.java
index bdda0b7eb63b..a164b0a601a2 100644
--- a/services/core/java/com/android/server/am/AppRestrictionController.java
+++ b/services/core/java/com/android/server/am/AppRestrictionController.java
@@ -1095,6 +1095,14 @@ public final class AppRestrictionController {
DEVICE_CONFIG_SUBNAMESPACE_PREFIX + "restriction_exempted_packages";
/**
+ * Whether or not to show the notification for abusive apps, i.e. when the system
+ * detects it's draining significant amount of battery in the background.
+ * {@code true} - we'll show the prompt to user, {@code false} - we'll not show it.
+ */
+ static final String KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED =
+ DEVICE_CONFIG_SUBNAMESPACE_PREFIX + "prompt_abusive_apps_to_bg_restricted";
+
+ /**
* Default value to {@link #mBgAutoRestrictedBucket}.
*/
static final boolean DEFAULT_BG_AUTO_RESTRICTED_BUCKET_ON_BG_RESTRICTION = false;
@@ -1119,6 +1127,11 @@ public final class AppRestrictionController {
*/
final boolean mDefaultBgPromptFgsWithNotiToBgRestricted;
+ /**
+ * Default value to {@link #mBgPromptAbusiveAppsToBgRestricted}.
+ */
+ final boolean mDefaultBgPromptAbusiveAppToBgRestricted;
+
volatile boolean mBgAutoRestrictedBucket;
volatile boolean mRestrictedBucketEnabled;
@@ -1144,10 +1157,17 @@ public final class AppRestrictionController {
*/
volatile boolean mBgPromptFgsWithNotiOnLongRunning;
+ /**
+ * @see #KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED.
+ */
+ volatile boolean mBgPromptAbusiveAppsToBgRestricted;
+
ConstantsObserver(Handler handler, Context context) {
super(handler);
mDefaultBgPromptFgsWithNotiToBgRestricted = context.getResources().getBoolean(
com.android.internal.R.bool.config_bg_prompt_fgs_with_noti_to_bg_restricted);
+ mDefaultBgPromptAbusiveAppToBgRestricted = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_bg_prompt_abusive_apps_to_bg_restricted);
}
@Override
@@ -1172,6 +1192,9 @@ public final class AppRestrictionController {
case KEY_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING:
updateBgPromptFgsWithNotiOnLongRunning();
break;
+ case KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED:
+ updateBgPromptAbusiveAppToBgRestricted();
+ break;
case KEY_BG_RESTRICTION_EXEMPTED_PACKAGES:
updateBgRestrictionExemptedPackages();
break;
@@ -1209,6 +1232,7 @@ public final class AppRestrictionController {
updateBgLongFgsNotificationMinimalInterval();
updateBgPromptFgsWithNotiToBgRestricted();
updateBgPromptFgsWithNotiOnLongRunning();
+ updateBgPromptAbusiveAppToBgRestricted();
updateBgRestrictionExemptedPackages();
}
@@ -1251,6 +1275,13 @@ public final class AppRestrictionController {
DEFAULT_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING);
}
+ private void updateBgPromptAbusiveAppToBgRestricted() {
+ mBgPromptAbusiveAppsToBgRestricted = DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED,
+ mDefaultBgPromptAbusiveAppToBgRestricted);
+ }
+
private void updateBgRestrictionExemptedPackages() {
final String settings = DeviceConfig.getString(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
@@ -1290,6 +1321,10 @@ public final class AppRestrictionController {
pw.print('=');
pw.println(mBgPromptFgsWithNotiToBgRestricted);
pw.print(prefix);
+ pw.print(KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED);
+ pw.print('=');
+ pw.println(mBgPromptAbusiveAppsToBgRestricted);
+ pw.print(prefix);
pw.print(KEY_BG_RESTRICTION_EXEMPTED_PACKAGES);
pw.print('=');
pw.println(mBgRestrictionExemptedPackages.toString());
@@ -2296,6 +2331,13 @@ public final class AppRestrictionController {
}
void postRequestBgRestrictedIfNecessary(String packageName, int uid) {
+ if (!mBgController.mConstantsObserver.mBgPromptAbusiveAppsToBgRestricted) {
+ if (DEBUG_BG_RESTRICTION_CONTROLLER) {
+ Slog.i(TAG, "Not requesting bg-restriction due to config");
+ }
+ return;
+ }
+
final Intent intent = new Intent(Settings.ACTION_VIEW_ADVANCED_POWER_USAGE_DETAIL);
intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
diff --git a/services/core/java/com/android/server/pm/resolution/ComponentResolver.java b/services/core/java/com/android/server/pm/resolution/ComponentResolver.java
index 9aa53f18d0aa..7baec6217e2e 100644
--- a/services/core/java/com/android/server/pm/resolution/ComponentResolver.java
+++ b/services/core/java/com/android/server/pm/resolution/ComponentResolver.java
@@ -79,7 +79,8 @@ import java.util.Set;
import java.util.function.Function;
/** Resolves all Android component types [activities, services, providers and receivers]. */
-public class ComponentResolver extends ComponentResolverLocked implements Snappable {
+public class ComponentResolver extends ComponentResolverLocked implements
+ Snappable<ComponentResolverApi> {
private static final boolean DEBUG = false;
private static final String TAG = "PackageManager";
private static final boolean DEBUG_FILTERS = false;
@@ -166,11 +167,13 @@ public class ComponentResolver extends ComponentResolverLocked implements Snappa
mProvidersByAuthority = new ArrayMap<>();
mDeferProtectedFilters = true;
- mSnapshot = new SnapshotCache<ComponentResolverApi>(this, this) {
+ mSnapshot = new SnapshotCache<>(this, this) {
@Override
public ComponentResolverApi createSnapshot() {
- return new ComponentResolverSnapshot(ComponentResolver.this,
- userNeedsBadgingCache);
+ synchronized (mLock) {
+ return new ComponentResolverSnapshot(ComponentResolver.this,
+ userNeedsBadgingCache);
+ }
}};
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
index c0b4f0fe5812..ac542935fa0a 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
@@ -585,6 +585,7 @@ public final class BackgroundRestrictionTest {
DeviceConfigSession<Float> bgCurrentDrainRestrictedBucketThreshold = null;
DeviceConfigSession<Float> bgCurrentDrainBgRestrictedThreshold = null;
DeviceConfigSession<Boolean> bgPromptFgsWithNotiToBgRestricted = null;
+ DeviceConfigSession<Boolean> bgPromptAbusiveAppToBgRestricted = null;
DeviceConfigSession<Long> bgNotificationMinInterval = null;
DeviceConfigSession<Integer> bgBatteryExemptionTypes = null;
DeviceConfigSession<Boolean> bgCurrentDrainDecoupleThresholds = null;
@@ -642,6 +643,14 @@ public final class BackgroundRestrictionTest {
R.bool.config_bg_prompt_fgs_with_noti_to_bg_restricted));
bgPromptFgsWithNotiToBgRestricted.set(true);
+ bgPromptAbusiveAppToBgRestricted = new DeviceConfigSession<>(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ ConstantsObserver.KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED,
+ DeviceConfig::getBoolean,
+ mContext.getResources().getBoolean(
+ R.bool.config_bg_prompt_abusive_apps_to_bg_restricted));
+ bgPromptAbusiveAppToBgRestricted.set(true);
+
bgNotificationMinInterval = new DeviceConfigSession<>(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
ConstantsObserver.KEY_BG_ABUSIVE_NOTIFICATION_MINIMAL_INTERVAL,
@@ -1055,6 +1064,7 @@ public final class BackgroundRestrictionTest {
closeIfNotNull(bgCurrentDrainRestrictedBucketThreshold);
closeIfNotNull(bgCurrentDrainBgRestrictedThreshold);
closeIfNotNull(bgPromptFgsWithNotiToBgRestricted);
+ closeIfNotNull(bgPromptAbusiveAppToBgRestricted);
closeIfNotNull(bgNotificationMinInterval);
closeIfNotNull(bgBatteryExemptionTypes);
closeIfNotNull(bgCurrentDrainDecoupleThresholds);
@@ -1613,6 +1623,7 @@ public final class BackgroundRestrictionTest {
DeviceConfigSession<String> bgPermissionsInMonitor = null;
DeviceConfigSession<Boolean> bgCurrentDrainHighThresholdByBgLocation = null;
DeviceConfigSession<Boolean> bgCurrentDrainDecoupleThresholds = null;
+ DeviceConfigSession<Boolean> bgPromptAbusiveAppToBgRestricted = null;
mBgRestrictionController.addAppBackgroundRestrictionListener(listener);
@@ -1751,6 +1762,14 @@ public final class BackgroundRestrictionTest {
AppBatteryPolicy.DEFAULT_BG_CURRENT_DRAIN_DECOUPLE_THRESHOLD);
bgCurrentDrainDecoupleThresholds.set(true);
+ bgPromptAbusiveAppToBgRestricted = new DeviceConfigSession<>(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ ConstantsObserver.KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED,
+ DeviceConfig::getBoolean,
+ mContext.getResources().getBoolean(
+ R.bool.config_bg_prompt_abusive_apps_to_bg_restricted));
+ bgPromptAbusiveAppToBgRestricted.set(true);
+
mCurrentTimeMillis = 10_000L;
doReturn(mCurrentTimeMillis - windowMs).when(stats).getStatsStartTimestamp();
doReturn(mCurrentTimeMillis).when(stats).getStatsEndTimestamp();
@@ -2168,6 +2187,7 @@ public final class BackgroundRestrictionTest {
closeIfNotNull(bgBatteryExemptionTypes);
closeIfNotNull(bgPermissionMonitorEnabled);
closeIfNotNull(bgPermissionsInMonitor);
+ closeIfNotNull(bgPromptAbusiveAppToBgRestricted);
closeIfNotNull(bgCurrentDrainHighThresholdByBgLocation);
closeIfNotNull(bgCurrentDrainDecoupleThresholds);
}