Automation/app/src/main/java/eu/chainfire/libsuperuser/HideOverlaysReceiver.java

63 lines
2.3 KiB
Java
Raw Normal View History

2021-02-16 13:42:49 +01:00
/*
2021-05-18 20:02:45 +02:00
* Copyright (C) 2012-2019 Jorrit "Chainfire" Jongma
2021-02-16 13:42:49 +01:00
*
* 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;
/**
* <p>
* Base receiver to extend to catch notifications when overlays should be
* hidden.
* </p>
* <p>
* 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 <em>require</em> root, you still need to <em>request</em>
* it, and the user must grant it.
* </p>
* <p>
* Note that the word overlay as used here should be interpreted as "any view or
* window possibly obscuring SuperSU dialogs".
* </p>
*/
2021-05-18 20:02:45 +02:00
@SuppressWarnings({"unused"})
2021-02-16 13:42:49 +01:00
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)) {
2021-05-18 20:02:45 +02:00
onHideOverlays(context, intent, intent.getBooleanExtra(EXTRA_HIDE_OVERLAYS, false));
2021-02-16 13:42:49 +01:00
}
}
/**
* Called when overlays <em>should</em> be hidden or <em>may</em> be shown
* again.
2021-05-18 20:02:45 +02:00
*
* @param context App context
* @param intent Received intent
2021-02-16 13:42:49 +01:00
* @param hide Should overlays be hidden?
*/
2021-05-18 20:02:45 +02:00
public abstract void onHideOverlays(Context context, Intent intent, boolean hide);
2021-02-16 13:42:49 +01:00
}