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

Commit 454faf17 authored by Matt Gilbride's avatar Matt Gilbride
Browse files

Revert^2 "Make IDropBoxManagerService compatible with aidl_interface"

This reverts commit a6efcad3.

Reason for revert: Tweak of original change fixes b/424744354

The following is the delta from the original:

- Move throwing `NullPointerException` on null `tag` fields back to
  `DropBoxManagerService` instead of `DropBoxManager`. This corrects the
  unintended behavior change in the original, where the NPE was moved
  from the binder service itself to the client side manager.
- Rearrange the fields of `IDropBoxManagerService.Entry` to more closely
  match the (former) manual Parcel `DropBoxManager.Entry`.

Bug: 420949170
Bug: 368152571
Test: atest DropBoxManagerTestCpp
Test: atest CtsDropBoxManagerTestCases
Test: atest com.android.devicehealthchecks.SystemAppCheck#system_app_crash
Flag: EXEMPT pure refactor, no API or behavioral changes
Change-Id: Ifc52d1b88fdc2caa602951f98eeb6dd19bf63e47
parent 55ed100e
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -104,14 +104,15 @@ release_package_messagequeue_implementation_srcs {
    out: ["android/os/MessageQueue.java"],
}

aidl_library {
    name: "IDropBoxManagerService_aidl",
    srcs: [
        "com/android/internal/os/IDropBoxManagerService.aidl",
    ],
    hdrs: [
        "android/os/DropBoxManager.aidl",
    ],
aidl_interface {
    name: "dropboxmanager_aidl",
    srcs: ["com/android/internal/os/IDropBoxManagerService.aidl"],
    unstable: true,
    backend: {
        java: {
            enabled: false, // TODO(b/424186512) switch frameworks/base to using this as well, it uses core build **/*.aidl glob now
        },
    },
}

filegroup {
@@ -348,7 +349,7 @@ filegroup {
        "com/android/internal/util/XmlSerializerWrapper.java",
        "com/android/internal/util/XmlPullParserWrapper.java",
        "com/android/internal/util/XmlUtils.java",
    ]
    ],
}

// keep these files in sync with the apex/jobscheduler/service jarjar-rules.txt for
+0 −19
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

parcelable DropBoxManager.Entry cpp_header "android/os/DropBoxManager.h";
+27 −20
Original line number Diff line number Diff line
@@ -202,6 +202,16 @@ public class DropBoxManager {
            mFlags = flags;
        }

        private Entry(@NonNull IDropBoxManagerService.Entry internalEntry) {
            if (internalEntry == null) throw new NullPointerException("internalEntry == null");

            mTag = internalEntry.tag;
            mTimeMillis = internalEntry.timestampMillis;
            mData = internalEntry.data;
            mFileDescriptor = internalEntry.fd;
            mFlags = internalEntry.flags;
        }

        /** Close the input stream associated with this entry. */
        public void close() {
            try { if (mFileDescriptor != null) mFileDescriptor.close(); } catch (IOException e) { }
@@ -266,15 +276,9 @@ public class DropBoxManager {
        public static final @android.annotation.NonNull Parcelable.Creator<Entry> CREATOR = new Parcelable.Creator() {
            public Entry[] newArray(int size) { return new Entry[size]; }
            public Entry createFromParcel(Parcel in) {
                String tag = in.readString();
                long millis = in.readLong();
                int flags = in.readInt();
                if ((flags & HAS_BYTE_ARRAY) != 0) {
                    return new Entry(tag, millis, in.createByteArray(), flags & ~HAS_BYTE_ARRAY);
                } else {
                    ParcelFileDescriptor pfd = ParcelFileDescriptor.CREATOR.createFromParcel(in);
                    return new Entry(tag, millis, pfd, flags);
                }
                IDropBoxManagerService.Entry internalEntry =
                        IDropBoxManagerService.Entry.CREATOR.createFromParcel(in);
                return internalEntry == null ? null : new Entry(internalEntry);
            }
        };

@@ -283,15 +287,17 @@ public class DropBoxManager {
        }

        public void writeToParcel(Parcel out, int flags) {
            out.writeString(mTag);
            out.writeLong(mTimeMillis);
            if (mFileDescriptor != null) {
                out.writeInt(mFlags & ~HAS_BYTE_ARRAY);  // Clear bit just to be safe
                mFileDescriptor.writeToParcel(out, flags);
            } else {
                out.writeInt(mFlags | HAS_BYTE_ARRAY);
                out.writeByteArray(mData);
            toInternalEntry().writeToParcel(out, flags);
        }

        private IDropBoxManagerService.Entry toInternalEntry() {
            IDropBoxManagerService.Entry internalEntry = new IDropBoxManagerService.Entry();
            internalEntry.tag = mTag;
            internalEntry.timestampMillis = mTimeMillis;
            internalEntry.fd = mFileDescriptor;
            internalEntry.flags = mFlags;
            internalEntry.data = mData;
            return internalEntry;
        }
    }

@@ -393,8 +399,9 @@ public class DropBoxManager {
    @RequiresPermission(allOf = { READ_DROPBOX_DATA, PACKAGE_USAGE_STATS })
    public @Nullable Entry getNextEntry(String tag, long msec) {
        try {
            return mService.getNextEntryWithAttribution(tag, msec, mContext.getOpPackageName(),
                    mContext.getAttributionTag());
            IDropBoxManagerService.Entry entry = mService.getNextEntryWithAttribution(
                    tag, msec, mContext.getOpPackageName(), mContext.getAttributionTag());
            return entry == null ? null : new Entry(entry);
        } catch (SecurityException e) {
            if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) {
                throw e;
+15 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.internal.os;

import android.os.DropBoxManager;
import android.os.ParcelFileDescriptor;

/**
@@ -36,8 +35,21 @@ interface IDropBoxManagerService {
    /** @see DropBoxManager#getNextEntry */
    @UnsupportedAppUsage(maxTargetSdk=30,
            publicAlternatives="Use {@link android.os.DropBoxManager#getNextEntry} instead")
    DropBoxManager.Entry getNextEntry(String tag, long millis, String packageName);
    Entry getNextEntry(String tag, long millis, String packageName);

    DropBoxManager.Entry getNextEntryWithAttribution(String tag, long millis, String packageName,
    Entry getNextEntryWithAttribution(String tag, long millis, String packageName,
            String attributionTag);

    /**
     * An entry maintained by drop box, including contents and metadata.
     * @hide
     */
    parcelable Entry {
        String tag;
        long timestampMillis;
        int flags;
        ParcelFileDescriptor fd;
        byte[] data;
    }

}
+15 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ cc_library_shared {
        "libcutils",
        "liblog",
        "libutils",
        "dropboxmanager_aidl-cpp",
    ],
    header_libs: [
        "libbase_headers",
@@ -42,7 +43,6 @@ cc_library_shared {
    aidl: {
        libs: [
            "ILogcatManagerService_aidl",
            "IDropBoxManagerService_aidl",
        ],
    },

@@ -56,3 +56,17 @@ cc_library_shared {
        "-Wunreachable-code",
    ],
}

cc_test {
    name: "DropBoxManagerTestCpp",
    team: "trendy_team_framework_bpm",
    srcs: [
        "test/DropBoxManagerTest.cpp",
    ],
    shared_libs: [
        "libbase",
        "libservices",
        "libutils",
    ],
    require_root: true,
}
Loading