Remove Context from LightsManager constructor
Remove context from LightsManager as well as from its derived class: InputDeviceLightsManager. There aren't any usages of mContext in these classes. Hence, InputDeviceLightsManager can be called from InputManagerGlobal without any requirement of context to be passed. The Managers can also be removed from the InputManager class. Bug: b/267758905 Test: Pre-submit Change-Id: Ie89f5b47339d079216f93714718061efb478503a
This commit is contained in:
@@ -18,7 +18,6 @@ package android.hardware.input;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.ActivityThread;
|
||||
import android.content.Context;
|
||||
import android.hardware.lights.Light;
|
||||
import android.hardware.lights.LightState;
|
||||
import android.hardware.lights.LightsManager;
|
||||
@@ -44,8 +43,7 @@ class InputDeviceLightsManager extends LightsManager {
|
||||
// Package name
|
||||
private final String mPackageName;
|
||||
|
||||
InputDeviceLightsManager(Context context, int deviceId) {
|
||||
super(context);
|
||||
InputDeviceLightsManager(int deviceId) {
|
||||
mGlobal = InputManagerGlobal.getInstance();
|
||||
mDeviceId = deviceId;
|
||||
mPackageName = ActivityThread.currentPackageName();
|
||||
|
||||
@@ -32,8 +32,6 @@ import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.hardware.BatteryState;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.lights.LightsManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -41,7 +39,6 @@ import android.os.InputEventInjectionSync;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.os.Vibrator;
|
||||
import android.os.VibratorManager;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.InputDevice;
|
||||
@@ -1310,47 +1307,6 @@ public final class InputManager {
|
||||
return new InputDeviceVibrator(deviceId, vibratorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vibrator manager service associated with an input device, always creates a new
|
||||
* instance.
|
||||
* @return The vibrator manager, never null.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
public VibratorManager getInputDeviceVibratorManager(int deviceId) {
|
||||
return new InputDeviceVibratorManager(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sensor manager service associated with an input device, always creates a new instance.
|
||||
* @return The sensor manager, never null.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
public SensorManager getInputDeviceSensorManager(int deviceId) {
|
||||
return mGlobal.getInputDeviceSensorManager(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a battery state object associated with an input device, assuming it has one.
|
||||
* @return The battery, never null.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
public BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) {
|
||||
return mGlobal.getInputDeviceBatteryState(deviceId, hasBattery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a lights manager associated with an input device, always creates a new instance.
|
||||
* @return The lights manager, never null.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
public LightsManager getInputDeviceLightsManager(int deviceId) {
|
||||
return new InputDeviceLightsManager(getContext(), deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all ongoing pointer gestures on all displays.
|
||||
* @hide
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.hardware.input.InputManager.KeyboardBacklightListener;
|
||||
import android.hardware.input.InputManager.OnTabletModeChangedListener;
|
||||
import android.hardware.lights.Light;
|
||||
import android.hardware.lights.LightState;
|
||||
import android.hardware.lights.LightsManager;
|
||||
import android.hardware.lights.LightsRequest;
|
||||
import android.os.Binder;
|
||||
import android.os.CombinedVibration;
|
||||
@@ -876,7 +877,7 @@ public final class InputManagerGlobal {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InputManager#getInputDeviceSensorManager(int)
|
||||
* @see InputDevice#getSensorManager()
|
||||
*/
|
||||
@NonNull
|
||||
public SensorManager getInputDeviceSensorManager(int deviceId) {
|
||||
@@ -954,6 +955,14 @@ public final class InputManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InputDevice#getLightsManager()
|
||||
*/
|
||||
@NonNull
|
||||
public LightsManager getInputDeviceLightsManager(int deviceId) {
|
||||
return new InputDeviceLightsManager(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of light objects associated with an input device.
|
||||
* @return The list of lights, never null.
|
||||
@@ -1032,7 +1041,7 @@ public final class InputManagerGlobal {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InputManager#getInputDeviceVibratorManager(int)
|
||||
* @see InputDevice#getVibratorManager()
|
||||
*/
|
||||
@NonNull
|
||||
public VibratorManager getInputDeviceVibratorManager(int deviceId) {
|
||||
@@ -1138,7 +1147,7 @@ public final class InputManagerGlobal {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InputManager#getKeyCodeforKeyLocation(int, int)
|
||||
* @see InputManager#getKeyCodeForKeyLocation(int, int)
|
||||
*/
|
||||
public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) {
|
||||
try {
|
||||
|
||||
@@ -25,8 +25,6 @@ import android.content.Context;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
@@ -39,7 +37,6 @@ import java.util.List;
|
||||
public abstract class LightsManager {
|
||||
private static final String TAG = "LightsManager";
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
// These enum values copy the values from {@link com.android.server.lights.LightsManager}
|
||||
// and the light HAL. Since 0-7 are lights reserved for system use, only the microphone light
|
||||
// and following types are available through this API.
|
||||
@@ -62,9 +59,7 @@ public abstract class LightsManager {
|
||||
/**
|
||||
* @hide to prevent subclassing from outside of the framework
|
||||
*/
|
||||
public LightsManager(Context context) {
|
||||
mContext = Preconditions.checkNotNull(context);
|
||||
}
|
||||
public LightsManager() {}
|
||||
|
||||
/**
|
||||
* Returns the lights available on the device.
|
||||
|
||||
@@ -59,7 +59,6 @@ public final class SystemLightsManager extends LightsManager {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public SystemLightsManager(@NonNull Context context, @NonNull ILightsManager service) {
|
||||
super(context);
|
||||
mService = Preconditions.checkNotNull(service);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.hardware.BatteryState;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.input.HostUsiVersion;
|
||||
import android.hardware.input.InputDeviceIdentifier;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.hardware.input.InputManagerGlobal;
|
||||
import android.hardware.lights.LightsManager;
|
||||
import android.icu.util.ULocale;
|
||||
@@ -1191,7 +1190,8 @@ public final class InputDevice implements Parcelable {
|
||||
public LightsManager getLightsManager() {
|
||||
synchronized (mMotionRanges) {
|
||||
if (mLightsManager == null) {
|
||||
mLightsManager = InputManager.getInstance().getInputDeviceLightsManager(mId);
|
||||
mLightsManager = InputManagerGlobal.getInstance()
|
||||
.getInputDeviceLightsManager(mId);
|
||||
}
|
||||
}
|
||||
return mLightsManager;
|
||||
|
||||
Reference in New Issue
Block a user