Skip to content

Commit

Permalink
add SoSource.getName()
Browse files Browse the repository at this point in the history
Summary: SoSource.getName() identifies the sosource for the purpose of telemetry.

Reviewed By: adicatana

Differential Revision: D48040739

fbshipit-source-id: b8eb68a447d4b3c7bc4cba9ee7680dac19965ca8
  • Loading branch information
michalgr authored and facebook-github-bot committed Aug 17, 2023
1 parent 7d791d0 commit e260b74
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 6 deletions.
5 changes: 5 additions & 0 deletions java/com/facebook/soloader/ApkSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public ApkSoSource(Context context, File apkPath, String name, int flags) {
mFlags = flags;
}

@Override
public String getName() {
return "ApkSoSource";
}

@Override
protected Unpacker makeUnpacker() throws IOException {
return new ApkUnpacker(this);
Expand Down
8 changes: 7 additions & 1 deletion java/com/facebook/soloader/ApplicationSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ public void addToLdLibraryPath(Collection<String> paths) {
soSource.addToLdLibraryPath(paths);
}

@Override
public String getName() {
return "ApplicationSoSource";
}

@Override
public String toString() {
return new StringBuilder()
.append("ApplicationSoSource[")
.append(getName())
.append("[")
.append(soSource.toString())
.append("]")
.toString();
Expand Down
7 changes: 6 additions & 1 deletion java/com/facebook/soloader/DirectApkSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,15 @@ private void buildLibDepsCacheImpl(
}
}

@Override
public String getName() {
return "DirectApkSoSource";
}

@Override
public String toString() {
return new StringBuilder()
.append(getClass().getName())
.append(getName())
.append("[root = ")
.append(mDirectApkLdPaths.toString())
.append(']')
Expand Down
7 changes: 6 additions & 1 deletion java/com/facebook/soloader/DirectorySoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ public void addToLdLibraryPath(Collection<String> paths) {
}
}

@Override
public String getName() {
return "DirectorySoSource";
}

@Override
public String toString() {
String path;
Expand All @@ -177,7 +182,7 @@ public String toString() {
path = soDirectory.getName();
}
return new StringBuilder()
.append(getClass().getName())
.append(getName())
.append("[root = ")
.append(path)
.append(" flags = ")
Expand Down
5 changes: 5 additions & 0 deletions java/com/facebook/soloader/ExoSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public ExoSoSource(Context context, String name) {
super(context, name);
}

@Override
public String getName() {
return "ExoSoSource";
}

@Override
protected MessageDigest getHashingAlgorithm() throws NoSuchAlgorithmException {
return MessageDigest.getInstance("SHA-1");
Expand Down
5 changes: 5 additions & 0 deletions java/com/facebook/soloader/ExtractFromZipSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public ExtractFromZipSoSource(
mZipSearchPattern = zipSearchPattern;
}

@Override
public String getName() {
return "ExtractFromZipSoSource";
}

@Override
protected Unpacker makeUnpacker() throws IOException {
return new ZipUnpacker(this);
Expand Down
5 changes: 5 additions & 0 deletions java/com/facebook/soloader/NoopSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public int loadLibrary(String soName, int loadFlags, StrictMode.ThreadPolicy thr
public File unpackLibrary(String soName) {
throw new UnsupportedOperationException("unpacking not supported in test mode");
}

@Override
public String getName() {
return "NoopSoSource";
}
}
5 changes: 4 additions & 1 deletion java/com/facebook/soloader/SoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ public String[] getSoSourceAbis() {
return SysUtil.getSupportedAbis();
}

/** @return the name of this SoSource for logging purposes */
public abstract String getName();

/**
* Return the class name of the actual instance. Useful for debugging.
*
* @return the instance class name
*/
@Override
public String toString() {
return getClass().getName();
return getName();
}
}
4 changes: 2 additions & 2 deletions java/com/facebook/soloader/UnpackingSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ private void extractDso(InputDso iDso, byte[] ioBuffer) throws IOException {
}

private void regenerate(InputDsoIterator dsoIterator) throws IOException {
LogUtil.v(TAG, "regenerating DSO store " + getClass().getName());
LogUtil.v(TAG, "regenerating DSO store " + getName());
byte[] ioBuffer = new byte[32 * 1024];
while (dsoIterator.hasNext()) {
try (InputDso iDso = dsoIterator.next()) {
extractDso(iDso, ioBuffer);
}
}
LogUtil.v(TAG, "Finished regenerating DSO store " + getClass().getName());
LogUtil.v(TAG, "Finished regenerating DSO store " + getName());
}

protected MessageDigest getHashingAlgorithm() throws NoSuchAlgorithmException {
Expand Down

0 comments on commit e260b74

Please sign in to comment.