Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeef073e authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Disable overlays while installer is resumed

The install button can be disabled for other reasons, hence we have to
store the enabled state independant of the resumed/paused state.

Test: gts-tradefed run gts-dev -m PackageInstallerTapjacking
Fixes: 62239598
Change-Id: I2effa0f5afacfaed217a030550a778e32912cfbb
parent 15436b4c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@
            android:layout_height="wrap_content"
            android:text="@string/next"
            android:maxLines="2"
            android:filterTouchesWhenObscured="true"
            style="?android:attr/buttonBarButtonStyle" />

    </LinearLayout>
+0 −1
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@
            android:layout_height="wrap_content"
            android:text="@string/next"
            android:maxLines="2"
            android:filterTouchesWhenObscured="true"
            style="?android:attr/buttonBarButtonStyle" />

    </LinearLayout>
+0 −1
Original line number Diff line number Diff line
@@ -142,7 +142,6 @@
                android:layout_height="wrap_content"
                android:text="@string/next"
                android:maxLines="2"
                android:filterTouchesWhenObscured="true"
                style="?android:attr/buttonBarButtonStyle" />

        </LinearLayout>
+27 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.packageinstaller;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.AppOpsManager;
@@ -57,6 +56,8 @@ import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;

import com.android.packageinstaller.permission.ui.OverlayTouchActivity;

import java.io.File;

/**
@@ -69,7 +70,7 @@ import java.io.File;
 * Based on the user response the package is then installed by launching InstallAppConfirm
 * sub activity. All state transitions are handled in this activity
 */
public class PackageInstallerActivity extends Activity implements OnClickListener {
public class PackageInstallerActivity extends OverlayTouchActivity implements OnClickListener {
    private static final String TAG = "PackageInstaller";

    private static final int REQUEST_TRUST_EXTERNAL_SOURCE = 1;
@@ -128,6 +129,9 @@ public class PackageInstallerActivity extends Activity implements OnClickListene
    // If unknown sources are temporary allowed
    private boolean mAllowUnknownSources;

    // Would the mOk button be enabled if this activity would be resumed
    private boolean mEnableOk;

    private void startInstallConfirm() {
        // We might need to show permissions, load layout with permissions
        if (mAppInfo != null) {
@@ -441,6 +445,25 @@ public class PackageInstallerActivity extends Activity implements OnClickListene
        checkIfAllowedAndInitiateInstall();
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (mOk != null) {
            mOk.setEnabled(mEnableOk);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();

        if (mOk != null) {
            // Don't allow the install button to be clicked as there might be overlays
            mOk.setEnabled(false);
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
@@ -456,9 +479,8 @@ public class PackageInstallerActivity extends Activity implements OnClickListene
        mOk.setOnClickListener(this);
        mCancel.setOnClickListener(this);

        if (!enableOk) {
            mOk.setEnabled(false);
        }
        mEnableOk = enableOk;
        mOk.setEnabled(enableOk);

        PackageUtil.initSnippetForNewApp(this, mAppSnippet, R.id.app_snippet);
    }