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

Commit d603c9fd authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Remove ACTION_BOOT_COMPLETED filters"

parents 51ac26d8 cb6968c3
Loading
Loading
Loading
Loading
+0 −45
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final int MSG_DPM_STATE_CHANGED = 309;
    private static final int MSG_USER_SWITCHING = 310;
    private static final int MSG_KEYGUARD_RESET = 312;
    private static final int MSG_BOOT_COMPLETED = 313;
    private static final int MSG_USER_SWITCH_COMPLETE = 314;
    private static final int MSG_USER_INFO_CHANGED = 317;
    private static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318;
@@ -234,7 +233,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mGoingToSleep;
    private boolean mBouncer;
    private boolean mAuthInterruptActive;
    private boolean mBootCompleted;
    private boolean mNeedsSlowUnlockTransition;
    private boolean mHasLockscreenWallpaper;
    private boolean mAssistantVisible;
@@ -1075,8 +1073,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
            } else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
                mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
            } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
                dispatchBootCompleted();
            } else if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) {
                ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
                int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
@@ -1550,9 +1546,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    case MSG_KEYGUARD_BOUNCER_CHANGED:
                        handleKeyguardBouncerChanged(msg.arg1);
                        break;
                    case MSG_BOOT_COMPLETED:
                        handleBootCompleted();
                        break;
                    case MSG_USER_INFO_CHANGED:
                        handleUserInfoChanged(msg.arg1);
                        break;
@@ -1648,11 +1641,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
        broadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, mHandler);

        final IntentFilter bootCompleteFilter = new IntentFilter();
        bootCompleteFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
        bootCompleteFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
        broadcastDispatcher.registerReceiver(mBroadcastReceiver, bootCompleteFilter, mHandler);

        final IntentFilter allUserFilter = new IntentFilter();
        allUserFilter.addAction(Intent.ACTION_USER_INFO_CHANGED);
        allUserFilter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
@@ -2102,39 +2090,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    /**
     * This is exposed since {@link Intent#ACTION_BOOT_COMPLETED} is not sticky. If
     * keyguard crashes sometime after boot, then it will never receive this
     * broadcast and hence not handle the event. This method is ultimately called by
     * PhoneWindowManager in this case.
     */
    public void dispatchBootCompleted() {
        mHandler.sendEmptyMessage(MSG_BOOT_COMPLETED);
    }

    /**
     * Handle {@link #MSG_BOOT_COMPLETED}
     */
    private void handleBootCompleted() {
        checkIsHandlerThread();
        if (mBootCompleted) return;
        mBootCompleted = true;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onBootCompleted();
            }
        }
    }

    /**
     * We need to store this state in the KeyguardUpdateMonitor since this class will not be
     * destroyed.
     */
    public boolean hasBootCompleted() {
        return mBootCompleted;
    }

    /**
     * Handle {@link #MSG_DEVICE_PROVISIONED}
     */
+0 −8
Original line number Diff line number Diff line
@@ -147,14 +147,6 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onUserUnlocked() { }

    /**
     * Called when boot completed.
     *
     * Note, this callback will only be received if boot complete occurs after registering with
     * KeyguardUpdateMonitor.
     */
    public void onBootCompleted() { }

    /**
     * Called when the emergency call button is pressed.
     */
+16 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.annotation.Nullable;
import androidx.slice.Clock;

import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.systemui.BootCompleteCache;
import com.android.systemui.assist.AssistHandleBehaviorController.BehaviorController;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -83,7 +84,6 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {

    private static final String[] DEFAULT_HOME_CHANGE_ACTIONS = new String[] {
            PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED,
            Intent.ACTION_BOOT_COMPLETED,
            Intent.ACTION_PACKAGE_ADDED,
            Intent.ACTION_PACKAGE_CHANGED,
            Intent.ACTION_PACKAGE_REMOVED
@@ -150,6 +150,15 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
            mDefaultHome = getCurrentDefaultHome();
        }
    };

    private final BootCompleteCache.BootCompleteListener mBootCompleteListener =
            new BootCompleteCache.BootCompleteListener() {
        @Override
        public void onBootComplete() {
            mDefaultHome = getCurrentDefaultHome();
        }
    };

    private final IntentFilter mDefaultHomeIntentFilter;
    private final Runnable mResetConsecutiveTaskSwitches = this::resetConsecutiveTaskSwitches;

@@ -163,6 +172,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
    private final Lazy<WakefulnessLifecycle> mWakefulnessLifecycle;
    private final Lazy<PackageManagerWrapper> mPackageManagerWrapper;
    private final Lazy<BroadcastDispatcher> mBroadcastDispatcher;
    private final Lazy<BootCompleteCache> mBootCompleteCache;

    private boolean mOnLockscreen;
    private boolean mIsDozing;
@@ -196,7 +206,8 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
            Lazy<SysUiState> sysUiFlagContainer,
            Lazy<WakefulnessLifecycle> wakefulnessLifecycle,
            Lazy<PackageManagerWrapper> packageManagerWrapper,
            Lazy<BroadcastDispatcher> broadcastDispatcher) {
            Lazy<BroadcastDispatcher> broadcastDispatcher,
            Lazy<BootCompleteCache> bootCompleteCache) {
        mClock = clock;
        mHandler = handler;
        mDeviceConfigHelper = deviceConfigHelper;
@@ -211,6 +222,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
            mDefaultHomeIntentFilter.addAction(action);
        }
        mBroadcastDispatcher = broadcastDispatcher;
        mBootCompleteCache = bootCompleteCache;
    }

    @Override
@@ -218,6 +230,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
        mContext = context;
        mAssistHandleCallbacks = callbacks;
        mConsecutiveTaskSwitches = 0;
        mBootCompleteCache.get().addListener(mBootCompleteListener);
        mDefaultHome = getCurrentDefaultHome();
        mBroadcastDispatcher.get()
                .registerReceiver(mDefaultHomeBroadcastReceiver, mDefaultHomeIntentFilter);
@@ -250,6 +263,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
        mAssistHandleCallbacks = null;
        if (mContext != null) {
            mBroadcastDispatcher.get().unregisterReceiver(mDefaultHomeBroadcastReceiver);
            mBootCompleteCache.get().removeListener(mBootCompleteListener);
            Settings.Secure.putLong(mContext.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, 0);
            Settings.Secure.putInt(mContext.getContentResolver(), LEARNING_EVENT_COUNT_KEY, 0);
            Settings.Secure.putLong(mContext.getContentResolver(), LEARNED_HINT_LAST_SHOWN_KEY, 0);
+3 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.pm.ResolveInfo;

import androidx.annotation.Nullable;

import com.android.systemui.BootCompleteCache;
import com.android.systemui.Dependency;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -62,7 +63,6 @@ public final class PhoneStateMonitor {

    private static final String[] DEFAULT_HOME_CHANGE_ACTIONS = new String[] {
            PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED,
            Intent.ACTION_BOOT_COMPLETED,
            Intent.ACTION_PACKAGE_ADDED,
            Intent.ACTION_PACKAGE_CHANGED,
            Intent.ACTION_PACKAGE_REMOVED
@@ -77,13 +77,14 @@ public final class PhoneStateMonitor {

    @Inject
    PhoneStateMonitor(Context context, BroadcastDispatcher broadcastDispatcher,
            Optional<Lazy<StatusBar>> statusBarOptionalLazy) {
            Optional<Lazy<StatusBar>> statusBarOptionalLazy, BootCompleteCache bootCompleteCache) {
        mContext = context;
        mStatusBarOptionalLazy = statusBarOptionalLazy;
        mStatusBarStateController = Dependency.get(StatusBarStateController.class);

        ActivityManagerWrapper activityManagerWrapper = ActivityManagerWrapper.getInstance();
        mDefaultHome = getCurrentDefaultHome();
        bootCompleteCache.addListener(() -> mDefaultHome = getCurrentDefaultHome());
        IntentFilter intentFilter = new IntentFilter();
        for (String action : DEFAULT_HOME_CHANGE_ACTIONS) {
            intentFilter.addAction(action);
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ private const val DEBUG = false
 * a given broadcast.
 *
 * Use only for IntentFilters with actions and optionally categories. It does not support,
 * permissions, schemes, data types or data authorities.
 * permissions, schemes, data types, data authorities or priority different than 0.
 * Cannot be used for getting sticky broadcasts.
 */
@Singleton
@@ -104,6 +104,7 @@ open class BroadcastDispatcher @Inject constructor (
        if (filter.countDataPaths() != 0) sb.append("Filter cannot contain DataPaths. ")
        if (filter.countDataSchemes() != 0) sb.append("Filter cannot contain DataSchemes. ")
        if (filter.countDataTypes() != 0) sb.append("Filter cannot contain DataTypes. ")
        if (filter.priority != 0) sb.append("Filter cannot modify priority. ")
        if (!TextUtils.isEmpty(sb)) throw IllegalArgumentException(sb.toString())
    }

Loading