Use config instead of local string for qr scanner
This is required so that a download can be triggered for the required component if it not already present on the device. Test: Manually Bug: 230319091 Change-Id: I1ecdd526c3616b98e268deb0959338f517c4f67b
This commit is contained in:
@@ -5660,6 +5660,9 @@
|
||||
<!-- Whether or not to enable the lock screen entry point for the QR code scanner. -->
|
||||
<bool name="config_enableQrCodeScannerOnLockScreen">false</bool>
|
||||
|
||||
<!-- Default component for QR code scanner -->
|
||||
<string name="config_defaultQrCodeComponent"></string>
|
||||
|
||||
<!-- Whether Low Power Standby is supported and can be enabled. -->
|
||||
<bool name="config_lowPowerStandbySupported">false</bool>
|
||||
|
||||
|
||||
@@ -4707,6 +4707,7 @@
|
||||
|
||||
<java-symbol type="string" name="config_wearSysUiPackage"/>
|
||||
<java-symbol type="string" name="config_wearSysUiMainActivity"/>
|
||||
<java-symbol type="string" name="config_defaultQrCodeComponent"/>
|
||||
|
||||
<java-symbol type="dimen" name="secondary_rounded_corner_radius" />
|
||||
<java-symbol type="dimen" name="secondary_rounded_corner_radius_top" />
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright (c) 2009, 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.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- Default for SystemUiDeviceConfigFlags.DEFAULT_QR_CODE_SCANNER.
|
||||
To be set if the device wants to support out of the box QR code scanning experience -->
|
||||
<string name="def_qr_code_component" translatable="false"></string>
|
||||
</resources>
|
||||
@@ -29,7 +29,6 @@ import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
@@ -119,7 +118,6 @@ public class QRCodeScannerController implements
|
||||
mSecureSettings = secureSettings;
|
||||
mDeviceConfigProxy = proxy;
|
||||
mUserTracker = userTracker;
|
||||
|
||||
mConfigEnableLockScreenButton = mContext.getResources().getBoolean(
|
||||
android.R.bool.config_enableQrCodeScannerOnLockScreen);
|
||||
}
|
||||
@@ -258,16 +256,20 @@ public class QRCodeScannerController implements
|
||||
}
|
||||
}
|
||||
|
||||
private String getDefaultScannerActivity() {
|
||||
return mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_defaultQrCodeComponent);
|
||||
}
|
||||
|
||||
private void updateQRCodeScannerActivityDetails() {
|
||||
String qrCodeScannerActivity = mDeviceConfigProxy.getString(
|
||||
DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||
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
|
||||
// want to use R.string.config_defaultQrCodeComponent
|
||||
if (Objects.equals(qrCodeScannerActivity, "")) {
|
||||
qrCodeScannerActivity =
|
||||
mContext.getResources().getString(R.string.def_qr_code_component);
|
||||
qrCodeScannerActivity = getDefaultScannerActivity();
|
||||
}
|
||||
|
||||
String prevQrCodeScannerActivity = mQRCodeScannerActivity;
|
||||
|
||||
@@ -24,7 +24,6 @@ import static com.android.systemui.qrcodescanner.controller.QRCodeScannerControl
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -32,6 +31,7 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
@@ -41,7 +41,6 @@ import android.testing.TestableLooper;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.util.DeviceConfigProxyFake;
|
||||
@@ -90,8 +89,9 @@ public class QRCodeScannerControllerTest extends SysuiTestCase {
|
||||
when(mPackageManager.queryIntentActivities(any(Intent.class),
|
||||
any(Integer.class))).thenReturn(resolveInfoList);
|
||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)).thenReturn(true);
|
||||
mContext.getOrCreateTestableResources().addOverride(R.string.def_qr_code_component,
|
||||
defaultActivity);
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
com.android.internal.R.string.config_defaultQrCodeComponent, defaultActivity);
|
||||
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
android.R.bool.config_enableQrCodeScannerOnLockScreen, enableOnLockScreen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user