mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-02-22 15:31:10 +01:00
Show notification for applications that don't do it theirself...
This commit is contained in:
parent
dab1d35b21
commit
da731b082c
@ -19,6 +19,8 @@ package org.microg.gms.auth;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountAuthenticatorActivity;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
@ -88,6 +90,10 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||
} else {
|
||||
Log.d(TAG, "No Consent details attached");
|
||||
}
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(packageName.hashCode());
|
||||
|
||||
if (getIntent().hasExtra(EXTRA_FROM_ACCOUNT_MANAGER)) fromAccountManager = true;
|
||||
int callerUid = getIntent().getIntExtra(KEY_CALLER_UID, 0);
|
||||
PackageUtils.checkPackageUid(this, packageName, callerUid);
|
||||
@ -181,6 +187,8 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(packageName.hashCode());
|
||||
super.finish();
|
||||
}
|
||||
|
||||
|
@ -17,14 +17,19 @@
|
||||
package org.microg.gms.auth;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.auth.IAuthManagerService;
|
||||
import com.google.android.gms.R;
|
||||
import com.google.android.gms.auth.AccountChangeEventsRequest;
|
||||
import com.google.android.gms.auth.AccountChangeEventsResponse;
|
||||
|
||||
@ -101,6 +106,15 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Can't decode consent data: ", e);
|
||||
}
|
||||
if (notify) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(packageName.hashCode(), new NotificationCompat.Builder(context)
|
||||
.setContentIntent(PendingIntent.getActivity(context, 0, i, 0))
|
||||
.setContentTitle(context.getString(R.string.auth_notification_title))
|
||||
.setContentText(context.getString(R.string.auth_notification_content, getPackageLabel(packageName, context.getPackageManager())))
|
||||
.setSmallIcon(android.R.drawable.stat_notify_error)
|
||||
.build());
|
||||
}
|
||||
result.putParcelable(KEY_USER_RECOVERY_INTENT, i);
|
||||
return result;
|
||||
}
|
||||
@ -112,6 +126,14 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private static CharSequence getPackageLabel(String packageName, PackageManager pm) {
|
||||
try {
|
||||
return pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return packageName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountChangeEventsResponse getChangeEvents(AccountChangeEventsRequest request) {
|
||||
return new AccountChangeEventsResponse();
|
||||
|
@ -34,6 +34,8 @@ Try again later."</string>
|
||||
This can take a couple of minutes."</string>
|
||||
<string name="allow">Allow</string>
|
||||
<string name="deny">Deny</string>
|
||||
<string name="auth_notification_title">Authentication required</string>
|
||||
<string name="auth_notification_content">%s requires your authentication to access your Google-Account.</string>
|
||||
|
||||
<string name="perm_status_broadcast_label">listen to internal status broadcasts</string>
|
||||
<string name="perm_c2dm_receive_label">listen to C2DM messages</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user