From: Beverly Date: Fri, 1 Sep 2017 15:14:57 +0000 (-0400) Subject: DO NOT MERGE Backporting potential usb tapjacking precaution. X-Git-Tag: android-x86-8.1-r1~46^2~1^2~2^2^2^2^2~3^2~3^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=cc4bec01404ac375fc109448614143293688ce48;p=android-x86%2Fframeworks-base.git DO NOT MERGE Backporting potential usb tapjacking precaution. Bug: 62187985 Test: manual, backport Change-Id: I02f615624b33c3fb6e2fbb15ce44a0032b6f4387 --- diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index f7a169cb4d5b..b061c57d2e9c 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1702,4 +1702,9 @@ Page %1$d of %2$d + + Because an app is obscuring a permission request, Settings + can’t verify your response. diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java index f5447a293503..0ba8c08a8f18 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java @@ -31,8 +31,12 @@ import android.os.ServiceManager; import android.os.SystemProperties; import android.util.Log; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.Window; +import android.view.WindowManager; import android.widget.CheckBox; +import android.widget.Toast; 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,26 @@ 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) + || ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_PARTIALLY_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 {