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

Commit f3251e96 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6034952 from c53b7367 to qt-qpr2-release

Change-Id: I0c235233fff1a4af5ca0b74eb62f7fc4cad26827
parents a506aa54 c53b7367
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -8945,6 +8945,14 @@ public final class Settings {
        private static final Validator NAVIGATION_MODE_VALIDATOR =
                new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1", "2"});
        /**
         * Current provider of proximity-based sharing services.
         * Default value in @string/config_defaultNearbySharingComponent.
         * No VALIDATOR as this setting will not be backed up.
         * @hide
         */
        public static final String NEARBY_SHARING_COMPONENT = "nearby_sharing_component";
        /**
         * Controls whether aware is enabled.
         * @hide
+67 −30
Original line number Diff line number Diff line
@@ -92,7 +92,10 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
@@ -421,6 +424,13 @@ public final class InputMethodManager {
    int mCursorCandStart;
    int mCursorCandEnd;

    /**
     * Initial startInput with {@link StartInputReason.WINDOW_FOCUS_GAIN} is executed
     * in a background thread. Later, if there is an actual startInput it will wait on
     * main thread till the background thread completes.
     */
    private CompletableFuture<Void> mWindowFocusGainFuture;

    /**
     * The instance that has previously been sent to the input method.
     */
@@ -645,6 +655,7 @@ public final class InputMethodManager {
                            } catch (RemoteException e) {
                            }
                        }
                    }
                    // Check focus again in case that "onWindowFocus" is called before
                    // handling this message.
                    if (mServedView != null && canStartInput(mServedView)) {
@@ -654,7 +665,6 @@ public final class InputMethodManager {
                            startInputInner(reason, null, 0, 0, 0);
                        }
                    }
                    }
                    return;
                }
                case MSG_SEND_INPUT_EVENT: {
@@ -1215,6 +1225,10 @@ public final class InputMethodManager {
     */
    void clearBindingLocked() {
        if (DEBUG) Log.v(TAG, "Clearing binding!");
        if (mWindowFocusGainFuture != null) {
            mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */);
            mWindowFocusGainFuture = null;
        }
        clearConnectionLocked();
        setInputChannelLocked(null);
        mBindSequence = -1;
@@ -1598,6 +1612,18 @@ public final class InputMethodManager {
    boolean startInputInner(@StartInputReason int startInputReason,
            @Nullable IBinder windowGainingFocus, @StartInputFlags int startInputFlags,
            @SoftInputModeFlags int softInputMode, int windowFlags) {
        if (startInputReason != StartInputReason.WINDOW_FOCUS_GAIN
                && mWindowFocusGainFuture != null) {
            try {
                mWindowFocusGainFuture.get();
            } catch (ExecutionException | InterruptedException e) {
                // do nothing
            } catch (CancellationException e) {
                // window no longer has focus.
                return true;
            }
        }

        final View view;
        synchronized (mH) {
            view = mServedView;
@@ -1951,13 +1977,19 @@ public final class InputMethodManager {
            startInputFlags |= StartInputFlags.FIRST_WINDOW_FOCUS_GAIN;
        }

        if (checkFocusNoStartInput(forceNewFocus)) {
        final boolean forceNewFocus1 = forceNewFocus;
        final int startInputFlags1 = startInputFlags;
        if (mWindowFocusGainFuture != null) {
            mWindowFocusGainFuture.cancel(false/* mayInterruptIfRunning */);
        }
        mWindowFocusGainFuture = CompletableFuture.runAsync(() -> {
            if (checkFocusNoStartInput(forceNewFocus1)) {
                // We need to restart input on the current focus view.  This
                // should be done in conjunction with telling the system service
                // about the window gaining focus, to help make the transition
                // smooth.
                if (startInputInner(StartInputReason.WINDOW_FOCUS_GAIN, rootView.getWindowToken(),
                    startInputFlags, softInputMode, windowFlags)) {
                        startInputFlags1, softInputMode, windowFlags)) {
                    return;
                }
            }
@@ -1969,13 +2001,14 @@ public final class InputMethodManager {
                    if (DEBUG) Log.v(TAG, "Reporting focus gain, without startInput");
                    mService.startInputOrWindowGainedFocus(
                            StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
                        rootView.getWindowToken(), startInputFlags, softInputMode, windowFlags,
                            rootView.getWindowToken(), startInputFlags1, softInputMode, windowFlags,
                            null, null, 0 /* missingMethodFlags */,
                            rootView.getContext().getApplicationInfo().targetSdkVersion);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
            }
        });
    }

    /** @hide */
@@ -1990,6 +2023,10 @@ public final class InputMethodManager {
                // If the mCurRootView is losing window focus, release the strong reference to it
                // so as not to prevent it from being garbage-collected.
                mCurRootView = null;
                if (mWindowFocusGainFuture != null) {
                    mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */);
                    mWindowFocusGainFuture = null;
                }
            } else {
                if (DEBUG) {
                    Log.v(TAG, "Ignoring onPreWindowFocus()."
+101 −4
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ import android.provider.DeviceConfig;
import android.provider.DocumentsContract;
import android.provider.Downloads;
import android.provider.OpenableColumns;
import android.provider.Settings;
import android.service.chooser.ChooserTarget;
import android.service.chooser.ChooserTargetService;
import android.service.chooser.IChooserTargetResult;
@@ -106,6 +107,7 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -126,6 +128,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.URISyntaxException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
@@ -156,6 +159,9 @@ public class ChooserActivity extends ResolverActivity {

    private static final String PREF_NUM_SHEET_EXPANSIONS = "pref_num_sheet_expansions";

    private static final String CHIP_LABEL_METADATA_KEY = "android.service.chooser.chip_label";
    private static final String CHIP_ICON_METADATA_KEY = "android.service.chooser.chip_icon";

    private static final boolean DEBUG = false;

    /**
@@ -522,6 +528,15 @@ public class ChooserActivity extends ResolverActivity {
        mIsSuccessfullySelected = false;
        Intent intent = getIntent();
        Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
        if (targetParcelable instanceof Uri) {
            try {
                targetParcelable = Intent.parseUri(targetParcelable.toString(),
                        Intent.URI_INTENT_SCHEME);
            } catch (URISyntaxException ex) {
                // doesn't parse as an intent; let the next test fail and error out
            }
        }

        if (!(targetParcelable instanceof Intent)) {
            Log.w("ChooserActivity", "Target is not an intent: " + targetParcelable);
            finish();
@@ -890,6 +905,85 @@ public class ChooserActivity extends ResolverActivity {
        }
    }

    private ComponentName getNearbySharingComponent() {
        String nearbyComponent = Settings.Secure.getString(
                getContentResolver(),
                Settings.Secure.NEARBY_SHARING_COMPONENT);
        if (TextUtils.isEmpty(nearbyComponent)) {
            nearbyComponent = getString(R.string.config_defaultNearbySharingComponent);
        }
        if (TextUtils.isEmpty(nearbyComponent)) {
            return null;
        }
        return ComponentName.unflattenFromString(nearbyComponent);
    }

    private TargetInfo getNearbySharingTarget(Intent originalIntent) {
        final ComponentName cn = getNearbySharingComponent();
        if (cn == null) return null;

        final Intent resolveIntent = new Intent();
        resolveIntent.setComponent(cn);
        final ResolveInfo ri = getPackageManager().resolveActivity(resolveIntent, 0);
        if (ri == null) {
            Log.e(TAG, "Device-specified nearby sharing component (" + cn
                    + ") not available");
            return null;
        }

        // TODO(b/144290152): CHIP_LABEL_METADATA_KEY / CHIP_ICON_METADATA_KEY

        CharSequence name = ri.loadLabel(getPackageManager());

        final DisplayResolveInfo dri = new DisplayResolveInfo(
                originalIntent, ri, name, "", null);
        dri.setDisplayIcon(ri.loadIcon(getPackageManager()));
        return dri;
    }

    private Button createActionButton(Drawable icon, CharSequence title, View.OnClickListener r) {
        Button b = (Button) LayoutInflater.from(this).inflate(R.layout.chooser_action_button, null);
        if (icon != null) {
            final int size = getResources()
                    .getDimensionPixelSize(R.dimen.chooser_action_button_icon_size);
            icon.setBounds(0, 0, size, size);
            b.setCompoundDrawablesRelative(icon, null, null, null);
        }
        b.setText(title);
        b.setOnClickListener(r);
        return b;
    }

    private Button createCopyButton() {
        final Button b = createActionButton(
                getDrawable(R.drawable.ic_menu_copy_material),
                getString(R.string.copy), this::onCopyButtonClicked);
        b.setId(R.id.chooser_copy_button);
        return b;
    }

    private @Nullable Button createNearbyButton(Intent originalIntent) {
        final TargetInfo ti = getNearbySharingTarget(originalIntent);
        if (ti == null) return null;

        return createActionButton(
                ti.getDisplayIcon(),
                ti.getDisplayLabel(),
                (View unused) -> safelyStartActivity(ti)
        );
    }

    private void addActionButton(ViewGroup parent, Button b) {
        if (b == null) return;
        final ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(
                        LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT
                );
        final int gap = getResources().getDimensionPixelSize(R.dimen.resolver_icon_margin) / 2;
        lp.setMarginsRelative(gap, 0, gap, 0);
        parent.addView(b, lp);
    }

    private ViewGroup displayContentPreview(@ContentPreviewType int previewType,
            Intent targetIntent, LayoutInflater layoutInflater, ViewGroup convertView,
            ViewGroup parent) {
@@ -923,8 +1017,10 @@ public class ChooserActivity extends ResolverActivity {
        ViewGroup contentPreviewLayout = (ViewGroup) layoutInflater.inflate(
                R.layout.chooser_grid_preview_text, parent, false);

        contentPreviewLayout.findViewById(R.id.copy_button).setOnClickListener(
                this::onCopyButtonClicked);
        final ViewGroup actionRow =
                (ViewGroup) contentPreviewLayout.findViewById(R.id.chooser_action_row);
        addActionButton(actionRow, createCopyButton());
        addActionButton(actionRow, createNearbyButton(targetIntent));

        CharSequence sharingText = targetIntent.getCharSequenceExtra(Intent.EXTRA_TEXT);
        if (sharingText == null) {
@@ -1082,7 +1178,8 @@ public class ChooserActivity extends ResolverActivity {

        // TODO(b/120417119): Disable file copy until after moving to sysui,
        // due to permissions issues
        contentPreviewLayout.findViewById(R.id.file_copy_button).setVisibility(View.GONE);
        //((ViewGroup) contentPreviewLayout.findViewById(R.id.chooser_action_row))
        //        .addView(createCopyButton());

        String action = targetIntent.getAction();
        if (Intent.ACTION_SEND.equals(action)) {
@@ -1534,7 +1631,7 @@ public class ChooserActivity extends ResolverActivity {
            }
            return new IntentFilter(intent.getAction(), dataString);
        } catch (Exception e) {
            Log.e(TAG, "failed to get target intent filter " + e);
            Log.e(TAG, "failed to get target intent filter", e);
            return null;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -488,7 +488,7 @@ static jlong create(JNIEnv* env, jclass clazz, jlong rootNodePtr, jlong surfaceP
        proxy->setWideGamut(true);
    }
    proxy->setSwapBehavior(SwapBehavior::kSwap_discardBuffer);
    proxy->setSurface(surface);
    proxy->setSurface(surface, false);
    // Shadows can't be used via this interface, so just set the light source
    // to all 0s.
    proxy->setLightAlpha(0, 0);
+33 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="@color/lighter_gray">
    <item>
        <inset
            android:insetLeft="0dp"
            android:insetTop="8dp"
            android:insetRight="0dp"
            android:insetBottom="8dp">
            <shape android:shape="rectangle">
              <corners android:radius="16dp"></corners>
                <stroke android:width="1dp"
                        android:color="?attr/textColorSecondary" />
                <solid android:color="?attr/colorBackground" />
            </shape>
        </inset>
    </item>
</ripple>
Loading