Skip to content

Commit

Permalink
Merge some fixes from ReVanced
Browse files Browse the repository at this point in the history
  • Loading branch information
YT-Advanced authored Mar 28, 2024
2 parents 1c06ec0 + 0651a51 commit 33583ea
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ allprojects {
group = 'org.microg.gms'
ext.appVersionCode = 241017000
ext.baseVersion = ext.appVersionCode.toString()[0..1] + '.' + ext.appVersionCode.toString()[2..3] + '.' + ext.appVersionCode.toString()[4..5]
version = "0.3.0." + ext.baseVersion.replaceAll("\\.", "")
version = "0.3.1." + ext.baseVersion.replaceAll("\\.", "")
ext.isReleaseVersion = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.util.Log;

import androidx.annotation.Nullable;
import com.google.android.gms.common.BuildConfig;
import org.microg.gms.utils.ExtendedPackageInfo;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -60,7 +61,7 @@ public static boolean isGooglePackage(Context context, String packageName) {
*/
@Deprecated
public static boolean callerHasExtendedAccessPermission(Context context) {
return context.checkCallingPermission("org.microg.gms.EXTENDED_ACCESS") == PackageManager.PERMISSION_GRANTED;
return context.checkCallingPermission(BuildConfig.BASE_PACKAGE_NAME + ".microg.gms.EXTENDED_ACCESS") == PackageManager.PERMISSION_GRANTED;
}

public static void assertGooglePackagePermission(Context context, GooglePackagePermission permission) {
Expand All @@ -80,6 +81,11 @@ public static boolean callerHasGooglePackagePermission(Context context, GooglePa
packageCandidate
);

// See https://github.com/ReVanced/GmsCore/issues/10.
ExtendedPackageInfo extendedPackageInfo = new ExtendedPackageInfo(context, packageName);
if (!extendedPackageInfo.isInstalled())
return true;

if (new ExtendedPackageInfo(context, packageName).hasGooglePackagePermission(permission)) {
return true;
}
Expand Down Expand Up @@ -240,7 +246,7 @@ public static String getAndCheckPackage(Context context, String suggestedPackage
if (packageName != null && suggestedPackageName != null && !packageName.equals(suggestedPackageName)) {
throw new SecurityException("UID [" + callingUid + "] is not related to packageName [" + suggestedPackageName + "] (seems to be " + packageName + ")");
}
return PackageSpoofUtils.spoofPackageName(context.getPackageManager(), packageName);
return packageName;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.util.*
/**
* Utilities to spoof package information.
*/
internal object PackageSpoofUtils {
object PackageSpoofUtils {
private const val TAG = "SpoofUtils"
private const val META_SPOOF_PACKAGE_NAME =
BuildConfig.BASE_PACKAGE_NAME + ".android.gms.SPOOFED_PACKAGE_NAME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.content.pm.ResolveInfo;
import android.os.IBinder;
import android.util.Log;
import com.google.android.gms.base.BuildConfig;

import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -179,7 +180,7 @@ public boolean isMicrog(ResolveInfo resolveInfo) {
if (resolveInfo == null || resolveInfo.serviceInfo == null) return false;
if (resolveInfo.serviceInfo.name.startsWith("org.microg.")) return true;
try {
PermissionInfo info = context.getPackageManager().getPermissionInfo("org.microg.gms.EXTENDED_ACCESS", 0);
PermissionInfo info = context.getPackageManager().getPermissionInfo(BuildConfig.BASE_PACKAGE_NAME + ".microg.gms.EXTENDED_ACCESS", 0);

This comment has been minimized.

Copy link
@Neto48-estar

Neto48-estar Aug 12, 2024

Ola

return info.packageName.equals(resolveInfo.serviceInfo.packageName);
} catch (PackageManager.NameNotFoundException e) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
android:protectionLevel="dangerous" />

<permission
android:name="org.microg.gms.STATUS_BROADCAST"
android:name="${basePackageName}.microg.gms.STATUS_BROADCAST"
android:label="@string/perm_status_broadcast_label"
android:protectionLevel="normal" />
<permission
android:name="org.microg.gms.EXTENDED_ACCESS"
android:name="${basePackageName}.microg.gms.EXTENDED_ACCESS"
android:label="@string/perm_extended_access_label"
android:protectionLevel="dangerous" />
<permission
android:name="org.microg.gms.PROVISION"
android:name="${basePackageName}.microg.gms.PROVISION"
android:description="@string/perm_provision_description"
android:label="@string/perm_provision_label"
android:protectionLevel="privileged|signature" />
Expand Down Expand Up @@ -98,7 +98,7 @@
<uses-permission android:name="${basePackageName}.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="${basePackageName}.android.c2dm.permission.SEND" />

<uses-permission android:name="org.microg.gms.STATUS_BROADCAST" />
<uses-permission android:name="${basePackageName}.microg.gms.STATUS_BROADCAST" />

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down Expand Up @@ -128,7 +128,7 @@
<service
android:name="org.microg.gms.provision.ProvisionService"
android:exported="true"
android:permission="org.microg.gms.PROVISION" />
android:permission="${basePackageName}.microg.gms.PROVISION" />

<!-- Services Framework -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import androidx.annotation.RequiresPermission;
import com.google.android.gms.base.BuildConfig;
import org.microg.gms.common.PackageSpoofUtils;
import org.microg.gms.common.PackageUtils;
import org.microg.gms.settings.SettingsContract;

Expand Down Expand Up @@ -269,7 +270,10 @@ public AuthResponse requestAuth(boolean legacy) throws IOException {
}
AuthRequest request = new AuthRequest().fromContext(context)
.source("android")
.app(packageName, getPackageSignature())
.app(
PackageSpoofUtils.spoofPackageName(context.getPackageManager(), packageName),
PackageSpoofUtils.spoofStringSignature(context.getPackageManager(), packageName, getPackageSignature())
)
.email(accountName)
.token(getAccountManager().getPassword(account))
.service(service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.microg.gms.auth.AuthManager;
import org.microg.gms.auth.AuthResponse;
import org.microg.gms.auth.login.LoginActivity;
import org.microg.gms.common.PackageSpoofUtils;
import org.microg.gms.common.PackageUtils;

import java.util.Arrays;
Expand Down Expand Up @@ -107,7 +108,7 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response, Account accoun
Intent i = new Intent(context, AskPermissionActivity.class);
i.putExtras(options);
i.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
i.putExtra(KEY_ANDROID_PACKAGE_NAME, app);
i.putExtra(KEY_ANDROID_PACKAGE_NAME, PackageSpoofUtils.spoofPackageName(context.getPackageManager(), app));
i.putExtra(KEY_ACCOUNT_TYPE, account.type);
i.putExtra(KEY_ACCOUNT_NAME, account.name);
i.putExtra(KEY_AUTHTOKEN, authTokenType);
Expand Down

3 comments on commit 33583ea

@manojkumark04
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can i get latest apk file?

@Shuaibbo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMG_1713071787179
Hii

@Shuaibbo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chalo

Please sign in to comment.