Revert "[binder] Expose public Rust API at crate top level"

Revert "[libprofcollectd] Fix binder import path"

Revert submission 1797473-binder_rs-public_api

Reason for revert: Build breakage
Reverted Changes:
Ia37ec9d1e:[binder_common] Update binder import path
Ie6b4a40d7:Update Rust binder import paths
Ia9695e549:[keystore2] Fix binder import path
I811426fa7:[binder] Expose public Rust API at crate top level...
I773767a3a:[libprofcollectd] Fix binder import path

Change-Id: Iab6971b6d16922bd985795a383815ed5f48e1cbb
diff --git a/libs/binder/rust/tests/integration.rs b/libs/binder/rust/tests/integration.rs
index 50daf1c..80dc476 100644
--- a/libs/binder/rust/tests/integration.rs
+++ b/libs/binder/rust/tests/integration.rs
@@ -17,13 +17,11 @@
 //! Rust Binder crate integration tests
 
 use binder::{declare_binder_enum, declare_binder_interface};
-use binder::{BinderFeatures, Interface, StatusCode, ThreadState};
-// Import from internal API for testing only, do not use this module in
-// production.
-use binder::binder_impl::{
-    Binder, BorrowedParcel, IBinderInternal, TransactionCode, FIRST_CALL_TRANSACTION,
+use binder::parcel::BorrowedParcel;
+use binder::{
+    Binder, BinderFeatures, IBinderInternal, Interface, StatusCode, ThreadState, TransactionCode,
+    FIRST_CALL_TRANSACTION,
 };
-
 use std::convert::{TryFrom, TryInto};
 use std::ffi::CStr;
 use std::fs::File;
@@ -122,7 +120,7 @@
 }
 
 impl Interface for TestService {
-    fn dump(&self, _file: &File, args: &[&CStr]) -> Result<(), StatusCode> {
+    fn dump(&self, _file: &File, args: &[&CStr]) -> binder::Result<()> {
         let mut dump_args = self.dump_args.lock().unwrap();
         dump_args.extend(args.iter().map(|s| s.to_str().unwrap().to_owned()));
         Ok(())
@@ -130,22 +128,22 @@
 }
 
 impl ITest for TestService {
-    fn test(&self) -> Result<String, StatusCode> {
+    fn test(&self) -> binder::Result<String> {
         Ok(self.s.clone())
     }
 
-    fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> {
+    fn get_dump_args(&self) -> binder::Result<Vec<String>> {
         let args = self.dump_args.lock().unwrap().clone();
         Ok(args)
     }
 
-    fn get_selinux_context(&self) -> Result<String, StatusCode> {
+    fn get_selinux_context(&self) -> binder::Result<String> {
         let sid =
             ThreadState::with_calling_sid(|sid| sid.map(|s| s.to_string_lossy().into_owned()));
         sid.ok_or(StatusCode::UNEXPECTED_NULL)
     }
 
-    fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> {
+    fn get_is_handling_transaction(&self) -> binder::Result<bool> {
         Ok(binder::is_handling_transaction())
     }
 }
@@ -153,31 +151,31 @@
 /// Trivial testing binder interface
 pub trait ITest: Interface {
     /// Returns a test string
-    fn test(&self) -> Result<String, StatusCode>;
+    fn test(&self) -> binder::Result<String>;
 
     /// Return the arguments sent via dump
-    fn get_dump_args(&self) -> Result<Vec<String>, StatusCode>;
+    fn get_dump_args(&self) -> binder::Result<Vec<String>>;
 
     /// Returns the caller's SELinux context
-    fn get_selinux_context(&self) -> Result<String, StatusCode>;
+    fn get_selinux_context(&self) -> binder::Result<String>;
 
     /// Returns the value of calling `is_handling_transaction`.
-    fn get_is_handling_transaction(&self) -> Result<bool, StatusCode>;
+    fn get_is_handling_transaction(&self) -> binder::Result<bool>;
 }
 
 /// Async trivial testing binder interface
 pub trait IATest<P>: Interface {
     /// Returns a test string
-    fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>>;
+    fn test(&self) -> binder::BoxFuture<'static, binder::Result<String>>;
 
     /// Return the arguments sent via dump
-    fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>>;
+    fn get_dump_args(&self) -> binder::BoxFuture<'static, binder::Result<Vec<String>>>;
 
     /// Returns the caller's SELinux context
-    fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>>;
+    fn get_selinux_context(&self) -> binder::BoxFuture<'static, binder::Result<String>>;
 
     /// Returns the value of calling `is_handling_transaction`.
-    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>>;
+    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, binder::Result<bool>>;
 }
 
 declare_binder_interface! {
@@ -195,7 +193,7 @@
     code: TransactionCode,
     _data: &BorrowedParcel<'_>,
     reply: &mut BorrowedParcel<'_>,
-) -> Result<(), StatusCode> {
+) -> binder::Result<()> {
     match code.try_into()? {
         TestTransactionCode::Test => reply.write(&service.test()?),
         TestTransactionCode::GetDumpArgs => reply.write(&service.get_dump_args()?),
@@ -205,21 +203,21 @@
 }
 
 impl ITest for BpTest {
-    fn test(&self) -> Result<String, StatusCode> {
+    fn test(&self) -> binder::Result<String> {
         let reply =
             self.binder
                 .transact(TestTransactionCode::Test as TransactionCode, 0, |_| Ok(()))?;
         reply.read()
     }
 
-    fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> {
+    fn get_dump_args(&self) -> binder::Result<Vec<String>> {
         let reply =
             self.binder
                 .transact(TestTransactionCode::GetDumpArgs as TransactionCode, 0, |_| Ok(()))?;
         reply.read()
     }
 
-    fn get_selinux_context(&self) -> Result<String, StatusCode> {
+    fn get_selinux_context(&self) -> binder::Result<String> {
         let reply = self.binder.transact(
             TestTransactionCode::GetSelinuxContext as TransactionCode,
             0,
@@ -228,7 +226,7 @@
         reply.read()
     }
 
-    fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> {
+    fn get_is_handling_transaction(&self) -> binder::Result<bool> {
         let reply = self.binder.transact(
             TestTransactionCode::GetIsHandlingTransaction as TransactionCode,
             0,
@@ -239,7 +237,7 @@
 }
 
 impl<P: binder::BinderAsyncPool> IATest<P> for BpTest {
-    fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> {
+    fn test(&self) -> binder::BoxFuture<'static, binder::Result<String>> {
         let binder = self.binder.clone();
         P::spawn(
             move || binder.transact(TestTransactionCode::Test as TransactionCode, 0, |_| Ok(())),
@@ -247,7 +245,7 @@
         )
     }
 
-    fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>> {
+    fn get_dump_args(&self) -> binder::BoxFuture<'static, binder::Result<Vec<String>>> {
         let binder = self.binder.clone();
         P::spawn(
             move || binder.transact(TestTransactionCode::GetDumpArgs as TransactionCode, 0, |_| Ok(())),
@@ -255,7 +253,7 @@
         )
     }
 
-    fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> {
+    fn get_selinux_context(&self) -> binder::BoxFuture<'static, binder::Result<String>> {
         let binder = self.binder.clone();
         P::spawn(
             move || binder.transact(TestTransactionCode::GetSelinuxContext as TransactionCode, 0, |_| Ok(())),
@@ -263,7 +261,7 @@
         )
     }
 
-    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>> {
+    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, binder::Result<bool>> {
         let binder = self.binder.clone();
         P::spawn(
             move || binder.transact(TestTransactionCode::GetIsHandlingTransaction as TransactionCode, 0, |_| Ok(())),
@@ -273,40 +271,40 @@
 }
 
 impl ITest for Binder<BnTest> {
-    fn test(&self) -> Result<String, StatusCode> {
+    fn test(&self) -> binder::Result<String> {
         self.0.test()
     }
 
-    fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> {
+    fn get_dump_args(&self) -> binder::Result<Vec<String>> {
         self.0.get_dump_args()
     }
 
-    fn get_selinux_context(&self) -> Result<String, StatusCode> {
+    fn get_selinux_context(&self) -> binder::Result<String> {
         self.0.get_selinux_context()
     }
 
-    fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> {
+    fn get_is_handling_transaction(&self) -> binder::Result<bool> {
         self.0.get_is_handling_transaction()
     }
 }
 
 impl<P: binder::BinderAsyncPool> IATest<P> for Binder<BnTest> {
-    fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> {
+    fn test(&self) -> binder::BoxFuture<'static, binder::Result<String>> {
         let res = self.0.test();
         Box::pin(async move { res })
     }
 
-    fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>> {
+    fn get_dump_args(&self) -> binder::BoxFuture<'static, binder::Result<Vec<String>>> {
         let res = self.0.get_dump_args();
         Box::pin(async move { res })
     }
 
-    fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> {
+    fn get_selinux_context(&self) -> binder::BoxFuture<'static, binder::Result<String>> {
         let res = self.0.get_selinux_context();
         Box::pin(async move { res })
     }
 
-    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>> {
+    fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, binder::Result<bool>> {
         let res = self.0.get_is_handling_transaction();
         Box::pin(async move { res })
     }
@@ -327,7 +325,7 @@
     _code: TransactionCode,
     _data: &BorrowedParcel<'_>,
     _reply: &mut BorrowedParcel<'_>,
-) -> Result<(), StatusCode> {
+) -> binder::Result<()> {
     Ok(())
 }
 
@@ -365,12 +363,9 @@
     use std::time::Duration;
 
     use binder::{
-        BinderFeatures, DeathRecipient, FromIBinder, IBinder, Interface, SpIBinder, StatusCode,
-        Strong,
+        Binder, BinderFeatures, DeathRecipient, FromIBinder, IBinder, IBinderInternal, Interface,
+        SpIBinder, StatusCode, Strong,
     };
-    // Import from impl API for testing only, should not be necessary as long as
-    // you are using AIDL.
-    use binder::binder_impl::{Binder, IBinderInternal, TransactionCode};
 
     use binder_tokio::Tokio;
 
@@ -748,7 +743,8 @@
             let _process = ScopedServiceProcess::new(service_name);
 
             let test_client: Strong<dyn ITest> =
-                binder::get_interface(service_name).expect("Did not get test binder service");
+                binder::get_interface(service_name)
+                .expect("Did not get test binder service");
             let mut remote = test_client.as_binder();
             assert!(remote.is_binder_alive());
             remote.ping_binder().expect("Could not ping remote service");
@@ -929,7 +925,7 @@
         let service2 = service2.as_binder();
 
         let parcel = service1.prepare_transact().unwrap();
-        let res = service2.submit_transact(super::TestTransactionCode::Test as TransactionCode, parcel, 0);
+        let res = service2.submit_transact(super::TestTransactionCode::Test as binder::TransactionCode, parcel, 0);
 
         match res {
             Ok(_) => panic!("submit_transact should fail"),
diff --git a/libs/binder/rust/tests/serialization.rs b/libs/binder/rust/tests/serialization.rs
index b62da7b..1fc761e 100644
--- a/libs/binder/rust/tests/serialization.rs
+++ b/libs/binder/rust/tests/serialization.rs
@@ -18,12 +18,11 @@
 //! access.
 
 use binder::declare_binder_interface;
+use binder::parcel::ParcelFileDescriptor;
 use binder::{
-    BinderFeatures, ExceptionCode, Interface, ParcelFileDescriptor, SpIBinder, Status, StatusCode,
+    Binder, BinderFeatures, BorrowedParcel, ExceptionCode, Interface, Result, SpIBinder, Status,
+    StatusCode, TransactionCode,
 };
-// Import from impl API for testing only, should not be necessary as long as you
-// are using AIDL.
-use binder::binder_impl::{BorrowedParcel, Binder, TransactionCode};
 
 use std::ffi::{c_void, CStr, CString};
 use std::sync::Once;
@@ -114,7 +113,7 @@
     code: TransactionCode,
     parcel: &BorrowedParcel<'_>,
     reply: &mut BorrowedParcel<'_>,
-) -> Result<(), StatusCode> {
+) -> Result<()> {
     match code {
         bindings::Transaction_TEST_BOOL => {
             assert_eq!(parcel.read::<bool>()?, true);