Play vibration when Wi-Fi QR code scanner recognize a valid QR code
Bug: 127377350 Test: manual Change-Id: I9bfcb6f4d1d4dee45d2cacdedfc07d2f4eccd758
This commit is contained in:
@@ -140,6 +140,11 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
break;
|
||||
|
||||
case MESSAGE_SCAN_WIFI_DPP_SUCCESS:
|
||||
if (mCamera != null) {
|
||||
mCamera.stop();
|
||||
}
|
||||
|
||||
mDecorateView.setFocused(true);
|
||||
mErrorMessage.setVisibility(View.INVISIBLE);
|
||||
|
||||
if (mScanWifiDppSuccessListener == null) {
|
||||
@@ -154,15 +159,24 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
mSummary.sendAccessibilityEvent(
|
||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||
}
|
||||
|
||||
WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext());
|
||||
break;
|
||||
|
||||
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
|
||||
if (mCamera != null) {
|
||||
mCamera.stop();
|
||||
}
|
||||
|
||||
mDecorateView.setFocused(true);
|
||||
mErrorMessage.setVisibility(View.INVISIBLE);
|
||||
|
||||
final WifiNetworkConfig wifiNetworkConfig = (WifiNetworkConfig)msg.obj;
|
||||
mWifiConfiguration = wifiNetworkConfig.getWifiConfigurationOrNull();
|
||||
wifiNetworkConfig.connect(getContext(),
|
||||
/* listener */ WifiDppQrCodeScannerFragment.this);
|
||||
|
||||
WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -409,11 +423,6 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
}
|
||||
|
||||
private void handleWifiDpp() {
|
||||
if (mCamera != null) {
|
||||
mCamera.stop();
|
||||
}
|
||||
mDecorateView.setFocused(true);
|
||||
|
||||
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
|
||||
message.obj = new WifiQrCode(mWifiQrCode.getQrCode());
|
||||
|
||||
@@ -421,11 +430,6 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
}
|
||||
|
||||
private void handleZxingWifiFormat() {
|
||||
if (mCamera != null) {
|
||||
mCamera.stop();
|
||||
}
|
||||
mDecorateView.setFocused(true);
|
||||
|
||||
Message message = mHandler.obtainMessage(MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS);
|
||||
message.obj = new WifiQrCode(mWifiQrCode.getQrCode()).getWifiNetworkConfig();
|
||||
|
||||
|
@@ -26,6 +26,8 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
@@ -35,6 +37,8 @@ import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
|
||||
*
|
||||
@@ -94,6 +98,8 @@ public class WifiDppUtils {
|
||||
*/
|
||||
public static final int EASY_CONNECT_EVENT_SUCCESS = 1;
|
||||
|
||||
private static final Duration VIBRATE_DURATION_QR_CODE_RECOGNITION = Duration.ofMillis(3);
|
||||
|
||||
/**
|
||||
* Returns whether the device support WiFi DPP.
|
||||
*/
|
||||
@@ -386,4 +392,14 @@ public class WifiDppUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void triggerVibrationForQrCodeRecognition(Context context) {
|
||||
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vibrator == null) {
|
||||
return;
|
||||
}
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(
|
||||
VIBRATE_DURATION_QR_CODE_RECOGNITION.toMillis(),
|
||||
VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user