Manual merge of ag/2319717
Bug: 62104030 Test: Manually tested as described in original commit msg. Change-Id: Ie00bafa736c837881a258c9de10891b27c5baefd
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user