Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f217104 authored by Yao Chen's avatar Yao Chen
Browse files

make statsd run in its own uid

+ Assign permission android.permission.STATSCOMPANION to statsd
+ Fixes in StatsCompanionService to allow statsd to get uid mapping

Test: manual
Change-Id: I3e6ca79eefed7f93a4588578c156321c4c278fd3
parent 422a6798
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -14,5 +14,5 @@


service statsd /system/bin/statsd
service statsd /system/bin/statsd
    class main
    class main
    user system
    user statsd
    group system
    group statsd log
+2 −0
Original line number Original line Diff line number Diff line
@@ -168,6 +168,8 @@
    <assign-permission name="android.permission.ACCESS_LOWPAN_STATE" uid="lowpan" />
    <assign-permission name="android.permission.ACCESS_LOWPAN_STATE" uid="lowpan" />
    <assign-permission name="android.permission.MANAGE_LOWPAN_INTERFACES" uid="lowpan" />
    <assign-permission name="android.permission.MANAGE_LOWPAN_INTERFACES" uid="lowpan" />


    <assign-permission name="android.permission.STATSCOMPANION" uid="statsd" />

    <!-- This is a list of all the libraries available for application
    <!-- This is a list of all the libraries available for application
         code to link against. -->
         code to link against. -->


+7 −3
Original line number Original line Diff line number Diff line
@@ -743,9 +743,13 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                filter.addAction(Intent.ACTION_SHUTDOWN);
                filter.addAction(Intent.ACTION_SHUTDOWN);
                mContext.registerReceiverAsUser(
                mContext.registerReceiverAsUser(
                        mShutdownEventReceiver, UserHandle.ALL, filter, null, null);
                        mShutdownEventReceiver, UserHandle.ALL, filter, null, null);

                final long token = Binder.clearCallingIdentity();
                try {
                    // Pull the latest state of UID->app name, version mapping when statsd starts.
                    // Pull the latest state of UID->app name, version mapping when statsd starts.
                    informAllUidsLocked(mContext);
                    informAllUidsLocked(mContext);
                } finally {
                    restoreCallingIdentity(token);
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to inform statsd that statscompanion is ready", e);
                Slog.e(TAG, "Failed to inform statsd that statscompanion is ready", e);
                forgetEverything();
                forgetEverything();