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

Commit f18719bb authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Apply fixes for EfficientStrings.

Refactoring to avoid paying the cost of extra StringBuilder that are
quickly disposed.

Bug: 170978902
Test: none
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Icd914a63cdadf8123c1e5a5073f85245f0791f0b
parent 1c08f482
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -533,21 +533,21 @@ public class ContentProviderOperation implements Parcelable {
    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ContentProviderOperation(");
        sb.append("type=" + typeToString(mType) + " ");
        sb.append("type=").append(typeToString(mType)).append(' ');
        if (mUri != null) {
            sb.append("uri=" + mUri + " ");
            sb.append("uri=").append(mUri).append(' ');
        }
        if (mValues != null) {
            sb.append("values=" + mValues + " ");
            sb.append("values=").append(mValues).append(' ');
        }
        if (mSelection != null) {
            sb.append("selection=" + mSelection + " ");
            sb.append("selection=").append(mSelection).append(' ');
        }
        if (mSelectionArgs != null) {
            sb.append("selectionArgs=" + mSelectionArgs + " ");
            sb.append("selectionArgs=").append(mSelectionArgs).append(' ');
        }
        if (mExpectedCount != null) {
            sb.append("expectedCount=" + mExpectedCount + " ");
            sb.append("expectedCount=").append(mExpectedCount).append(' ');
        }
        if (mYieldAllowed) {
            sb.append("yieldAllowed ");
+4 −4
Original line number Diff line number Diff line
@@ -143,16 +143,16 @@ public class ContentProviderResult implements Parcelable {
    public String toString() {
        final StringBuilder sb = new StringBuilder("ContentProviderResult(");
        if (uri != null) {
            sb.append("uri=" + uri + " ");
            sb.append("uri=").append(uri).append(' ');
        }
        if (count != null) {
            sb.append("count=" + count + " ");
            sb.append("count=").append(count).append(' ');
        }
        if (extras != null) {
            sb.append("extras=" + extras + " ");
            sb.append("extras=").append(extras).append(' ');
        }
        if (exception != null) {
            sb.append("exception=" + exception + " ");
            sb.append("exception=").append(exception).append(' ');
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(")");
+29 −26
Original line number Diff line number Diff line
@@ -453,82 +453,85 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
    /** @hide */
    @UnsupportedAppUsage
    public static @NonNull String protectionToString(int level) {
        String protLevel = "????";
        final StringBuilder protLevel = new StringBuilder();
        switch (level & PROTECTION_MASK_BASE) {
            case PermissionInfo.PROTECTION_DANGEROUS:
                protLevel = "dangerous";
                protLevel.append("dangerous");
                break;
            case PermissionInfo.PROTECTION_NORMAL:
                protLevel = "normal";
                protLevel.append("normal");
                break;
            case PermissionInfo.PROTECTION_SIGNATURE:
                protLevel = "signature";
                protLevel.append("signature");
                break;
            case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
                protLevel = "signatureOrSystem";
                protLevel.append("signatureOrSystem");
                break;
            default:
                protLevel.append("????");
                break;
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0) {
            protLevel += "|privileged";
            protLevel.append("|privileged");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
            protLevel += "|development";
            protLevel.append("|development");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_APPOP) != 0) {
            protLevel += "|appop";
            protLevel.append("|appop");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_PRE23) != 0) {
            protLevel += "|pre23";
            protLevel.append("|pre23");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_INSTALLER) != 0) {
            protLevel += "|installer";
            protLevel.append("|installer");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_VERIFIER) != 0) {
            protLevel += "|verifier";
            protLevel.append("|verifier");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_PREINSTALLED) != 0) {
            protLevel += "|preinstalled";
            protLevel.append("|preinstalled");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_SETUP) != 0) {
            protLevel += "|setup";
            protLevel.append("|setup");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_INSTANT) != 0) {
            protLevel += "|instant";
            protLevel.append("|instant");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY) != 0) {
            protLevel += "|runtime";
            protLevel.append("|runtime");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_OEM) != 0) {
            protLevel += "|oem";
            protLevel.append("|oem");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_VENDOR_PRIVILEGED) != 0) {
            protLevel += "|vendorPrivileged";
            protLevel.append("|vendorPrivileged");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER) != 0) {
            protLevel += "|textClassifier";
            protLevel.append("|textClassifier");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_WELLBEING) != 0) {
            protLevel += "|wellbeing";
            protLevel.append("|wellbeing");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_DOCUMENTER) != 0) {
            protLevel += "|documenter";
            protLevel.append("|documenter");
        }
        if ((level & PROTECTION_FLAG_CONFIGURATOR) != 0) {
            protLevel += "|configurator";
            protLevel.append("|configurator");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_INCIDENT_REPORT_APPROVER) != 0) {
            protLevel += "|incidentReportApprover";
            protLevel.append("|incidentReportApprover");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_APP_PREDICTOR) != 0) {
            protLevel += "|appPredictor";
            protLevel.append("|appPredictor");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_COMPANION) != 0) {
            protLevel += "|companion";
            protLevel.append("|companion");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_RETAIL_DEMO) != 0) {
            protLevel += "|retailDemo";
            protLevel.append("|retailDemo");
        }
        return protLevel;
        return protLevel.toString();
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -792,10 +792,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
            if (pid == myPid) {
                buff.append("this proc=");
            } else {
                buff.append("pid " + pid + "=");
                buff.append("pid ").append(pid).append('=');
            }
            int num = pidCounts.get(pid);
            buff.append(num + ")");
            buff.append(num).append(')');
            total += num;
        }
        // limit the returned string size to 1000
+3 −3
Original line number Diff line number Diff line
@@ -672,7 +672,7 @@ public class DatabaseUtils {
     * @param sb the StringBuilder to print to
     */
    public static void dumpCursor(Cursor cursor, StringBuilder sb) {
        sb.append(">>>>> Dumping cursor " + cursor + "\n");
        sb.append(">>>>> Dumping cursor ").append(cursor).append('\n');
        if (cursor != null) {
            int startPos = cursor.getPosition();

@@ -739,7 +739,7 @@ public class DatabaseUtils {
     */
    public static void dumpCurrentRow(Cursor cursor, StringBuilder sb) {
        String[] cols = cursor.getColumnNames();
        sb.append("" + cursor.getPosition() + " {\n");
        sb.append(cursor.getPosition()).append(" {\n");
        int length = cols.length;
        for (int i = 0; i < length; i++) {
            String value;
@@ -750,7 +750,7 @@ public class DatabaseUtils {
                // representable by a string, e.g. it is a BLOB.
                value = "<unprintable>";
            }
            sb.append("   " + cols[i] + '=' + value + "\n");
            sb.append("   ").append(cols[i]).append('=').append(value).append('\n');
        }
        sb.append("}\n");
    }
Loading