From 74f45a446c333951b783f8d0924a93fbf41ded75 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Mon, 10 Feb 2020 01:52:14 +0800 Subject: [PATCH 1/8] [Settings] Replace ImsManager#getImsServiceState() Replacing ImsManager#getImsServiceState() into ImsMmTelManager#getFeatureState(). Bug: 140542283 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=VideoCallingPreferenceControllerTest Change-Id: Id0832bf523409ae9d02ee49d809f62701e33b15e --- .../network/ims/ImsQueryController.java | 17 ++++++ .../settings/network/ims/IntegerConsumer.java | 58 +++++++++++++++++++ .../settings/network/ims/VtQueryImsState.java | 22 +++++-- .../network/ims/MockVtQueryImsState.java | 15 +++++ .../VideoCallingPreferenceControllerTest.java | 3 +- 5 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 src/com/android/settings/network/ims/IntegerConsumer.java diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java index 8fdad4004fe..068a80537b9 100644 --- a/src/com/android/settings/network/ims/ImsQueryController.java +++ b/src/com/android/settings/network/ims/ImsQueryController.java @@ -20,6 +20,7 @@ import android.telephony.AccessNetworkConstants; import android.telephony.SubscriptionManager; import android.telephony.ims.ImsException; import android.telephony.ims.ImsMmTelManager; +import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.feature.MmTelFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; @@ -84,4 +85,20 @@ abstract class ImsQueryController { boolean isProvisionedOnDevice(int subId) { return (new ImsQueryProvisioningStat(subId, mCapability, mTech)).query(); } + + @VisibleForTesting + boolean isServiceStateReady(int subId) throws InterruptedException, ImsException, + IllegalArgumentException { + if (!SubscriptionManager.isValidSubscriptionId(subId)) { + return false; + } + + final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(subId); + // TODO: have a shared thread pool instead of create ExecutorService + // everytime to improve performance. + final ExecutorService executor = Executors.newSingleThreadExecutor(); + final IntegerConsumer intResult = new IntegerConsumer(); + imsMmTelManager.getFeatureState(executor, intResult); + return (intResult.get(TIMEOUT_MILLIS) == ImsFeature.STATE_READY); + } } diff --git a/src/com/android/settings/network/ims/IntegerConsumer.java b/src/com/android/settings/network/ims/IntegerConsumer.java new file mode 100644 index 00000000000..02c82275a86 --- /dev/null +++ b/src/com/android/settings/network/ims/IntegerConsumer.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2020 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.settings.network.ims; + +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + +class IntegerConsumer extends Semaphore implements Consumer { + + private static final String TAG = "IntegerConsumer"; + + IntegerConsumer() { + super(0); + mValue = new AtomicInteger(); + } + + private volatile AtomicInteger mValue; + + /** + * Get boolean value reported from callback + * + * @param timeout callback waiting time in milliseconds + * @return int value reported + * @throws InterruptedException when thread get interrupted + */ + int get(long timeout) throws InterruptedException { + tryAcquire(timeout, TimeUnit.MILLISECONDS); + return mValue.get(); + } + + /** + * Implementation of {@link Consumer#accept(Integer)} + * + * @param value int reported from {@link Consumer#accept(Integer)} + */ + public void accept(Integer value) { + if (value != null) { + mValue.set(value.intValue()); + } + release(); + } +} diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java index 60bd72988e3..c0776036bf1 100644 --- a/src/com/android/settings/network/ims/VtQueryImsState.java +++ b/src/com/android/settings/network/ims/VtQueryImsState.java @@ -20,20 +20,23 @@ import android.content.Context; import android.telecom.TelecomManager; import android.telephony.AccessNetworkConstants; import android.telephony.SubscriptionManager; +import android.telephony.ims.ImsException; import android.telephony.ims.feature.MmTelFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; +import android.util.Log; import androidx.annotation.VisibleForTesting; import com.android.ims.ImsManager; import com.android.settings.network.SubscriptionUtil; -import com.android.settings.network.telephony.MobileNetworkUtils; /** * Controller class for querying VT status */ public class VtQueryImsState extends ImsQueryController { + private static final String LOG_TAG = "VtQueryImsState"; + private Context mContext; private int mSubId; @@ -71,14 +74,25 @@ public class VtQueryImsState extends ImsQueryController { * @return true when Video Call can be performed, otherwise false */ public boolean isReadyToVideoCall() { + if (!isProvisionedOnDevice(mSubId)) { + return false; + } + final ImsManager imsManager = getImsManager(mSubId); if (imsManager == null) { return false; } - return imsManager.isVtEnabledByPlatform() - && isProvisionedOnDevice(mSubId) - && MobileNetworkUtils.isImsServiceStateReady(imsManager); + if (!imsManager.isVtEnabledByPlatform()) { + return false; + } + + try { + return isServiceStateReady(mSubId); + } catch (InterruptedException | IllegalArgumentException | ImsException exception) { + Log.w(LOG_TAG, "fail to get Vt service status. subId=" + mSubId, exception); + } + return false; } /** diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java index 4fd7d0c6dfb..3daf6cb0f1e 100644 --- a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java +++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java @@ -17,6 +17,7 @@ package com.android.settings.network.ims; import android.content.Context; +import android.telephony.ims.ImsException; import com.android.ims.ImsManager; @@ -29,6 +30,7 @@ public class MockVtQueryImsState extends VtQueryImsState { private Boolean mIsTtyOnVolteEnabled; private Boolean mIsProvisionedOnDevice; private Boolean mIsEnabledByUser; + private Boolean mIsServiceStateReady; /** * Constructor @@ -68,6 +70,19 @@ public class MockVtQueryImsState extends VtQueryImsState { return super.isProvisionedOnDevice(subId); } + public void setServiceStateReady(boolean isReady) { + mIsServiceStateReady = isReady; + } + + @Override + boolean isServiceStateReady(int subId) throws InterruptedException, ImsException, + IllegalArgumentException { + if (mIsServiceStateReady != null) { + return mIsServiceStateReady; + } + return super.isServiceStateReady(subId); + } + public void setIsEnabledByUser(boolean enabled) { mIsEnabledByUser = enabled; } diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java index c766289c2b6..04fc4b94889 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java @@ -27,7 +27,6 @@ import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.telephony.TelephonyManager; import android.telephony.ims.ProvisioningManager; -import android.telephony.ims.feature.ImsFeature; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; @@ -98,7 +97,7 @@ public class VideoCallingPreferenceControllerTest { doReturn(true).when(mImsManager).isVtEnabledByPlatform(); mQueryImsState.setIsProvisionedOnDevice(true); - doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState(); + mQueryImsState.setServiceStateReady(true); doReturn(true).when(mTelephonyManager).isDataEnabled(); mController.mCallState = TelephonyManager.CALL_STATE_IDLE; From 8881b110cd5084f503a70e4b9d178041c810746a Mon Sep 17 00:00:00 2001 From: Blake Kragten Date: Mon, 16 Mar 2020 16:46:03 -0700 Subject: [PATCH 2/8] Enhanced Connectivity Enabled Default Changed to enable enhanced connectivity by default Test: On Device Test: make RunSettingsRoboTests ROBOTEST_FILTER=EnhancedConnectivityPreferenceControllerTest Test: On-device using developer option menu Bug: 151633345 Change-Id: I8706f3a15af02214f4516503e685ff2b8f348a3a --- .../EnhancedConnectivityPreferenceController.java | 8 ++++---- ...EnhancedConnectivityPreferenceControllerTest.java | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/development/EnhancedConnectivityPreferenceController.java b/src/com/android/settings/development/EnhancedConnectivityPreferenceController.java index 2dbd7d1ee2b..dc6597384d2 100644 --- a/src/com/android/settings/development/EnhancedConnectivityPreferenceController.java +++ b/src/com/android/settings/development/EnhancedConnectivityPreferenceController.java @@ -37,7 +37,7 @@ public class EnhancedConnectivityPreferenceController extends @VisibleForTesting static final int ENHANCED_CONNECTIVITY_ON = 1; - // default is enhanced connectivity disabled. + // default is enhanced connectivity enabled. @VisibleForTesting static final int ENHANCED_CONNECTIVITY_OFF = 0; @@ -65,7 +65,7 @@ public class EnhancedConnectivityPreferenceController extends public void updateState(Preference preference) { final int enhancedConnectivityEnabled = Settings.Global.getInt( mContext.getContentResolver(), Settings.Global.ENHANCED_CONNECTIVITY_ENABLED, - ENHANCED_CONNECTIVITY_OFF); + ENHANCED_CONNECTIVITY_ON); ((SwitchPreference) mPreference).setChecked( enhancedConnectivityEnabled == ENHANCED_CONNECTIVITY_ON); } @@ -75,7 +75,7 @@ public class EnhancedConnectivityPreferenceController extends super.onDeveloperOptionsSwitchDisabled(); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ENHANCED_CONNECTIVITY_ENABLED, - ENHANCED_CONNECTIVITY_OFF); - ((SwitchPreference) mPreference).setChecked(false); + ENHANCED_CONNECTIVITY_ON); + ((SwitchPreference) mPreference).setChecked(true); } } diff --git a/tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java index 6fd6f553850..171fc6bc5de 100644 --- a/tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java @@ -88,20 +88,20 @@ public class EnhancedConnectivityPreferenceControllerTest { } @Test - public void onDeveloperOptionsDisabled_shouldDisablePreference() { - mController.onDeveloperOptionsDisabled(); + public void onDeveloperOptionsDisabled_shouldEnablePreference() { + mController.onDeveloperOptionsSwitchDisabled(); verify(mPreference).setEnabled(false); - verify(mPreference).setChecked(false); + verify(mPreference).setChecked(true); - assertThat(isSettingEnabled()).isFalse(); + assertThat(isSettingEnabled()).isTrue(); } private boolean isSettingEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ENHANCED_CONNECTIVITY_ENABLED, - EnhancedConnectivityPreferenceController.ENHANCED_CONNECTIVITY_OFF - /* default off */) + EnhancedConnectivityPreferenceController.ENHANCED_CONNECTIVITY_ON + /* default on */) == EnhancedConnectivityPreferenceController.ENHANCED_CONNECTIVITY_ON; } } From 26b70a9bc71e60192ec8b1fe63f98954ea97d852 Mon Sep 17 00:00:00 2001 From: govenliu Date: Tue, 17 Mar 2020 17:58:41 +0800 Subject: [PATCH 3/8] [Wi-Fi] Remove @Ignore tag in ConfigureWifiEntryFragmentTest Remove the @Ignore tag in ConfigureWifiEntryFragmentTest, and add a fake NetworkDetailsTracker to pass test. Bug: 151696220 Test: Run make RunSettingsRoboTests ROBOTEST_FILTER=ConfigureWifiEntryFragmentTest Change-Id: Icf06d27030fa2c68d3c2bee03beb583592beb599 --- .../settings/wifi/ConfigureWifiEntryFragment.java | 3 ++- .../wifi/ConfigureWifiEntryFragmentTest.java | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java index a28f9907d6b..23971e717ac 100644 --- a/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java +++ b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java @@ -71,7 +71,8 @@ public class ConfigureWifiEntryFragment extends InstrumentedFragment implements private Button mSubmitBtn; private Button mCancelBtn; private WifiEntry mWifiEntry; - private NetworkDetailsTracker mNetworkDetailsTracker; + @VisibleForTesting + NetworkDetailsTracker mNetworkDetailsTracker; private HandlerThread mWorkerThread; @Override diff --git a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java index 1f0c3127d55..ce9d10ca99d 100644 --- a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java +++ b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java @@ -24,21 +24,17 @@ import static org.mockito.Mockito.verify; import android.app.settings.SettingsEnums; import android.os.Bundle; -import com.android.settings.testutils.shadow.ShadowConnectivityManager; +import com.android.wifitrackerlib.NetworkDetailsTracker; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; import org.robolectric.shadows.androidx.fragment.FragmentController; -// TODO(b/70983952): Can't test because b/146802959, should remove @Ignore tag after it's fixed. -@Ignore @RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowConnectivityManager.class) public class ConfigureWifiEntryFragmentTest { private static final String KEY_SSID = "key_ssid"; @@ -46,6 +42,9 @@ public class ConfigureWifiEntryFragmentTest { private ConfigureWifiEntryFragment mConfigureWifiEntryFragment; + @Mock + private NetworkDetailsTracker mNetworkDetailsTracker; + @Before public void setUp() { MockitoAnnotations.initMocks(this); @@ -55,6 +54,8 @@ public class ConfigureWifiEntryFragmentTest { bundle.putInt(KEY_SECURITY, 1 /* WEP */); mConfigureWifiEntryFragment = spy(new ConfigureWifiEntryFragment()); mConfigureWifiEntryFragment.setArguments(bundle); + mConfigureWifiEntryFragment.mNetworkDetailsTracker = mNetworkDetailsTracker; + FragmentController.setupFragment(mConfigureWifiEntryFragment); } From 06da8b6ebc9a351bff3ad588dccfeebc941cfe4c Mon Sep 17 00:00:00 2001 From: atrost Date: Tue, 17 Mar 2020 20:37:49 +0000 Subject: [PATCH 4/8] Show only listUIChanges instead of all Use the new method that filters out changes that shouldn't be in the developer UI. Test: make RunSettingsRoboTests ROBOTEST_FILTER=PlatformCompatDashboardTest Bug: 151299145 Change-Id: I7c725a1eca32e2d253b9671c789777b5422ed469 --- .../settings/development/compat/PlatformCompatDashboard.java | 2 +- .../development/compat/PlatformCompatDashboardTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java index 7b79da77954..2f2c7509851 100644 --- a/src/com/android/settings/development/compat/PlatformCompatDashboard.java +++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java @@ -100,7 +100,7 @@ public class PlatformCompatDashboard extends DashboardFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); try { - mChanges = getPlatformCompat().listAllChanges(); + mChanges = getPlatformCompat().listUIChanges(); } catch (RemoteException e) { throw new RuntimeException("Could not list changes!", e); } diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java index 1e59167e500..e59bd0b3446 100644 --- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java +++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java @@ -93,7 +93,7 @@ public class PlatformCompatDashboardTest { mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false, false, ""); mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false, false, ""); mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false, false, ""); - when(mPlatformCompat.listAllChanges()).thenReturn(mChanges); + when(mPlatformCompat.listUIChanges()).thenReturn(mChanges); when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator); // By default, allow any change when(mOverrideValidator.getOverrideAllowedState(anyLong(),anyString())) From 8b411bfa55da5076faa78943f4a54b310327338d Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Wed, 18 Mar 2020 17:06:15 +0800 Subject: [PATCH 5/8] Revise strings for tutorial improvement. Bug: 148989018 Test: manual test Change-Id: I249c5ae896123b546b028c959cd1a5404008aec3 --- res/values/strings.xml | 58 ++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 5dcab3ef4b6..227cd4caaae 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4880,49 +4880,57 @@
To zoom in:
\t1. Use shortcut to start magnification
\t2. Tap the screen
\t3. Drag 2 fingers to move around screen
\t4. Pinch with 2 fingers to adjust zoom
\t5. Use shortcut to stop magnification

To zoom in temporarily:
\t1. Use shortcut to start magnification
\t2. Touch & hold anywhere on the screen
\t3. Drag finger to move around screen
\t4. Lift finger to stop magnification]]>
When magnification is turned on, you can zoom in on your screen.\n\nTo zoom, start magnification, then tap anywhere on the screen.\n
  • Drag 2 or more fingers to scroll
  • \n
  • Pinch 2 or more fingers to adjust zoom
\n\nTo zoom temporarily, start magnification, then touch & hold anywhere on the screen.\n
  • Drag to move around the screen
  • \n
  • Lift finger to zoom out
\n\nYou can’t zoom in on the keyboard or navigation bar.
- + Use accessibility button to open - + + Hold volume key to open + + Triple tap screen to open + Use gesture to open - + Use new accessibility gesture - - To turn this service on or off, tap the accessibility button %s on the bottom of your screen.\n\nTo switch between services, touch & hold the accessibility button. - - To turn this service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold. - - To turn this service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold. - - To turn an accessibility service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold. - - To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold. - + + To turn this app on or off, tap the accessibility button %s on the bottom of your screen.\n\nTo switch between apps, touch & hold the accessibility button. + + To turn this app on or off, press & hold both volume keys for 1 second. + + To start and stop magnification, triple-tap anywhere on your screen. + + To turn this app on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between apps, swipe up with two fingers and hold. + + To turn this app on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between apps, swipe up with three fingers and hold. + + To turn an accessibility app on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between apps, swipe up with two fingers and hold. + + To turn an accessibility app on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between apps, swipe up with three fingers and hold. + Got it %1$s shortcut - + Accessibility Button - + Swipe up with 2 fingers - + Swipe up with 3 fingers Tap accessibility button - + Tap the accessibility button %s at the bottom of your screen - + Swipe up from the bottom of the screen with 2 fingers - + Swipe up from the bottom of the screen with 3 fingers - + Hold volume keys - + Press & hold both volume keys for 1 second - + Triple-tap screen - + Quickly tap screen 3 times. This shortcut may slow down your device. - + Advanced The Accessibility button is set to %1$s. To use magnification, touch & hold the Accessibility button, then select magnification. From 7f11d3f74aea8f6a48ac7306db079df992006e8a Mon Sep 17 00:00:00 2001 From: robertluo Date: Wed, 19 Feb 2020 13:31:43 +0800 Subject: [PATCH 6/8] Rename "Tap & pay" to "Contactless payments" Fixes: 149270345 Test: manual and check if new string is applied Change-Id: I412c5b5681a85d482541ae30faa13e904942b612 Merged-In: I412c5b5681a85d482541ae30faa13e904942b612 (cherry picked from commit 86a6cb8ead56443116d2badf9147c1a5e0ff6b89) --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6ff3a00df8f..cd8315f1c85 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6997,7 +6997,7 @@ Expand settings for application - Tap & pay + Contactless payments How it works From 397ee8b5635711b80a7455a230cbfce5c84ce725 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Tue, 17 Mar 2020 16:34:26 +0000 Subject: [PATCH 7/8] Do not reset incorrect password attempts after biometric authentication For work challenges, do not reset incorrect password attempts if challenge is resolved via biometric authentication. This is the behaviour for personal keyguard and work challenge should be consistent. Bug: 139438785 Test: manual: enroll work challenge with fingerprint, set failed wipe count (3) via TestDPC and attempt two failed attempts (via cmd lock_settings). Resolve work challenge with fingerprint and attempt one last failed attempt. Verify work profiel is wiped. Change-Id: Ic64d3e44f3faa5adf8ac43db09e33c8403427990 --- .../android/settings/password/BiometricFragment.java | 7 +++++++ .../password/ConfirmDeviceCredentialActivity.java | 12 ++++++++++-- .../password/ConfirmDeviceCredentialUtils.java | 9 +++++++-- .../settings/password/ConfirmLockPassword.java | 3 ++- .../settings/password/ConfirmLockPattern.java | 3 ++- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java index bc0e5c75231..7e783227362 100644 --- a/src/com/android/settings/password/BiometricFragment.java +++ b/src/com/android/settings/password/BiometricFragment.java @@ -70,6 +70,13 @@ public class BiometricFragment extends InstrumentedFragment { }); cleanup(); } + + @Override + public void onAuthenticationFailed() { + mClientExecutor.execute(() -> { + mClientCallback.onAuthenticationFailed(); + }); + } }; private final DialogInterface.OnClickListener mNegativeButtonListener = diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java index 83368f95e0f..220b64929ad 100644 --- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java +++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java @@ -111,6 +111,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { }); private AuthenticationCallback mAuthenticationCallback = new AuthenticationCallback() { + @Override public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) { if (!mGoingToBackground) { if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED @@ -123,17 +124,24 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { } } + @Override public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) { mTrustManager.setDeviceLockedForUser(mUserId, false); - + final boolean isStrongAuth = result.getAuthenticationType() + == BiometricPrompt.AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL; ConfirmDeviceCredentialUtils.reportSuccessfulAttempt(mLockPatternUtils, mUserManager, - mUserId); + mDevicePolicyManager, mUserId, isStrongAuth); ConfirmDeviceCredentialUtils.checkForPendingIntent( ConfirmDeviceCredentialActivity.this); setResult(Activity.RESULT_OK); finish(); } + + @Override + public void onAuthenticationFailed() { + mDevicePolicyManager.reportFailedBiometricAttempt(mUserId); + } }; private String getStringForError(int errorCode) { diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java b/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java index 11d69246206..a5febebc198 100644 --- a/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java +++ b/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.IActivityManager; +import android.app.admin.DevicePolicyManager; import android.content.Intent; import android.content.IntentSender; import android.os.RemoteException; @@ -54,8 +55,12 @@ public class ConfirmDeviceCredentialUtils { } public static void reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager, - int userId) { - utils.reportSuccessfulPasswordAttempt(userId); + DevicePolicyManager dpm, int userId, boolean isStrongAuth) { + if (isStrongAuth) { + utils.reportSuccessfulPasswordAttempt(userId); + } else { + dpm.reportSuccessfulBiometricAttempt(userId); + } if (userManager.isManagedProfile(userId)) { // Keyguard is responsible to disable StrongAuth for primary user. Disable StrongAuth // for work challenge only here. diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java index ce8813ffbad..260919dbcee 100644 --- a/src/com/android/settings/password/ConfirmLockPassword.java +++ b/src/com/android/settings/password/ConfirmLockPassword.java @@ -475,7 +475,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity { if (matched) { if (newResult) { ConfirmDeviceCredentialUtils.reportSuccessfulAttempt(mLockPatternUtils, - mUserManager, mEffectiveUserId); + mUserManager, mDevicePolicyManager, mEffectiveUserId, + /* isStrongAuth */ true); } startDisappearAnimation(intent); ConfirmDeviceCredentialUtils.checkForPendingIntent(getActivity()); diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java index b2afb22da96..06f3d93d3c8 100644 --- a/src/com/android/settings/password/ConfirmLockPattern.java +++ b/src/com/android/settings/password/ConfirmLockPattern.java @@ -509,7 +509,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { if (matched) { if (newResult) { ConfirmDeviceCredentialUtils.reportSuccessfulAttempt(mLockPatternUtils, - mUserManager, mEffectiveUserId); + mUserManager, mDevicePolicyManager, mEffectiveUserId, + /* isStrongAuth */ true); } startDisappearAnimation(intent); ConfirmDeviceCredentialUtils.checkForPendingIntent(getActivity()); From 2012e6706a158a1f0c76eb55fc396646f5340dc6 Mon Sep 17 00:00:00 2001 From: Anthony Stange Date: Wed, 18 Mar 2020 21:33:10 +0000 Subject: [PATCH 8/8] Revert "Show only listUIChanges instead of all" Revert submission 10721220-hide Reason for revert: Caused build breakage - b/151857606 Reverted Changes: I7c725a1ec:Show only listUIChanges instead of all Iec8755171:Introduce listUIChanges API for developer UI Change-Id: I7753051b06faf1f48a818a134d1eda2500f817f8 --- .../settings/development/compat/PlatformCompatDashboard.java | 2 +- .../development/compat/PlatformCompatDashboardTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java index 2f2c7509851..7b79da77954 100644 --- a/src/com/android/settings/development/compat/PlatformCompatDashboard.java +++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java @@ -100,7 +100,7 @@ public class PlatformCompatDashboard extends DashboardFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); try { - mChanges = getPlatformCompat().listUIChanges(); + mChanges = getPlatformCompat().listAllChanges(); } catch (RemoteException e) { throw new RuntimeException("Could not list changes!", e); } diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java index e59bd0b3446..1e59167e500 100644 --- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java +++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java @@ -93,7 +93,7 @@ public class PlatformCompatDashboardTest { mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false, false, ""); mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false, false, ""); mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false, false, ""); - when(mPlatformCompat.listUIChanges()).thenReturn(mChanges); + when(mPlatformCompat.listAllChanges()).thenReturn(mChanges); when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator); // By default, allow any change when(mOverrideValidator.getOverrideAllowedState(anyLong(),anyString()))