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

Commit 445969db authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8857231 from 928a1ea2 to tm-qpr1-release

Change-Id: Ie6f35d0230c8c42b49b6769f30c1d52ae0aa6ce7
parents 63fd52ea 928a1ea2
Loading
Loading
Loading
Loading
+48 −8
Original line number Diff line number Diff line
@@ -713,6 +713,15 @@ public class PackageParser {
        if (!checkUseInstalledOrHidden(flags, state, p.applicationInfo) || !p.isMatch(flags)) {
            return null;
        }

        final ApplicationInfo applicationInfo;
        if ((flags & (PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS
                | PackageManager.GET_SERVICES | PackageManager.GET_PROVIDERS)) != 0) {
            applicationInfo = generateApplicationInfo(p, flags, state, userId);
        } else {
            applicationInfo = null;
        }

        PackageInfo pi = new PackageInfo();
        pi.packageName = p.packageName;
        pi.splitNames = p.splitNames;
@@ -773,7 +782,7 @@ public class PackageParser {
                        if (PackageManager.APP_DETAILS_ACTIVITY_CLASS_NAME.equals(a.className)) {
                            continue;
                        }
                        res[num++] = generateActivityInfo(a, flags, state, userId);
                        res[num++] = generateActivityInfo(a, flags, state, userId, applicationInfo);
                    }
                }
                pi.activities = ArrayUtils.trimToSize(res, num);
@@ -787,7 +796,7 @@ public class PackageParser {
                for (int i = 0; i < N; i++) {
                    final Activity a = p.receivers.get(i);
                    if (isMatch(state, a.info, flags)) {
                        res[num++] = generateActivityInfo(a, flags, state, userId);
                        res[num++] = generateActivityInfo(a, flags, state, userId, applicationInfo);
                    }
                }
                pi.receivers = ArrayUtils.trimToSize(res, num);
@@ -801,7 +810,7 @@ public class PackageParser {
                for (int i = 0; i < N; i++) {
                    final Service s = p.services.get(i);
                    if (isMatch(state, s.info, flags)) {
                        res[num++] = generateServiceInfo(s, flags, state, userId);
                        res[num++] = generateServiceInfo(s, flags, state, userId, applicationInfo);
                    }
                }
                pi.services = ArrayUtils.trimToSize(res, num);
@@ -815,7 +824,8 @@ public class PackageParser {
                for (int i = 0; i < N; i++) {
                    final Provider pr = p.providers.get(i);
                    if (isMatch(state, pr.info, flags)) {
                        res[num++] = generateProviderInfo(pr, flags, state, userId);
                        res[num++] = generateProviderInfo(pr, flags, state, userId,
                                applicationInfo);
                    }
                }
                pi.providers = ArrayUtils.trimToSize(res, num);
@@ -8216,6 +8226,11 @@ public class PackageParser {
    @UnsupportedAppUsage
    public static final ActivityInfo generateActivityInfo(Activity a, int flags,
            FrameworkPackageUserState state, int userId) {
        return generateActivityInfo(a, flags, state, userId, null);
    }

    private static ActivityInfo generateActivityInfo(Activity a, int flags,
            FrameworkPackageUserState state, int userId, ApplicationInfo applicationInfo) {
        if (a == null) return null;
        if (!checkUseInstalledOrHidden(flags, state, a.owner.applicationInfo)) {
            return null;
@@ -8227,7 +8242,12 @@ public class PackageParser {
        // Make shallow copies so we can store the metadata safely
        ActivityInfo ai = new ActivityInfo(a.info);
        ai.metaData = a.metaData;
        ai.applicationInfo = generateApplicationInfo(a.owner, flags, state, userId);

        if (applicationInfo == null) {
            applicationInfo = generateApplicationInfo(a.owner, flags, state, userId);
        }
        ai.applicationInfo = applicationInfo;

        return ai;
    }

@@ -8308,6 +8328,11 @@ public class PackageParser {
    @UnsupportedAppUsage
    public static final ServiceInfo generateServiceInfo(Service s, int flags,
            FrameworkPackageUserState state, int userId) {
        return generateServiceInfo(s, flags, state, userId, null);
    }

    private static ServiceInfo generateServiceInfo(Service s, int flags,
            FrameworkPackageUserState state, int userId, ApplicationInfo applicationInfo) {
        if (s == null) return null;
        if (!checkUseInstalledOrHidden(flags, state, s.owner.applicationInfo)) {
            return null;
@@ -8319,7 +8344,12 @@ public class PackageParser {
        // Make shallow copies so we can store the metadata safely
        ServiceInfo si = new ServiceInfo(s.info);
        si.metaData = s.metaData;
        si.applicationInfo = generateApplicationInfo(s.owner, flags, state, userId);

        if (applicationInfo == null) {
            applicationInfo = generateApplicationInfo(s.owner, flags, state, userId);
        }
        si.applicationInfo = applicationInfo;

        return si;
    }

@@ -8406,6 +8436,11 @@ public class PackageParser {
    @UnsupportedAppUsage
    public static final ProviderInfo generateProviderInfo(Provider p, int flags,
            FrameworkPackageUserState state, int userId) {
        return generateProviderInfo(p, flags, state, userId, null);
    }

    private static ProviderInfo generateProviderInfo(Provider p, int flags,
            FrameworkPackageUserState state, int userId, ApplicationInfo applicationInfo) {
        if (p == null) return null;
        if (!checkUseInstalledOrHidden(flags, state, p.owner.applicationInfo)) {
            return null;
@@ -8422,7 +8457,12 @@ public class PackageParser {
        if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
            pi.uriPermissionPatterns = null;
        }
        pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);

        if (applicationInfo == null) {
            applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
        }
        pi.applicationInfo = applicationInfo;

        return pi;
    }

+2 −1
Original line number Diff line number Diff line
@@ -1325,7 +1325,8 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * flashlight brightness level via
     * {@link android.hardware.camera2.CameraManager#turnOnTorchWithStrengthLevel }.
     * If this value is equal to 1, flashlight brightness control is not supported.
     * The value for this key will be null for devices with no flash unit.</p>
     * The value for this key will be null for devices with no flash unit.
     * This level must be set to a safe value to prevent any burn out issues.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     */
    @PublicKey
+1 −0
Original line number Diff line number Diff line
@@ -3759,6 +3759,7 @@ public final class ViewRootImpl implements ViewParent,
            }
        }
        mFirstInputStage.onWindowFocusChanged(hasWindowFocus);
        mOnBackInvokedDispatcher.onWindowFocusChanged(hasWindowFocus);

        // NOTE: there's no view visibility (appeared / disapparead) events when the windows focus
        // is lost, so we don't need to to force a flush - there might be other events such as
+3 −1
Original line number Diff line number Diff line
@@ -81,8 +81,10 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
            @OnBackInvokedDispatcher.Priority int priority,
            @NonNull OnBackInvokedCallback callback) {
        final Bundle bundle = new Bundle();
        // Always invoke back for ime without checking the window focus.
        final IOnBackInvokedCallback iCallback =
                new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback);
                new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback,
                        () -> true);
        bundle.putBinder(RESULT_KEY_CALLBACK, iCallback.asBinder());
        bundle.putInt(RESULT_KEY_PRIORITY, priority);
        bundle.putInt(RESULT_KEY_ID, callback.hashCode());
+22 −4
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Objects;
import java.util.TreeMap;
import java.util.function.Supplier;

/**
 * Provides window based implementation of {@link OnBackInvokedDispatcher}.
@@ -64,6 +65,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
    private final TreeMap<Integer, ArrayList<OnBackInvokedCallback>>
            mOnBackInvokedCallbacks = new TreeMap<>();
    private final Checker mChecker;
    private boolean mHasFocus;

    public WindowOnBackInvokedDispatcher(boolean applicationCallBackEnabled) {
        mChecker = new Checker(applicationCallBackEnabled);
@@ -189,7 +191,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
                                    .ImeOnBackInvokedCallback
                                ? ((ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback)
                                        callback).getIOnBackInvokedCallback()
                                : new OnBackInvokedCallbackWrapper(callback);
                                : new OnBackInvokedCallbackWrapper(callback, this::hasFocus);
                callbackInfo = new OnBackInvokedCallbackInfo(iCallback, priority);
            }
            mWindowSession.setOnBackInvokedCallbackInfo(mWindow, callbackInfo);
@@ -198,6 +200,17 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
        }
    }

    /**
     * Called when window focus changed.
     */
    public void onWindowFocusChanged(boolean hasFocus) {
        mHasFocus = hasFocus;
    }

    private boolean hasFocus() {
        return mHasFocus;
    }

    public OnBackInvokedCallback getTopCallback() {
        if (mAllCallbacks.isEmpty()) {
            return null;
@@ -221,9 +234,11 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {

    static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
        private final WeakReference<OnBackInvokedCallback> mCallback;

        OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback) {
        private final Supplier<Boolean> mHasFocus;
        OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback,
                @NonNull Supplier<Boolean> hasFocus) {
            mCallback = new WeakReference<>(callback);
            mHasFocus = hasFocus;
        }

        @Override
@@ -263,7 +278,10 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
                if (callback == null) {
                    return;
                }

                if (!mHasFocus.get()) {
                    Log.w(TAG, "Skip back invoke due to current focus has lost.");
                    return;
                }
                callback.onBackInvoked();
            });
        }
Loading