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

Commit 7d4a7fa3 authored by Ashutosh Joshi's avatar Ashutosh Joshi Committed by Android (Google) Code Review
Browse files

Merge "Add dumpsys capabilities for context hub service" into nyc-dev

parents a5ec16e3 6239cc6f
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -345,6 +345,24 @@ public class ContextHubInfo {
        mMemoryRegions = Arrays.copyOf(memoryRegions, memoryRegions.length);
    }

    @Override
    public String toString() {
      String retVal = "";
      retVal += "Id : " + mId;
      retVal += ", Name : " + mName;
      retVal += "\n\tVendor : " + mVendor;
      retVal += ", ToolChain : " + mToolchain;
      retVal += "\n\tPlatformVersion : " + mPlatformVersion;
      retVal += ", StaticSwVersion : " + mStaticSwVersion;
      retVal += "\n\tPeakMips : " + mPeakMips;
      retVal += ", StoppedPowerDraw : " + mStoppedPowerDrawMw + " mW";
      retVal += ", PeakPowerDraw : " + mPeakPowerDrawMw + " mW";
      retVal += "\n\tSupported sensors : " + Arrays.toString(mSupportedSensors);
      retVal += "\n\tMemory Regions : " + Arrays.toString(mMemoryRegions);

      return retVal;
    }

    private ContextHubInfo(Parcel in) {
        mId = in.readInt();
        mName = in.readString();
+46 −20
Original line number Diff line number Diff line
@@ -18,9 +18,12 @@ package android.hardware.location;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.util.Log;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

@@ -28,7 +31,6 @@ import java.util.HashMap;
 * @hide
 */
public class ContextHubService extends IContextHubService.Stub {

    public static final String CONTEXTHUB_SERVICE = "contexthub_service";

    private static final String TAG = "ContextHubService";
@@ -90,7 +92,7 @@ public class ContextHubService extends IContextHubService.Stub {
        int[] returnArray = new int[mContextHubInfo.length];

        for (int i = 0; i < returnArray.length; ++i) {
            returnArray[i] = i + 1; //valid handles from 1...n
            returnArray[i] = i;
            Log.d(TAG, String.format("Hub %s is mapped to %d",
                                     mContextHubInfo[i].getName(), returnArray[i]));
        }
@@ -101,7 +103,6 @@ public class ContextHubService extends IContextHubService.Stub {
    @Override
    public ContextHubInfo getContextHubInfo(int contextHubHandle) throws RemoteException {
        checkPermissions();
        contextHubHandle -= 1;
        if (!(contextHubHandle >= 0 && contextHubHandle < mContextHubInfo.length)) {
            return null; // null means fail
        }
@@ -112,13 +113,12 @@ public class ContextHubService extends IContextHubService.Stub {
    @Override
    public int loadNanoApp(int contextHubHandle, NanoApp app) throws RemoteException {
        checkPermissions();
        contextHubHandle -= 1;

        if (!(contextHubHandle >= 0 && contextHubHandle < mContextHubInfo.length)) {
            return -1; // negative handle are invalid, means failed
            Log.e(TAG, "Invalid contextHubhandle " + contextHubHandle);
            return -1;
        }

        // Call Native interface here
        int[] msgHeader = new int[MSG_HEADER_SIZE];
        msgHeader[MSG_FIELD_HUB_HANDLE] = contextHubHandle;
        msgHeader[MSG_FIELD_APP_INSTANCE] = OS_APP_INSTANCE;
@@ -203,6 +203,32 @@ public class ContextHubService extends IContextHubService.Stub {
        return nativeSendMessage(msgHeader, msg.getData());
    }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (mContext.checkCallingOrSelfPermission("android.permission.DUMP")
            != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump contexthub_service");
            return;
        }

        pw.println("Dumping ContextHub Service");

        pw.println("");
        // dump ContextHubInfo
        pw.println("=================== CONTEXT HUBS ====================");
        for (int i = 0; i < mContextHubInfo.length; i++) {
            pw.println("Handle " + i + " : " + mContextHubInfo[i].toString());
        }
        pw.println("");
        pw.println("=================== NANOAPPS ====================");
        // Dump nanoAppHash
        for (Integer nanoAppInstance: mNanoAppHash.keySet()) {
            pw.println(nanoAppInstance + " : " + mNanoAppHash.get(nanoAppInstance).toString());
        }

        // dump eventLog
    }

    private void checkPermissions() {
        mContext.enforceCallingPermission(HARDWARE_PERMISSION, ENFORCE_HW_PERMISSION_MESSAGE);
    }
+27 −0
Original line number Diff line number Diff line
@@ -78,6 +78,33 @@ public class MemoryRegion implements Parcelable{
        return mIsExecutable;
    }

    @Override
    public String toString() {
        String mask = "";

        if (isReadable()) {
            mask += "r";
        } else {
            mask += "-";
        }

        if (isWritable()) {
            mask += "w";
        } else {
            mask += "-";
        }

        if (isExecutable()) {
            mask += "x";
        } else {
            mask += "-";
        }

        String retVal = "[ " + mSizeBytesFree + "/ " + mSizeBytes + " ] : " + mask;

        return retVal;
    }

    @Override
    public int describeContents() {
        return 0;
+10 −0
Original line number Diff line number Diff line
@@ -284,4 +284,14 @@ public class NanoApp {
            return new NanoApp[size];
        }
    };

    @Override
    public String toString() {
        String retVal = "Id : " + mAppId;
        retVal += ", Version : " + mAppVersion;
        retVal += ", Name : " + mName;
        retVal += ", Publisher : " + mPublisher;

        return retVal;
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -320,4 +320,15 @@ public class NanoAppInstanceInfo {
            return new NanoAppInstanceInfo[size];
        }
    };

    @Override
    public String toString() {
        String retVal = "handle : " + mHandle;
        retVal += ", Id : 0x" + Long.toHexString(mAppId);
        retVal += ", Version : " + mAppVersion;
        retVal += ", Name : " + mName;
        retVal += ", Publisher : " + mPublisher;

        return retVal;
    }
}
Loading