Fix an issue that the icon rewritten logic not working in non-primary user

1.IconsContentProvider should be singleUser, i.e. it should run
  in user 0 only.
2.IconsContentProvider should get the icon from the calling user.

Fixes: 157073154

Test: Run our mts.
Test: Create a work profile. Select an email address, verify the icon.
Test: Create a work profile. Install a browser in work profile only.
      Select a URL and verify the icon
Change-Id: Idf4ef86f8f2aa110f755e9518cd151b943f2aea0
This commit is contained in:
Tony Mak
2020-05-20 11:29:45 +01:00
parent c74a76863b
commit 6c4f9670f3
2 changed files with 4 additions and 2 deletions

View File

@@ -5477,13 +5477,14 @@
<service android:name="com.android.server.pm.PackageManagerShellCommandDataLoader"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.LOAD_DATA" />
<action android:name="android.intent.action.LOAD_DATA"/>
</intent-filter>
</service>
<provider
android:name="com.android.server.textclassifier.IconsContentProvider"
android:authorities="com.android.textclassifier.icons"
android:singleUser="true"
android:enabled="true"
android:exported="true">
</provider>

View File

@@ -25,6 +25,7 @@ import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor.AutoCloseOutputStream;
import android.os.UserHandle;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -51,7 +52,7 @@ public final class IconsContentProvider extends ContentProvider {
try {
final ResourceInfo res = IconsUriHelper.getInstance().getResourceInfo(uri);
final Drawable drawable = Icon.createWithResource(res.packageName, res.id)
.loadDrawable(getContext());
.loadDrawableAsUser(getContext(), UserHandle.getCallingUserId());
final byte[] data = getBitmapData(drawable);
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
final ParcelFileDescriptor readSide = pipe[0];