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

Commit 1388aadb authored by yutingfang's avatar yutingfang
Browse files

Change system API getDeviceId to be @NonNull

This is to address the feedback from api council that
OpEventProxyInfo#getDeviceId should be @NonNull. The device Id will be
set to VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT when the
parameter passed to the constructor is null.

Flag: android.permission.flags.device_id_in_op_proxy_info_enabled
Test: presubmit
Bug: 341319360
Change-Id: I95ade50744ec80fc24a559547bc0bb8e2c17373c
parent 3fede68d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ package android.app {
  public static final class AppOpsManager.OpEventProxyInfo implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getAttributionTag();
    method @FlaggedApi("android.permission.flags.device_id_in_op_proxy_info_enabled") @Nullable public String getDeviceId();
    method @FlaggedApi("android.permission.flags.device_id_in_op_proxy_info_enabled") @NonNull public String getDeviceId();
    method @Nullable public String getPackageName();
    method @IntRange(from=0) public int getUid();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
+9 −7
Original line number Diff line number Diff line
@@ -3586,7 +3586,7 @@ public class AppOpsManager {
        /** Attribution tag of the proxy that noted the op */
        private @Nullable String mAttributionTag;
        /** Persistent device Id of the proxy that noted the op */
        private @Nullable String mDeviceId;
        private @NonNull String mDeviceId;

        /**
         * Reinit existing object with new state.
@@ -3599,7 +3599,7 @@ public class AppOpsManager {
         * @hide
         */
        public void reinit(@IntRange(from = 0) int uid, @Nullable String packageName,
                @Nullable String attributionTag, @Nullable String deviceId) {
                @Nullable String attributionTag, @NonNull String deviceId) {
            mUid = Preconditions.checkArgumentNonnegative(uid);
            mPackageName = packageName;
            mAttributionTag = attributionTag;
@@ -3662,7 +3662,8 @@ public class AppOpsManager {
                    "from", 0);
            this.mPackageName = packageName;
            this.mAttributionTag = attributionTag;
            this.mDeviceId = deviceId;
            this.mDeviceId = deviceId == null ? VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
                    : deviceId;
        }
        /**
         * Copy constructor
@@ -3705,7 +3706,7 @@ public class AppOpsManager {
         * Persistent device Id of the proxy that noted the op
         */
        @FlaggedApi(Flags.FLAG_DEVICE_ID_IN_OP_PROXY_INFO_ENABLED)
        public @Nullable String getDeviceId() { return mDeviceId; }
        public @NonNull String getDeviceId() { return mDeviceId; }

        @Override
        @DataClass.Generated.Member
@@ -3716,12 +3717,12 @@ public class AppOpsManager {
            byte flg = 0;
            if (mPackageName != null) flg |= 0x2;
            if (mAttributionTag != null) flg |= 0x4;
            if (mDeviceId != null) flg |= 0x8;
            flg |= 0x8;
            dest.writeByte(flg);
            dest.writeInt(mUid);
            if (mPackageName != null) dest.writeString(mPackageName);
            if (mAttributionTag != null) dest.writeString(mAttributionTag);
            if (mDeviceId != null) dest.writeString(mDeviceId);
            dest.writeString(mDeviceId);
        }

        @Override
@@ -3739,7 +3740,8 @@ public class AppOpsManager {
            int uid = in.readInt();
            String packageName = (flg & 0x2) == 0 ? null : in.readString();
            String attributionTag = (flg & 0x4) == 0 ? null : in.readString();
            String deviceId = (flg & 0x8) == 0 ? null : in.readString();
            String deviceId = (flg & 0x8) == 0 ? VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
                    : in.readString();
            this.mUid = uid;
            com.android.internal.util.AnnotationValidations.validate(
                    IntRange.class, null, mUid,