0

I am trying to build Aosp Launcher app with android studio.

packages/apps/Launcher3/src/full_lib/com/android/launcher3/icons/SimpleIconCache.java

@Override
protected long getSerialNumberForUser(UserHandle user) {
    synchronized (mUserSerialMap) {
        int index = mUserSerialMap.indexOfKey(user.getIdentifier());
        if (index >= 0) {
            return mUserSerialMap.valueAt(index);
        }
        long serial = mUserManager.getSerialNumberForUser(user);
        mUserSerialMap.put(user.getIdentifier(), serial);
        return serial;
    }
}

After building the source code, I can get see error "cannot find symbol method getIdentifier()".

However function getIdentifier() is defined in UserHandle class.

android-29/android/os/UserHandle.java

@SystemApi
@TestApi
public @UserIdInt int getIdentifier() {
    return mHandle;
}

Error occured because the function is defined with @SystemAPI annotation.

Is there any way to call functions that have systemapi annotation?

Gary Chen
  • 248
  • 2
  • 14

1 Answers1

1

You need to be re-build AOSP in order to force reveal these methods to Android Studio. You can remove the hide annotation (and the systemapi annotation) in the .java files under framework, and then compile the sdk using the following lines,

lunch sdk-eng

make update-api

make sdk

Then resolve the lint errors as they come, the errors themselves will tell you ways in which you can resolve them.

Once this is done, copy the generated sdk folder to the ".Android/sdk/platforms" directory and re-open Android Studio.

EDIT: Just adding that such apps based on a re-compiled sdk would not work on a normal sdk since those functions are not recognized by the normal sdk. So in a controlled environment, you can make it work.

SamT01
  • 125
  • 1
  • 14