diff options
28 files changed, 234 insertions, 127 deletions
diff --git a/api/current.txt b/api/current.txt index 8b24826a267b..54fb459b3bc8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -143,6 +143,7 @@ package android { field public static final String SET_WALLPAPER_HINTS = "android.permission.SET_WALLPAPER_HINTS"; field public static final String SIGNAL_PERSISTENT_PROCESSES = "android.permission.SIGNAL_PERSISTENT_PROCESSES"; field public static final String SMS_FINANCIAL_TRANSACTIONS = "android.permission.SMS_FINANCIAL_TRANSACTIONS"; + field public static final String START_VIEW_PERMISSION_USAGE = "android.permission.START_VIEW_PERMISSION_USAGE"; field public static final String STATUS_BAR = "android.permission.STATUS_BAR"; field public static final String SYSTEM_ALERT_WINDOW = "android.permission.SYSTEM_ALERT_WINDOW"; field public static final String TRANSMIT_IR = "android.permission.TRANSMIT_IR"; @@ -10326,6 +10327,7 @@ package android.content { field public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; field public static final String ACTION_VIEW = "android.intent.action.VIEW"; field public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; + field @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) public static final String ACTION_VIEW_PERMISSION_USAGE = "android.intent.action.VIEW_PERMISSION_USAGE"; field public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; field @Deprecated public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; field public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index b9a4b52d6c48..f53ac1b77021 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -298,6 +298,7 @@ message Atom { VehicleMapServicePacketFailureReported vms_packet_failure_reported = 202; CarPowerStateChanged car_power_state_changed = 203; GarageModeInfo garage_mode_info = 204; + TestAtomReported test_atom_reported = 205 [(log_from_module) = "cts"]; } // Pulled events will start at field 10000. @@ -3342,6 +3343,23 @@ message BinaryPushStateChanged { optional int32 user_id = 8; } +/* Test atom, is not logged anywhere */ +message TestAtomReported { + repeated AttributionNode attribution_node = 1; + optional int32 int_field = 2; + optional int64 long_field = 3; + optional float float_field = 4; + optional string string_field = 5; + optional bool boolean_field = 6; + enum State { + UNKNOWN = 0; + OFF = 1; + ON = 2; + } + optional State state = 7; + optional TrainExperimentIds bytes_field = 8 [(android.os.statsd.log_mode) = MODE_BYTES]; +} + /** Represents USB port overheat event. */ message UsbPortOverheatEvent { /* Temperature of USB port at USB plug event, in 1/10ths of degree C. */ diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 50d1785c6059..9e5fcfb6f73e 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1881,6 +1881,31 @@ public class Intent implements Parcelable, Cloneable { "android.intent.action.REVIEW_PERMISSIONS"; /** + * Activity action: Launch UI to show information about the usage + * of a given permission. This action would be handled by apps that + * want to show details about how and why given permission is being + * used. + * <p> + * <strong>Important:</strong>You must protect the activity that handles + * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE + * START_VIEW_PERMISSION_USAGE} permission to ensure that only the + * system can launch this activity. The system will not launch + * activities that are not properly protected. + * + * <p> + * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission + * for which the launched UI would be targeted. + * </p> + * <p> + * Output: Nothing. + * </p> + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) + public static final String ACTION_VIEW_PERMISSION_USAGE = + "android.intent.action.VIEW_PERMISSION_USAGE"; + + /** * Activity action: Launch UI to manage a default app. * <p> * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 57b770455817..b634bb2a6e9e 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4213,6 +4213,15 @@ android:description="@string/permdesc_bindCarrierServices" android:protectionLevel="signature|privileged" /> + <!-- + Allows the holder to start the permission usage screen for an app. + <p>Protection level: signature|installer + --> + <permission android:name="android.permission.START_VIEW_PERMISSION_USAGE" + android:label="@string/permlab_startViewPermissionUsage" + android:description="@string/permdesc_startViewPermissionUsage" + android:protectionLevel="signature|installer" /> + <!-- Allows an application to query whether DO_NOT_ASK_CREDENTIALS_ON_BOOT flag is set. @hide --> diff --git a/core/res/res/layout/media_route_chooser_dialog.xml b/core/res/res/layout/media_route_chooser_dialog.xml index d1c6267ea4e7..cd1c74fd7d7d 100644 --- a/core/res/res/layout/media_route_chooser_dialog.xml +++ b/core/res/res/layout/media_route_chooser_dialog.xml @@ -40,7 +40,7 @@ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:paddingLeft="16dp" + android:paddingStart="16dp" android:text="@string/media_route_chooser_searching" /> </LinearLayout> diff --git a/core/res/res/layout/media_route_list_item.xml b/core/res/res/layout/media_route_list_item.xml index bdca433c1c58..e8460db69582 100644 --- a/core/res/res/layout/media_route_list_item.xml +++ b/core/res/res/layout/media_route_list_item.xml @@ -34,6 +34,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" + android:textAlignment="viewStart" android:textAppearance="?android:attr/textAppearanceMedium" android:duplicateParentState="true" /> @@ -42,6 +43,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" + android:textAlignment="viewStart" android:textAppearance="?android:attr/textAppearanceSmall" android:duplicateParentState="true" /> </LinearLayout> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 5652c85cf28f..0cf950043079 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1726,6 +1726,11 @@ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permdesc_access_notification_policy">Allows the app to read and write Do Not Disturb configuration.</string> + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> + <string name="permlab_startViewPermissionUsage">start view permission usage</string> + <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> + <string name="permdesc_startViewPermissionUsage">Allows the holder to start the permission usage for an app. Should never be needed for normal apps.</string> + <!-- Policy administration --> <!-- Title of policy access to limiting the user's password choices --> diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index 835cedf9cdd9..f5dab01d1b09 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -131,6 +131,8 @@ public class CarStatusBar extends StatusBar implements // The container for the notifications. private CarNotificationView mNotificationView; private RecyclerView mNotificationList; + // The controller for the notification view. + private NotificationViewController mNotificationViewController; // The state of if the notification list is currently showing the bottom. private boolean mNotificationListAtBottom; // Was the notification list at the bottom when the user first touched the screen @@ -544,7 +546,7 @@ public class CarStatusBar extends StatusBar implements } }); - NotificationViewController mNotificationViewController = new NotificationViewController( + mNotificationViewController = new NotificationViewController( mNotificationView, PreprocessingManager.getInstance(mContext), carNotificationListener, @@ -651,9 +653,11 @@ public class CarStatusBar extends StatusBar implements mStatusBarWindowController.setPanelVisible(false); mNotificationView.setVisibility(View.INVISIBLE); mNotificationList.setClipBounds(null); + mNotificationViewController.setIsInForeground(false); // let the status bar know that the panel is closed setPanelExpanded(false); } else { + mNotificationViewController.setIsInForeground(true); // let the status bar know that the panel is open mNotificationView.setVisibleNotificationsAsSeen(); setPanelExpanded(true); diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp index 62de2ba45455..c3051245e723 100644 --- a/packages/NetworkStack/Android.bp +++ b/packages/NetworkStack/Android.bp @@ -108,6 +108,8 @@ android_app { defaults: ["NetworkStackAppCommon"], certificate: "platform", manifest: "AndroidManifest_InProcess.xml", + // InProcessNetworkStack is a replacement for NetworkStack + overrides: ["NetworkStack"], } // Updatable network stack packaged as an application diff --git a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java index b8e1251dd79a..6fd874989c35 100644 --- a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java +++ b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java @@ -18,11 +18,11 @@ package com.android.settingslib.location; import android.app.AppOpsManager; import android.content.Context; +import android.content.PermissionChecker; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.Drawable; -import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.text.format.DateUtils; @@ -48,10 +48,15 @@ public class RecentLocationApps { private static final long RECENT_TIME_INTERVAL_MILLIS = DateUtils.DAY_IN_MILLIS; @VisibleForTesting - static final int[] LOCATION_OPS = new int[] { + static final int[] LOCATION_REQUEST_OPS = new int[]{ AppOpsManager.OP_MONITOR_LOCATION, AppOpsManager.OP_MONITOR_HIGH_POWER_LOCATION, }; + @VisibleForTesting + static final int[] LOCATION_PERMISSION_OPS = new int[]{ + AppOpsManager.OP_FINE_LOCATION, + AppOpsManager.OP_COARSE_LOCATION, + }; private final PackageManager mPackageManager; private final Context mContext; @@ -67,11 +72,13 @@ public class RecentLocationApps { * Fills a list of applications which queried location recently within specified time. * Apps are sorted by recency. Apps with more recent location requests are in the front. */ - public List<Request> getAppList() { + public List<Request> getAppList(boolean showSystemApps) { + // Retrieve a location usage list from AppOps + PackageManager pm = mContext.getPackageManager(); // Retrieve a location usage list from AppOps AppOpsManager aoManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); - List<AppOpsManager.PackageOps> appOps = aoManager.getPackagesForOps(LOCATION_OPS); + List<AppOpsManager.PackageOps> appOps = aoManager.getPackagesForOps(LOCATION_REQUEST_OPS); final int appOpsCount = appOps != null ? appOps.size() : 0; @@ -83,26 +90,58 @@ public class RecentLocationApps { for (int i = 0; i < appOpsCount; ++i) { AppOpsManager.PackageOps ops = appOps.get(i); - // Don't show the Android System in the list - it's not actionable for the user. - // Also don't show apps belonging to background users except managed users. String packageName = ops.getPackageName(); int uid = ops.getUid(); - int userId = UserHandle.getUserId(uid); - boolean isAndroidOs = - (uid == Process.SYSTEM_UID) && ANDROID_SYSTEM_PACKAGE_NAME.equals(packageName); - if (isAndroidOs || !profiles.contains(new UserHandle(userId))) { + final UserHandle user = UserHandle.getUserHandleForUid(uid); + + // Don't show apps belonging to background users except managed users. + if (!profiles.contains(user)) { continue; } - Request request = getRequestFromOps(now, ops); - if (request != null) { - requests.add(request); + + // Don't show apps that do not have user sensitive location permissions + boolean showApp = true; + if (!showSystemApps) { + for (int op : LOCATION_PERMISSION_OPS) { + final String permission = AppOpsManager.opToPermission(op); + final int permissionFlags = pm.getPermissionFlags(permission, packageName, + user); + if (PermissionChecker.checkPermission(mContext, permission, -1, uid, + packageName) + == PermissionChecker.PERMISSION_GRANTED) { + if ((permissionFlags + & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED) + == 0) { + showApp = false; + break; + } + } else { + if ((permissionFlags + & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED) == 0) { + showApp = false; + break; + } + } + } + } + if (showApp) { + Request request = getRequestFromOps(now, ops); + if (request != null) { + requests.add(request); + } } } return requests; } - public List<Request> getAppListSorted() { - List<Request> requests = getAppList(); + /** + * Gets a list of apps that requested for location recently, sorting by recency. + * + * @param showSystemApps whether includes system apps in the list. + * @return the list of apps that recently requested for location. + */ + public List<Request> getAppListSorted(boolean showSystemApps) { + List<Request> requests = getAppList(showSystemApps); // Sort the list of Requests by recency. Most recent request first. Collections.sort(requests, Collections.reverseOrder(new Comparator<Request>() { @Override diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java index 8bd5fd2163ae..7a553fc91ff6 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java @@ -16,8 +16,8 @@ import android.content.res.Resources; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; - import android.util.LongSparseLongArray; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -75,7 +75,8 @@ public class RecentLocationAppsTest { long[] testRequestTime = {ONE_MIN_AGO, TWENTY_THREE_HOURS_AGO, TWO_DAYS_AGO}; List<PackageOps> appOps = createTestPackageOpsList(TEST_PACKAGE_NAMES, testRequestTime); - when(mAppOpsManager.getPackagesForOps(RecentLocationApps.LOCATION_OPS)).thenReturn(appOps); + when(mAppOpsManager.getPackagesForOps(RecentLocationApps.LOCATION_REQUEST_OPS)).thenReturn( + appOps); mockTestApplicationInfos(mTestUserId, TEST_PACKAGE_NAMES); mRecentLocationApps = new RecentLocationApps(mContext); @@ -83,7 +84,7 @@ public class RecentLocationAppsTest { @Test public void testGetAppList_shouldFilterRecentApps() { - List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppList(); + List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppList(true); // Only two of the apps have requested location within 15 min. assertThat(requests).hasSize(2); // Make sure apps are ordered by recency @@ -107,11 +108,12 @@ public class RecentLocationAppsTest { {ONE_MIN_AGO, TWENTY_THREE_HOURS_AGO, TWO_DAYS_AGO, ONE_MIN_AGO}; List<PackageOps> appOps = createTestPackageOpsList(TEST_PACKAGE_NAMES, testRequestTime); appOps.add(androidSystemPackageOps); - when(mAppOpsManager.getPackagesForOps(RecentLocationApps.LOCATION_OPS)).thenReturn(appOps); + when(mAppOpsManager.getPackagesForOps(RecentLocationApps.LOCATION_REQUEST_OPS)).thenReturn( + appOps); mockTestApplicationInfos( Process.SYSTEM_UID, RecentLocationApps.ANDROID_SYSTEM_PACKAGE_NAME); - List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppList(); + List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppList(true); // Android OS shouldn't show up in the list of apps. assertThat(requests).hasSize(2); // Make sure apps are ordered by recency @@ -133,7 +135,7 @@ public class RecentLocationAppsTest { private List<PackageOps> createTestPackageOpsList(String[] packageNameList, long[] time) { List<PackageOps> packageOpsList = new ArrayList<>(); - for (int i = 0; i < packageNameList.length ; i++) { + for (int i = 0; i < packageNameList.length; i++) { PackageOps packageOps = createPackageOps( packageNameList[i], TEST_UID, @@ -156,11 +158,11 @@ public class RecentLocationAppsTest { private OpEntry createOpEntryWithTime(int op, long time, int duration) { final LongSparseLongArray accessTimes = new LongSparseLongArray(); accessTimes.put(AppOpsManager.makeKey(AppOpsManager.UID_STATE_TOP, - AppOpsManager.OP_FLAG_SELF), time); + AppOpsManager.OP_FLAG_SELF), time); final LongSparseLongArray durations = new LongSparseLongArray(); durations.put(AppOpsManager.makeKey(AppOpsManager.UID_STATE_TOP, - AppOpsManager.OP_FLAG_SELF), duration); + AppOpsManager.OP_FLAG_SELF), duration); return new OpEntry(op, false, AppOpsManager.MODE_ALLOWED, accessTimes, - null /*rejectTimes*/, durations, null /* proxyUids */, null /* proxyPackages */); + null /*rejectTimes*/, durations, null /* proxyUids */, null /* proxyPackages */); } } diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index c2495b586144..94259416d274 100644 --- a/packages/SystemUI/Android.bp +++ b/packages/SystemUI/Android.bp @@ -58,6 +58,7 @@ android_library { "androidx.arch.core_core-runtime", "androidx.lifecycle_lifecycle-extensions", "androidx.dynamicanimation_dynamicanimation", + "iconloader_base", "SystemUI-tags", "SystemUI-proto", "dagger2-2.19", diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml index 29376ce01e4f..796123db7c79 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml @@ -38,6 +38,7 @@ android:clipChildren="false" android:clipToPadding="false" android:padding="0dp" + android:fitsSystemWindows="true" android:layout_gravity="center"> <com.android.keyguard.KeyguardSecurityViewFlipper android:id="@+id/view_flipper" diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index fbb439af7c51..62974238cd9f 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -252,6 +252,9 @@ <!-- size at which Notification icons will be drawn on Ambient Display --> <dimen name="status_bar_icon_drawing_size_dark">@*android:dimen/notification_header_icon_size_ambient</dimen> + <!-- size of notification icons on AOD --> + <dimen name="dark_shelf_icon_size">16dp</dimen> + <!-- opacity at which Notification icons will be drawn in the status bar --> <item type="dimen" name="status_bar_icon_drawing_alpha">90%</item> diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl index 670980420a57..577e3bbefdad 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl @@ -134,9 +134,4 @@ oneway interface IOverviewProxy { * Sent when some system ui state changes. */ void onSystemUiStateChanged(int stateFlags) = 16; - - /** - * Sent when the scrim colors (based on wallpaper) change. - */ - void onScrimColorsChanged(int color, int type) = 17; } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index d051defc1f25..0914fb8330be 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -20,6 +20,7 @@ import android.app.AlertDialog; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.res.ColorStateList; +import android.graphics.Rect; import android.metrics.LogMaker; import android.os.UserHandle; import android.util.AttributeSet; @@ -139,7 +140,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe getSecurityView(mCurrentSecuritySelection).onResume(reason); } updateBiometricRetry(); - updatePaddings(); } @Override @@ -180,7 +180,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe } int index = event.findPointerIndex(mActivePointerId); int touchSlop = mViewConfiguration.getScaledTouchSlop(); - if (mCurrentSecurityView != null + if (mCurrentSecurityView != null && index != -1 && mStartTouchY - event.getY(index) > touchSlop) { mIsDragging = true; return true; @@ -319,17 +319,11 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe } @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - updatePaddings(); - } - - private void updatePaddings() { - int bottomPadding = getRootWindowInsets().getSystemWindowInsets().bottom; - if (getPaddingBottom() == bottomPadding) { - return; - } - setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), bottomPadding); + protected boolean fitSystemWindows(Rect insets) { + // Consume bottom insets because we're setting the padding locally (for IME and navbar.) + setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), insets.bottom); + insets.bottom = 0; + return false; } private void showDialog(String title, String message) { diff --git a/packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java b/packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java index de1069064518..05665b5ae4a2 100644 --- a/packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java +++ b/packages/SystemUI/src/com/android/systemui/colorextraction/SysuiColorExtractor.java @@ -16,8 +16,6 @@ package com.android.systemui.colorextraction; -import android.annotation.ColorInt; -import android.annotation.IntDef; import android.app.WallpaperColors; import android.app.WallpaperManager; import android.content.Context; @@ -36,13 +34,10 @@ import com.android.internal.colorextraction.types.ExtractionType; import com.android.internal.colorextraction.types.Tonal; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.Dumpable; -import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.statusbar.policy.ConfigurationController; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import javax.inject.Inject; @@ -55,41 +50,23 @@ import javax.inject.Singleton; public class SysuiColorExtractor extends ColorExtractor implements Dumpable, ConfigurationController.ConfigurationListener { private static final String TAG = "SysuiColorExtractor"; - - public static final int SCRIM_TYPE_REGULAR = 1; - public static final int SCRIM_TYPE_LIGHT = 2; - public static final int SCRIM_TYPE_DARK = 3; - - @IntDef(prefix = {"SCRIM_TYPE_"}, value = { - SCRIM_TYPE_REGULAR, - SCRIM_TYPE_LIGHT, - SCRIM_TYPE_DARK - }) - @Retention(RetentionPolicy.SOURCE) - public @interface ScrimType { - } - private final Tonal mTonal; - private final OverviewProxyService mOverviewProxyService; private boolean mWallpaperVisible; private boolean mHasBackdrop; // Colors to return when the wallpaper isn't visible private final GradientColors mWpHiddenColors; @Inject - public SysuiColorExtractor(Context context, ConfigurationController configurationController, - OverviewProxyService overviewProxyService) { - this(context, new Tonal(context), configurationController, true, overviewProxyService); + public SysuiColorExtractor(Context context, ConfigurationController configurationController) { + this(context, new Tonal(context), configurationController, true); } @VisibleForTesting public SysuiColorExtractor(Context context, ExtractionType type, - ConfigurationController configurationController, boolean registerVisibility, - OverviewProxyService overviewProxyService) { + ConfigurationController configurationController, boolean registerVisibility) { super(context, type, false /* immediately */); mTonal = type instanceof Tonal ? (Tonal) type : new Tonal(context); mWpHiddenColors = new GradientColors(); - mOverviewProxyService = overviewProxyService; configurationController.addCallback(this); WallpaperColors systemColors = getWallpaperColors(WallpaperManager.FLAG_SYSTEM); @@ -133,35 +110,17 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable, return; } + super.onColorsChanged(colors, which); + if ((which & WallpaperManager.FLAG_SYSTEM) != 0) { updateDefaultGradients(colors); } - super.onColorsChanged(colors, which); } @Override public void onUiModeChanged() { WallpaperColors systemColors = getWallpaperColors(WallpaperManager.FLAG_SYSTEM); updateDefaultGradients(systemColors); - triggerColorsChanged(WallpaperManager.FLAG_SYSTEM); - } - - @Override - protected void triggerColorsChanged(int which) { - super.triggerColorsChanged(which); - - if (mWpHiddenColors != null && (which & WallpaperManager.FLAG_SYSTEM) != 0) { - @ColorInt int colorInt = mWpHiddenColors.getMainColor(); - @ScrimType int scrimType; - if (colorInt == Tonal.MAIN_COLOR_LIGHT) { - scrimType = SCRIM_TYPE_LIGHT; - } else if (colorInt == Tonal.MAIN_COLOR_DARK) { - scrimType = SCRIM_TYPE_DARK; - } else { - scrimType = SCRIM_TYPE_REGULAR; - } - mOverviewProxyService.onScrimColorsChanged(colorInt, scrimType); - } } /** diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index e87ff520e028..acc0197c07b8 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -25,6 +25,7 @@ import android.app.ActivityManager; import android.app.Dialog; import android.app.KeyguardManager; import android.app.PendingIntent; +import android.app.StatusBarManager; import android.app.WallpaperManager; import android.app.admin.DevicePolicyManager; import android.app.trust.TrustManager; @@ -38,7 +39,9 @@ import android.database.ContentObserver; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.net.ConnectivityManager; +import android.os.Binder; import android.os.Handler; +import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; @@ -75,6 +78,7 @@ import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.colorextraction.drawable.ScrimDrawable; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyProperties; import com.android.internal.util.EmergencyAffordanceManager; @@ -1501,6 +1505,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final Context mContext; private final MyAdapter mAdapter; + private final IStatusBarService mStatusBarService; + private final IBinder mToken = new Binder(); private MultiListLayout mGlobalActionsLayout; private Drawable mBackgroundDrawable; private final SysuiColorExtractor mColorExtractor; @@ -1516,6 +1522,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mContext = context; mAdapter = adapter; mColorExtractor = Dependency.get(SysuiColorExtractor.class); + mStatusBarService = Dependency.get(IStatusBarService.class); // Window initialization Window window = getWindow(); @@ -1574,6 +1581,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mContext, true, RotationUtils.ROTATION_NONE); } + // Disable rotation suggestions, if enabled + setRotationSuggestionsEnabled(false); + FrameLayout panelContainer = new FrameLayout(mContext); FrameLayout.LayoutParams panelParams = new FrameLayout.LayoutParams( @@ -1732,11 +1742,24 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } + private void setRotationSuggestionsEnabled(boolean enabled) { + try { + final int userId = Binder.getCallingUserHandle().getIdentifier(); + final int what = enabled + ? StatusBarManager.DISABLE2_NONE + : StatusBarManager.DISABLE2_ROTATE_SUGGESTIONS; + mStatusBarService.disable2ForUser(what, mToken, mContext.getPackageName(), userId); + } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); + } + } + private void resetOrientation() { if (mResetOrientationData != null) { RotationPolicy.setRotationLockAtAngle(mContext, mResetOrientationData.locked, mResetOrientationData.rotation); } + setRotationSuggestionsEnabled(true); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index c5591cf9d947..78c7cd406ba1 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -31,7 +31,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_B import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; -import android.annotation.ColorInt; import android.annotation.FloatRange; import android.app.ActivityTaskManager; import android.content.BroadcastReceiver; @@ -60,7 +59,6 @@ import com.android.internal.policy.ScreenDecorationsUtils; import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.SysUiServiceProvider; -import com.android.systemui.colorextraction.SysuiColorExtractor.ScrimType; import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener; import com.android.systemui.shared.recents.IOverviewProxy; import com.android.systemui.shared.recents.ISystemUiProxy; @@ -537,16 +535,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis dispatchNavButtonBounds(); } - public void onScrimColorsChanged(@ColorInt int color, @ScrimType int type) { - if (mOverviewProxy != null) { - try { - mOverviewProxy.onScrimColorsChanged(color, type); - } catch (RemoteException e) { - Log.e(TAG_OPS, "Failed to call onScrimColorsChanged()", e); - } - } - } - private void dispatchNavButtonBounds() { if (mOverviewProxy != null && mActiveNavBarRegion != null) { try { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 2cca701ef582..d202190724f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -71,6 +71,7 @@ public class NotificationShelf extends ActivatableNotificationView implements private int mIconAppearTopPadding; private int mShelfAppearTranslation; private float mDarkShelfPadding; + private float mDarkShelfIconSize; private int mStatusBarHeight; private int mStatusBarPaddingStart; private AmbientState mAmbientState; @@ -151,6 +152,7 @@ public class NotificationShelf extends ActivatableNotificationView implements mScrollFastThreshold = res.getDimensionPixelOffset(R.dimen.scroll_fast_threshold); mShowNotificationShelf = res.getBoolean(R.bool.config_showNotificationShelf); mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); + mDarkShelfIconSize = res.getDimensionPixelOffset(R.dimen.dark_shelf_icon_size); mGapHeight = res.getDimensionPixelSize(R.dimen.qs_notification_padding); if (!mShowNotificationShelf) { @@ -705,12 +707,13 @@ public class NotificationShelf extends ActivatableNotificationView implements } notificationIconPosition += iconTopPadding; float shelfIconPosition = getTranslationY() + icon.getTop(); - shelfIconPosition += (icon.getHeight() - icon.getIconScale() * mIconSize) / 2.0f; + float iconSize = mDark ? mDarkShelfIconSize : mIconSize; + shelfIconPosition += (icon.getHeight() - icon.getIconScale() * iconSize) / 2.0f; float iconYTranslation = NotificationUtils.interpolate( notificationIconPosition - shelfIconPosition, 0, transitionAmount); - float shelfIconSize = mIconSize * icon.getIconScale(); + float shelfIconSize = iconSize * icon.getIconScale(); float alpha = 1.0f; boolean noIcon = !row.isShowingIcon(); if (noIcon) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java index 3450a8a8ebfb..f93c5f0827ad 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java @@ -29,6 +29,7 @@ import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.hardware.biometrics.BiometricSourceType; import android.os.Handler; +import android.os.Trace; import android.util.AttributeSet; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; @@ -256,9 +257,12 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange if (getDrawable() == animation && state == getState() && doesAnimationLoop(iconAnimRes)) { animation.start(); + } else { + Trace.endAsyncSection("LockIcon#Animation", state); } } }); + Trace.beginAsyncSection("LockIcon#Animation", state); animation.start(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java b/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java index 3d3c29564910..67df60a3dcfc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java +++ b/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java @@ -34,14 +34,10 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.colorextraction.types.Tonal; import com.android.systemui.SysuiTestCase; -import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.statusbar.policy.ConfigurationController; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; /** * Tests color extraction generation. @@ -57,13 +53,6 @@ public class SysuiColorExtractorTests extends SysuiTestCase { ColorExtractor.TYPE_NORMAL, ColorExtractor.TYPE_DARK, ColorExtractor.TYPE_EXTRA_DARK}; - @Mock - private OverviewProxyService mOverviewProxyService; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } @Test public void getColors_usesGreyIfWallpaperNotVisible() { @@ -129,8 +118,7 @@ public class SysuiColorExtractorTests extends SysuiTestCase { Tonal tonal = mock(Tonal.class); ConfigurationController configurationController = mock(ConfigurationController.class); SysuiColorExtractor sysuiColorExtractor = new SysuiColorExtractor(getContext(), - tonal, configurationController, false /* registerVisibility */, - mOverviewProxyService); + tonal, configurationController, false /* registerVisibility */); verify(configurationController).addCallback(eq(sysuiColorExtractor)); reset(tonal); @@ -145,7 +133,7 @@ public class SysuiColorExtractorTests extends SysuiTestCase { outGradientColorsNormal.set(colors); outGradientColorsDark.set(colors); outGradientColorsExtraDark.set(colors); - }, mock(ConfigurationController.class), false, mOverviewProxyService); + }, mock(ConfigurationController.class), false); } private void simulateEvent(SysuiColorExtractor extractor) { diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java index 7605ccb5aeda..e14846863946 100644 --- a/services/core/java/com/android/server/attention/AttentionManagerService.java +++ b/services/core/java/com/android/server/attention/AttentionManagerService.java @@ -270,7 +270,7 @@ public class AttentionManagerService extends SystemService { return; } if (!userState.mCurrentAttentionCheck.mCallbackInternal.equals(callbackInternal)) { - Slog.e(LOG_TAG, "Cannot cancel a non-current request"); + Slog.w(LOG_TAG, "Cannot cancel a non-current request"); return; } cancel(userState); diff --git a/services/core/java/com/android/server/power/AttentionDetector.java b/services/core/java/com/android/server/power/AttentionDetector.java index 3262eb67a052..14f1196ab3a2 100644 --- a/services/core/java/com/android/server/power/AttentionDetector.java +++ b/services/core/java/com/android/server/power/AttentionDetector.java @@ -75,6 +75,8 @@ public class AttentionDetector { */ private final AtomicBoolean mRequested; + private long mLastActedOnNextScreenDimming; + /** * Monotonously increasing ID for the requests sent. */ @@ -150,6 +152,9 @@ public class AttentionDetector { } public long updateUserActivity(long nextScreenDimming) { + if (nextScreenDimming == mLastActedOnNextScreenDimming) { + return nextScreenDimming; + } if (!mIsSettingEnabled) { return nextScreenDimming; } @@ -190,13 +195,14 @@ public class AttentionDetector { // afterwards if AttentionManager couldn't deliver it. mRequested.set(true); mRequestId++; + mLastActedOnNextScreenDimming = nextScreenDimming; mCallback = new AttentionCallbackInternalImpl(mRequestId); + Slog.v(TAG, "Checking user attention, ID: " + mRequestId); final boolean sent = mAttentionManager.checkAttention(getAttentionTimeout(), mCallback); if (!sent) { mRequested.set(false); } - Slog.v(TAG, "Checking user attention, ID: " + mRequestId); return whenToCheck; } diff --git a/services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java b/services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java index c30a7dd8321c..a63f49b1fe3d 100644 --- a/services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java +++ b/services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.atMost; +import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -182,10 +183,22 @@ public class AttentionDetectorTest extends AndroidTestCase { } @Test + public void testOnUserActivity_ignoresIfAlreadyDoneForThatNextScreenDimming() { + long when = registerAttention(); + verify(mAttentionManagerInternal).checkAttention(anyLong(), any()); + assertThat(when).isLessThan(mNextDimming); + clearInvocations(mAttentionManagerInternal); + + long redundantWhen = mAttentionDetector.updateUserActivity(mNextDimming); + assertThat(redundantWhen).isEqualTo(mNextDimming); + verify(mAttentionManagerInternal, never()).checkAttention(anyLong(), any()); + } + + @Test public void testOnUserActivity_skipsIfAlreadyScheduled() { registerAttention(); reset(mAttentionManagerInternal); - long when = mAttentionDetector.updateUserActivity(mNextDimming); + long when = mAttentionDetector.updateUserActivity(mNextDimming + 1); verify(mAttentionManagerInternal, never()).checkAttention(anyLong(), any()); assertThat(when).isLessThan(mNextDimming); } diff --git a/services/usage/java/com/android/server/usage/AppStandbyController.java b/services/usage/java/com/android/server/usage/AppStandbyController.java index 77866279a751..75e8fb5a34fe 100644 --- a/services/usage/java/com/android/server/usage/AppStandbyController.java +++ b/services/usage/java/com/android/server/usage/AppStandbyController.java @@ -1356,7 +1356,7 @@ public class AppStandbyController { private void fetchCarrierPrivilegedAppsLocked() { TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class); - mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivileges(); + mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivilegesForAllPhones(); mHaveCarrierPrivilegedApps = true; if (DEBUG) { Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 328a0a7a9512..dab1e6f4abde 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7475,7 +7475,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.checkCarrierPrivilegesForPackage(pkgName); + return telephony.checkCarrierPrivilegesForPackage(getSubId(), pkgName); } catch (RemoteException ex) { Rlog.e(TAG, "checkCarrierPrivilegesForPackage RemoteException", ex); } catch (NullPointerException ex) { @@ -7526,7 +7526,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.getPackagesWithCarrierPrivileges(); + return telephony.getPackagesWithCarrierPrivileges(getPhoneId()); } } catch (RemoteException ex) { Rlog.e(TAG, "getPackagesWithCarrierPrivileges RemoteException", ex); @@ -7537,6 +7537,22 @@ public class TelephonyManager { } /** @hide */ + public List<String> getPackagesWithCarrierPrivilegesForAllPhones() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.getPackagesWithCarrierPrivilegesForAllPhones(); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones NPE", ex); + } + return Collections.EMPTY_LIST; + } + + + /** @hide */ @SystemApi @SuppressLint("Doclava125") public void dial(String number) { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index e8ce2b457ab4..68fd9ac8d6bd 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1000,7 +1000,7 @@ interface ITelephony { /** * Similar to above, but check for the package whose name is pkgName. */ - int checkCarrierPrivilegesForPackage(String pkgName); + int checkCarrierPrivilegesForPackage(int subId, String pkgName); /** * Similar to above, but check across all phones. @@ -1357,9 +1357,14 @@ interface ITelephony { in PhoneAccountHandle phoneAccountHandle, boolean enabled); /** - * Returns a list of packages that have carrier privileges. + * Returns a list of packages that have carrier privileges for the specific phone. */ - List<String> getPackagesWithCarrierPrivileges(); + List<String> getPackagesWithCarrierPrivileges(int phoneId); + + /** + * Returns a list of packages that have carrier privileges. + */ + List<String> getPackagesWithCarrierPrivilegesForAllPhones(); /** * Return the application ID for the app type. |