diff options
author | Beverly Tai <beverlyt@google.com> | 2017-09-14 17:16:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-09-14 17:16:48 +0000 |
commit | 61bc3f3c9b042bd5b99095c649ecf5ac231bdd93 (patch) | |
tree | bfbc61f61c41874e9b31c99832bc7e0c8c4f55ba | |
parent | 0a93f42be2b0fb269218b7874d5616d3ecca98f2 (diff) | |
parent | 87949cf278a6dd3af0d5e358cd3e479ba629e384 (diff) | |
download | base-61bc3f3c9b042bd5b99095c649ecf5ac231bdd93.tar.gz |
Merge "DO NOT MERGE Backporting potential usb tapjacking precaution." into nyc-mr1-dev
-rw-r--r-- | packages/SystemUI/res/values/strings.xml | 6 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 2ea475a1166b..d122c149ed3b 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1672,4 +1672,10 @@ <!-- Label that replaces other notification controls when the notification is from the system and cannot be silenced (see @string/show_silently) or blocked (see @string/block) --> <string name="cant_silence_or_block">Notifications can\'t be silenced or blocked</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 + can’t verify your response.</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java index f5447a293503..570d2383d746 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 { |