| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.service.autofill; |
| 17 |
|
| 18 |
import static android.view.autofill.Helper.sDebug; |
| 19 |
|
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.TestApi; |
| 22 |
import android.os.Parcelable; |
| 23 |
import android.util.Log; |
| 24 |
import android.util.Pair; |
| 25 |
import android.widget.RemoteViews; |
| 26 |
|
| 27 |
import java.util.ArrayList; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
@TestApi |
| 36 |
public abstract class InternalTransformation implements Transformation, Parcelable { |
| 37 |
|
| 38 |
private static final String TAG = "InternalTransformation"; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
@SuppressWarnings("HiddenAbstractMethod") |
| 49 |
abstract void apply(@NonNull ValueFinder finder, @NonNull RemoteViews template, |
| 50 |
int childViewId) throws Exception; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public static boolean batchApply(@NonNull ValueFinder finder, @NonNull RemoteViews template, |
| 62 |
@NonNull ArrayList<Pair<Integer, InternalTransformation>> transformations) { |
| 63 |
final int size = transformations.size(); |
| 64 |
if (sDebug) Log.d(TAG, "getPresentation(): applying " + size + " transformations"); |
| 65 |
for (int i = 0; i < size; i++) { |
| 66 |
final Pair<Integer, InternalTransformation> pair = transformations.get(i); |
| 67 |
final int id = pair.first; |
| 68 |
final InternalTransformation transformation = pair.second; |
| 69 |
if (sDebug) Log.d(TAG, "#" + i + ": " + transformation); |
| 70 |
|
| 71 |
try { |
| 72 |
transformation.apply(finder, template, id); |
| 73 |
} catch (Exception e) { |
| 74 |
|
| 75 |
Log.e(TAG, "Could not apply transformation " + transformation + ": " |
| 76 |
+ e.getClass()); |
| 77 |
return false; |
| 78 |
} |
| 79 |
} |
| 80 |
return true; |
| 81 |
} |
| 82 |
} |