diff options
34 files changed, 416 insertions, 101 deletions
diff --git a/core/java/android/companion/CompanionDeviceManager.java b/core/java/android/companion/CompanionDeviceManager.java index 4400ad3316e3..86a30cf0c846 100644 --- a/core/java/android/companion/CompanionDeviceManager.java +++ b/core/java/android/companion/CompanionDeviceManager.java @@ -214,10 +214,12 @@ public final class CompanionDeviceManager { return; } try { - mService.requestNotificationAccess(component).send(); + IntentSender intentSender = mService.requestNotificationAccess(component) + .getIntentSender(); + mContext.startIntentSender(intentSender, null, 0, 0, 0); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } catch (PendingIntent.CanceledException e) { + } catch (IntentSender.SendIntentException e) { throw new RuntimeException(e); } } diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index 88c1627f955b..6834ba816910 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -16,29 +16,26 @@ package android.content.res; -import android.graphics.Point; -import android.graphics.Rect; -import android.util.DisplayMetrics; -import android.view.Display; -import android.view.DisplayInfo; -import com.android.internal.util.XmlUtils; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlSerializer; - import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.Config; +import android.graphics.Rect; import android.os.Build; import android.os.LocaleList; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; +import android.view.DisplayInfo; import android.view.View; +import com.android.internal.util.XmlUtils; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlSerializer; + import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1818,9 +1815,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration } /** - * Return whether the screen has a wide color gamut. + * Return whether the screen has a wide color gamut and wide color gamut rendering + * is supported by this device. * - * @return true if the screen has a wide color gamut, false otherwise + * @return true if the screen has a wide color gamut and wide color gamut rendering + * is supported, false otherwise */ public boolean isScreenWideColorGamut() { return (colorMode & COLOR_MODE_WIDE_COLOR_GAMUT_MASK) == COLOR_MODE_WIDE_COLOR_GAMUT_YES; diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index 0611f175e809..2b82c77d5909 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -936,6 +936,11 @@ public final class StrictMode { return this; } + Builder disable(int bit) { + mMask &= ~bit; + return this; + } + /** * Construct the VmPolicy instance. * @@ -1214,7 +1219,13 @@ public final class StrictMode { if (IS_USER_BUILD) { setCloseGuardEnabled(false); } else { - VmPolicy.Builder policyBuilder = new VmPolicy.Builder().detectAll().penaltyDropBox(); + VmPolicy.Builder policyBuilder = new VmPolicy.Builder().detectAll(); + if (!IS_ENG_BUILD) { + // Activity leak detection causes too much slowdown for userdebug because of the + // GCs. + policyBuilder = policyBuilder.disable(DETECT_VM_ACTIVITY_LEAKS); + } + policyBuilder = policyBuilder.penaltyDropBox(); if (IS_ENG_BUILD) { policyBuilder.penaltyLog(); } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index bdc27f269427..88930bada15c 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5216,6 +5216,15 @@ public final class Settings { public static final String USER_SETUP_COMPLETE = "user_setup_complete"; /** + * Whether the current user has been set up via setup wizard (0 = false, 1 = true) + * This value differs from USER_SETUP_COMPLETE in that it can be reset back to 0 + * in case SetupWizard has been re-enabled on TV devices. + * + * @hide + */ + public static final String TV_USER_SETUP_COMPLETE = "tv_user_setup_complete"; + + /** * Prefix for category name that marks whether a suggested action from that category was * completed. * @hide diff --git a/core/java/android/service/autofill/AutofillService.java b/core/java/android/service/autofill/AutofillService.java index a90ee93d9852..07c3503934ae 100644 --- a/core/java/android/service/autofill/AutofillService.java +++ b/core/java/android/service/autofill/AutofillService.java @@ -23,7 +23,6 @@ import com.android.internal.os.HandlerCaller; import android.annotation.SdkConstant; import android.app.Activity; import android.app.Service; -import android.app.assist.AssistStructure; import android.content.Intent; import android.os.CancellationSignal; import android.os.IBinder; @@ -208,12 +207,6 @@ public abstract class AutofillService extends Service { public void onDisconnected() { } - /** @hide */ - @Deprecated - public final void disableSelf() { - getSystemService(AutofillManager.class).disableOwnedAutofillServices(); - } - /** * Returns the {@link FillEventHistory.Event events} since the last {@link FillResponse} was * returned. diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 3e9fab1aee27..cdb9b8229314 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -21,6 +21,7 @@ import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE; import android.annotation.IntDef; import android.annotation.RequiresPermission; import android.content.res.CompatibilityInfo; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PixelFormat; import android.graphics.Point; @@ -854,6 +855,9 @@ public final class Display { /** * Returns whether this display can be used to display wide color gamut content. + * This does not necessarily mean the device itself can render wide color gamut + * content. To ensure wide color gamut content can be produced, refer to + * {@link Configuration#isScreenWideColorGamut()}. */ public boolean isWideColorGamut() { synchronized (this) { diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 34ceeb7bcc0d..7e0ade4c8d20 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -641,7 +641,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mSurface.copyFrom(mSurfaceControl); } - if (getContext().getApplicationInfo().targetSdkVersion + if (sizeChanged && getContext().getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.O) { // Some legacy applications use the underlying native {@link Surface} object // as a key to whether anything has changed. In these cases, updates to the diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 04da4f1235e9..86b19f4a0929 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -963,7 +963,8 @@ public final class ViewRootImpl implements ViewParent, || insets.top != 0 || insets.bottom != 0; final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets; final boolean wideGamut = - attrs.getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT; + mContext.getResources().getConfiguration().isScreenWideColorGamut() + && attrs.getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT; mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); diff --git a/core/java/com/android/internal/app/NightDisplayController.java b/core/java/com/android/internal/app/NightDisplayController.java index bb54085ac3bf..860c5c4c3d3b 100644 --- a/core/java/com/android/internal/app/NightDisplayController.java +++ b/core/java/com/android/internal/app/NightDisplayController.java @@ -182,6 +182,10 @@ public final class NightDisplayController { throw new IllegalArgumentException("Invalid autoMode: " + autoMode); } + if (getAutoMode() != autoMode) { + Secure.putLongForUser(mContext.getContentResolver(), + Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME, -1L, mUserId); + } return Secure.putIntForUser(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, autoMode, mUserId); } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 76cee70fa0e8..062da9584305 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2968,6 +2968,8 @@ <!-- Name of a font family to use for headlines. If empty, falls back to platform default --> <string name="config_headlineFontFamily" translatable="false"></string> + <!-- Name of a font family to use for headlines. Defaults to sans-serif-light --> + <string name="config_headlineFontFamilyLight" translatable="false">sans-serif-light</string> <!-- An array of packages that need to be treated as type system in battery settings --> <string-array translatable="false" name="config_batteryPackageTypeSystem"> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 241886c97ec1..733890232c37 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3041,6 +3041,7 @@ <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" /> <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" /> <java-symbol type="string" name="config_headlineFontFamily" /> + <java-symbol type="string" name="config_headlineFontFamilyLight" /> <java-symbol type="drawable" name="stat_sys_vitals" /> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml index 9a9716277662..501d0a57148a 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml @@ -53,7 +53,7 @@ android:gravity="center" android:layout_centerHorizontal="true" android:layout_marginRight="72dp" - androidprv:scaledTextSize="28" + androidprv:scaledTextSize="@integer/scaled_password_text_size" android:textColor="?attr/bgProtectTextColor" android:contentDescription="@string/keyguard_accessibility_pin_area" /> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml index f0dec762abc6..c4732e42b5ad 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml @@ -66,7 +66,7 @@ android:gravity="center" android:layout_centerHorizontal="true" android:layout_marginRight="72dp" - androidprv:scaledTextSize="28" + androidprv:scaledTextSize="@integer/scaled_password_text_size" android:textColor="?attr/bgProtectTextColor" android:contentDescription="@string/keyguard_accessibility_sim_pin_area" /> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml index 119b3ee11335..1c7defd6399a 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml @@ -67,7 +67,7 @@ android:gravity="center" android:layout_centerHorizontal="true" android:layout_marginRight="72dp" - androidprv:scaledTextSize="28" + androidprv:scaledTextSize="@integer/scaled_password_text_size" android:textColor="?attr/bgProtectTextColor" android:contentDescription="@string/keyguard_accessibility_sim_puk_area" /> diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml index 41c723e3daf7..a721dd0609dc 100644 --- a/packages/SystemUI/res-keyguard/values/dimens.xml +++ b/packages/SystemUI/res-keyguard/values/dimens.xml @@ -48,6 +48,8 @@ <!-- The size of the dots in the PIN unlock method. --> <dimen name="password_dot_size">9dp</dimen> + <!-- The size of PIN text in the PIN unlock method. --> + <integer name="scaled_password_text_size">40</integer> <!-- The padding between chars of the password view. --> <dimen name="password_char_padding">8dp</dimen> diff --git a/packages/SystemUI/res-keyguard/values/styles.xml b/packages/SystemUI/res-keyguard/values/styles.xml index d7ff349b52bf..0c96b0b221ab 100644 --- a/packages/SystemUI/res-keyguard/values/styles.xml +++ b/packages/SystemUI/res-keyguard/values/styles.xml @@ -32,8 +32,8 @@ <item name="android:singleLine">true</item> <item name="android:gravity">center_horizontal|center_vertical</item> <item name="android:background">@null</item> - <item name="android:textSize">36sp</item> - <item name="android:fontFamily">sans-serif-light</item> + <item name="android:textSize">32sp</item> + <item name="android:fontFamily">@*android:string/config_headlineFontFamilyLight</item> <item name="android:textColor">?attr/bgProtectTextColor</item> <item name="android:paddingBottom">-16dp</item> </style> @@ -53,7 +53,7 @@ </style> <style name="widget_big_thin"> <item name="android:textSize">@dimen/widget_big_font_size</item> - <item name="android:fontFamily">sans-serif-light</item> + <item name="android:fontFamily">@*android:string/config_headlineFontFamilyLight</item> </style> <style name="BouncerSecurityContainer"> diff --git a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java index 7e811731c87d..d8bebabf0c5e 100644 --- a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java +++ b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java @@ -135,7 +135,9 @@ public class PasswordTextView extends View { } mDrawPaint.setFlags(Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); mDrawPaint.setTextAlign(Paint.Align.CENTER); - mDrawPaint.setTypeface(Typeface.create("sans-serif-light", 0)); + mDrawPaint.setTypeface(Typeface.create( + context.getString(com.android.internal.R.string.config_headlineFontFamilyLight), + 0)); mShowPassword = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; mAppearInterpolator = AnimationUtils.loadInterpolator(mContext, diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 6476416a4e72..c4de63bdd303 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -235,6 +235,7 @@ public class BatteryMeterView extends LinearLayout implements scaledLayoutParams.setMargins(0, 0, 0, marginBottom); mBatteryIconView.setLayoutParams(scaledLayoutParams); + FontSizeUtils.updateFontSize(mBatteryPercentView, R.dimen.qs_time_expanded_size); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index 86b1d3b7efce..4de121488ecc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -72,6 +72,7 @@ import com.android.systemui.recents.events.ui.RecentsDrawnEvent; import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent; import com.android.systemui.recents.events.ui.ShowIncompatibleAppOverlayEvent; import com.android.systemui.recents.events.ui.StackViewScrolledEvent; +import com.android.systemui.recents.events.ui.TaskViewDismissedEvent; import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent; import com.android.systemui.recents.events.ui.UserInteractionEvent; import com.android.systemui.recents.events.ui.focus.DismissFocusedTaskViewEvent; @@ -420,8 +421,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails; loader.loadTasks(this, loadPlan, loadOpts); TaskStack stack = loadPlan.getTaskStack(); - mRecentsView.onReload(mIsVisible, stack.getTaskCount() == 0); - mRecentsView.updateStack(stack, true /* setStackViewTasks */); + mRecentsView.onReload(stack, mIsVisible); // Update the nav bar scrim, but defer the animation until the enter-window event boolean animateNavBarScrim = !launchState.launchedViaDockGesture; @@ -755,6 +755,10 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD ssp.removeTask(event.task.key.id); } + public final void onBusEvent(TaskViewDismissedEvent event) { + mRecentsView.updateScrimOpacity(); + } + public final void onBusEvent(AllTaskViewsDismissedEvent event) { SystemServicesProxy ssp = Recents.getSystemServices(); if (ssp.hasDockedTask()) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index d710244988cb..dca4a8d3308a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -31,6 +31,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.ArraySet; import android.util.AttributeSet; +import android.util.MathUtils; import android.view.AppTransitionAnimationSpec; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -79,6 +80,7 @@ import com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecC import com.android.systemui.recents.views.RecentsTransitionHelper.AppTransitionAnimationSpecsFuture; import com.android.systemui.stackdivider.WindowManagerProxy; import com.android.systemui.statusbar.FlingAnimationUtils; +import com.android.systemui.statusbar.phone.ScrimController; import com.google.android.colorextraction.ColorExtractor; import com.google.android.colorextraction.drawable.GradientDrawable; @@ -96,11 +98,12 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC private static final String TAG = "RecentsView"; private static final int DEFAULT_UPDATE_SCRIM_DURATION = 200; - private static final float DEFAULT_SCRIM_ALPHA = 0.8f; private static final int SHOW_STACK_ACTION_BUTTON_DURATION = 134; private static final int HIDE_STACK_ACTION_BUTTON_DURATION = 100; + private static final int BUSY_RECENTS_TASK_COUNT = 3; + private TaskStackView mTaskStackView; private TextView mStackActionButton; private TextView mEmptyView; @@ -112,7 +115,7 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC Rect mSystemInsets = new Rect(); private int mDividerSize; - private final float mScrimAlpha; + private float mBusynessFactor; private GradientDrawable mBackgroundScrim; private final SysuiColorExtractor mColorExtractor; private Animator mBackgroundScrimAnimator; @@ -143,10 +146,8 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC mDividerSize = ssp.getDockedDividerSize(context); mTouchHandler = new RecentsViewTouchHandler(this); mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f); - mScrimAlpha = DEFAULT_SCRIM_ALPHA; mBackgroundScrim = new GradientDrawable(context); mBackgroundScrim.setCallback(this); - mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); mColorExtractor = Dependency.get(SysuiColorExtractor.class); LayoutInflater inflater = LayoutInflater.from(context); @@ -168,9 +169,10 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC /** * Called from RecentsActivity when it is relaunched. */ - public void onReload(boolean isResumingFromVisible, boolean isTaskStackEmpty) { - RecentsConfiguration config = Recents.getConfiguration(); - RecentsActivityLaunchState launchState = config.getLaunchState(); + public void onReload(TaskStack stack, boolean isResumingFromVisible) { + final RecentsConfiguration config = Recents.getConfiguration(); + final RecentsActivityLaunchState launchState = config.getLaunchState(); + final boolean isTaskStackEmpty = stack.getTaskCount() == 0; if (mTaskStackView == null) { isResumingFromVisible = false; @@ -185,17 +187,19 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC // Update the stack mTaskStackView.onReload(isResumingFromVisible); + updateStack(stack, true /* setStackViewTasks */); + updateBusyness(); if (isResumingFromVisible) { // If we are already visible, then restore the background scrim - animateBackgroundScrim(1f, DEFAULT_UPDATE_SCRIM_DURATION); + animateBackgroundScrim(getOpaqueScrimAlpha(), DEFAULT_UPDATE_SCRIM_DURATION); } else { // If we are already occluded by the app, then set the final background scrim alpha now. // Otherwise, defer until the enter animation completes to animate the scrim alpha with // the tasks for the home animation. if (launchState.launchedViaDockGesture || launchState.launchedFromApp || isTaskStackEmpty) { - mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); + mBackgroundScrim.setAlpha((int) (getOpaqueScrimAlpha() * 255)); } else { mBackgroundScrim.setAlpha(0); } @@ -219,13 +223,40 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC } /** + * Animates the scrim opacity based on how many tasks are visible. + * Called from {@link RecentsActivity} when tasks are dismissed. + */ + public void updateScrimOpacity() { + if (updateBusyness()) { + animateBackgroundScrim(getOpaqueScrimAlpha(), DEFAULT_UPDATE_SCRIM_DURATION); + } + } + + /** + * Updates the busyness factor. + * + * @return True if it changed. + */ + private boolean updateBusyness() { + final int taskCount = mTaskStackView.getStack().getStackTaskCount(); + final float busyness = Math.min(taskCount, BUSY_RECENTS_TASK_COUNT) + / (float) BUSY_RECENTS_TASK_COUNT; + if (mBusynessFactor == busyness) { + return false; + } else { + mBusynessFactor = busyness; + return true; + } + } + + /** * Returns the current TaskStack. */ public TaskStack getStack() { return mTaskStackView.getStack(); } - /* + /** * Returns the window background scrim. */ public Drawable getBackgroundScrim() { @@ -619,7 +650,7 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState(); if (!launchState.launchedViaDockGesture && !launchState.launchedFromApp && getStack().getTaskCount() > 0) { - animateBackgroundScrim(1f, + animateBackgroundScrim(getOpaqueScrimAlpha(), TaskStackAnimationHelper.ENTER_FROM_HOME_TRANSLATION_DURATION); } } @@ -779,13 +810,25 @@ public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsC } /** + * Scrim alpha based on how busy recents is: + * Scrim will be {@link ScrimController#GRADIENT_SCRIM_ALPHA} when the stack is empty, + * and {@link ScrimController#GRADIENT_SCRIM_ALPHA_BUSY} when it's full. + * + * @return Alpha from 0 to 1. + */ + private float getOpaqueScrimAlpha() { + return MathUtils.map(0, 1, ScrimController.GRADIENT_SCRIM_ALPHA, + ScrimController.GRADIENT_SCRIM_ALPHA_BUSY, mBusynessFactor); + } + + /** * Animates the background scrim to the given {@param alpha}. */ private void animateBackgroundScrim(float alpha, int duration) { Utilities.cancelAnimationWithoutCallbacks(mBackgroundScrimAnimator); // Calculate the absolute alpha to animate from - int fromAlpha = mBackgroundScrim.getAlpha(); - int toAlpha = (int) (alpha * mScrimAlpha * 255); + final int fromAlpha = mBackgroundScrim.getAlpha(); + final int toAlpha = (int) (alpha * 255); mBackgroundScrimAnimator = ObjectAnimator.ofInt(mBackgroundScrim, Utilities.DRAWABLE_ALPHA, fromAlpha, toAlpha); mBackgroundScrimAnimator.setDuration(duration); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java index 7eaa290c9d23..bf926c625e4f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java @@ -48,6 +48,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class NotificationInflater { + public static final String TAG = "NotificationInflater"; @VisibleForTesting static final int FLAG_REINFLATE_ALL = ~0; private static final int FLAG_REINFLATE_CONTENT_VIEW = 1<<0; @@ -315,7 +316,8 @@ public class NotificationInflater { return cancellationSignal; } - private static void applyRemoteView(final InflationProgress result, + @VisibleForTesting + static void applyRemoteView(final InflationProgress result, final int reInflateFlags, int inflationId, final ExpandableNotificationRow row, final boolean redactAmbient, boolean isNewView, @@ -325,6 +327,7 @@ public class NotificationInflater { NotificationViewWrapper existingWrapper, final HashMap<Integer, CancellationSignal> runningInflations, ApplyCallback applyCallback) { + RemoteViews newContentView = applyCallback.getRemoteView(); RemoteViews.OnViewAppliedListener listener = new RemoteViews.OnViewAppliedListener() { @@ -343,12 +346,31 @@ public class NotificationInflater { @Override public void onError(Exception e) { - runningInflations.remove(inflationId); - handleInflationError(runningInflations, e, entry.notification, callback); + // Uh oh the async inflation failed. Due to some bugs (see b/38190555), this could + // actually also be a system issue, so let's try on the UI thread again to be safe. + try { + View newView = existingView; + if (isNewView) { + newView = newContentView.apply( + result.packageContext, + parentLayout, + remoteViewClickHandler); + } else { + newContentView.reapply( + result.packageContext, + existingView, + remoteViewClickHandler); + } + Log.wtf(TAG, "Async Inflation failed but normal inflation finished normally.", + e); + onViewApplied(newView); + } catch (Exception anotherException) { + runningInflations.remove(inflationId); + handleInflationError(runningInflations, e, entry.notification, callback); + } } }; CancellationSignal cancellationSignal; - RemoteViews newContentView = applyCallback.getRemoteView(); if (isNewView) { cancellationSignal = newContentView.applyAsync( result.packageContext, @@ -620,14 +642,16 @@ public class NotificationInflater { } } - private static class InflationProgress { + @VisibleForTesting + static class InflationProgress { private RemoteViews newContentView; private RemoteViews newHeadsUpView; private RemoteViews newExpandedView; private RemoteViews newAmbientView; private RemoteViews newPublicView; - private Context packageContext; + @VisibleForTesting + Context packageContext; private View inflatedContentView; private View inflatedHeadsUpView; @@ -636,7 +660,8 @@ public class NotificationInflater { private View inflatedPublicView; } - private abstract static class ApplyCallback { + @VisibleForTesting + abstract static class ApplyCallback { public abstract void setResultView(View v); public abstract RemoteViews getRemoteView(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index bc278e0c3c2d..9275358e78bd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -58,7 +58,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, public static final Interpolator KEYGUARD_FADE_OUT_INTERPOLATOR_LOCKED = new PathInterpolator(0.3f, 0f, 0.8f, 1f); // Default alpha value for most scrims, if unsure use this constant - public static final float GRADIENT_SCRIM_ALPHA = 0.60f; + public static final float GRADIENT_SCRIM_ALPHA = 0.45f; // A scrim varies its opacity based on a busyness factor, for example // how many notifications are currently visible. public static final float GRADIENT_SCRIM_ALPHA_BUSY = 0.90f; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java index c7af0d9c8979..1b42d1b5dffc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java @@ -24,12 +24,17 @@ import static org.mockito.Mockito.verify; import android.app.Notification; import android.content.Context; +import android.os.CancellationSignal; +import android.os.Handler; +import android.os.Looper; import android.service.notification.StatusBarNotification; import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import android.view.View; +import android.view.ViewGroup; import android.widget.RemoteViews; import com.android.systemui.R; @@ -45,7 +50,9 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import java.util.HashMap; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executor; @SmallTest @RunWith(AndroidJUnit4.class) @@ -142,6 +149,41 @@ public class NotificationInflaterTest extends SysuiTestCase { Assert.assertNull(mRow.getEntry().getRunningTask()); } + @Test + public void testInflationIsRetriedIfAsyncFails() throws Exception { + NotificationInflater.InflationProgress result = + new NotificationInflater.InflationProgress(); + result.packageContext = mContext; + CountDownLatch countDownLatch = new CountDownLatch(1); + NotificationInflater.applyRemoteView(result, + NotificationInflater.FLAG_REINFLATE_EXPANDED_VIEW, 0, mRow, + false /* redactAmbient */, true /* isNewView */, new RemoteViews.OnClickHandler(), + new NotificationInflater.InflationCallback() { + @Override + public void handleInflationException(StatusBarNotification notification, + Exception e) { + countDownLatch.countDown(); + throw new RuntimeException("No Exception expected"); + } + + @Override + public void onAsyncInflationFinished(NotificationData.Entry entry) { + countDownLatch.countDown(); + } + }, mRow.getEntry(), mRow.getPrivateLayout(), null, null, new HashMap<>(), + new NotificationInflater.ApplyCallback() { + @Override + public void setResultView(View v) { + } + + @Override + public RemoteViews getRemoteView() { + return new AsyncFailRemoteView(mContext.getPackageName(), + R.layout.custom_view_dark); + } + }); + countDownLatch.await(); + } @Test public void testSupersedesExistingTask() throws Exception { @@ -200,4 +242,30 @@ public class NotificationInflaterTest extends SysuiTestCase { mException = exception; } } + + private class AsyncFailRemoteView extends RemoteViews { + Handler mHandler = new Handler(Looper.getMainLooper()); + + public AsyncFailRemoteView(String packageName, int layoutId) { + super(packageName, layoutId); + } + + @Override + public View apply(Context context, ViewGroup parent) { + return super.apply(context, parent); + } + + @Override + public CancellationSignal applyAsync(Context context, ViewGroup parent, Executor executor, + OnViewAppliedListener listener, OnClickHandler handler) { + mHandler.post(() -> listener.onError(new RuntimeException("Failed to inflate async"))); + return new CancellationSignal(); + } + + @Override + public CancellationSignal applyAsync(Context context, ViewGroup parent, Executor executor, + OnViewAppliedListener listener) { + return applyAsync(context, parent, executor, listener, null); + } + } } diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index baa135db9d4b..2eb94d30d4e5 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -4104,6 +4104,16 @@ message MetricsEvent { // OS: O DR DIALOG_BLUETOOTH_PAIRED_DEVICE_RENAME = 1015; + // ACTION: Settings > Notification Settings > Open application notification + // CATEGORY: SETTINGS + // OS: O DR + ACTION_OPEN_APP_NOTIFICATION_SETTING = 1016; + + // ACTION: Settings > App Info > Open app settings + // CATEGORY: SETTINGS + // OS: O DR + ACTION_OPEN_APP_SETTING = 1017; + // Add new aosp constants above this line. // END OF AOSP CONSTANTS } diff --git a/services/core/Android.mk b/services/core/Android.mk index 4d080e9d6103..0d01c2026176 100644 --- a/services/core/Android.mk +++ b/services/core/Android.mk @@ -33,6 +33,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android.hardware.oemlock-V1.0-java-static \ android.hardware.tetheroffload.control-V1.0-java-static \ android.hardware.vibrator-V1.0-java-constants \ + android.hardware.configstore-V1.0-java-static ifneq ($(INCREMENTAL_BUILDS),) LOCAL_PROGUARD_ENABLED := disabled diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 6202b912adc0..5b2e77937199 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -4118,7 +4118,8 @@ public class ActivityManagerService extends IActivityManager.Stub ri.activityInfo.packageName, ri.activityInfo.name)); mActivityStarter.startActivityLocked(null, intent, null /*ephemeralIntent*/, null, ri.activityInfo, null /*rInfo*/, null, null, null, null, 0, 0, 0, - null, 0, 0, 0, null, false, false, null, null, null); + null, 0, 0, 0, null, false, false, null, null, null, + "startSetupActivity"); } } } @@ -4457,8 +4458,9 @@ public class ActivityManagerService extends IActivityManager.Stub container.checkEmbeddedAllowedInner(userId, intent, mimeType); intent.addFlags(FORCE_NEW_TASK_FLAGS); - return mActivityStarter.startActivityMayWait(null, -1, null, intent, mimeType, null, null, null, - null, 0, 0, null, null, null, null, false, userId, container, null); + return mActivityStarter.startActivityMayWait(null, -1, null, intent, mimeType, null, null, + null, null, 0, 0, null, null, null, null, false, userId, container, null, + "startActivity"); } @Override @@ -4471,7 +4473,8 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: Switch to user app stacks here. return mActivityStarter.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, - profilerInfo, null, null, bOptions, false, userId, null, null); + profilerInfo, null, null, bOptions, false, userId, null, null, + "startActivityAsUser"); } @Override @@ -4534,7 +4537,8 @@ public class ActivityManagerService extends IActivityManager.Stub try { int ret = mActivityStarter.startActivityMayWait(null, targetUid, targetPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, null, - null, null, bOptions, ignoreTargetSecurity, userId, null, null); + null, null, bOptions, ignoreTargetSecurity, userId, null, null, + "startActivityAsCaller"); return ret; } catch (SecurityException e) { // XXX need to figure out how to propagate to original app. @@ -4563,7 +4567,7 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: Switch to user app stacks here. mActivityStarter.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, profilerInfo, res, null, - bOptions, false, userId, null, null); + bOptions, false, userId, null, null, "startActivityAndWait"); return res; } @@ -4577,7 +4581,7 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: Switch to user app stacks here. int ret = mActivityStarter.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, - null, null, config, bOptions, false, userId, null, null); + null, null, config, bOptions, false, userId, null, null, "startActivityWithConfig"); return ret; } @@ -4634,7 +4638,7 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: Switch to user app stacks here. return mActivityStarter.startActivityMayWait(null, callingUid, callingPackage, intent, resolvedType, session, interactor, null, null, 0, startFlags, profilerInfo, null, - null, bOptions, false, userId, null, null); + null, bOptions, false, userId, null, null, "startVoiceActivity"); } @Override @@ -4653,7 +4657,7 @@ public class ActivityManagerService extends IActivityManager.Stub ALLOW_FULL_ONLY, "startAssistantActivity", null); return mActivityStarter.startActivityMayWait(null, callingUid, callingPackage, intent, resolvedType, null, null, null, null, 0, 0, null, null, null, bOptions, false, - userId, null, null); + userId, null, null, "startAssistantActivity"); } @Override @@ -4826,7 +4830,7 @@ public class ActivityManagerService extends IActivityManager.Stub null /*ephemeralIntent*/, r.resolvedType, aInfo, null /*rInfo*/, null, null, resultTo != null ? resultTo.appToken : null, resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, -1, r.launchedFromUid, 0, options, - false, false, null, null, null); + false, false, null, null, null, "startNextMatchingActivity"); Binder.restoreCallingIdentity(origId); r.finishing = wasFinishing; @@ -4858,7 +4862,7 @@ public class ActivityManagerService extends IActivityManager.Stub final int startActivityInPackage(int uid, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, Bundle bOptions, int userId, - IActivityContainer container, TaskRecord inTask) { + IActivityContainer container, TaskRecord inTask, String reason) { userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY, "startActivityInPackage", null); @@ -4866,7 +4870,7 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: Switch to user app stacks here. int ret = mActivityStarter.startActivityMayWait(null, uid, callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, - null, null, null, bOptions, false, userId, container, inTask); + null, null, null, bOptions, false, userId, container, inTask, reason); return ret; } @@ -4874,12 +4878,13 @@ public class ActivityManagerService extends IActivityManager.Stub public final int startActivities(IApplicationThread caller, String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle bOptions, int userId) { - enforceNotIsolatedCaller("startActivities"); + final String reason = "startActivities"; + enforceNotIsolatedCaller(reason); userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), - userId, false, ALLOW_FULL_ONLY, "startActivity", null); + userId, false, ALLOW_FULL_ONLY, reason, null); // TODO: Switch to user app stacks here. int ret = mActivityStarter.startActivities(caller, -1, callingPackage, intents, - resolvedTypes, resultTo, bOptions, userId); + resolvedTypes, resultTo, bOptions, userId, reason); return ret; } @@ -4887,11 +4892,12 @@ public class ActivityManagerService extends IActivityManager.Stub Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle bOptions, int userId) { + final String reason = "startActivityInPackage"; userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), - userId, false, ALLOW_FULL_ONLY, "startActivityInPackage", null); + userId, false, ALLOW_FULL_ONLY, reason, null); // TODO: Switch to user app stacks here. int ret = mActivityStarter.startActivities(null, uid, callingPackage, intents, resolvedTypes, - resultTo, bOptions, userId); + resultTo, bOptions, userId, reason); return ret; } @@ -15005,6 +15011,10 @@ public class ActivityManagerService extends IActivityManager.Stub synchronized (this) { dumpLastANRLocked(pw); } + } else if ("starter".equals(cmd)) { + synchronized (this) { + dumpActivityStarterLocked(pw); + } } else if ("recents".equals(cmd) || "r".equals(cmd)) { synchronized (this) { dumpRecentsLocked(fd, pw, args, opti, true, dumpPackage); @@ -15238,6 +15248,11 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } + dumpActivityStarterLocked(pw); + pw.println(); + if (dumpAll) { + pw.println("-------------------------------------------------------------------------------"); + } dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); if (mAssociations.size() > 0) { pw.println(); @@ -15303,6 +15318,11 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } + dumpActivityStarterLocked(pw); + pw.println(); + if (dumpAll) { + pw.println("-------------------------------------------------------------------------------"); + } dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); if (mAssociations.size() > 0) { pw.println(); @@ -15322,14 +15342,19 @@ public class ActivityManagerService extends IActivityManager.Stub } private void dumpLastANRLocked(PrintWriter pw) { + pw.println("ACTIVITY MANAGER ACTIVITIES (dumpsys activity lastanr)"); if (mLastANRState == null) { - pw.println("ACTIVITY MANAGER ACTIVITIES (dumpsys activity lastanr)"); pw.println(" <no ANR has occurred since boot>"); } else { pw.println(mLastANRState); } } + private void dumpActivityStarterLocked(PrintWriter pw) { + pw.println("ACTIVITY MANAGER ACTIVITIES (dumpsys activity starter)"); + mActivityStarter.dump(pw, ""); + } + void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, @@ -15356,7 +15381,6 @@ public class ActivityManagerService extends IActivityManager.Stub if (needSep) { pw.println(); } - needSep = true; printedAnything = true; mStackSupervisor.dump(pw, " "); } @@ -24079,17 +24103,13 @@ public class ActivityManagerService extends IActivityManager.Stub if (reason != null) { pw.println(" Reason: " + reason); } - pw.println(" mLastHomeActivityStartResult: " - + mActivityStarter.mLastHomeActivityStartResult); - final ActivityRecord r = mActivityStarter.mLastHomeActivityStartRecord[0]; - if (r != null) { - pw.println(" mLastHomeActivityStartRecord:"); - r.dump(pw, " "); - } pw.println(); + mActivityStarter.dump(pw, " "); + pw.println(); + pw.println("-------------------------------------------------------------------------------"); dumpActivitiesLocked(null /* fd */, pw, null /* args */, 0 /* opti */, true /* dumpAll */, false /* dumpClient */, null /* dumpPackage */, - "ACTIVITY MANAGER ACTIVITIES (dumpsys activity lastanr)"); + "" /* header */); pw.println(); pw.close(); @@ -24331,7 +24351,7 @@ public class ActivityManagerService extends IActivityManager.Stub } return mActivityStarter.startActivityMayWait(appThread, -1, callingPackage, intent, resolvedType, null, null, null, null, 0, 0, null, null, - null, bOptions, false, callingUser, null, tr); + null, bOptions, false, callingUser, null, tr, "AppTaskImpl"); } @Override diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index a45becdd1dda..9cde98598987 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -3920,7 +3920,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai destIntent, null /*ephemeralIntent*/, null, aInfo, null /*rInfo*/, null, null, parent.appToken, null, 0, -1, parent.launchedFromUid, parent.launchedFromPackage, -1, parent.launchedFromUid, 0, null, - false, true, null, null, null); + false, true, null, null, null, "navigateUpTo"); foundParentInTask = res == ActivityManager.START_SUCCESS; } catch (RemoteException e) { foundParentInTask = false; diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 957b406373d4..1ccac1b8dc8a 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -5184,7 +5184,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); userId = task.userId; int result = mService.startActivityInPackage(callingUid, callingPackage, intent, null, - null, null, 0, 0, bOptions, userId, null, task); + null, null, 0, 0, bOptions, userId, null, task, "startActivityFromRecents"); if (launchStackId == DOCKED_STACK_ID) { setResizingDuringAnimation(task); } diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index c7ee149a9727..be30d5aaeab9 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -115,6 +115,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; import android.service.voice.IVoiceInteractionSession; +import android.text.TextUtils; import android.util.EventLog; import android.util.Slog; @@ -124,7 +125,10 @@ import com.android.server.am.ActivityStackSupervisor.PendingActivityLaunch; import com.android.server.pm.InstantAppResolver; import com.android.server.wm.WindowManagerService; +import java.io.PrintWriter; +import java.text.DateFormat; import java.util.ArrayList; +import java.util.Date; /** * Controller for interpreting how and then launching activities. @@ -189,9 +193,17 @@ class ActivityStarter { private boolean mUsingVr2dDisplay; // Last home activity record we attempted to start - final ActivityRecord[] mLastHomeActivityStartRecord = new ActivityRecord[1]; + private final ActivityRecord[] mLastHomeActivityStartRecord = new ActivityRecord[1]; // The result of the last home activity we attempted to start. - int mLastHomeActivityStartResult; + private int mLastHomeActivityStartResult; + // Last activity record we attempted to start + private final ActivityRecord[] mLastStartActivityRecord = new ActivityRecord[1]; + // The result of the last activity we attempted to start. + private int mLastStartActivityResult; + // Time in milli seconds we attempted to start the last activity. + private long mLastStartActivityTimeMs; + // The reason we were trying to start the last activity + private String mLastStartReason; private void reset() { mStartActivity = null; @@ -241,7 +253,37 @@ class ActivityStarter { mUsingVr2dDisplay = false; } - final int startActivityLocked(IApplicationThread caller, Intent intent, Intent ephemeralIntent, + int startActivityLocked(IApplicationThread caller, Intent intent, Intent ephemeralIntent, + String resolvedType, ActivityInfo aInfo, ResolveInfo rInfo, + IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor, + IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, + String callingPackage, int realCallingPid, int realCallingUid, int startFlags, + ActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified, + ActivityRecord[] outActivity, ActivityStackSupervisor.ActivityContainer container, + TaskRecord inTask, String reason) { + + if (TextUtils.isEmpty(reason)) { + throw new IllegalArgumentException("Need to specify a reason."); + } + mLastStartReason = reason; + mLastStartActivityTimeMs = System.currentTimeMillis(); + mLastStartActivityRecord[0] = null; + + mLastStartActivityResult = startActivity(caller, intent, ephemeralIntent, resolvedType, + aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode, + callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags, + options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord, + container, inTask); + + if (outActivity != null) { + // mLastStartActivityRecord[0] is set in the call to startActivity above. + outActivity[0] = mLastStartActivityRecord[0]; + } + return mLastStartActivityResult; + } + + /** DO NOT call this method directly. Use {@link #startActivityLocked} instead. */ + private int startActivity(IApplicationThread caller, Intent intent, Intent ephemeralIntent, String resolvedType, ActivityInfo aInfo, ResolveInfo rInfo, IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor, IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, @@ -604,7 +646,7 @@ class ActivityStarter { null /*callingPackage*/, 0 /*realCallingPid*/, 0 /*realCallingUid*/, 0 /*startFlags*/, null /*options*/, false /*ignoreTargetSecurity*/, false /*componentSpecified*/, mLastHomeActivityStartRecord /*outActivity*/, - null /*container*/, null /*inTask*/); + null /*container*/, null /*inTask*/, "startHomeActivity: " + reason); if (mSupervisor.inResumeTopActivity) { // If we are in resume section already, home activity will be initialized, but not // resumed (to avoid recursive resume) and will stay that way until something pokes it @@ -629,7 +671,7 @@ class ActivityStarter { IBinder resultTo, String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo, WaitResult outResult, Configuration globalConfig, Bundle bOptions, boolean ignoreTargetSecurity, int userId, - IActivityContainer iContainer, TaskRecord inTask) { + IActivityContainer iContainer, TaskRecord inTask, String reason) { // Refuse possible leaked file descriptors if (intent != null && intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); @@ -784,7 +826,7 @@ class ActivityStarter { resultTo, resultWho, requestCode, callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags, options, ignoreTargetSecurity, componentSpecified, outRecord, container, - inTask); + inTask, reason); Binder.restoreCallingIdentity(origId); @@ -847,7 +889,7 @@ class ActivityStarter { final int startActivities(IApplicationThread caller, int callingUid, String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo, - Bundle bOptions, int userId) { + Bundle bOptions, int userId, String reason) { if (intents == null) { throw new NullPointerException("intents is null"); } @@ -909,7 +951,7 @@ class ActivityStarter { resolvedTypes[i], aInfo, null /*rInfo*/, null, null, resultTo, null, -1, callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, 0, - options, false, componentSpecified, outActivity, null, null); + options, false, componentSpecified, outActivity, null, null, reason); if (res < 0) { return res; } @@ -2261,4 +2303,40 @@ class ActivityStarter { } return didSomething; } + + void dump(PrintWriter pw, String prefix) { + pw.println(prefix + "ActivityStarter:"); + prefix = prefix + " "; + + pw.println(prefix + "mLastStartReason=" + mLastStartReason); + pw.println(prefix + "mLastStartActivityTimeMs=" + + DateFormat.getDateTimeInstance().format(new Date(mLastStartActivityTimeMs))); + pw.println(prefix + "mLastStartActivityResult=" + mLastStartActivityResult); + ActivityRecord r = mLastStartActivityRecord[0]; + if (r != null) { + pw.println(prefix + "mLastStartActivityRecord:"); + r.dump(pw, prefix + " "); + } + pw.println(prefix + "mLastHomeActivityStartResult=" + mLastHomeActivityStartResult); + r = mLastHomeActivityStartRecord[0]; + if (r != null) { + pw.println(prefix + "mLastHomeActivityStartRecord:"); + r.dump(pw, prefix + " "); + } + if (mStartActivity != null) { + pw.println(prefix + "mStartActivity:"); + mStartActivity.dump(pw, prefix + " "); + } + if (mIntent != null) { + pw.println(prefix + "mIntent=" + mIntent); + } + if (mOptions != null) { + pw.println(prefix + "mOptions=" + mOptions); + } + pw.println(prefix + "mLaunchSingleTop=" + mLaunchSingleTop + + " mLaunchSingleInstance=" + mLaunchSingleInstance + + " mLaunchSingleTask=" + mLaunchSingleTask + + " mLaunchFlags=0x" + Integer.toHexString(mLaunchFlags) + + " mDoResume=" + mDoResume + " mAddingToTask=" + mAddingToTask); + } } diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java index a83f989fbc5d..0d1c579f2b81 100644 --- a/services/core/java/com/android/server/am/AppErrors.java +++ b/services/core/java/com/android/server/am/AppErrors.java @@ -412,7 +412,7 @@ class AppErrors { task.mCallingPackage, task.intent, null, null, null, 0, 0, ActivityOptions.makeBasic().toBundle(), - task.userId, null, null); + task.userId, null, null, "AppErrors"); } } } diff --git a/services/core/java/com/android/server/am/PendingIntentRecord.java b/services/core/java/com/android/server/am/PendingIntentRecord.java index 6eca3fa7350a..cad5dcf6b565 100644 --- a/services/core/java/com/android/server/am/PendingIntentRecord.java +++ b/services/core/java/com/android/server/am/PendingIntentRecord.java @@ -346,7 +346,7 @@ final class PendingIntentRecord extends IIntentSender.Stub { } else { owner.startActivityInPackage(uid, key.packageName, finalIntent, resolvedType, resultTo, resultWho, requestCode, 0, - options, userId, container, null); + options, userId, container, null, "PendingIntentRecord"); } } catch (RuntimeException e) { Slog.w(TAG, "Unable to send startActivity intent", e); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index fbe6f94ddc3b..c98d60dcad93 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1217,7 +1217,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo (displayInfo.isHdr() ? Configuration.COLOR_MODE_HDR_YES : Configuration.COLOR_MODE_HDR_NO) - | (displayInfo.isWideColorGamut() + | (displayInfo.isWideColorGamut() && mService.hasWideColorGamutSupport() ? Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_YES : Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_NO); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 7944e68259bb..0c2ca859a31f 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -131,6 +131,8 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; +import android.hardware.configstore.V1_0.ISurfaceFlingerConfigs; +import android.hardware.configstore.V1_0.OptionalBool; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.hardware.input.InputManager; @@ -715,6 +717,9 @@ public class WindowManagerService extends IWindowManager.Stub final DisplayManager mDisplayManager; private final Display[] mDisplays; + // Indicates whether this device supports wide color gamut rendering + private boolean mHasWideColorGamutSupport; + // Who is holding the screen on. private Session mHoldingScreenOn; private PowerManager.WakeLock mHoldingScreenWakeLock; @@ -4726,6 +4731,20 @@ public class WindowManagerService extends IWindowManager.Stub public void systemReady() { mPolicy.systemReady(); mTaskSnapshotController.systemReady(); + mHasWideColorGamutSupport = queryWideColorGamutSupport(); + } + + private static boolean queryWideColorGamutSupport() { + try { + ISurfaceFlingerConfigs surfaceFlinger = ISurfaceFlingerConfigs.getService(); + OptionalBool hasWideColor = surfaceFlinger.hasWideColorDisplay(); + if (hasWideColor != null) { + return hasWideColor.value; + } + } catch (RemoteException e) { + // Ignore, we're in big trouble if we can't talk to SurfaceFlinger's config store + } + return false; } // ------------------------------------------------------------- @@ -7521,4 +7540,8 @@ public class WindowManagerService extends IWindowManager.Stub } } } + + boolean hasWideColorGamutSupport() { + return mHasWideColorGamutSupport; + } } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index ec8d91baf1ba..613c529fa616 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -676,16 +676,28 @@ public class WifiManager { @SystemApi public static final int CHANGE_REASON_CONFIG_CHANGE = 2; /** - * An access point scan has completed, and results are available from the supplicant. - * Call {@link #getScanResults()} to obtain the results. {@link #EXTRA_RESULTS_UPDATED} - * indicates if the scan was completed successfully. + * An access point scan has completed, and results are available. + * Call {@link #getScanResults()} to obtain the results. + * The broadcast intent may contain an extra field with the key {@link #EXTRA_RESULTS_UPDATED} + * and a {@code boolean} value indicating if the scan was successful. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String SCAN_RESULTS_AVAILABLE_ACTION = "android.net.wifi.SCAN_RESULTS"; /** - * Lookup key for a {@code boolean} representing the result of previous {@link #startScan} - * operation, reported with {@link #SCAN_RESULTS_AVAILABLE_ACTION}. + * Lookup key for a {@code boolean} extra in intent {@link #SCAN_RESULTS_AVAILABLE_ACTION} + * representing if the scan was successful or not. + * Scans may fail for multiple reasons, these may include: + * <ol> + * <li>A non-privileged app requested too many scans in a certain period of time. + * This may lead to additional scan request rejections via "scan throttling". + * See + * <a href="https://developer.android.com/preview/features/background-location-limits.html"> + * here</a> for details. + * </li> + * <li>The device is idle and scanning is disabled.</li> + * <li>Wifi hardware reported a scan failure.</li> + * </ol> * @return true scan was successful, results are updated * @return false scan was not successful, results haven't been updated since previous scan */ |