From 694534be581a6c908eb3464413e15c8b3d51beee Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 17 Nov 2014 21:24:51 +0800 Subject: [PATCH] add missing file --- .../libsuperuser/HideOverlaysReceiver.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/eu/chainfire/libsuperuser/HideOverlaysReceiver.java diff --git a/src/main/java/eu/chainfire/libsuperuser/HideOverlaysReceiver.java b/src/main/java/eu/chainfire/libsuperuser/HideOverlaysReceiver.java new file mode 100644 index 00000000..4b4ce5a8 --- /dev/null +++ b/src/main/java/eu/chainfire/libsuperuser/HideOverlaysReceiver.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package eu.chainfire.libsuperuser; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +/** + *

+ * Base receiver to extend to catch notifications when overlays should be + * hidden. + *

+ *

+ * Tapjacking protection in SuperSU prevents some dialogs from receiving user + * input when overlays are present. For security reasons this notification is + * only sent to apps that have previously been granted root access, so even if + * your app does not require root, you still need to request + * it, and the user must grant it. + *

+ *

+ * Note that the word overlay as used here should be interpreted as "any view or + * window possibly obscuring SuperSU dialogs". + *

+ */ +public abstract class HideOverlaysReceiver extends BroadcastReceiver { + public static final String ACTION_HIDE_OVERLAYS = "eu.chainfire.supersu.action.HIDE_OVERLAYS"; + public static final String CATEGORY_HIDE_OVERLAYS = Intent.CATEGORY_INFO; + public static final String EXTRA_HIDE_OVERLAYS = "eu.chainfire.supersu.extra.HIDE"; + + @Override + public final void onReceive(Context context, Intent intent) { + if (intent.hasExtra(EXTRA_HIDE_OVERLAYS)) { + onHideOverlays(intent.getBooleanExtra(EXTRA_HIDE_OVERLAYS, false)); + } + } + + /** + * Called when overlays should be hidden or may be shown + * again. + * + * @param hide Should overlays be hidden? + */ + public abstract void onHideOverlays(boolean hide); +}