Add support for only enabling QR scanner in QS tile
This CL adds a config to control enabling/disabling of just the lockscreen button for QR code scanner Bug: 200536509 Test: Manually Change-Id: I9850994d9c53446d82506369e5069eea6eceb6da
This commit is contained in:
@@ -366,6 +366,7 @@ package android {
|
||||
}
|
||||
|
||||
public static final class R.bool {
|
||||
field public static final int config_enableQrCodeScannerOnLockScreen;
|
||||
field public static final int config_sendPackageName = 17891328; // 0x1110000
|
||||
field public static final int config_showDefaultAssistant = 17891329; // 0x1110001
|
||||
field public static final int config_showDefaultEmergency = 17891330; // 0x1110002
|
||||
|
||||
@@ -5607,4 +5607,7 @@
|
||||
|
||||
<!-- Flag indicating if help links for Settings app should be enabled. -->
|
||||
<bool name="config_settingsHelpLinksEnabled">false</bool>
|
||||
|
||||
<!-- Whether or not to enable the lock screen entry point for the QR code scanner. -->
|
||||
<bool name="config_enableQrCodeScannerOnLockScreen">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -3322,6 +3322,8 @@
|
||||
<staging-public-group type="bool" first-id="0x01cf0000">
|
||||
<!-- @hide @TestApi -->
|
||||
<public name="config_preventImeStartupUnlessTextEditor" />
|
||||
<!-- @hide @SystemApi -->
|
||||
<public name="config_enableQrCodeScannerOnLockScreen" />
|
||||
</staging-public-group>
|
||||
|
||||
<staging-public-group type="fraction" first-id="0x01ce0000">
|
||||
|
||||
@@ -93,6 +93,7 @@ public class QRCodeScannerController implements
|
||||
private final DeviceConfigProxy mDeviceConfigProxy;
|
||||
private final ArrayList<Callback> mCallbacks = new ArrayList<>();
|
||||
private final UserTracker mUserTracker;
|
||||
private final boolean mConfigEnableLockScreenButton;
|
||||
|
||||
private HashMap<Integer, ContentObserver> mQRCodeScannerPreferenceObserver = new HashMap<>();
|
||||
private DeviceConfig.OnPropertiesChangedListener mOnDefaultQRCodeScannerChangedListener = null;
|
||||
@@ -118,6 +119,9 @@ public class QRCodeScannerController implements
|
||||
mSecureSettings = secureSettings;
|
||||
mDeviceConfigProxy = proxy;
|
||||
mUserTracker = userTracker;
|
||||
|
||||
mConfigEnableLockScreenButton = mContext.getResources().getBoolean(
|
||||
android.R.bool.config_enableQrCodeScannerOnLockScreen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +160,7 @@ public class QRCodeScannerController implements
|
||||
* Returns true if lock screen entry point for QR Code Scanner is to be enabled.
|
||||
*/
|
||||
public boolean isEnabledForLockScreenButton() {
|
||||
return mQRCodeScannerEnabled && mIntent != null;
|
||||
return mQRCodeScannerEnabled && mIntent != null && mConfigEnableLockScreenButton;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,6 +239,11 @@ public class QRCodeScannerController implements
|
||||
}
|
||||
|
||||
private void updateQRCodeScannerPreferenceDetails(boolean updateSettings) {
|
||||
if (!mConfigEnableLockScreenButton) {
|
||||
// Settings only apply to lock screen entry point.
|
||||
return;
|
||||
}
|
||||
|
||||
boolean prevQRCodeScannerEnabled = mQRCodeScannerEnabled;
|
||||
mQRCodeScannerEnabled = mSecureSettings.getIntForUser(LOCK_SCREEN_SHOW_QR_CODE_SCANNER, 0,
|
||||
mUserTracker.getUserId()) != 0;
|
||||
@@ -251,8 +260,15 @@ public class QRCodeScannerController implements
|
||||
private void updateQRCodeScannerActivityDetails() {
|
||||
String qrCodeScannerActivity = mDeviceConfigProxy.getString(
|
||||
DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||
SystemUiDeviceConfigFlags.DEFAULT_QR_CODE_SCANNER,
|
||||
mContext.getResources().getString(R.string.def_qr_code_component));
|
||||
SystemUiDeviceConfigFlags.DEFAULT_QR_CODE_SCANNER, "");
|
||||
|
||||
// "" means either the flags is not available or is set to "", and in both the cases we
|
||||
// want to use R.string.def_qr_code_component
|
||||
if (Objects.equals(qrCodeScannerActivity, "")) {
|
||||
qrCodeScannerActivity =
|
||||
mContext.getResources().getString(R.string.def_qr_code_component);
|
||||
}
|
||||
|
||||
String prevQrCodeScannerActivity = mQRCodeScannerActivity;
|
||||
ComponentName componentName = null;
|
||||
Intent intent = new Intent();
|
||||
@@ -296,6 +312,11 @@ public class QRCodeScannerController implements
|
||||
}
|
||||
|
||||
private void unregisterQRCodePreferenceObserver() {
|
||||
if (!mConfigEnableLockScreenButton) {
|
||||
// Settings only apply to lock screen entry point.
|
||||
return;
|
||||
}
|
||||
|
||||
mQRCodeScannerPreferenceObserver.forEach((key, value) -> {
|
||||
mSecureSettings.unregisterContentObserver(value);
|
||||
});
|
||||
@@ -357,6 +378,11 @@ public class QRCodeScannerController implements
|
||||
}
|
||||
|
||||
private void registerQRCodePreferenceObserver() {
|
||||
if (!mConfigEnableLockScreenButton) {
|
||||
// Settings only apply to lock screen entry point.
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = mUserTracker.getUserId();
|
||||
if (mQRCodeScannerPreferenceObserver.getOrDefault(userId, null) != null) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user