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

Commit bba732de authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Remove Dependency.staticOnConfigurationChanged

ConfigurationChangedReceiver is removed. Classes that want to be
notified of configuration changes should implement
ConfigurationController.ConfigurationListener instead and register
themselves with the ConfigurationController.

Bug: 144782965
Test: atest SystemUITests
Change-Id: Id2c3fe5ae2729b181769fb31b8050da264299d72
parent ad51c4d8
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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;

import android.content.res.Configuration;

public interface ConfigurationChangedReceiver {
    void onConfigurationChanged(Configuration newConfiguration);
}
+0 −10
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ import android.annotation.Nullable;
import android.app.AlarmManager;
import android.app.INotificationManager;
import android.app.IWallpaperManager;
import android.content.res.Configuration;
import android.hardware.SensorPrivacyManager;
import android.hardware.display.NightDisplayListener;
import android.os.Handler;
@@ -555,15 +554,6 @@ public class Dependency {
                .forEach(o -> ((Dumpable) o).dump(fd, pw, args));
    }

    protected static void staticOnConfigurationChanged(Configuration newConfig) {
        sDependency.onConfigurationChanged(newConfig);
    }

    protected synchronized void onConfigurationChanged(Configuration newConfig) {
        mDependencies.values().stream().filter(obj -> obj instanceof ConfigurationChangedReceiver)
                .forEach(o -> ((ConfigurationChangedReceiver) o).onConfigurationChanged(newConfig));
    }

    protected final <T> T getDependency(Class<T> cls) {
        return getDependencyInner(cls);
    }
+5 −1
Original line number Diff line number Diff line
@@ -218,7 +218,11 @@ public class SystemUIApplication extends Application implements
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (mServicesStarted) {
            Dependency.staticOnConfigurationChanged(newConfig);
            SystemUIFactory
                    .getInstance()
                    .getRootComponent()
                    .getConfigurationController()
                    .onConfigurationChanged(newConfig);
            int len = mServices.length;
            for (int i = 0; i < len; i++) {
                if (mServices[i] != null) {
+34 −27
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.settingslib.applications.InterestingConfigChanges;
import com.android.systemui.ConfigurationChangedReceiver;
import com.android.systemui.R;
import com.android.systemui.assist.ui.DefaultUiController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;

import javax.inject.Inject;
@@ -55,7 +55,7 @@ import javax.inject.Singleton;
 * Class to manage everything related to assist in SystemUI.
 */
@Singleton
public class AssistManager implements ConfigurationChangedReceiver {
public class AssistManager {

    /**
     * Controls the UI for showing Assistant invocation progress.
@@ -154,6 +154,33 @@ public class AssistManager implements ConfigurationChangedReceiver {
        }
    };

    private ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
                @Override
                public void onConfigChanged(Configuration newConfig) {
                    if (!mInterestingConfigChanges.applyNewConfig(mContext.getResources())) {
                        return;
                    }
                    boolean visible = false;
                    if (mView != null) {
                        visible = mView.isShowing();
                        mWindowManager.removeView(mView);
                    }

                    mView = (AssistOrbContainer) LayoutInflater.from(mContext).inflate(
                            R.layout.assist_orb, null);
                    mView.setVisibility(View.GONE);
                    mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
                    WindowManager.LayoutParams lp = getLayoutParams();
                    mWindowManager.addView(mView, lp);
                    if (visible) {
                        mView.show(true /* show */, false /* animate */);
                    }
                }
            };

    @Inject
    public AssistManager(
            DeviceProvisionedController controller,
@@ -162,7 +189,8 @@ public class AssistManager implements ConfigurationChangedReceiver {
            AssistHandleBehaviorController handleController,
            CommandQueue commandQueue,
            PhoneStateMonitor phoneStateMonitor,
            OverviewProxyService overviewProxyService) {
            OverviewProxyService overviewProxyService,
            ConfigurationController configurationController) {
        mContext = context;
        mDeviceProvisionedController = controller;
        mCommandQueue = commandQueue;
@@ -172,11 +200,13 @@ public class AssistManager implements ConfigurationChangedReceiver {
        mPhoneStateMonitor = phoneStateMonitor;
        mHandleController = handleController;

        configurationController.addCallback(mConfigurationListener);

        registerVoiceInteractionSessionListener();
        mInterestingConfigChanges = new InterestingConfigChanges(ActivityInfo.CONFIG_ORIENTATION
                | ActivityInfo.CONFIG_LOCALE | ActivityInfo.CONFIG_UI_MODE
                | ActivityInfo.CONFIG_SCREEN_LAYOUT | ActivityInfo.CONFIG_ASSETS_PATHS);
        onConfigurationChanged(context.getResources().getConfiguration());
        mConfigurationListener.onConfigChanged(context.getResources().getConfiguration());
        mShouldEnableOrb = !ActivityManager.isLowRamDeviceStatic();

        mUiController = new DefaultUiController(mContext);
@@ -225,29 +255,6 @@ public class AssistManager implements ConfigurationChangedReceiver {
                });
    }

    public void onConfigurationChanged(Configuration newConfiguration) {
        if (!mInterestingConfigChanges.applyNewConfig(mContext.getResources())) {
            return;
        }
        boolean visible = false;
        if (mView != null) {
            visible = mView.isShowing();
            mWindowManager.removeView(mView);
        }

        mView = (AssistOrbContainer) LayoutInflater.from(mContext).inflate(
                R.layout.assist_orb, null);
        mView.setVisibility(View.GONE);
        mView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        WindowManager.LayoutParams lp = getLayoutParams();
        mWindowManager.addView(mView, lp);
        if (visible) {
            mView.show(true /* show */, false /* animate */);
        }
    }

    protected boolean shouldShowOrb() {
        return false;
    }
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.InjectionInflationController;

import javax.inject.Named;
@@ -46,6 +47,12 @@ import dagger.Component;
        SystemUIDefaultModule.class})
public interface SystemUIRootComponent {

    /**
     * Creates a ContextComponentHelper.
     */
    @Singleton
    ConfigurationController getConfigurationController();

    /**
     * Creates a ContextComponentHelper.
     */
Loading