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

Commit 4e6b50d5 authored by Mark White's avatar Mark White
Browse files

Disable system_uid_target_system_sdk behaviour on Wear devices

com.google.android.apps.wearable.settings app on Wear devices currently doesn't work if the system uid apps all get behavior from the  current sdk, as implemented by system_uid_target_system_sdk flag. This CL temporarily disables the new behavior on Wear devices.

Test: presubmit
Flag: com.android.server.compat.system_uid_target_system_sdk
Bug: 371614141

Change-Id: Id49b1f6d252bd4ee7e6c36c171df500d848f66e7
parent a33c539a
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;