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;
|
break;
|
||||||
|
|
||||||
case MESSAGE_SCAN_WIFI_DPP_SUCCESS:
|
case MESSAGE_SCAN_WIFI_DPP_SUCCESS:
|
||||||
|
if (mCamera != null) {
|
||||||
|
mCamera.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
mDecorateView.setFocused(true);
|
||||||
mErrorMessage.setVisibility(View.INVISIBLE);
|
mErrorMessage.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
if (mScanWifiDppSuccessListener == null) {
|
if (mScanWifiDppSuccessListener == null) {
|
||||||
@@ -154,15 +159,24 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
mSummary.sendAccessibilityEvent(
|
mSummary.sendAccessibilityEvent(
|
||||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
|
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
|
||||||
|
if (mCamera != null) {
|
||||||
|
mCamera.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
mDecorateView.setFocused(true);
|
||||||
mErrorMessage.setVisibility(View.INVISIBLE);
|
mErrorMessage.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
final WifiNetworkConfig wifiNetworkConfig = (WifiNetworkConfig)msg.obj;
|
final WifiNetworkConfig wifiNetworkConfig = (WifiNetworkConfig)msg.obj;
|
||||||
mWifiConfiguration = wifiNetworkConfig.getWifiConfigurationOrNull();
|
mWifiConfiguration = wifiNetworkConfig.getWifiConfigurationOrNull();
|
||||||
wifiNetworkConfig.connect(getContext(),
|
wifiNetworkConfig.connect(getContext(),
|
||||||
/* listener */ WifiDppQrCodeScannerFragment.this);
|
/* listener */ WifiDppQrCodeScannerFragment.this);
|
||||||
|
|
||||||
|
WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -409,11 +423,6 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleWifiDpp() {
|
private void handleWifiDpp() {
|
||||||
if (mCamera != null) {
|
|
||||||
mCamera.stop();
|
|
||||||
}
|
|
||||||
mDecorateView.setFocused(true);
|
|
||||||
|
|
||||||
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
|
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
|
||||||
message.obj = new WifiQrCode(mWifiQrCode.getQrCode());
|
message.obj = new WifiQrCode(mWifiQrCode.getQrCode());
|
||||||
|
|
||||||
@@ -421,11 +430,6 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleZxingWifiFormat() {
|
private void handleZxingWifiFormat() {
|
||||||
if (mCamera != null) {
|
|
||||||
mCamera.stop();
|
|
||||||
}
|
|
||||||
mDecorateView.setFocused(true);
|
|
||||||
|
|
||||||
Message message = mHandler.obtainMessage(MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS);
|
Message message = mHandler.obtainMessage(MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS);
|
||||||
message.obj = new WifiQrCode(mWifiQrCode.getQrCode()).getWifiNetworkConfig();
|
message.obj = new WifiQrCode(mWifiQrCode.getQrCode()).getWifiNetworkConfig();
|
||||||
|
|
||||||
|
@@ -26,6 +26,8 @@ import android.net.wifi.WifiManager;
|
|||||||
import android.os.CancellationSignal;
|
import android.os.CancellationSignal;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.os.VibrationEffect;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
@@ -35,6 +37,8 @@ import com.android.settingslib.wifi.AccessPoint;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
|
* 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;
|
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.
|
* Returns whether the device support WiFi DPP.
|
||||||
*/
|
*/
|
||||||
@@ -386,4 +392,14 @@ public class WifiDppUtils {
|
|||||||
}
|
}
|
||||||
return false;
|
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