Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12a8f62c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9037458 from 33c34d0a to tm-qpr1-release

Change-Id: Ib8923cddd41ae6b0797da93074520adf8d64cf1e
parents 380ee459 33c34d0a
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -3920,6 +3920,12 @@ public class Intent implements Parcelable, Cloneable {
     * that has been started.  This is sent as a foreground
     * broadcast, since it is part of a visible user interaction; be as quick
     * as possible when handling it.
     *
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     * @hide
     */
    public static final String ACTION_USER_STARTED =
@@ -3937,6 +3943,12 @@ public class Intent implements Parcelable, Cloneable {
     * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
     * other user state broadcasts since those are foreground broadcasts so can
     * execute in a different order.
     *
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     * @hide
     */
    public static final String ACTION_USER_STARTING =
@@ -3955,6 +3967,11 @@ public class Intent implements Parcelable, Cloneable {
     * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
     * other user state broadcasts since those are foreground broadcasts so can
     * execute in a different order.
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     * @hide
     */
    public static final String ACTION_USER_STOPPING =
@@ -3967,6 +3984,12 @@ public class Intent implements Parcelable, Cloneable {
     * specific package.  This is only sent to registered receivers, not manifest
     * receivers.  It is sent to all running users <em>except</em> the one that
     * has just been stopped (which is no longer running).
     *
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     * @hide
     */
    @TestApi
@@ -3999,6 +4022,12 @@ public class Intent implements Parcelable, Cloneable {
     * It is sent to all running users.
     * You must hold
     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
     *
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     * @hide
     */
    @SystemApi
@@ -4009,6 +4038,12 @@ public class Intent implements Parcelable, Cloneable {
     * Broadcast Action: Sent when the credential-encrypted private storage has
     * become unlocked for the target user. This is only sent to registered
     * receivers, not manifest receivers.
     *
     * <p>
     * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
     * received. For example, the user could have been removed, started or stopped already,
     * regardless of which broadcast you receive. Because of that, receivers should always check
     * the current state of the user.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
+1 −1
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
        mPassword = password;
        mRsaPrivateKey = rsaPrivateKey;
        mUserCert = userCert;
        mProxyInfo = new ProxyInfo(proxyInfo);
        mProxyInfo = (proxyInfo == null) ? null : new ProxyInfo(proxyInfo);

        // UnmodifiableList doesn't make a defensive copy by default.
        mAllowedAlgorithms = Collections.unmodifiableList(new ArrayList<>(allowedAlgorithms));
+27 −2
Original line number Diff line number Diff line
@@ -397,6 +397,8 @@ public final class TransitionInfo implements Parcelable {
        private @Surface.Rotation int mEndFixedRotation = ROTATION_UNDEFINED;
        private int mRotationAnimation = ROTATION_ANIMATION_UNSPECIFIED;
        private @ColorInt int mBackgroundColor;
        private SurfaceControl mSnapshot = null;
        private float mSnapshotLuma;

        public Change(@Nullable WindowContainerToken container, @NonNull SurfaceControl leash) {
            mContainer = container;
@@ -420,6 +422,8 @@ public final class TransitionInfo implements Parcelable {
            mEndFixedRotation = in.readInt();
            mRotationAnimation = in.readInt();
            mBackgroundColor = in.readInt();
            mSnapshot = in.readTypedObject(SurfaceControl.CREATOR);
            mSnapshotLuma = in.readFloat();
        }

        /** Sets the parent of this change's container. The parent must be a participant or null. */
@@ -489,6 +493,12 @@ public final class TransitionInfo implements Parcelable {
            mBackgroundColor = backgroundColor;
        }

        /** Sets a snapshot surface for the "start" state of the container. */
        public void setSnapshot(@Nullable SurfaceControl snapshot, float luma) {
            mSnapshot = snapshot;
            mSnapshotLuma = luma;
        }

        /** @return the container that is changing. May be null if non-remotable (eg. activity) */
        @Nullable
        public WindowContainerToken getContainer() {
@@ -587,6 +597,17 @@ public final class TransitionInfo implements Parcelable {
            return mBackgroundColor;
        }

        /** @return a snapshot surface (if applicable). */
        @Nullable
        public SurfaceControl getSnapshot() {
            return mSnapshot;
        }

        /** @return the luma calculated for the snapshot surface (if applicable). */
        public float getSnapshotLuma() {
            return mSnapshotLuma;
        }

        /** @hide */
        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
@@ -605,6 +626,8 @@ public final class TransitionInfo implements Parcelable {
            dest.writeInt(mEndFixedRotation);
            dest.writeInt(mRotationAnimation);
            dest.writeInt(mBackgroundColor);
            dest.writeTypedObject(mSnapshot, flags);
            dest.writeFloat(mSnapshotLuma);
        }

        @NonNull
@@ -629,11 +652,13 @@ public final class TransitionInfo implements Parcelable {

        @Override
        public String toString() {
            return "{" + mContainer + "(" + mParent + ") leash=" + mLeash
            String out = "{" + mContainer + "(" + mParent + ") leash=" + mLeash
                    + " m=" + modeToString(mMode) + " f=" + flagsToString(mFlags) + " sb="
                    + mStartAbsBounds + " eb=" + mEndAbsBounds + " eo=" + mEndRelOffset + " r="
                    + mStartRotation + "->" + mEndRotation + ":" + mRotationAnimation
                    + " endFixedRotation=" + mEndFixedRotation + "}";
                    + " endFixedRotation=" + mEndFixedRotation;
            if (mSnapshot != null) out += " snapshot=" + mSnapshot;
            return out + "}";
        }
    }

+113 −22
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.view.ViewGroup;
import android.widget.TextView;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
import com.android.internal.app.chooser.ChooserTargetInfo;
import com.android.internal.app.chooser.DisplayResolveInfo;
@@ -86,7 +87,7 @@ public class ChooserListAdapter extends ResolverListAdapter {
    private final ChooserActivityLogger mChooserActivityLogger;

    private int mNumShortcutResults = 0;
    private Map<DisplayResolveInfo, LoadIconTask> mIconLoaders = new HashMap<>();
    private final Map<TargetInfo, AsyncTask> mIconLoaders = new HashMap<>();
    private boolean mApplySharingAppLimits;

    // Reserve spots for incoming direct share targets by adding placeholders
@@ -104,6 +105,8 @@ public class ChooserListAdapter extends ResolverListAdapter {
    private AppPredictor mAppPredictor;
    private AppPredictor.Callback mAppPredictorCallback;

    private LoadDirectShareIconTaskProvider mTestLoadDirectShareTaskProvider;

    // For pinned direct share labels, if the text spans multiple lines, the TextView will consume
    // the full width, even if the characters actually take up less than that. Measure the actual
    // line widths and constrain the View's width based upon that so that the pin doesn't end up
@@ -240,7 +243,6 @@ public class ChooserListAdapter extends ResolverListAdapter {
        mListViewDataChanged = false;
    }


    private void createPlaceHolders() {
        mNumShortcutResults = 0;
        mServiceTargets.clear();
@@ -265,31 +267,25 @@ public class ChooserListAdapter extends ResolverListAdapter {
            return;
        }

        if (!(info instanceof DisplayResolveInfo)) {
        if (info instanceof DisplayResolveInfo) {
            DisplayResolveInfo dri = (DisplayResolveInfo) info;
            holder.bindLabel(dri.getDisplayLabel(), dri.getExtendedInfo(), alwaysShowSubLabel());
            startDisplayResolveInfoIconLoading(holder, dri);
        } else {
            holder.bindLabel(info.getDisplayLabel(), info.getExtendedInfo(), alwaysShowSubLabel());
            holder.bindIcon(info);

            if (info instanceof SelectableTargetInfo) {
                SelectableTargetInfo selectableInfo = (SelectableTargetInfo) info;
                // direct share targets should append the application name for a better readout
                DisplayResolveInfo rInfo = ((SelectableTargetInfo) info).getDisplayResolveInfo();
                DisplayResolveInfo rInfo = selectableInfo.getDisplayResolveInfo();
                CharSequence appName = rInfo != null ? rInfo.getDisplayLabel() : "";
                CharSequence extendedInfo = info.getExtendedInfo();
                String contentDescription = String.join(" ", info.getDisplayLabel(),
                CharSequence extendedInfo = selectableInfo.getExtendedInfo();
                String contentDescription = String.join(" ", selectableInfo.getDisplayLabel(),
                        extendedInfo != null ? extendedInfo : "", appName);
                holder.updateContentDescription(contentDescription);
            }
                startSelectableTargetInfoIconLoading(holder, selectableInfo);
            } else {
            DisplayResolveInfo dri = (DisplayResolveInfo) info;
            holder.bindLabel(dri.getDisplayLabel(), dri.getExtendedInfo(), alwaysShowSubLabel());
            LoadIconTask task = mIconLoaders.get(dri);
            if (task == null) {
                task = new LoadIconTask(dri, holder);
                mIconLoaders.put(dri, task);
                task.execute();
            } else {
                // The holder was potentially changed as the underlying items were
                // reshuffled, so reset the target holder
                task.setViewHolder(holder);
                holder.bindIcon(info);
            }
        }

@@ -330,6 +326,32 @@ public class ChooserListAdapter extends ResolverListAdapter {
        }
    }

    private void startDisplayResolveInfoIconLoading(ViewHolder holder, DisplayResolveInfo info) {
        LoadIconTask task = (LoadIconTask) mIconLoaders.get(info);
        if (task == null) {
            task = new LoadIconTask(info, holder);
            mIconLoaders.put(info, task);
            task.execute();
        } else {
            // The holder was potentially changed as the underlying items were
            // reshuffled, so reset the target holder
            task.setViewHolder(holder);
        }
    }

    private void startSelectableTargetInfoIconLoading(
            ViewHolder holder, SelectableTargetInfo info) {
        LoadDirectShareIconTask task = (LoadDirectShareIconTask) mIconLoaders.get(info);
        if (task == null) {
            task = mTestLoadDirectShareTaskProvider == null
                    ? new LoadDirectShareIconTask(info)
                    : mTestLoadDirectShareTaskProvider.get();
            mIconLoaders.put(info, task);
            task.loadIcon();
        }
        task.setViewHolder(holder);
    }

    void updateAlphabeticalList() {
        new AsyncTask<Void, Void, List<DisplayResolveInfo>>() {
            @Override
@@ -739,11 +761,25 @@ public class ChooserListAdapter extends ResolverListAdapter {
        }
    }

    /**
     * An alias for onBindView to use with unit tests.
     */
    @VisibleForTesting
    public void testViewBind(View view, TargetInfo info, int position) {
        onBindView(view, info, position);
    }

    @VisibleForTesting
    public void setTestLoadDirectShareTaskProvider(LoadDirectShareIconTaskProvider provider) {
        mTestLoadDirectShareTaskProvider = provider;
    }

    /**
     * Necessary methods to communicate between {@link ChooserListAdapter}
     * and {@link ChooserActivity}.
     */
    interface ChooserListCommunicator extends ResolverListCommunicator {
    @VisibleForTesting
    public interface ChooserListCommunicator extends ResolverListCommunicator {

        int getMaxRankedTargets();

@@ -751,4 +787,59 @@ public class ChooserListAdapter extends ResolverListAdapter {

        boolean isSendAction(Intent targetIntent);
    }

    /**
     * Loads direct share targets icons.
     */
    @VisibleForTesting
    public class LoadDirectShareIconTask extends AsyncTask<Void, Void, Void> {
        private final SelectableTargetInfo mTargetInfo;
        private ViewHolder mViewHolder;

        private LoadDirectShareIconTask(SelectableTargetInfo targetInfo) {
            mTargetInfo = targetInfo;
        }

        @Override
        protected Void doInBackground(Void... voids) {
            mTargetInfo.loadIcon();
            return null;
        }

        @Override
        protected void onPostExecute(Void arg) {
            if (mViewHolder != null) {
                mViewHolder.bindIcon(mTargetInfo);
                notifyDataSetChanged();
            }
        }

        /**
         * Specifies a view holder that will be updated when the task is completed.
         */
        public void setViewHolder(ViewHolder viewHolder) {
            mViewHolder = viewHolder;
            mViewHolder.bindIcon(mTargetInfo);
            notifyDataSetChanged();
        }

        /**
         * An alias for execute to use with unit tests.
         */
        public void loadIcon() {
            execute();
        }
    }

    /**
     * An interface for the unit tests to override icon loading task creation
     */
    @VisibleForTesting
    public interface LoadDirectShareIconTaskProvider {
        /**
         * Provides an instance of the task.
         * @return
         */
        LoadDirectShareIconTask get();
    }
}
+7 −2
Original line number Diff line number Diff line
@@ -834,7 +834,11 @@ public class ResolverListAdapter extends BaseAdapter {
        void onHandlePackagesChanged(ResolverListAdapter listAdapter);
    }

    static class ViewHolder {
    /**
     * A view holder.
     */
    @VisibleForTesting
    public static class ViewHolder {
        public View itemView;
        public Drawable defaultItemViewBackground;

@@ -842,7 +846,8 @@ public class ResolverListAdapter extends BaseAdapter {
        public TextView text2;
        public ImageView icon;

        ViewHolder(View view) {
        @VisibleForTesting
        public ViewHolder(View view) {
            itemView = view;
            defaultItemViewBackground = view.getBackground();
            text = (TextView) view.findViewById(com.android.internal.R.id.text1);
Loading