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

Commit b939f5a3 authored by Vineeth Bhende's avatar Vineeth Bhende
Browse files

Revert "Move registering receivers to corestartable"

This reverts commit ac6e09a5.

Reason for revert: This change is unused due to the regression observed with the battery percentage update delayed on startup - b/341240049

Change-Id: I497ce12a3ff2b82bf22a80b897ab4012dcf7b20b
parent 7c7f6d3a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -294,7 +294,6 @@ filegroup {
        "tests/src/**/systemui/qs/tiles/dialog/InternetDetailsContentManagerTest.kt",
        "tests/src/**/systemui/qs/external/TileLifecycleManagerTest.java",
        "tests/src/**/systemui/ScreenDecorationsTest.java",
        "tests/src/**/systemui/statusbar/policy/BatteryControllerStartableTest.java",
        "tests/src/**/systemui/user/domain/interactor/HeadlessSystemUserModeImplTest.kt",
        "tests/src/**/keyguard/CarrierTextManagerTest.java",
        "tests/src/**/keyguard/KeyguardUpdateMonitorTest.java",
+0 −10
Original line number Diff line number Diff line
@@ -1053,16 +1053,6 @@ flag {
    }
}

flag {
    name: "register_battery_controller_receivers_in_corestartable"
    namespace: "systemui"
    description: "Decide whether to register the receivers in battery controller impl in the BatteryControllerStartable corestartable."
    bug: "307517093"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
  name: "ambient_touch_monitor_listen_to_display_changes"
  namespace: "systemui"
+0 −7
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import com.android.systemui.statusbar.ImmersiveModeConfirmation
import com.android.systemui.statusbar.gesture.GesturePointerEventListener
import com.android.systemui.statusbar.notification.InstantAppNotifier
import com.android.systemui.statusbar.notification.headsup.StatusBarHeadsUpChangeListener
import com.android.systemui.statusbar.policy.BatteryControllerStartable
import com.android.systemui.stylus.StylusUsiPowerStartable
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.theme.ThemeOverlayController
@@ -304,12 +303,6 @@ abstract class SystemUICoreStartableModule {
    @ClassKey(HomeControlsDreamStartable::class)
    abstract fun bindHomeControlsDreamStartable(impl: HomeControlsDreamStartable): CoreStartable

    /** Binds {@link BatteryControllerStartable} as a {@link CoreStartable}. */
    @Binds
    @IntoMap
    @ClassKey(BatteryControllerStartable::class)
    abstract fun bindsBatteryControllerStartable(impl: BatteryControllerStartable): CoreStartable

    @Binds
    @IntoMap
    @ClassKey(MSDLCoreStartable::class)
+1 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.os.BatteryManager.EXTRA_CHARGING_STATUS;
import static android.os.BatteryManager.EXTRA_PRESENT;

import static com.android.settingslib.fuelgauge.BatterySaverLogging.SAVER_ENABLED_QS;
import static com.android.systemui.Flags.registerBatteryControllerReceiversInCorestartable;
import static com.android.systemui.util.DumpUtilsKt.asIndenting;

import android.annotation.WorkerThread;
@@ -150,9 +149,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
    @Override
    public void init() {
        mLogger.logBatteryControllerInit(this, mHasReceivedBattery);
        if (!registerBatteryControllerReceiversInCorestartable()) {
        registerReceiver();
        }
        if (!mHasReceivedBattery) {
            // Get initial state. Relying on Sticky behavior until API for getting info.
            Intent intent = mContext.registerReceiver(
+0 −74
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.systemui.statusbar.policy;

import static com.android.systemui.Flags.registerBatteryControllerReceiversInCorestartable;

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbManager;
import android.os.PowerManager;

import com.android.systemui.CoreStartable;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;

import java.util.concurrent.Executor;

import javax.inject.Inject;

/** A {@link CoreStartable} responsible for registering the receivers for
 * {@link BatteryControllerImpl}.
 */
@SysUISingleton
public class BatteryControllerStartable implements CoreStartable {

    private final BatteryController mBatteryController;
    private final Executor mBackgroundExecutor;

    private static final String ACTION_LEVEL_TEST = "com.android.systemui.BATTERY_LEVEL_TEST";

    protected final BroadcastDispatcher mBroadcastDispatcher;
    @Inject
    public BatteryControllerStartable(
            BatteryController batteryController,
            BroadcastDispatcher broadcastDispatcher,
            @Background Executor backgroundExecutor) {
        mBatteryController = batteryController;
        mBroadcastDispatcher = broadcastDispatcher;
        mBackgroundExecutor = backgroundExecutor;
    }

    private void registerReceiver() {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
        filter.addAction(ACTION_LEVEL_TEST);
        filter.addAction(UsbManager.ACTION_USB_PORT_COMPLIANCE_CHANGED);
        mBroadcastDispatcher.registerReceiver((BroadcastReceiver) mBatteryController, filter);
    }

    @Override
    public void start() {
        if (registerBatteryControllerReceiversInCorestartable()
                && mBatteryController instanceof BatteryControllerImpl) {
            mBackgroundExecutor.execute(() -> registerReceiver());
        }
    }
}
Loading