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

Commit 77f9a215 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [7076555, 7076828, 7076829, 7076556, 7076801] into qt-release

Change-Id: Ie5eaf6dc7e3e2433c8c77636a151efc33f7f7cb5
parents 2d361be4 e20fcec6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1092,11 +1092,12 @@ package android.app.prediction {
  }
  public static final class AppTarget.Builder {
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull String, @NonNull android.os.UserHandle);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull android.content.pm.ShortcutInfo);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId);
    method @NonNull public android.app.prediction.AppTarget build();
    method @NonNull public android.app.prediction.AppTarget.Builder setClassName(@NonNull String);
    method @NonNull public android.app.prediction.AppTarget.Builder setRank(@IntRange(from=0) int);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull android.content.pm.ShortcutInfo);
  }
  public final class AppTargetEvent implements android.os.Parcelable {
+3 −2
Original line number Diff line number Diff line
@@ -498,11 +498,12 @@ package android.app.prediction {
  }

  public static final class AppTarget.Builder {
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull String, @NonNull android.os.UserHandle);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull android.content.pm.ShortcutInfo);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId);
    method @NonNull public android.app.prediction.AppTarget build();
    method @NonNull public android.app.prediction.AppTarget.Builder setClassName(@NonNull String);
    method @NonNull public android.app.prediction.AppTarget.Builder setRank(@IntRange(from=0) int);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull android.content.pm.ShortcutInfo);
  }

  public final class AppTargetEvent implements android.os.Parcelable {
+14 −39
Original line number Diff line number Diff line
@@ -203,50 +203,25 @@ public final class AppTarget implements Parcelable {
        private String mClassName;
        private int mRank;

        /**
         * @deprecated Use the other Builder constructors.
         * @hide
         */
        @Deprecated
        public Builder(@NonNull AppTargetId id) {
            mId = id;
        }

        /**
         * @param id A unique id for this launchable target.
         * @param packageName PackageName of the target.
         * @param user The UserHandle of the user which this target belongs to.
         * @hide
         */
        @SystemApi
        @TestApi
        public Builder(@NonNull AppTargetId id, @NonNull String packageName,
                @NonNull UserHandle user) {
            mId = Preconditions.checkNotNull(id);
            mPackageName = Preconditions.checkNotNull(packageName);
            mUser = Preconditions.checkNotNull(user);
        }

        /**
         * @param id A unique id for this launchable target.
         * @param info The ShortcutInfo that represents this launchable target.
         * @hide
         */
        @SystemApi
        @TestApi
        public Builder(@NonNull AppTargetId id, @NonNull ShortcutInfo info) {
            mId = Preconditions.checkNotNull(id);
            mShortcutInfo = Preconditions.checkNotNull(info);
            mPackageName = info.getPackage();
            mUser = info.getUserHandle();
        public Builder(@NonNull AppTargetId id) {
            mId = id;
        }

        /**
         * @deprecated Use the appropriate constructor.
         * @hide
         * Sets the target to be an app.
         *
         * @param packageName PackageName of the app
         * @param user The UserHandle of the user which this target belongs to.
         *
         * @throws IllegalArgumentException is the target is already set
         */
        @NonNull
        @Deprecated
        public Builder setTarget(@NonNull String packageName, @NonNull UserHandle user) {
            if (mPackageName != null) {
                throw new IllegalArgumentException("Target is already set");
@@ -257,11 +232,11 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * @deprecated Use the appropriate constructor.
         * @hide
         * Sets the target to be a ShortcutInfo.
         *
         * @throws IllegalArgumentException is the target is already set
         */
        @NonNull
        @Deprecated
        public Builder setTarget(@NonNull ShortcutInfo info) {
            setTarget(info.getPackage(), info.getUserHandle());
            mShortcutInfo = Preconditions.checkNotNull(info);
@@ -269,7 +244,7 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * Sets the className for the target.
         * Sets the className for the target
         */
        @NonNull
        public Builder setClassName(@NonNull String className) {
@@ -278,7 +253,7 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * Sets the rank of the target.
         * Sets the rank of the for the target.
         */
        @NonNull
        public Builder setRank(@IntRange(from = 0) int rank) {
@@ -299,7 +274,7 @@ public final class AppTarget implements Parcelable {
        @NonNull
        public AppTarget build() {
            if (mPackageName == null) {
                throw new IllegalStateException("No target is set");
                throw new IllegalStateException("No target set");
            }
            return new AppTarget(mId, mPackageName, mUser, mShortcutInfo, mClassName, mRank);
        }
+5 −5
Original line number Diff line number Diff line
@@ -1349,12 +1349,12 @@ public class ChooserActivity extends ResolverActivity {
        appPredictor.notifyAppTargetEvent(
                new AppTargetEvent.Builder(
                    // TODO(b/124404997) Send full shortcut info, not just Id with AppTargetId.
                    new AppTarget.Builder(new AppTargetId(shortcutId),
                            componentName.getPackageName(), getUser())
                    new AppTarget.Builder(new AppTargetId(shortcutId))
                        .setTarget(componentName.getPackageName(), getUser())
                        .setClassName(componentName.getClassName())
                        .build(),
                    AppTargetEvent.ACTION_LAUNCH)
                    .setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE)
                    AppTargetEvent.ACTION_LAUNCH
                ).setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE)
                .build());
    }

+23 −14
Original line number Diff line number Diff line
@@ -18,42 +18,51 @@

#include "core_jni_helpers.h"

void* android::nio_getPointer(JNIEnv *_env, jobject buffer, jarray *array) {
    assert(array);
namespace {

void* getPointer(JNIEnv *_env, jobject buffer, jarray *array, void** elements) {
    assert(array);
    jint position;
    jint limit;
    jint elementSizeShift;
    jlong pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
    if (pointer != 0L) {
        *array = nullptr;
        *elements = nullptr;
        pointer += position << elementSizeShift;
        return reinterpret_cast<void*>(pointer);
    }

    jint offset = jniGetNioBufferBaseArrayOffset(_env, buffer);
    *array = jniGetNioBufferBaseArray(_env, buffer);
    void * data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
    return reinterpret_cast<void*>(reinterpret_cast<char*>(data) + offset);
    *elements = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
    return reinterpret_cast<void*>(reinterpret_cast<char*>(*elements) + offset);
}

void releasePointer(JNIEnv *_env, jarray array, void *elements, jboolean commit) {
    _env->ReleasePrimitiveArrayCritical(array, elements, commit ? 0 : JNI_ABORT);
}

}  // namespace

void* android::nio_getPointer(JNIEnv *_env, jobject buffer, jarray *array) {
    void* elements;
    return getPointer(_env, buffer, array, &elements);
}

void android::nio_releasePointer(JNIEnv *_env, jarray array, void *data,
                                jboolean commit) {
    _env->ReleasePrimitiveArrayCritical(array, data,
                                        commit ? 0 : JNI_ABORT);
void android::nio_releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) {
    releasePointer(_env, array, data, commit);
}

///////////////////////////////////////////////////////////////////////////////

android::AutoBufferPointer::AutoBufferPointer(JNIEnv* env, jobject nioBuffer,
                                              jboolean commit) {
android::AutoBufferPointer::AutoBufferPointer(JNIEnv* env, jobject nioBuffer, jboolean commit) {
    fEnv = env;
    fCommit = commit;
    fPointer = android::nio_getPointer(env, nioBuffer, &fArray);
    fPointer = getPointer(env, nioBuffer, &fArray, &fElements);
}

android::AutoBufferPointer::~AutoBufferPointer() {
    if (NULL != fArray) {
        android::nio_releasePointer(fEnv, fArray, fPointer, fCommit);
    if (nullptr != fArray) {
        releasePointer(fEnv, fArray, fElements, fCommit);
    }
}
Loading