Update FontManager#getFontConfig to require permission
There is no security risk in getFontConfig without calling permissions but for keeping compatibility it is recommended to have permissions to all (non-mainline) system APIs. To be able to test these APIs, grant UPDATE_FONTS permission to shell. Bug: 181796732 Test: atest FontManagerTest Change-Id: Ic1f663e1e01f3625a076e68949f717366e79f5fa
This commit is contained in:
@@ -2893,7 +2893,7 @@ package android.graphics.fonts {
|
||||
}
|
||||
|
||||
public class FontManager {
|
||||
method @NonNull public android.text.FontConfig getFontConfig();
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public android.text.FontConfig getFontConfig();
|
||||
method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFamily(@NonNull android.graphics.fonts.FontFamilyUpdateRequest, @IntRange(from=0) int);
|
||||
field public static final int RESULT_ERROR_DOWNGRADING = -5; // 0xfffffffb
|
||||
field public static final int RESULT_ERROR_FAILED_TO_WRITE_FONT_FILE = -1; // 0xffffffff
|
||||
|
||||
@@ -960,7 +960,7 @@ package android.graphics.drawable {
|
||||
package android.graphics.fonts {
|
||||
|
||||
public class FontManager {
|
||||
method @NonNull public android.text.FontConfig getFontConfig();
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public android.text.FontConfig getFontConfig();
|
||||
method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFamily(@NonNull android.graphics.fonts.FontFamilyUpdateRequest, @IntRange(from=0) int);
|
||||
field public static final int RESULT_ERROR_DOWNGRADING = -5; // 0xfffffffb
|
||||
field public static final int RESULT_ERROR_FAILED_TO_WRITE_FONT_FILE = -1; // 0xffffffff
|
||||
|
||||
@@ -195,6 +195,7 @@ public class FontManager {
|
||||
* @return The current font configuration. null if failed to fetch information from the system
|
||||
* service.
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.UPDATE_FONTS)
|
||||
public @NonNull FontConfig getFontConfig() {
|
||||
try {
|
||||
return mIFontManager.getFontConfig();
|
||||
|
||||
@@ -488,6 +488,8 @@ applications that come with the platform
|
||||
<permission name="android.permission.MANAGE_UI_TRANSLATION" />
|
||||
<!-- Permission required for CTS test - ClipboardManagerTest -->
|
||||
<permission name="android.permission.SET_CLIP_SOURCE" />
|
||||
<!-- Permission required for CTS test - FontManagerTest -->
|
||||
<permission name="android.permission.UPDATE_FONTS" />
|
||||
</privapp-permissions>
|
||||
|
||||
<privapp-permissions package="com.android.statementservice">
|
||||
|
||||
@@ -426,6 +426,9 @@
|
||||
<!-- Permission required for CTS test - ClipboardManagerTest -->
|
||||
<uses-permission android:name="android.permission.SET_CLIP_SOURCE" />
|
||||
|
||||
<!-- Permission required for CTS test - FontManagerTest -->
|
||||
<uses-permission android:name="android.permission.UPDATE_FONTS" />
|
||||
|
||||
<application android:label="@string/app_label"
|
||||
android:theme="@android:style/Theme.DeviceDefault.DayNight"
|
||||
android:defaultToDeviceProtectedStorage="true"
|
||||
|
||||
@@ -66,6 +66,8 @@ public final class FontManagerService extends IFontManager.Stub {
|
||||
|
||||
@Override
|
||||
public FontConfig getFontConfig() {
|
||||
getContext().enforceCallingPermission(Manifest.permission.UPDATE_FONTS,
|
||||
"UPDATE_FONTS permission required.");
|
||||
return getSystemFontConfig();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user