This commit is contained in:
inotia00 2023-12-23 05:12:29 +09:00 • committed by Cuynu
commit 10a29689c1
6 changed files with 33 additions and 7 deletions

View file

@ -230,7 +230,7 @@ public class PackageUtils {
if (suggestedCallerPid > 0 && suggestedCallerPid != callingPid) {
throw new SecurityException("suggested PID [" + suggestedCallerPid + "] and real calling PID [" + callingPid + "] mismatch!");
}
return getAndCheckPackage(context, suggestedPackageName, callingUid, Binder.getCallingPid());
return getAndCheckPackage(context, suggestedPackageName, callingUid, callingPid);
}
@Nullable

View file

@ -12,13 +12,13 @@ import android.util.Log
private const val TAG = "BinderUtils"
fun IBinder.warnOnTransactionIssues(code: Int, reply: Parcel?, flags: Int, base: () -> Boolean): Boolean {
fun IBinder.warnOnTransactionIssues(code: Int, reply: Parcel?, flags: Int, tag: String = TAG, base: () -> Boolean): Boolean {
if (base.invoke()) {
if ((flags and Binder.FLAG_ONEWAY) > 0 && (reply?.dataSize() ?: 0) > 0) {
Log.w(TAG, "Method $code in $interfaceDescriptor is oneway, but returned data")
Log.w(tag, "Method $code in $interfaceDescriptor is oneway, but returned data")
}
return true
}
Log.w(TAG, "Unknown method $code in $interfaceDescriptor, skipping")
Log.w(tag, "Unknown method $code in $interfaceDescriptor, skipping")
return (flags and Binder.FLAG_ONEWAY) > 0 // Don't return false on oneway transaction to suppress warning
}

View file

@ -48,6 +48,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
<<<<<<< HEAD
=======
import static android.accounts.AccountManager.*;
import static android.os.Build.VERSION.SDK_INT;
>>>>>>> 6f98f5aa (Asorted fixes https://github.com/microg/GmsCore/commit/80c1d9cf61baeec0692ec9efd3233305cda3c016)
public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
private static final String TAG = "GmsAuthManagerSvc";
@ -169,8 +175,23 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
}
@Override
<<<<<<< HEAD
public Bundle requestGoogleAccountsAccess(String packageName) {
Log.w(TAG, "Not implemented: requestGoogleAccountsAccess(" + packageName + ")");
=======
public Bundle requestGoogleAccountsAccess(String packageName) throws RemoteException {
PackageUtils.assertExtendedAccess(context);
if (SDK_INT >= 26) {
for (Account account : get(context).getAccountsByType(AuthConstants.DEFAULT_ACCOUNT_TYPE)) {
AccountManager.get(context).setAccountVisibility(account, packageName, VISIBILITY_VISIBLE);
}
Bundle res = new Bundle();
res.putString("Error", "Ok");
return res;
} else {
Log.w(TAG, "Not implemented: requestGoogleAccountsAccess(" + packageName + ")");
}
>>>>>>> 6f98f5aa (Asorted fixes https://github.com/microg/GmsCore/commit/80c1d9cf61baeec0692ec9efd3233305cda3c016)
return null;
}

View file

@ -38,5 +38,5 @@ class AppCertServiceImpl(private val context: Context) : IAppCertService.Stub()
return runBlocking { manager.getSpatulaHeader(packageName) }
}
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}

View file

@ -52,5 +52,5 @@ class CredentialsServiceImpl : ICredentialsService.Stub() {
callbacks.onStatus(Status.SUCCESS)
}
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}

View file

@ -59,5 +59,10 @@ class AuthServiceImpl(private val context: Context, private val lifecycle: Lifec
override fun getLifecycle(): Lifecycle = lifecycle
<<<<<<< HEAD
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }
}
}
=======
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}
>>>>>>> 6f98f5aa (Asorted fixes https://github.com/microg/GmsCore/commit/80c1d9cf61baeec0692ec9efd3233305cda3c016)