Manual merge of ag/2319717

Bug: 62104030
Test: Manually tested as described in original commit msg.
Change-Id: Ie00bafa736c837881a258c9de10891b27c5baefd
This commit is contained in:
Phil Weaver
2017-05-30 10:41:52 -07:00
parent 8e0754e84c
commit 2e2dbfe549
5 changed files with 53 additions and 7 deletions

View File

@@ -25,6 +25,7 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.Fragment;
import android.app.IActivityManager;
@@ -1272,6 +1273,20 @@ public final class Utils extends com.android.settingslib.Utils {
return info.enabled ? R.string.installed : R.string.disabled;
}
/**
* Control if other apps can display overlays. By default this is allowed. Be sure to
* re-enable overlays, as the effect is system-wide.
*/
public static void setOverlayAllowed(Context context, IBinder token, boolean allowed) {
AppOpsManager appOpsManager = context.getSystemService(AppOpsManager.class);
if (appOpsManager != null) {
appOpsManager.setUserRestriction(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
!allowed, token);
appOpsManager.setUserRestriction(AppOpsManager.OP_TOAST_WINDOW,
!allowed, token);
}
}
private static boolean isVolumeValid(VolumeInfo volume) {
return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
&& volume.isMountedReadable();