Remove IStatsd reference from StatsLog.java

Also remove sendAppBreadcrumb binder api because it's no longer used.

Bug: 154264326
Test: atest com.google.android.statsd.gts.StatsdHostTestCases
Change-Id: Ic51a057bb01a89a24337521a49c54a52e2073cd1
diff --git a/apex/aidl/android/os/IStatsd.aidl b/apex/aidl/android/os/IStatsd.aidl
index 80308d2..0d3f420 100644
--- a/apex/aidl/android/os/IStatsd.aidl
+++ b/apex/aidl/android/os/IStatsd.aidl
@@ -182,12 +182,6 @@
     void unsetBroadcastSubscriber(long configId, long subscriberId, int callingUid);
 
     /**
-     * Apps can send an atom via this application breadcrumb with the specified label and state for
-     * this label. This allows building custom metrics and predicates.
-     */
-    void sendAppBreadcrumbAtom(int label, int state);
-
-    /**
      * Tell the stats daemon that all the pullers registered during boot have been sent.
      */
     oneway void allPullersFromBootRegistered();
diff --git a/apex/framework/java/android/util/StatsLog.java b/apex/framework/java/android/util/StatsLog.java
index 536b71a..4eeae57 100644
--- a/apex/framework/java/android/util/StatsLog.java
+++ b/apex/framework/java/android/util/StatsLog.java
@@ -25,8 +25,7 @@
 import android.annotation.SystemApi;
 import android.content.Context;
 import android.os.IStatsd;
-import android.os.RemoteException;
-import android.os.StatsFrameworkInitializer;
+import android.os.Process;
 import android.util.proto.ProtoOutputStream;
 
 import com.android.internal.util.StatsdStatsLog;
@@ -45,10 +44,6 @@
     private static final boolean DEBUG = false;
     private static final int EXPERIMENT_IDS_FIELD_ID = 1;
 
-    private static IStatsd sService;
-
-    private static Object sLogLock = new Object();
-
     private StatsLog() {
     }
 
@@ -59,26 +54,13 @@
      * @return True if the log request was sent to statsd.
      */
     public static boolean logStart(int label) {
-        synchronized (sLogLock) {
-            try {
-                IStatsd service = getIStatsdLocked();
-                if (service == null) {
-                    if (DEBUG) {
-                        Log.d(TAG, "Failed to find statsd when logging start");
-                    }
-                    return false;
-                }
-                service.sendAppBreadcrumbAtom(label,
-                        StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__START);
-                return true;
-            } catch (RemoteException e) {
-                sService = null;
-                if (DEBUG) {
-                    Log.d(TAG, "Failed to connect to statsd when logging start");
-                }
-                return false;
-            }
-        }
+        int callingUid = Process.myUid();
+        StatsdStatsLog.write(
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED,
+                callingUid,
+                label,
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__START);
+        return true;
     }
 
     /**
@@ -88,26 +70,13 @@
      * @return True if the log request was sent to statsd.
      */
     public static boolean logStop(int label) {
-        synchronized (sLogLock) {
-            try {
-                IStatsd service = getIStatsdLocked();
-                if (service == null) {
-                    if (DEBUG) {
-                        Log.d(TAG, "Failed to find statsd when logging stop");
-                    }
-                    return false;
-                }
-                service.sendAppBreadcrumbAtom(
-                        label, StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__STOP);
-                return true;
-            } catch (RemoteException e) {
-                sService = null;
-                if (DEBUG) {
-                    Log.d(TAG, "Failed to connect to statsd when logging stop");
-                }
-                return false;
-            }
-        }
+        int callingUid = Process.myUid();
+        StatsdStatsLog.write(
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED,
+                callingUid,
+                label,
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__STOP);
+        return true;
     }
 
     /**
@@ -117,26 +86,13 @@
      * @return True if the log request was sent to statsd.
      */
     public static boolean logEvent(int label) {
-        synchronized (sLogLock) {
-            try {
-                IStatsd service = getIStatsdLocked();
-                if (service == null) {
-                    if (DEBUG) {
-                        Log.d(TAG, "Failed to find statsd when logging event");
-                    }
-                    return false;
-                }
-                service.sendAppBreadcrumbAtom(
-                        label, StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
-                return true;
-            } catch (RemoteException e) {
-                sService = null;
-                if (DEBUG) {
-                    Log.d(TAG, "Failed to connect to statsd when logging event");
-                }
-                return false;
-            }
-        }
+        int callingUid = Process.myUid();
+        StatsdStatsLog.write(
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED,
+                callingUid,
+                label,
+                StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
+        return true;
     }
 
     /**
@@ -181,17 +137,6 @@
         return true;
     }
 
-    private static IStatsd getIStatsdLocked() throws RemoteException {
-        if (sService != null) {
-            return sService;
-        }
-        sService = IStatsd.Stub.asInterface(StatsFrameworkInitializer
-            .getStatsServiceManager()
-            .getStatsdServiceRegisterer()
-            .get());
-        return sService;
-    }
-
     /**
      * Write an event to stats log using the raw format.
      *