| | | |
Offset 1, 139 lines modified | Offset 1, 136 lines modified |
| |
1 | package·com.android.providers.media; | 1 | package·com.android.providers.media; |
| |
2 | import·java.util.Objects; | 2 | import·java.util.Objects; |
3 | import·android.widget.ImageView; | 3 | import·android.widget.ImageView; |
4 | import·android.graphics.ImageDecoder$Source; | |
5 | import·android.util.DisplayMetrics; | 4 | import·android.util.DisplayMetrics; |
6 | import·android.database.Cursor; | 5 | import·android.database.Cursor; |
7 | import·android.content.ContentResolver; | 6 | import·android.content.ContentResolver; |
8 | import·android.content.res.Resources; | 7 | import·android.content.res.Resources; |
9 | import·android.util.Log; | |
10 | import·android.graphics.ImageDecoder$OnHeaderDecodedListener; | |
11 | import·java.io.IOException; | 8 | import·java.io.IOException; |
12 | import·android.graphics.ImageDecoder; | 9 | import·android.graphics.ImageDecoder; |
13 | import·android.util.Size; | 10 | import·android.util.Size; |
14 | import·android.os.CancellationSignal; | 11 | import·android.os.CancellationSignal; |
15 | import·android.os.Bundle; | 12 | import·android.os.Bundle; |
16 | import·android.net.Uri; | 13 | import·android.net.Uri; |
17 | import·android.content.Context; | 14 | import·android.content.Context; |
| 15 | import·android.graphics.drawable.Icon; |
18 | import·android.graphics.Bitmap; | 16 | import·android.graphics.Bitmap; |
| |
19 | class·PermissionActivity$Description | 17 | class·PermissionActivity$Description |
20 | { | 18 | { |
21 | ····public·static·final·int·LOAD_CONTENT_DESCRIPTION·=·1; | 19 | ····public·static·final·int·LOAD_CONTENT_DESCRIPTION·=·1; |
22 | ····public·static·final·int·LOAD_FULL·=·4; | 20 | ····public·static·final·int·LOAD_FULL·=·4; |
23 | ····public·static·final·int·LOAD_THUMBNAIL·=·2; | 21 | ····public·static·final·int·LOAD_THUMBNAIL·=·2; |
24 | ····public·CharSequence·contentDescription; | 22 | ····public·CharSequence·contentDescription; |
25 | ····public·Bitmap·full; | 23 | ····public·Bitmap·full; |
| 24 | ····public·Icon·mimeIcon; |
26 | ····public·Bitmap·thumbnail; | 25 | ····public·Bitmap·thumbnail; |
27 | ···· | 26 | ···· |
28 | ····public·PermissionActivity$Description(final·Context·context,·final·Uri·uri,·int·mimeTypeSupported)·{ | 27 | ····public·PermissionActivity$Description(final·Context·context,·final·Uri·uri,·int·mimeTypeSupported)·{ |
29 | ········final·Resources·resources·=·context.getResources(); | 28 | ········final·Resources·resources·=·context.getResources(); |
30 | ········final·ContentResolver·contentResolver·=·context.getContentResolver(); | 29 | ········final·ContentResolver·contentResolver·=·context.getContentResolver(); |
31 | ········while·(true)·{ | 30 | ········while·(true)·{ |
32 | ············if·((mimeTypeSupported·&·0x1)·!=·0x0)·{ | 31 | ············if·((mimeTypeSupported·&·0x1)·!=·0x0)·{ |
33 | ················final·String·s·=·"_display_name"; | 32 | ················final·String·s·=·"_display_name"; |
34 | ················final·PermissionActivity$Description·permissionActivity$Description; | 33 | ················try·{ |
35 | ················Label_0273:·{ | 34 | ····················final·Cursor·query·=·contentResolver.query(uri,·new·String[]·{·s·},·(Bundle)null,·(CancellationSignal)null); |
36 | ····················PermissionActivity$Resizer·permissionActivity$Resizer·=·null; | |
37 | ····················ImageDecoder$Source·imageDecoder$Source·=·null; | |
38 | ····················try·{ | 35 | ····················try·{ |
39 | ························final·Cursor·query·=·contentResolver.query(uri,·new·String[]·{·s·},·(Bundle)null,·(CancellationSignal)null); | 36 | ························if·(query.moveToFirst())·{ |
40 | ························try·{ | 37 | ····························this.contentDescription·=·query.getString(0); |
41 | ····························if·(query.moveToFirst())·{ | 38 | ························} |
42 | ································this.contentDescription·=·query.getString(0); | 39 | ························if·(query·!=·null)·{ |
43 | ····························} | 40 | ····························query.close(); |
44 | ····························if·(query·!=·null)·{ | 41 | ························} |
| 42 | ····················} |
| 43 | ····················finally·{ |
| 44 | ························if·(query·!=·null)·{ |
| 45 | ····························try·{ |
45 | ································query.close(); | 46 | ································query.close(); |
46 | ····························} | 47 | ····························} |
47 | ························} | 48 | ····························finally·{ |
48 | ························finally·{ | 49 | ································final·Throwable·t; |
49 | ····························if·(query·!=·null)·{ | 50 | ································((Throwable)context).addSuppressed(t); |
50 | ································try·{ | |
51 | ····································query.close(); | |
52 | ································} | |
53 | ································finally·{ | |
54 | ····································((Throwable)permissionActivity$Description).addSuppressed((Throwable)context); | |
55 | ································} | |
56 | ····························} | 51 | ····························} |
57 | ························} | 52 | ························} |
58 | ························Label_0204:·{ | 53 | ····················} |
59 | ····························if·((mimeTypeSupported·&·0x2)·==·0x0)·{ | 54 | ····················Label_0206:·{ |
60 | ································break·Label_0204; | 55 | ························if·((mimeTypeSupported·&·0x2)·==·0x0)·{ |
61 | ····························} | 56 | ····························break·Label_0206; |
| 57 | ························} |
| 58 | ························try·{ |
| 59 | ····························final·DisplayMetrics·displayMetrics·=·resources.getDisplayMetrics(); |
62 | ····························try·{ | 60 | ····························try·{ |
63 | ································final·DisplayMetrics·displayMetrics·=·resources.getDisplayMetrics(); | 61 | ································final·int·widthPixels·=·displayMetrics.widthPixels; |
64 | ································try·{ | 62 | ································try·{ |
65 | ····································final·int·widthPixels·=·displayMetrics.widthPixels; | 63 | ····································final·DisplayMetrics·displayMetrics2·=·resources.getDisplayMetrics(); |
66 | ····································try·{ | 64 | ····································try·{ |
67 | ········································final·DisplayMetrics·displayMetrics2·=·resources.getDisplayMetrics(); | 65 | ········································this.thumbnail·=·contentResolver.loadThumbnail(uri,·new·Size(widthPixels,·displayMetrics2.widthPixels),·(CancellationSignal)null); |
| 66 | ········································mimeTypeSupported·&=·0x4; |
| 67 | ········································if·(mimeTypeSupported·==·0)·{ |
| 68 | ············································return; |
| 69 | ········································} |
| 70 | ········································final·String·type·=·contentResolver.getType(uri); |
68 | ········································try·{ | 71 | ········································try·{ |
69 | ············································permissionActivity$Description.thumbnail·=·contentResolver.loadThumbnail(uri,·new·Size(widthPixels,·displayMetrics2.widthPixels),·(CancellationSignal)null); | 72 | ············································mimeTypeSupported·=·(ImageDecoder.isMimeTypeSupported(type)·?·1·:·0); |
70 | ············································mimeTypeSupported·&=·0x4; | |
71 | ············································if·(mimeTypeSupported·==·0)·{ | 73 | ············································if·(mimeTypeSupported·==·0)·{ |
72 | ················································return; | 74 | ················································goto·Label_0277; |
73 | ············································} | 75 | ············································} |
74 | ············································final·String·type·=·contentResolver.getType(uri); | 76 | ············································ImageDecoder.createSource(contentResolver,·uri); |
75 | ············································try·{ | 77 | ············································try·{ |
76 | ················································mimeTypeSupported·=·(ImageDecoder.isMimeTypeSupported(type)·?·1·:·0); | |
77 | ················································if·(mimeTypeSupported·==·0)·{ | |
78 | ····················································break·Label_0273; | |
79 | ················································} | |
80 | ················································final·ImageDecoder$Source·source·=·ImageDecoder.createSource(contentResolver,·uri); | |
81 | ················································try·{ | 78 | ················································try·{ |
| 79 | ····················································final·Resources·resources2·=·context.getResources(); |
82 | ····················································try·{ | 80 | ····················································try·{ |
83 | ························································final·Resources·resources2·=·context.getResources(); | 81 | ························································final·PermissionActivity$Resizer·permissionActivity$Resizer·=·new·PermissionActivity$Resizer(resources2.getDisplayMetrics()); |
84 | ························································try·{ | |
85 | ····························································permissionActivity$Resizer·=·new·PermissionActivity$Resizer(resources2.getDisplayMetrics()); | |
86 | ····························································imageDecoder$Source·=·source; | |
87 | ························································} | |
88 | ························································catch·(IOException·ex2)·{} | |
89 | ····················································} | 82 | ····················································} |
90 | ····················································catch·(IOException·ex3)·{} | 83 | ····················································catch·(IOException·ex)·{} |
91 | ················································} | 84 | ················································} |
92 | ················································catch·(IOException·ex4)·{} | 85 | ················································catch·(IOException·ex2)·{} |
93 | ············································} | 86 | ············································} |
94 | ············································catch·(IOException·ex5)·{} | 87 | ············································catch·(IOException·ex3)·{} |
95 | ········································} | 88 | ········································} |
96 | ········································catch·(IOException·ex6)·{} | 89 | ········································catch·(IOException·ex4)·{} |
97 | ····································} | 90 | ····································} |
98 | ····································catch·(IOException·ex7)·{} | 91 | ····································catch·(IOException·ex5)·{} |
99 | ································} | 92 | ································} |
100 | ································catch·(IOException·ex8)·{} | 93 | ································catch·(IOException·ex6)·{} |
101 | ····························} | 94 | ····························} |
102 | ····························catch·(IOException·ex9)·{} | 95 | ····························catch·(IOException·ex7)·{} |
103 | ························} | 96 | ························} |
| 97 | ························catch·(IOException·ex8)·{} |
104 | ····················} | 98 | ····················} |
105 | ····················catch·(IOException·ex10)·{} | |
106 | ····················permissionActivity$Description.full·=·ImageDecoder.decodeBitmap(imageDecoder$Source,·(ImageDecoder$OnHeaderDecodedListener)permissionActivity$Resizer); | |
107 | ····················return; | |
108 | ················} | 99 | ················} |
109 | ················permissionActivity$Description.full·=·permissionActivity$Description.thumbnail; | 100 | ················catch·(IOException·ex9)·{} |
110 | ················return; | 101 | ················return; |
111 | ············} | 102 | ············} |
112 | ············continue; | 103 | ············continue; |
113 | ········} | 104 | ········} |
114 | ········final·IOException·ex; | |
115 | ········Log.w("MediaProvider",·(Throwable)ex); | |
116 | ····} | 105 | ····} |
117 | ···· | 106 | ···· |
118 | ····public·void·bindFull(final·ImageView·imageView)·{ | 107 | ····public·void·bindFull(final·ImageView·imageView)·{ |
119 | ········Objects.requireNonNull(this.full); | 108 | ········Objects.requireNonNull(this.full); |
120 | ········imageView.setImageBitmap(this.full); | 109 | ········imageView.setImageBitmap(this.full); |
121 | ········imageView.setContentDescription(this.contentDescription); | 110 | ········imageView.setContentDescription(this.contentDescription); |
122 | ········imageView.setVisibility(0); | 111 | ········imageView.setVisibility(0); |
123 | ····} | 112 | ····} |
124 | ···· | 113 | ···· |
| 114 | ····public·void·bindMimeIcon(final·ImageView·imageView)·{ |
| 115 | ········Objects.requireNonNull(this.mimeIcon); |
| 116 | ········imageView.setImageIcon(this.mimeIcon); |
| 117 | ········imageView.setContentDescription(this.contentDescription); |
| 118 | ········imageView.setVisibility(0); |
| 119 | ········imageView.setClipToOutline(true); |
| 120 | ····} |
| 121 | ···· |
125 | ····public·void·bindThumbnail(final·ImageView·imageView)·{ | 122 | ····public·void·bindThumbnail(final·ImageView·imageView)·{ |
126 | ········Objects.requireNonNull(this.thumbnail); | 123 | ········Objects.requireNonNull(this.thumbnail); |
127 | ········imageView.setImageBitmap(this.thumbnail); | 124 | ········imageView.setImageBitmap(this.thumbnail); |
128 | ········imageView.setContentDescription(this.contentDescription); | 125 | ········imageView.setContentDescription(this.contentDescription); |
129 | ········imageView.setVisibility(0); | 126 | ········imageView.setVisibility(0); |
130 | ········imageView.setClipToOutline(true); | 127 | ········imageView.setClipToOutline(true); |
131 | ····} | 128 | ····} |
132 | ···· | 129 | ···· |
133 | ····public·boolean·isVisual()·{ | 130 | ····public·boolean·isVisual()·{ |
134 | ········return·this.thumbnail·!=·null·||·this.full·!=·null; | 131 | ········return·this.thumbnail·!=·null·||·this.full·!=·null·||·this.mimeIcon·!=·null; |
135 | ····} | 132 | ····} |
136 | } | 133 | } |