OSDN Git Service

Update FontsContract.requestFonts
authorSeigo Nonaka <nona@google.com>
Wed, 26 Apr 2017 02:39:23 +0000 (19:39 -0700)
committerSeigo Nonaka <nona@google.com>
Wed, 26 Apr 2017 02:56:56 +0000 (19:56 -0700)
- Change FontsContract.requestFont plural form to meet other method
naming convension.
- Change FontsContract.requestFonts to accept CancellationSignal to
be able to notify to remote.

Bug: 37326126
Test: am instrument -w -e class android.provider.FontsContractE2ETest
      com.android.frameworks.coretests/\
      android.support.test.runner.AndroidJUnitRunner

Change-Id: I154f943eb4e7c91bff8afd86be479f72e66e5cb7

api/current.txt
api/system-current.txt
api/test-current.txt
core/java/android/provider/FontsContract.java
core/tests/coretests/src/android/provider/FontsContractE2ETest.java

index 93caec3..5d7965e 100644 (file)
@@ -34495,7 +34495,7 @@ package android.provider {
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[], int, boolean, java.lang.String);
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[]);
     method public static android.provider.FontsContract.FontFamilyResult fetchFonts(android.content.Context, android.os.CancellationSignal, android.graphics.fonts.FontRequest) throws android.content.pm.PackageManager.NameNotFoundException;
-    method public static void requestFont(android.content.Context, android.graphics.fonts.FontRequest, android.provider.FontsContract.FontRequestCallback, android.os.Handler);
+    method public static void requestFonts(android.content.Context, android.graphics.fonts.FontRequest, android.os.Handler, android.os.CancellationSignal, android.provider.FontsContract.FontRequestCallback);
   }
 
   public static final class FontsContract.Columns implements android.provider.BaseColumns {
index bbced6c..eccd569 100644 (file)
@@ -37485,7 +37485,7 @@ package android.provider {
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[], int, boolean, java.lang.String);
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[]);
     method public static android.provider.FontsContract.FontFamilyResult fetchFonts(android.content.Context, android.os.CancellationSignal, android.graphics.fonts.FontRequest) throws android.content.pm.PackageManager.NameNotFoundException;
-    method public static void requestFont(android.content.Context, android.graphics.fonts.FontRequest, android.provider.FontsContract.FontRequestCallback, android.os.Handler);
+    method public static void requestFonts(android.content.Context, android.graphics.fonts.FontRequest, android.os.Handler, android.os.CancellationSignal, android.provider.FontsContract.FontRequestCallback);
   }
 
   public static final class FontsContract.Columns implements android.provider.BaseColumns {
index b5cfa24..9d0bc72 100644 (file)
@@ -34631,7 +34631,7 @@ package android.provider {
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[], int, boolean, java.lang.String);
     method public static android.graphics.Typeface buildTypeface(android.content.Context, android.os.CancellationSignal, android.provider.FontsContract.FontInfo[]);
     method public static android.provider.FontsContract.FontFamilyResult fetchFonts(android.content.Context, android.os.CancellationSignal, android.graphics.fonts.FontRequest) throws android.content.pm.PackageManager.NameNotFoundException;
-    method public static void requestFont(android.content.Context, android.graphics.fonts.FontRequest, android.provider.FontsContract.FontRequestCallback, android.os.Handler);
+    method public static void requestFonts(android.content.Context, android.graphics.fonts.FontRequest, android.os.Handler, android.os.CancellationSignal, android.provider.FontsContract.FontRequestCallback);
   }
 
   public static final class FontsContract.Columns implements android.provider.BaseColumns {
index 068628a..0e2b531 100644 (file)
@@ -487,11 +487,15 @@ public class FontsContract {
      * @param context A context to be used for fetching from font provider.
      * @param request A {@link FontRequest} object that identifies the provider and query for the
      *                request. May not be null.
-     * @param callback A callback that will be triggered when results are obtained. May not be null.
      * @param handler A handler to be processed the font fetching.
+     * @param cancellationSignal A signal to cancel the operation in progress, or null if none. If
+     *                           the operation is canceled, then {@link
+     *                           android.os.OperationCanceledException} will be thrown.
+     * @param callback A callback that will be triggered when results are obtained. May not be null.
      */
-    public static void requestFont(@NonNull Context context, @NonNull FontRequest request,
-            @NonNull FontRequestCallback callback, @NonNull Handler handler) {
+    public static void requestFonts(@NonNull Context context, @NonNull FontRequest request,
+            @NonNull Handler handler, @Nullable CancellationSignal cancellationSignal,
+            @NonNull FontRequestCallback callback) {
 
         final Handler callerThreadHandler = new Handler();
         final Typeface cachedTypeface = sTypefaceCache.get(request.getIdentifier());
@@ -503,7 +507,7 @@ public class FontsContract {
         handler.post(() -> {
             FontFamilyResult result;
             try {
-                result = fetchFonts(context, null /* cancellation signal */, request);
+                result = fetchFonts(context, cancellationSignal, request);
             } catch (NameNotFoundException e) {
                 callerThreadHandler.post(() -> callback.onTypefaceRequestFailed(
                         FontRequestCallback.FAIL_REASON_PROVIDER_NOT_FOUND));
@@ -558,7 +562,7 @@ public class FontsContract {
                 }
             }
 
-            final Typeface typeface = buildTypeface(context, null /* cancellation signal */, fonts);
+            final Typeface typeface = buildTypeface(context, cancellationSignal, fonts);
             if (typeface == null) {
                 // Something went wrong during reading font files. This happens if the given font
                 // file is an unsupported font type.
index 479f6dd..78c7f4d 100644 (file)
@@ -120,7 +120,7 @@ public class FontsContractE2ETest {
         inst.runOnMainSync(() -> {
             FontRequest request = new FontRequest(
                     AUTHORITY, PACKAGE, "singleFontFamily", SIGNATURE);
-            FontsContract.requestFont(ctx, request, callback, new Handler());
+            FontsContract.requestFonts(ctx, request, new Handler(), null, callback);
         });
         inst.waitForIdleSync();
         assertEquals(1, callback.getSuccessCallCount());
@@ -131,7 +131,7 @@ public class FontsContractE2ETest {
         inst.runOnMainSync(() -> {
             FontRequest request = new FontRequest(
                     AUTHORITY, PACKAGE, "singleFontFamily", SIGNATURE);
-            FontsContract.requestFont(ctx, request, callback2, new Handler());
+            FontsContract.requestFonts(ctx, request, new Handler(), null, callback2);
         });
         inst.waitForIdleSync();
         assertEquals(1, callback2.getSuccessCallCount());
@@ -142,7 +142,7 @@ public class FontsContractE2ETest {
         inst.runOnMainSync(() -> {
             FontRequest request = new FontRequest(
                     AUTHORITY, PACKAGE, "singleFontFamily2", SIGNATURE);
-            FontsContract.requestFont(ctx, request, callback3, new Handler());
+            FontsContract.requestFonts(ctx, request, new Handler(), null, callback3);
         });
         inst.waitForIdleSync();
         assertEquals(1, callback3.getSuccessCallCount());