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

Commit 898e1bbf authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Remove calls to Dependency.get(FalsingManager.class)

This removes all calls except one, which is used in a View.

Bug: 136279712
Test: atest SystemUITests
Change-Id: Ibadb81a41a4d23208842a99fa89436fd34b7a8a0
parent 4bec4b2f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2752,7 +2752,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

    private void checkIsHandlerThread() {
        if (!mHandler.getLooper().isCurrentThread()) {
            Log.wtf(TAG, "must call on mHandler's thread "
            Log.wtfStack(TAG, "must call on mHandler's thread "
                    + mHandler.getLooper().getThread() + ", not " + Thread.currentThread());
        }
    }
+9 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui;

import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.power.PowerUI;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsModule;

import dagger.Binds;
import dagger.Module;
@@ -27,7 +29,7 @@ import dagger.multibindings.IntoMap;
/**
 * SystemUI objects that are injectable should go here.
 */
@Module
@Module(includes = {RecentsModule.class})
public abstract class SystemUIBinder {
    /** Inject into KeyguardViewMediator. */
    @Binds
@@ -40,4 +42,10 @@ public abstract class SystemUIBinder {
    @IntoMap
    @ClassKey(PowerUI.class)
    public abstract SystemUI bindPowerUI(PowerUI sysui);

    /** Inject into StatusBar. */
    @Binds
    @IntoMap
    @ClassKey(Recents.class)
    public abstract SystemUI bindRecents(Recents sysui);
}
+8 −25
Original line number Diff line number Diff line
@@ -21,25 +21,30 @@ import android.content.res.Configuration;
import android.graphics.Rect;
import android.provider.Settings;

import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.CommandQueue;

import java.io.FileDescriptor;
import java.io.PrintWriter;

import javax.inject.Inject;

/**
 * A proxy to a Recents implementation.
 */
public class Recents extends SystemUI implements CommandQueue.Callbacks {

    private RecentsImplementation mImpl;
    private final RecentsImplementation mImpl;

    @Inject
    public Recents(RecentsImplementation impl) {
        mImpl = impl;
    }

    @Override
    public void start() {
        getComponent(CommandQueue.class).addCallback(this);
        putComponent(Recents.class, this);
        mImpl = createRecentsImplementationFromConfig();
        mImpl.onStart(mContext, this);
    }

@@ -139,28 +144,6 @@ public class Recents extends SystemUI implements CommandQueue.Callbacks {
                (Settings.Secure.getInt(cr, Settings.Secure.USER_SETUP_COMPLETE, 0) != 0);
    }

    /**
     * @return The recents implementation from the config.
     */
    private RecentsImplementation createRecentsImplementationFromConfig() {
        final String clsName = mContext.getString(R.string.config_recentsComponent);
        if (clsName == null || clsName.length() == 0) {
            throw new RuntimeException("No recents component configured", null);
        }
        Class<?> cls = null;
        try {
            cls = mContext.getClassLoader().loadClass(clsName);
        } catch (Throwable t) {
            throw new RuntimeException("Error loading recents component: " + clsName, t);
        }
        try {
            RecentsImplementation impl = (RecentsImplementation) cls.newInstance();
            return impl;
        } catch (Throwable t) {
            throw new RuntimeException("Error creating recents component: " + clsName, t);
        }
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        mImpl.dump(pw);
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.recents;

import android.content.Context;

import com.android.systemui.R;

import dagger.Module;
import dagger.Provides;

/**
 * Dagger injection module for {@link RecentsImplementation}
 */
@Module
public class RecentsModule {
    /**
     * @return The {@link RecentsImplementation} from the config.
     */
    @Provides
    public RecentsImplementation provideRecentsImpl(Context context) {
        final String clsName = context.getString(R.string.config_recentsComponent);
        if (clsName == null || clsName.length() == 0) {
            throw new RuntimeException("No recents component configured", null);
        }
        Class<?> cls = null;
        try {
            cls = context.getClassLoader().loadClass(clsName);
        } catch (Throwable t) {
            throw new RuntimeException("Error loading recents component: " + clsName, t);
        }
        try {
            RecentsImplementation impl = (RecentsImplementation) cls.newInstance();
            return impl;
        } catch (Throwable t) {
            throw new RuntimeException("Error creating recents component: " + clsName, t);
        }
    }
}
+6 −8
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.SystemClock
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.ViewConfiguration
import com.android.systemui.Dependency

import com.android.systemui.Gefingerpoken
import com.android.systemui.Interpolators
@@ -58,7 +57,8 @@ constructor(
    private val bypassController: KeyguardBypassController,
    private val headsUpManager: HeadsUpManagerPhone,
    private val roundnessManager: NotificationRoundnessManager,
    private val statusBarStateController: StatusBarStateController
    private val statusBarStateController: StatusBarStateController,
    private val falsingManager: FalsingManager
) : Gefingerpoken {
    companion object {
        private val RUBBERBAND_FACTOR_STATIC = 0.25f
@@ -99,7 +99,6 @@ constructor(
    private val mTemp2 = IntArray(2)
    private var mDraggedFarEnough: Boolean = false
    private var mStartingChild: ExpandableView? = null
    private val mFalsingManager: FalsingManager
    private var mPulsing: Boolean = false
    var isWakingToShadeLocked: Boolean = false
        private set
@@ -109,7 +108,7 @@ constructor(
    private var velocityTracker: VelocityTracker? = null

    private val isFalseTouch: Boolean
        get() = mFalsingManager.isFalseTouch
        get() = falsingManager.isFalseTouch
    var qsExpanded: Boolean = false
    var pulseExpandAbortListener: Runnable? = null
    var bouncerShowing: Boolean = false
@@ -118,7 +117,6 @@ constructor(
        mMinDragDistance = context.resources.getDimensionPixelSize(
                R.dimen.keyguard_drag_down_min_distance)
        mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat()
        mFalsingManager = Dependency.get(FalsingManager::class.java)
        mPowerManager = context.getSystemService(PowerManager::class.java)
    }

@@ -151,7 +149,7 @@ constructor(
            MotionEvent.ACTION_MOVE -> {
                val h = y - mInitialTouchY
                if (h > mTouchSlop && h > Math.abs(x - mInitialTouchX)) {
                    mFalsingManager.onStartExpandingFromPulse()
                    falsingManager.onStartExpandingFromPulse()
                    isExpanding = true
                    captureStartingChild(mInitialTouchX, mInitialTouchY)
                    mInitialTouchY = y
@@ -192,7 +190,7 @@ constructor(
                velocityTracker!!.computeCurrentVelocity(1000 /* units */)
                val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 &&
                        statusBarStateController.state != StatusBarState.SHADE
                if (!mFalsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) {
                if (!falsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) {
                    finishExpansion()
                } else {
                    cancelExpansion()
@@ -297,7 +295,7 @@ constructor(

    private fun cancelExpansion() {
        isExpanding = false
        mFalsingManager.onExpansionFromPulseStopped()
        falsingManager.onExpansionFromPulseStopped()
        if (mStartingChild != null) {
            reset(mStartingChild!!)
            mStartingChild = null
Loading