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

Verified Commit af0aa228 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Auth: Log and handle invalid package names

parent f12536e6
Loading
Loading
Loading
Loading
+23 −46
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
@@ -39,7 +38,6 @@ import android.widget.ListView;
import android.widget.TextView;

import com.google.android.gms.R;
import com.squareup.wire.Wire;

import org.microg.gms.common.PackageUtils;
import org.microg.gms.people.PeopleManager;
@@ -107,7 +105,7 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
        try {
            applicationInfo = packageManager.getApplicationInfo(packageName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, e);
            Log.w(TAG, "Failed to find package " + packageName, e);
            finish();
            return;
        }
@@ -119,18 +117,9 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
        if (profileIcon != null) {
            ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
        } else {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    final Bitmap profileIcon = PeopleManager.getOwnerAvatarBitmap(AskPermissionActivity.this, account.name, true);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
                        }
                    });

                }
            new Thread(() -> {
                final Bitmap profileIcon1 = PeopleManager.getOwnerAvatarBitmap(AskPermissionActivity.this, account.name, true);
                runOnUiThread(() -> ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon1));
            }).start();
        }

@@ -140,18 +129,8 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
        } else {
            ((TextView) findViewById(R.id.title)).setText(getString(R.string.ask_service_permission_title, appLabel));
        }
        findViewById(android.R.id.button1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onAllow();
            }
        });
        findViewById(android.R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onDeny();
            }
        });
        findViewById(android.R.id.button1).setOnClickListener(v -> onAllow());
        findViewById(android.R.id.button2).setOnClickListener(v -> onDeny());
        ((ListView) findViewById(R.id.permissions)).setAdapter(new PermissionAdapter());
    }

@@ -161,9 +140,7 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
        findViewById(android.R.id.button2).setEnabled(false);
        findViewById(R.id.progress_bar).setVisibility(VISIBLE);
        findViewById(R.id.no_progress_bar).setVisibility(GONE);
        new Thread(new Runnable() {
            @Override
            public void run() {
        new Thread(() -> {
            try {
                AuthResponse response = authManager.requestAuth(fromAccountManager);
                Bundle result = new Bundle();
@@ -177,8 +154,6 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
                Log.w(TAG, e);
            }
            finish();

            }
        }).start();
    }

@@ -189,8 +164,10 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {

    @Override
    public void finish() {
        if (packageName != null) {
            NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            nm.cancel(packageName.hashCode());
        }
        super.finish();
    }