Use getPackageInfoAsUser in requestBufferForProcess

Notice that the exception is caught now, so it doesn't crash the app.
And seems the buffer is used for stats only, so seems thing is still
working. But it is still good to have it fixed :)

Fix: 36349295

Test: Install Avast Passwords in work profile only, launch it.
      Observe that no more log complaining failed to get application.

Change-Id: I27b213303e9cf08c32e2ffdb7bda131c2b7f9ecb
This commit is contained in:
Tony Mak
2017-03-20 18:35:43 +00:00
parent 7ba04df38c
commit 8256680743

View File

@@ -32,6 +32,7 @@ import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.util.Log;
import android.view.IGraphicsStats;
import android.view.IGraphicsStatsCallback;
@@ -167,7 +168,10 @@ public class GraphicsStatsService extends IGraphicsStats.Stub {
long callingIdentity = Binder.clearCallingIdentity();
try {
mAppOps.checkPackage(uid, packageName);
PackageInfo info = mContext.getPackageManager().getPackageInfo(packageName, 0);
PackageInfo info = mContext.getPackageManager().getPackageInfoAsUser(
packageName,
0,
UserHandle.getUserId(uid));
synchronized (mLock) {
pfd = requestBufferForProcessLocked(token, uid, pid, packageName, info.versionCode);
}