Merge "Implement StylusListener SystemUI CoreStartable." into tm-qpr-dev
This commit is contained in:
@@ -30,6 +30,7 @@ import android.app.ActivityThread;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.BatteryState;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.lights.Light;
|
||||
@@ -1893,6 +1894,31 @@ public final class InputManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether stylus has ever been used on device (false by default).
|
||||
* @hide
|
||||
*/
|
||||
public boolean isStylusEverUsed(@NonNull Context context) {
|
||||
return Settings.Global.getInt(context.getContentResolver(),
|
||||
Settings.Global.STYLUS_EVER_USED, 0) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether stylus has ever been used on device.
|
||||
* Should only ever be set to true once after stylus first usage.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
public void setStylusEverUsed(@NonNull Context context, boolean stylusEverUsed) {
|
||||
if (context.checkCallingPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException("You need WRITE_SECURE_SETTINGS permission "
|
||||
+ "to set stylus ever used.");
|
||||
}
|
||||
Settings.Global.putInt(context.getContentResolver(),
|
||||
Settings.Global.STYLUS_EVER_USED, stylusEverUsed ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback used to be notified about battery state changes for an input device. The
|
||||
* {@link #onBatteryStateChanged(int, long, BatteryState)} method will be called once after the
|
||||
|
||||
@@ -15787,6 +15787,15 @@ public final class Settings {
|
||||
@SuppressLint("NoSettingsProvider")
|
||||
public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
|
||||
|
||||
/**
|
||||
* Indicates whether a stylus has ever been used on the device.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Readable
|
||||
@SuppressLint("NoSettingsProvider")
|
||||
public static final String STYLUS_EVER_USED = "stylus_ever_used";
|
||||
|
||||
/**
|
||||
* Exemptions to the hidden API blacklist.
|
||||
*
|
||||
|
||||
@@ -175,6 +175,7 @@ public class GlobalSettingsValidators {
|
||||
VALIDATORS.put(Global.ADVANCED_BATTERY_USAGE_AMOUNT, PERCENTAGE_INTEGER_VALIDATOR);
|
||||
VALIDATORS.put(Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Global.POWER_BUTTON_LONG_PRESS_DURATION_MS, NONE_NEGATIVE_LONG_VALIDATOR);
|
||||
VALIDATORS.put(Global.STYLUS_EVER_USED, BOOLEAN_VALIDATOR);
|
||||
|
||||
VALIDATORS.put(Global.Wearable.HAS_PAY_TOKENS, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Global.Wearable.GMS_CHECKIN_TIMEOUT_MIN, ANY_INTEGER_VALIDATOR);
|
||||
|
||||
@@ -276,6 +276,7 @@ public class SettingsBackupTest {
|
||||
Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
|
||||
Settings.Global.SMART_SUGGESTIONS_IN_NOTIFICATIONS_FLAGS,
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED,
|
||||
Settings.Global.STYLUS_EVER_USED,
|
||||
Settings.Global.ENABLE_ADB_INCREMENTAL_INSTALL_DEFAULT,
|
||||
Settings.Global.ENABLE_MULTI_SLOT_TIMEOUT_MILLIS,
|
||||
Settings.Global.ENHANCED_4G_MODE_ENABLED,
|
||||
|
||||
@@ -55,6 +55,7 @@ import android.hardware.display.ColorDisplayManager;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.media.AudioManager;
|
||||
import android.media.IAudioService;
|
||||
import android.media.MediaRouter2Manager;
|
||||
@@ -282,6 +283,12 @@ public class FrameworkServicesModule {
|
||||
return InteractionJankMonitor.getInstance();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static InputManager provideInputManager(Context context) {
|
||||
return context.getSystemService(InputManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static InputMethodManager provideInputMethodManager(Context context) {
|
||||
|
||||
@@ -420,6 +420,9 @@ object Flags {
|
||||
@JvmField val UDFPS_ELLIPSE_DEBUG_UI = unreleasedFlag(2201, "udfps_ellipse_debug")
|
||||
@JvmField val UDFPS_ELLIPSE_DETECTION = unreleasedFlag(2202, "udfps_ellipse_detection")
|
||||
|
||||
// 2300 - stylus
|
||||
@JvmField val TRACK_STYLUS_EVER_USED = unreleasedFlag(2300, "track_stylus_ever_used")
|
||||
|
||||
// TODO(b259590361): Tracking bug
|
||||
val EXPERIMENTAL_FLAG = unreleasedFlag(2, "exp_flag_release")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user