Merge "Should not decode Wi-Fi QR code after onPause" into qt-dev

am: d50bb09876

Change-Id: I172943a14dffbde595440f9586598b5564e526c2
This commit is contained in:
Arc Wang
2019-04-09 01:54:36 -07:00
committed by android-build-merger
3 changed files with 59 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ import android.widget.TextView;
import androidx.annotation.StringRes;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.ViewModelProviders;
import com.android.settings.R;
@@ -261,6 +262,24 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
});
}
@Override
public void onPause() {
if (mCamera != null) {
mCamera.stop();
}
super.onPause();
}
@Override
public void onResume() {
super.onResume();
if (!isGoingInitiator()) {
restartCamera();
}
}
@Override
public int getMetricsCategory() {
if (mIsConfiguratorMode) {
@@ -702,4 +721,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
public void onAccessPointsChanged() {
// Do nothing.
}
@VisibleForTesting
protected boolean isDecodeTaskAlive() {
return mCamera != null && mCamera.isDecodeTaskAlive();
}
}

View File

@@ -401,4 +401,14 @@ public class QrCamera extends Handler {
mScannerCallback.handleSuccessfulResult(qrCode.getText());
}
}
/**
* After {@link #start(SurfaceTexture)}, DecodingTask runs continuously to capture images and
* decode QR code. DecodingTask become null After {@link #stop()}.
*
* Uses this method in test case to prevent power consumption problem.
*/
public boolean isDecodeTaskAlive() {
return mDecodeTask != null;
}
}