DO NOT MERGE Backporting potential usb tapjacking precaution.

Bug: 62187985
Test: manual, backport
Change-Id: I52e27f84338fdcf63cad0ee7436233736499d87b
This commit is contained in:
Beverly
2017-08-31 15:32:36 -04:00
committed by Beverly Tai
parent 3280efe50e
commit 088bc504db
2 changed files with 32 additions and 0 deletions

View File

@@ -911,4 +911,10 @@
<!-- Accessibility string for current zen mode and selected exit condition. A template that simply concatenates existing mode string and the current condition description. [CHAR LIMIT=20] -->
<string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string>
<!-- Warning shown when user input has been blocked due to another app overlaying screen
content. Since we don't know what the app is showing on top of the input target, we
can't verify user consent. [CHAR LIMIT=NONE] -->
<string name="touch_filtered_warning">Because an app is obscuring a permission request, Settings
cant verify your response.</string>
</resources>

View File

@@ -33,6 +33,10 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
import android.view.Window;
import android.view.WindowManager;
import android.view.MotionEvent;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
@@ -48,6 +52,10 @@ public class UsbDebuggingActivity extends AlertActivity
@Override
public void onCreate(Bundle icicle) {
Window window = getWindow();
window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
super.onCreate(icicle);
if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
@@ -79,6 +87,24 @@ public class UsbDebuggingActivity extends AlertActivity
ap.mView = checkbox;
setupAlert();
// adding touch listener on affirmative button - checks if window is obscured
// if obscured, do not let user give permissions (could be tapjacking involved)
final View.OnTouchListener filterTouchListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// Filter obscured touches by consuming them.
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Toast.makeText(v.getContext(),
R.string.touch_filtered_warning,
Toast.LENGTH_SHORT).show();
}
return true;
}
return false;
}
};
mAlert.getButton(BUTTON_POSITIVE).setOnTouchListener(filterTouchListener);
}
private class UsbDisconnectedReceiver extends BroadcastReceiver {