При добавлении окна получено сообщение об ошибке отказа в доступе для типа окна 2010 - PullRequest
0 голосов
/ 21 июня 2019

Я уже предоставил разрешение на отображение поверх других приложений, все еще получая "Unable to add window android.view.ViewRootImpl$W@8ab9bbf -- permission denied for window type 2010"

Замеченная вещь: если изменить целевой SDK на 21, тогда приложение работает нормально, что означает, что проблема с правами доступа может быть там.

Код:

  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TelephonyManager telephonyManager = (TelephonyManager) getSystemService("phone");
        this.db = new Database(this);
        Cursor res = this.db.getData();
        Cursor res2 = this.db.backUpGetData();
        int totalResults = res.getCount();
        int totalResultsBack = res2.getCount();
        if ((totalResults == 0 && totalResultsBack == 0) || ((totalResults == 0 && totalResultsBack != 0) || (totalResults != 0 && totalResultsBack == 0))) {
            finish();
        }
        LayoutParams localLayoutParams = new LayoutParams(2010, 4719904, -2);
        this.winManager = (WindowManager) getApplicationContext().getSystemService("window");
        this.wrapperView = new RelativeLayout(getBaseContext());
        getWindow().setAttributes(localLayoutParams);
        View.inflate(this, R.layout.activity_lock_screen, this.wrapperView);
        this.buttonGifImage = (GifImageButton) this.wrapperView.findViewById(R.id.imagebuton);
        this.buttonGifImage.setVisibility(0);
        ((GifDrawable) this.buttonGifImage.getDrawable()).stop();
        this.textToSpeech = new TextToSpeech(this, this);
        this.keywordField = (TextView) this.wrapperView.findViewById(R.id.unlockfiled);
        this.keywordField.setVisibility(0);
        this.switchToPincode = (ImageButton) this.wrapperView.findViewById(R.id.switchToPinCode);
        this.switchToPincode.setVisibility(0);
        this.switchPin = (TextView) this.wrapperView.findViewById(R.id.switchPin);
        this.switchPin.setVisibility(0);
        this.enterBackPassword = (EditText) this.wrapperView.findViewById(R.id.enterPassword);
        this.enterBackPassword.setVisibility(8);
        this.b1 = (Button) this.wrapperView.findViewById(R.id.n1);
        this.b1.setVisibility(8);
        this.b2 = (Button) this.wrapperView.findViewById(R.id.n2);
        this.b2.setVisibility(8);
        this.b3 = (Button) this.wrapperView.findViewById(R.id.n3);
        this.b3.setVisibility(8);
        this.b4 = (Button) this.wrapperView.findViewById(R.id.n4);
        this.b4.setVisibility(8);
        this.b5 = (Button) this.wrapperView.findViewById(R.id.n5);
        this.b5.setVisibility(8);
        this.b6 = (Button) this.wrapperView.findViewById(R.id.n6);
        this.b6.setVisibility(8);
        this.b7 = (Button) this.wrapperView.findViewById(R.id.n7);
        this.b7.setVisibility(8);
        this.b8 = (Button) this.wrapperView.findViewById(R.id.n8);
        this.b8.setVisibility(8);
        this.b9 = (Button) this.wrapperView.findViewById(R.id.n9);
        this.b9.setVisibility(8);
        this.b_Del = (Button) this.wrapperView.findViewById(R.id.del);
        this.b_Del.setVisibility(8);
        this.b0 = (Button) this.wrapperView.findViewById(R.id.n0);
        this.b0.setVisibility(8);
        this.b_OK = (Button) this.wrapperView.findViewById(R.id.okay);
        this.b_OK.setVisibility(8);
        this.imageLock = (ImageView) this.wrapperView.findViewById(R.id.lockImage);
        this.imageLock.setVisibility(8);
        this.enterPwd = (TextView) this.wrapperView.findViewById(R.id.enterPwd);
        this.enterPwd.setVisibility(8);
        this.speech = SpeechRecognizer.createSpeechRecognizer(this);
        this.speech.setRecognitionListener(new listener());
        makeFullScreen();
        DateFormat dateFormat = new SimpleDateFormat("hh \nmm");
        DateFormat datCurrent = new SimpleDateFormat("dd MMM,\n EEE");
        String localTime = dateFormat.format(new Date());
        String localDate = datCurrent.format(new Date());
        this.timeCount = (TextView) this.wrapperView.findViewById(R.id.Date);
        this.timeCount.setVisibility(0);
        this.timeCount.setText(localTime);
        this.view = this.wrapperView.findViewById(R.id.View06);
        this.view.setVisibility(0);
        this.currentDate = (TextView) this.wrapperView.findViewById(R.id.currentDate);
        this.currentDate.setVisibility(0);
        this.currentDate.setText(localDate);
        this.touchOnMic = (TextView) this.wrapperView.findViewById(R.id.touchOnMic);
        this.touchOnMic.setVisibility(0);
        this.touchOnMic.setText("Tap on mic to speak voice password");
        this.wrapperView.setFocusableInTouchMode(true);
        this.wrapperView.requestFocus();
        this.wrapperView.setOnKeyListener(new C01861());
        switchPinCode();
        this.backGroundPics = MainActivity.backgroundPics;
        if (this.backGroundPics == 0) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull1);
        } else if (this.backGroundPics == R.drawable.hfull1) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull1);
        } else if (this.backGroundPics == R.drawable.hfull2) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull2);
        } else if (this.backGroundPics == R.drawable.hfull3) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull3);
        } else if (this.backGroundPics == R.drawable.hfull4) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull4);
        } else if (this.backGroundPics == R.drawable.hfull5) {
            this.wrapperView.setBackgroundResource(R.drawable.hfull5);
        }
        this.winManager.addView(this.wrapperView, localLayoutParams);
        telephonyManager.listen(new C01872(), 32);
    }

Я декомпилировал приложение https://play.google.com/store/apps/details?id=com.lock.admin.screenlock

Это приложение работает совершенно нормально в последней версии Android.

...