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

Commit fc39b3fb authored by Mark White's avatar Mark White Committed by Android (Google) Code Review
Browse files

Merge "Disable system_uid_target_system_sdk behaviour on Wear devices" into main

parents 52613dde 4e6b50d5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.net.Uri;
import android.os.Binder;
@@ -75,6 +76,7 @@ public class PlatformCompat extends IPlatformCompat.Stub {
    private final ChangeReporter mChangeReporter;
    private final CompatConfig mCompatConfig;
    private final AndroidBuildClassifier mBuildClassifier;
    private Boolean mIsWear;

    public PlatformCompat(Context context) {
        super(PermissionEnforcer.fromContext(context));
@@ -511,9 +513,16 @@ public class PlatformCompat extends IPlatformCompat.Stub {
    }

    private ApplicationInfo fixTargetSdk(ApplicationInfo appInfo, int uid) {

        // mIsWear doesn't need to be locked, ok if executes twice
        if (mIsWear == null) {
            mIsWear = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
        }

        // b/282922910 - we don't want apps sharing system uid and targeting
        // older target sdk to impact all system uid apps
        if (Flags.systemUidTargetSystemSdk() && uid == Process.SYSTEM_UID) {
        if (Flags.systemUidTargetSystemSdk() && !mIsWear &&
                uid == Process.SYSTEM_UID) {
            appInfo.targetSdkVersion = Build.VERSION.SDK_INT;
        }
        return appInfo;