0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-12-03 16:27:26 +00:00

Auth: Log and handle invalid package names

This commit is contained in:
Marvin W 2021-01-06 12:13:20 +01:00
parent f12536e6ce
commit af0aa2288a
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -25,7 +25,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.util.Log; import android.util.Log;
@ -39,7 +38,6 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.gms.R; import com.google.android.gms.R;
import com.squareup.wire.Wire;
import org.microg.gms.common.PackageUtils; import org.microg.gms.common.PackageUtils;
import org.microg.gms.people.PeopleManager; import org.microg.gms.people.PeopleManager;
@ -107,7 +105,7 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
try { try {
applicationInfo = packageManager.getApplicationInfo(packageName, 0); applicationInfo = packageManager.getApplicationInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, e); Log.w(TAG, "Failed to find package " + packageName, e);
finish(); finish();
return; return;
} }
@ -119,18 +117,9 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
if (profileIcon != null) { if (profileIcon != null) {
((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon); ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
} else { } else {
new Thread(new Runnable() { new Thread(() -> {
@Override final Bitmap profileIcon1 = PeopleManager.getOwnerAvatarBitmap(AskPermissionActivity.this, account.name, true);
public void run() { runOnUiThread(() -> ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon1));
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);
}
});
}
}).start(); }).start();
} }
@ -140,18 +129,8 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
} else { } else {
((TextView) findViewById(R.id.title)).setText(getString(R.string.ask_service_permission_title, appLabel)); ((TextView) findViewById(R.id.title)).setText(getString(R.string.ask_service_permission_title, appLabel));
} }
findViewById(android.R.id.button1).setOnClickListener(new View.OnClickListener() { findViewById(android.R.id.button1).setOnClickListener(v -> onAllow());
@Override findViewById(android.R.id.button2).setOnClickListener(v -> onDeny());
public void onClick(View v) {
onAllow();
}
});
findViewById(android.R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onDeny();
}
});
((ListView) findViewById(R.id.permissions)).setAdapter(new PermissionAdapter()); ((ListView) findViewById(R.id.permissions)).setAdapter(new PermissionAdapter());
} }
@ -161,24 +140,20 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
findViewById(android.R.id.button2).setEnabled(false); findViewById(android.R.id.button2).setEnabled(false);
findViewById(R.id.progress_bar).setVisibility(VISIBLE); findViewById(R.id.progress_bar).setVisibility(VISIBLE);
findViewById(R.id.no_progress_bar).setVisibility(GONE); findViewById(R.id.no_progress_bar).setVisibility(GONE);
new Thread(new Runnable() { new Thread(() -> {
@Override try {
public void run() { AuthResponse response = authManager.requestAuth(fromAccountManager);
try { Bundle result = new Bundle();
AuthResponse response = authManager.requestAuth(fromAccountManager); result.putString(KEY_AUTHTOKEN, response.auth);
Bundle result = new Bundle(); result.putString(KEY_ACCOUNT_NAME, account.name);
result.putString(KEY_AUTHTOKEN, response.auth); result.putString(KEY_ACCOUNT_TYPE, account.type);
result.putString(KEY_ACCOUNT_NAME, account.name); result.putString(KEY_ANDROID_PACKAGE_NAME, packageName);
result.putString(KEY_ACCOUNT_TYPE, account.type); result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
result.putString(KEY_ANDROID_PACKAGE_NAME, packageName); setAccountAuthenticatorResult(result);
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true); } catch (IOException e) {
setAccountAuthenticatorResult(result); Log.w(TAG, e);
} catch (IOException e) {
Log.w(TAG, e);
}
finish();
} }
finish();
}).start(); }).start();
} }
@ -189,8 +164,10 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
@Override @Override
public void finish() { public void finish() {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (packageName != null) {
nm.cancel(packageName.hashCode()); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(packageName.hashCode());
}
super.finish(); super.finish();
} }