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

Commit 7f02b7f3 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10704513 from a9d53171 to udc-qpr1-release

Change-Id: I1b8aab2a5313fd1f2a8bdfe723e57b64db982f1f
parents 0b415993 a9d53171
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1118,6 +1118,7 @@ public final class JobStore {
            }
            boolean needFileMigration = false;
            long nowElapsed = sElapsedRealtimeClock.millis();
            int numDuplicates = 0;
            synchronized (mLock) {
                for (File file : files) {
                    final AtomicFile aFile = createJobFile(file);
@@ -1126,6 +1127,16 @@ public final class JobStore {
                        if (jobs != null) {
                            for (int i = 0; i < jobs.size(); i++) {
                                JobStatus js = jobs.get(i);
                                final JobStatus existingJob = this.jobSet.get(
                                        js.getUid(), js.getNamespace(), js.getJobId());
                                if (existingJob != null) {
                                    numDuplicates++;
                                    // Jobs are meant to have unique uid-namespace-jobId
                                    // combinations, but we've somehow read multiple jobs with the
                                    // combination. Drop the latter one since keeping both will
                                    // result in other issues.
                                    continue;
                                }
                                js.prepareLocked();
                                js.enqueueTime = nowElapsed;
                                this.jobSet.add(js);
@@ -1174,6 +1185,10 @@ public final class JobStore {
                migrateJobFilesAsync();
            }

            if (numDuplicates > 0) {
                Slog.wtf(TAG, "Encountered " + numDuplicates + " duplicate persisted jobs");
            }

            // Log the count immediately after loading from boot.
            mCurrentJobSetSize = numJobs;
            mScheduledJob30MinHighWaterMark = mCurrentJobSetSize;
+108 −19
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UiThread;
import android.annotation.UserIdInt;
import android.app.IServiceConnection;
import android.app.PendingIntent;
@@ -39,6 +40,10 @@ import android.content.pm.ShortcutInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.DisplayMetrics;
@@ -53,6 +58,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

/**
 * Updates AppWidget state; gets information about installed AppWidget providers and other
@@ -475,6 +481,8 @@ public class AppWidgetManager {

    private static final String TAG = "AppWidgetManager";

    private static Executor sUpdateExecutor;

    /**
     * An intent extra that contains multiple appWidgetIds.  These are id values as
     * they were provided to the application during a recent restore from backup.  It is
@@ -510,6 +518,8 @@ public class AppWidgetManager {
    private final IAppWidgetService mService;
    private final DisplayMetrics mDisplayMetrics;

    private boolean mHasPostedLegacyLists = false;

    /**
     * Get the AppWidgetManager instance to use for the supplied {@link android.content.Context
     * Context} object.
@@ -552,6 +562,13 @@ public class AppWidgetManager {
        });
    }

    private boolean isPostingTaskToBackground(@Nullable RemoteViews views) {
        return Looper.myLooper() == Looper.getMainLooper()
                && RemoteViews.isAdapterConversionEnabled()
                && (mHasPostedLegacyLists = mHasPostedLegacyLists
                        || (views != null && views.hasLegacyLists()));
    }

    /**
     * Set the RemoteViews to use for the specified appWidgetIds.
     * <p>
@@ -575,6 +592,19 @@ public class AppWidgetManager {
        if (mService == null) {
            return;
        }

        if (isPostingTaskToBackground(views)) {
            createUpdateExecutorIfNull().execute(() -> {
                try {
                    mService.updateAppWidgetIds(mPackageName, appWidgetIds, views);
                } catch (RemoteException e) {
                    Log.e(TAG, "Error updating app widget views in background", e);
                }
            });

            return;
        }

        try {
            mService.updateAppWidgetIds(mPackageName, appWidgetIds, views);
        } catch (RemoteException e) {
@@ -683,6 +713,19 @@ public class AppWidgetManager {
        if (mService == null) {
            return;
        }

        if (isPostingTaskToBackground(views)) {
            createUpdateExecutorIfNull().execute(() -> {
                try {
                    mService.partiallyUpdateAppWidgetIds(mPackageName, appWidgetIds, views);
                } catch (RemoteException e) {
                    Log.e(TAG, "Error partially updating app widget views in background", e);
                }
            });

            return;
        }

        try {
            mService.partiallyUpdateAppWidgetIds(mPackageName, appWidgetIds, views);
        } catch (RemoteException e) {
@@ -738,6 +781,19 @@ public class AppWidgetManager {
        if (mService == null) {
            return;
        }

        if (isPostingTaskToBackground(views)) {
            createUpdateExecutorIfNull().execute(() -> {
                try {
                    mService.updateAppWidgetProvider(provider, views);
                } catch (RemoteException e) {
                    Log.e(TAG, "Error updating app widget view using provider in background", e);
                }
            });

            return;
        }

        try {
            mService.updateAppWidgetProvider(provider, views);
        } catch (RemoteException e) {
@@ -786,8 +842,28 @@ public class AppWidgetManager {
        if (mService == null) {
            return;
        }

        if (!RemoteViews.isAdapterConversionEnabled()) {
            try {
                mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId);
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
            }

            return;
        }

        if (Looper.myLooper() == Looper.getMainLooper()) {
            mHasPostedLegacyLists = true;
            createUpdateExecutorIfNull().execute(() -> notifyCollectionWidgetChange(appWidgetIds,
                    viewId));
        } else {
            notifyCollectionWidgetChange(appWidgetIds, viewId);
        }
    }

    private void notifyCollectionWidgetChange(int[] appWidgetIds, int viewId) {
        try {
            if (RemoteViews.isAdapterConversionEnabled()) {
            List<CompletableFuture<Void>> updateFutures = new ArrayList<>();
            for (int i = 0; i < appWidgetIds.length; i++) {
                final int widgetId = appWidgetIds[i];
@@ -803,11 +879,8 @@ public class AppWidgetManager {
                }));
            }
            CompletableFuture.allOf(updateFutures.toArray(CompletableFuture[]::new)).join();
            } else {
                mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (Exception e) {
            Log.e(TAG, "Error notifying changes for all widgets", e);
        }
    }

@@ -1338,4 +1411,20 @@ public class AppWidgetManager {
            throw e.rethrowFromSystemServer();
        }
    }

    @UiThread
    private static @NonNull Executor createUpdateExecutorIfNull() {
        if (sUpdateExecutor == null) {
            sUpdateExecutor = new HandlerExecutor(createAndStartNewHandler(
                    "widget_manager_update_helper_thread", Process.THREAD_PRIORITY_FOREGROUND));
        }

        return sUpdateExecutor;
    }

    private static @NonNull Handler createAndStartNewHandler(@NonNull String name, int priority) {
        HandlerThread thread = new HandlerThread(name, priority);
        thread.start();
        return thread.getThreadHandler();
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_LOCKSCREEN_TRANSFER_API, "true");
        DEFAULT_FLAGS.put(SETTINGS_REMOTE_DEVICE_CREDENTIAL_VALIDATION, "true");
        DEFAULT_FLAGS.put(SETTINGS_BIOMETRICS2_FINGERPRINT_SETTINGS, "false");
        DEFAULT_FLAGS.put("settings_press_hold_nav_handle_to_search", "false");
    }

    private static final Set<String> PERSISTENT_FLAGS;
+5 −5
Original line number Diff line number Diff line
@@ -351,13 +351,13 @@ public class HandwritingInitiator {
    }

    private static boolean shouldTriggerStylusHandwritingForView(@NonNull View view) {
        if (!view.isAutoHandwritingEnabled()) {
        if (!view.shouldInitiateHandwriting()) {
            return false;
        }
        // The view may be a handwriting initiation delegate, in which case it is not the editor
        // The view may be a handwriting initiation delegator, in which case it is not the editor
        // view for which handwriting would be started. However, in almost all cases, the return
        // values of View#isStylusHandwritingAvailable will be the same for the delegate view and
        // the delegator editor view. So the delegate view can be used to decide whether handwriting
        // values of View#isStylusHandwritingAvailable will be the same for the delegator view and
        // the delegate editor view. So the delegator view can be used to decide whether handwriting
        // should be triggered.
        return view.isStylusHandwritingAvailable();
    }
@@ -682,7 +682,7 @@ public class HandwritingInitiator {
    /** The helper method to check if the given view is still active for handwriting. */
    private static boolean isViewActive(@Nullable View view) {
        return view != null && view.isAttachedToWindow() && view.isAggregatedVisible()
                && view.isAutoHandwritingEnabled();
                && view.shouldInitiateHandwriting();
    }

    /**
+13 −4
Original line number Diff line number Diff line
@@ -5488,7 +5488,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                (TEXT_ALIGNMENT_DEFAULT << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) |
                (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) |
                (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT);
        mPrivateFlags4 = PFLAG4_AUTO_HANDWRITING_ENABLED;
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        mTouchSlop = configuration.getScaledTouchSlop();
@@ -6213,7 +6212,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    setPreferKeepClear(a.getBoolean(attr, false));
                    break;
                case R.styleable.View_autoHandwritingEnabled:
                    setAutoHandwritingEnabled(a.getBoolean(attr, true));
                    setAutoHandwritingEnabled(a.getBoolean(attr, false));
                    break;
                case R.styleable.View_handwritingBoundsOffsetLeft:
                    mHandwritingBoundsOffsetLeft = a.getDimension(attr, 0);
@@ -12078,7 +12077,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (getSystemGestureExclusionRects().isEmpty()
                && collectPreferKeepClearRects().isEmpty()
                && collectUnrestrictedPreferKeepClearRects().isEmpty()
                && (info.mHandwritingArea == null || !isAutoHandwritingEnabled())) {
                && (info.mHandwritingArea == null || !shouldInitiateHandwriting())) {
            if (info.mPositionUpdateListener != null) {
                mRenderNode.removePositionUpdateListener(info.mPositionUpdateListener);
                info.mPositionUpdateListener = null;
@@ -12445,13 +12444,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    void updateHandwritingArea() {
        // If autoHandwritingArea is not enabled, do nothing.
        if (!isAutoHandwritingEnabled()) return;
        if (!shouldInitiateHandwriting()) return;
        final AttachInfo ai = mAttachInfo;
        if (ai != null) {
            ai.mViewRootImpl.getHandwritingInitiator().updateHandwritingAreasForView(this);
        }
    }
    /**
     * Returns true if a stylus {@link MotionEvent} within this view's bounds should initiate
     * handwriting mode, either for this view ({@link #isAutoHandwritingEnabled()} is {@code true})
     * or for a handwriting delegate view ({@link #getHandwritingDelegatorCallback()} is not {@code
     * null}).
     */
    boolean shouldInitiateHandwriting() {
        return isAutoHandwritingEnabled() || getHandwritingDelegatorCallback() != null;
    }
    /**
     * Sets a callback which should be called when a stylus {@link MotionEvent} occurs within this
     * view's bounds. The callback will be called from the UI thread.
Loading