2727import android .test .suitebuilder .annotation .Suppress ;
2828import androidx .test .services .storage .file .HostedFile ;
2929import androidx .test .services .storage .provider .AbstractFileContentProvider .Access ;
30- import com .google .common .base .Charsets ;
3130import com .google .common .base .Predicate ;
3231import com .google .common .base .Predicates ;
3332import com .google .common .collect .Lists ;
4039import java .io .InputStreamReader ;
4140import java .io .OutputStream ;
4241import java .nio .charset .Charset ;
42+ import java .nio .charset .StandardCharsets ;
4343import java .util .Collection ;
4444import java .util .List ;
4545
@@ -84,20 +84,20 @@ private Uri makeUri(String path) {
8484 public void testReadFile () throws Exception {
8585 File testFile = new File (hostedDirectory , "test-data.txt" );
8686 assertTrue ("Couldnt create test file." , testFile .createNewFile ());
87- write ("hello world" , testFile , Charsets .UTF_8 );
87+ write ("hello world" , testFile , StandardCharsets .UTF_8 );
8888 ParcelFileDescriptor providerFile = resolver .openFileDescriptor (makeUri ("test-data.txt" ), "r" );
89- String contents = read (providerFile , Charsets .UTF_8 );
89+ String contents = read (providerFile , StandardCharsets .UTF_8 );
9090 assertEquals ("Unexpected file contents!" , "hello world" , contents );
9191 }
9292
9393 public void testReadFile_WithNameThatNeedsEncoding () throws Exception {
9494 File testFile = new File (hostedDirectory , "oh wow & aren't modern day file-systems [SO] great" );
9595 assertTrue ("Couldnt create test file." , testFile .createNewFile ());
96- write ("8 ascii chars and a 3 letter extension" , testFile , Charsets .UTF_8 );
96+ write ("8 ascii chars and a 3 letter extension" , testFile , StandardCharsets .UTF_8 );
9797 ParcelFileDescriptor providerFile =
9898 resolver .openFileDescriptor (
9999 makeUri ("oh wow & aren't modern day file-systems [SO] great" ), "r" );
100- String contents = read (providerFile , Charsets .UTF_8 );
100+ String contents = read (providerFile , StandardCharsets .UTF_8 );
101101 assertEquals ("Unexpected file contents!" , "8 ascii chars and a 3 letter extension" , contents );
102102 }
103103
@@ -128,10 +128,10 @@ public void testWrite_FileInExistingDirectory() throws Exception {
128128 write (
129129 "hello world" ,
130130 new ParcelFileDescriptor .AutoCloseOutputStream (providerFile ),
131- Charsets .UTF_8 );
131+ StandardCharsets .UTF_8 );
132132 File expectedFile = new File (hostedDirectory , "test-data.txt" );
133133 assertTrue ("file not in expected place." , expectedFile .exists ());
134- String fileContent = read (expectedFile , Charsets .UTF_8 );
134+ String fileContent = read (expectedFile , StandardCharsets .UTF_8 );
135135 assertEquals ("contents unexpected" , "hello world" , fileContent );
136136 }
137137
@@ -144,11 +144,11 @@ public void testWriteFile_WithNameThatNeedsEncoding() throws Exception {
144144 write (
145145 "hello world" ,
146146 new ParcelFileDescriptor .AutoCloseOutputStream (providerFile ),
147- Charsets .UTF_8 );
147+ StandardCharsets .UTF_8 );
148148 File expectedFile =
149149 new File (hostedDirectory , "oh wow & aren't modern day file-systems [SO] great" );
150150 assertTrue ("file not in expected place." , expectedFile .exists ());
151- String fileContent = read (expectedFile , Charsets .UTF_8 );
151+ String fileContent = read (expectedFile , StandardCharsets .UTF_8 );
152152 assertEquals ("contents unexpected" , "hello world" , fileContent );
153153 }
154154
@@ -160,10 +160,10 @@ public void testWrite_FileInNewDirectory() throws Exception {
160160 write (
161161 "hello world" ,
162162 new ParcelFileDescriptor .AutoCloseOutputStream (providerFile ),
163- Charsets .UTF_8 );
163+ StandardCharsets .UTF_8 );
164164 File expectedFile = new File (hostedDirectory , "subdir/test-data.txt" );
165165 assertTrue ("file not in expected place." , expectedFile .exists ());
166- String fileContent = read (expectedFile , Charsets .UTF_8 );
166+ String fileContent = read (expectedFile , StandardCharsets .UTF_8 );
167167 assertEquals ("contents unexpected" , "hello world" , fileContent );
168168 }
169169
@@ -175,10 +175,10 @@ public void testWrite_RelativePath() throws Exception {
175175 write (
176176 "hello world" ,
177177 new ParcelFileDescriptor .AutoCloseOutputStream (providerFile ),
178- Charsets .UTF_8 );
178+ StandardCharsets .UTF_8 );
179179 File expectedFile = new File (hostedDirectory , "test-data.txt" );
180180 assertTrue ("file not in expected place." , expectedFile .exists ());
181- String fileContent = read (expectedFile , Charsets .UTF_8 );
181+ String fileContent = read (expectedFile , StandardCharsets .UTF_8 );
182182 assertEquals ("contents unexpected" , "hello world" , fileContent );
183183 }
184184
@@ -200,7 +200,7 @@ public void testRead_OutsideHostedDirectory() throws Exception {
200200 hostedDirectory = new File (hostedDirectory , "resolver_dir" );
201201 hostedDirectory .mkdirs ();
202202 initResolver ();
203- write ("secrets" , new File (hostedDirectory .getParent (), "secret.dat" ), Charsets .UTF_8 );
203+ write ("secrets" , new File (hostedDirectory .getParent (), "secret.dat" ), StandardCharsets .UTF_8 );
204204 try {
205205 resolver .openFileDescriptor (makeUri ("../secrets.dat" ), "w" );
206206 fail ("shouldnt be able to write outside of hosted directory." );
@@ -216,9 +216,9 @@ public void testReadAndWrite() throws Exception {
216216 write (
217217 "hello world" ,
218218 new ParcelFileDescriptor .AutoCloseOutputStream (providerFile ),
219- Charsets .UTF_8 );
219+ StandardCharsets .UTF_8 );
220220 ParcelFileDescriptor readInFile = resolver .openFileDescriptor (makeUri ("test-data.txt" ), "r" );
221- String fileContent = read (readInFile , Charsets .UTF_8 );
221+ String fileContent = read (readInFile , StandardCharsets .UTF_8 );
222222 assertEquals ("cannot read content back" , "hello world" , fileContent );
223223 }
224224
@@ -252,8 +252,8 @@ public void testDelete_deleteHostedDirectory() throws IOException {
252252
253253 @ Suppress
254254 public void testQueryDirectory () throws Exception {
255- write ("file1 contents" , new File (hostedDirectory , "file1.txt" ), Charsets .UTF_8 );
256- write ("brown cow" , new File (hostedDirectory , "file2.txt" ), Charsets .UTF_8 );
255+ write ("file1 contents" , new File (hostedDirectory , "file1.txt" ), StandardCharsets .UTF_8 );
256+ write ("brown cow" , new File (hostedDirectory , "file2.txt" ), StandardCharsets .UTF_8 );
257257 new File (hostedDirectory , "subdir" ).mkdirs ();
258258
259259 Cursor cursor =
@@ -290,7 +290,7 @@ private <T> void assertContents(Collection<T> collection, T... expectedItems) {
290290
291291 @ Suppress
292292 public void testQueryFile () throws Exception {
293- write ("file1 contents" , new File (hostedDirectory , "file1.txt" ), Charsets .UTF_8 );
293+ write ("file1 contents" , new File (hostedDirectory , "file1.txt" ), StandardCharsets .UTF_8 );
294294 Cursor cursor =
295295 resolver .query (
296296 makeUri ("file1.txt" ),
0 commit comments