Use public APIs not internal APIs
All Libcore.os calls used in StorageLifetimeFragment
can be replaced with public API usage.
Bug: 113148576
Test: build
Change-Id: I37b7849c983ee3cfb9d1f7142e07de54c7a8ce2a
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/storagelifetime/StorageLifetimeFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/storagelifetime/StorageLifetimeFragment.java
index fc4052e..c420af6 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/storagelifetime/StorageLifetimeFragment.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/storagelifetime/StorageLifetimeFragment.java
@@ -29,6 +29,7 @@
import android.os.StatFs;
import android.support.v4.app.Fragment;
import android.system.ErrnoException;
+import android.system.Os;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -40,8 +41,6 @@
import com.google.android.car.kitchensink.KitchenSinkActivity;
import com.google.android.car.kitchensink.R;
-import libcore.io.Libcore;
-
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -147,16 +146,16 @@
private void fsyncFile() {
try {
final Path filePath = getFilePath();
- FileDescriptor fd = Libcore.os.open(filePath.toString(), O_APPEND | O_RDWR, 0);
+ FileDescriptor fd = Os.open(filePath.toString(), O_APPEND | O_RDWR, 0);
if (!fd.valid()) {
Log.w(TAG, "file descriptor is invalid");
return;
}
// fill byteBuffer with arbitrary data in order to make an fsync() meaningful
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[] {101, 110, 114, 105, 99, 111});
- Libcore.os.write(fd, byteBuffer);
- Libcore.os.fsync(fd);
- Libcore.os.close(fd);
+ Os.write(fd, byteBuffer);
+ Os.fsync(fd);
+ Os.close(fd);
} catch (ErrnoException | IOException e) {
Log.w(TAG, "could not fsync data", e);
}