fixed widget don't load

This commit is contained in:
MrSluffy
2024-12-04 12:41:53 +08:00
parent 6c02371cbf
commit d1d2b9042e
4 changed files with 4 additions and 151 deletions

View File

@@ -79,7 +79,7 @@ public final class FeatureFlagsImpl implements FeatureFlags {
enableFocusOutline =
properties.getBoolean(Flags.FLAG_ENABLE_FOCUS_OUTLINE, true);
enableGeneratedPreviews =
properties.getBoolean(Flags.FLAG_ENABLE_GENERATED_PREVIEWS, true);
properties.getBoolean(Flags.FLAG_ENABLE_GENERATED_PREVIEWS, false);
enableGridOnlyOverview =
properties.getBoolean(Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW, false);
enableHandleDelayedGestureCallbacks =
@@ -109,7 +109,7 @@ public final class FeatureFlagsImpl implements FeatureFlags {
enableSmartspaceRemovalToggle =
properties.getBoolean(Flags.FLAG_ENABLE_SMARTSPACE_REMOVAL_TOGGLE, false);
enableSupportForArchiving =
properties.getBoolean(Flags.FLAG_ENABLE_SUPPORT_FOR_ARCHIVING, false);
properties.getBoolean(Flags.FLAG_ENABLE_SUPPORT_FOR_ARCHIVING, true);
enableTabletTwoPanePickerV2 =
properties.getBoolean(Flags.FLAG_ENABLE_TABLET_TWO_PANE_PICKER_V2, false);
enableTaskbarCustomization =

View File

@@ -87,8 +87,6 @@ import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AnalogClock;
import android.widget.TextClock;
import android.window.BackEvent;
import android.window.OnBackAnimationCallback;
import android.window.OnBackInvokedDispatcher;
@@ -169,7 +167,6 @@ import com.android.quickstep.RecentsModel;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TouchInteractionService.TISBinder;
import com.android.quickstep.util.AsyncClockEventDelegate;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.LauncherUnfoldAnimationController;
import com.android.quickstep.util.QuickstepOnboardingPrefs;
@@ -1477,18 +1474,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
switch (name) {
case "TextClock", "android.widget.TextClock" -> {
TextClock tc = new TextClock(context, attrs);
tc.setClockEventDelegate(AsyncClockEventDelegate.INSTANCE.get(this));
return tc;
}
case "AnalogClock", "android.widget.AnalogClock" -> {
AnalogClock ac = new AnalogClock(context, attrs);
ac.setClockEventDelegate(AsyncClockEventDelegate.INSTANCE.get(this));
return ac;
}
}
return super.onCreateView(parent, name, context, attrs);
}

View File

@@ -1,132 +0,0 @@
/*
* Copyright (C) 2023 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.
*/
package com.android.quickstep.util;
import static android.content.Intent.ACTION_TIMEZONE_CHANGED;
import static android.content.Intent.ACTION_TIME_CHANGED;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.provider.Settings;
import android.util.ArrayMap;
import android.widget.TextClock.ClockEventDelegate;
import androidx.annotation.WorkerThread;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SettingsCache;
import com.android.launcher3.util.SettingsCache.OnChangeListener;
import com.android.launcher3.util.SimpleBroadcastReceiver;
import java.util.ArrayList;
import java.util.List;
/**
* Extension of {@link ClockEventDelegate} to support async event registration
*/
public class AsyncClockEventDelegate extends ClockEventDelegate
implements OnChangeListener, SafeCloseable {
public static final MainThreadInitializedObject<AsyncClockEventDelegate> INSTANCE =
new MainThreadInitializedObject<>(AsyncClockEventDelegate::new);
private final Context mContext;
private final SimpleBroadcastReceiver mReceiver =
new SimpleBroadcastReceiver(this::onClockEventReceived);
private final ArrayMap<BroadcastReceiver, Handler> mTimeEventReceivers = new ArrayMap<>();
private final List<ContentObserver> mFormatObservers = new ArrayList<>();
private final Uri mFormatUri = Settings.System.getUriFor(Settings.System.TIME_12_24);
private boolean mFormatRegistered = false;
private boolean mDestroyed = false;
private AsyncClockEventDelegate(Context context) {
super(context);
mContext = context;
UI_HELPER_EXECUTOR.execute(() ->
mReceiver.register(mContext, ACTION_TIME_CHANGED, ACTION_TIMEZONE_CHANGED));
}
@Override
public void registerTimeChangeReceiver(BroadcastReceiver receiver, Handler handler) {
synchronized (mTimeEventReceivers) {
mTimeEventReceivers.put(receiver, handler == null ? new Handler() : handler);
}
}
@Override
public void unregisterTimeChangeReceiver(BroadcastReceiver receiver) {
synchronized (mTimeEventReceivers) {
mTimeEventReceivers.remove(receiver);
}
}
@Override
public void registerFormatChangeObserver(ContentObserver observer, int userHandle) {
if (mDestroyed) {
return;
}
synchronized (mFormatObservers) {
if (!mFormatRegistered && !mDestroyed) {
SettingsCache.INSTANCE.get(mContext).register(mFormatUri, this);
mFormatRegistered = true;
}
mFormatObservers.add(observer);
}
}
@Override
public void unregisterFormatChangeObserver(ContentObserver observer) {
synchronized (mFormatObservers) {
mFormatObservers.remove(observer);
}
}
@Override
public void onSettingsChanged(boolean isEnabled) {
if (mDestroyed) {
return;
}
synchronized (mFormatObservers) {
mFormatObservers.forEach(o -> o.dispatchChange(false, mFormatUri));
}
}
@WorkerThread
private void onClockEventReceived(Intent intent) {
if (mDestroyed) {
return;
}
synchronized (mReceiver) {
mTimeEventReceivers.forEach((r, h) -> h.post(() -> r.onReceive(mContext, intent)));
}
}
@Override
public void close() {
mDestroyed = true;
SettingsCache.INSTANCE.get(mContext).unregister(mFormatUri, this);
UI_HELPER_EXECUTOR.execute(() -> mReceiver.unregisterReceiverSafely(mContext));
}
}

View File

@@ -331,7 +331,7 @@ public final class FeatureFlags {
+ "them in launcher process using hinge sensor values.");
public static final BooleanFlag ENABLE_WIDGET_TRANSITION_FOR_RESIZING = getDebugFlag(268553314,
"ENABLE_WIDGET_TRANSITION_FOR_RESIZING", DISABLED,
"ENABLE_WIDGET_TRANSITION_FOR_RESIZING", ENABLED,
"Enable widget transition animation when resizing the widgets");
public static final BooleanFlag PREEMPTIVE_UNFOLD_ANIMATION_START = getDebugFlag(270397209,
@@ -347,7 +347,7 @@ public final class FeatureFlags {
// TODO(Block 26): Clean up flags
public static final BooleanFlag ENABLE_WIDGET_HOST_IN_BACKGROUND = getDebugFlag(270394384,
"ENABLE_WIDGET_HOST_IN_BACKGROUND", ENABLED,
"ENABLE_WIDGET_HOST_IN_BACKGROUND", DISABLED,
"Enable background widget updates listening for widget holder");
// TODO(Block 27): Clean up flags