Request system_alert_window permission in android m, fix #138,
This commit is contained in:
parent
4653fa2c10
commit
d83fc186b2
1 changed files with 12 additions and 8 deletions
|
@ -1,6 +1,5 @@
|
||||||
package com.zeapo.pwdstore.autofill;
|
package com.zeapo.pwdstore.autofill;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.accessibilityservice.AccessibilityService;
|
import android.accessibilityservice.AccessibilityService;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
@ -11,10 +10,11 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.provider.Settings;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
@ -69,12 +69,6 @@ public class AutofillService extends AccessibilityService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccessibilityEvent(AccessibilityEvent event) {
|
public void onAccessibilityEvent(AccessibilityEvent event) {
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SYSTEM_ALERT_WINDOW)
|
|
||||||
== PackageManager.PERMISSION_DENIED) {
|
|
||||||
// may need a way to request the permission but only activities can, so by notification?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if returning to the source app from a successful AutofillActivity
|
// if returning to the source app from a successful AutofillActivity
|
||||||
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|
||||||
&& event.getPackageName().equals(packageName) && resultData != null) {
|
&& event.getPackageName().equals(packageName) && resultData != null) {
|
||||||
|
@ -117,6 +111,16 @@ public class AutofillService extends AccessibilityService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// need to request permission before attempting to draw dialog
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
&& !Settings.canDrawOverlays(this)) {
|
||||||
|
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||||
|
Uri.parse("package:" + getApplicationContext().getPackageName()));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we are now going to attempt to fill, save AccessibilityNodeInfo for later in decryptAndVerify
|
// we are now going to attempt to fill, save AccessibilityNodeInfo for later in decryptAndVerify
|
||||||
// (there should be a proper way to do this, although this seems to work 90% of the time)
|
// (there should be a proper way to do this, although this seems to work 90% of the time)
|
||||||
info = source;
|
info = source;
|
||||||
|
|
Loading…
Reference in a new issue