Prevent leaking Wi-Fi dialog on lock screen
- The Wi-Fi dialog is designed to be displayed on the system UI - Dismiss Wi-Fi dialog to prevent leaking user data on lock screen Bug: 231583603 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=WifiDialogActivityTest Change-Id: Ie67ff1138ffeddd3e358331d8cef61e0629173e2
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.wifi;
|
||||
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -51,6 +52,7 @@ import com.android.wifitrackerlib.WifiEntry;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.time.Clock;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
@@ -96,10 +98,12 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
||||
// Interval between initiating NetworkDetailsTracker scans.
|
||||
private static final long SCAN_INTERVAL_MILLIS = 10_000;
|
||||
|
||||
private WifiDialog mDialog;
|
||||
@VisibleForTesting
|
||||
WifiDialog mDialog;
|
||||
private AccessPoint mAccessPoint;
|
||||
|
||||
private WifiDialog2 mDialog2;
|
||||
@VisibleForTesting
|
||||
WifiDialog2 mDialog2;
|
||||
|
||||
// The received intent supports a key of WifiTrackerLib or SettingsLib.
|
||||
private boolean mIsWifiTrackerLib;
|
||||
@@ -108,6 +112,7 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
||||
private NetworkDetailsTracker mNetworkDetailsTracker;
|
||||
private HandlerThread mWorkerThread;
|
||||
private WifiManager mWifiManager;
|
||||
private LockScreenMonitor mLockScreenMonitor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -184,6 +189,10 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
||||
mDialog.setOnDismissListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDialog2 != null || mDialog != null) {
|
||||
mLockScreenMonitor = new LockScreenMonitor(this);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -221,6 +230,10 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
||||
}
|
||||
}
|
||||
|
||||
if (mLockScreenMonitor != null) {
|
||||
mLockScreenMonitor.release();
|
||||
mLockScreenMonitor = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -411,4 +424,45 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void dismissDialog() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog = null;
|
||||
}
|
||||
if (mDialog2 != null) {
|
||||
mDialog2.dismiss();
|
||||
mDialog2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static final class LockScreenMonitor implements KeyguardManager.KeyguardLockedStateListener {
|
||||
private final WeakReference<WifiDialogActivity> mWifiDialogActivity;
|
||||
private KeyguardManager mKeyguardManager;
|
||||
|
||||
LockScreenMonitor(WifiDialogActivity activity) {
|
||||
mWifiDialogActivity = new WeakReference<>(activity);
|
||||
mKeyguardManager = activity.getSystemService(KeyguardManager.class);
|
||||
mKeyguardManager.addKeyguardLockedStateListener(activity.getMainExecutor(), this);
|
||||
}
|
||||
|
||||
void release() {
|
||||
if (mKeyguardManager == null) return;
|
||||
mKeyguardManager.removeKeyguardLockedStateListener(this);
|
||||
mKeyguardManager = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardLockedStateChanged(boolean isKeyguardLocked) {
|
||||
if (!isKeyguardLocked) return;
|
||||
WifiDialogActivity activity = mWifiDialogActivity.get();
|
||||
if (activity == null) return;
|
||||
activity.dismissDialog();
|
||||
|
||||
Log.e(TAG, "Dismiss Wi-Fi dialog to prevent leaking user data on lock screen!");
|
||||
EventLog.writeEvent(0x534e4554, "231583603", -1 /* UID */,
|
||||
"Leak Wi-Fi dialog on lock screen");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user