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

Commit 52cc4a43 authored by Meng Wang's avatar Meng Wang Committed by Gerrit Code Review
Browse files

Merge changes Iec082f0c,I86a479af

* changes:
  telephony/common/* should use android.util.Log
  Use com.android.telephony.Rlog for mainline module.
parents 6408fa47 eef76742
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.Log;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Slog;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -77,7 +77,7 @@ public final class CarrierAppUtils {
            IPackageManager packageManager, TelephonyManager telephonyManager,
            ContentResolver contentResolver, int userId) {
        if (DEBUG) {
            Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
            Log.d(TAG, "disableCarrierAppsUntilPrivileged");
        }
        SystemConfig config = SystemConfig.getInstance();
        ArraySet<String> systemCarrierAppsDisabledUntilUsed =
@@ -103,7 +103,7 @@ public final class CarrierAppUtils {
    public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage,
            IPackageManager packageManager, ContentResolver contentResolver, int userId) {
        if (DEBUG) {
            Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
            Log.d(TAG, "disableCarrierAppsUntilPrivileged");
        }
        SystemConfig config = SystemConfig.getInstance();
        ArraySet<String> systemCarrierAppsDisabledUntilUsed =
@@ -174,7 +174,7 @@ public final class CarrierAppUtils {
                            || ai.enabledSetting
                            == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
                            || (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0)) {
                        Slog.i(TAG, "Update state(" + packageName + "): ENABLED for user "
                        Log.i(TAG, "Update state(" + packageName + "): ENABLED for user "
                                + userId);
                        packageManager.setSystemAppInstallState(
                                packageName,
@@ -197,7 +197,7 @@ public final class CarrierAppUtils {
                                    == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
                                    || (associatedApp.flags
                                    & ApplicationInfo.FLAG_INSTALLED) == 0) {
                                Slog.i(TAG, "Update associated state(" + associatedApp.packageName
                                Log.i(TAG, "Update associated state(" + associatedApp.packageName
                                        + "): ENABLED for user " + userId);
                                packageManager.setSystemAppInstallState(
                                        associatedApp.packageName,
@@ -222,7 +222,7 @@ public final class CarrierAppUtils {
                            && ai.enabledSetting
                            == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                            && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
                        Slog.i(TAG, "Update state(" + packageName
                        Log.i(TAG, "Update state(" + packageName
                                + "): DISABLED_UNTIL_USED for user " + userId);
                        packageManager.setSystemAppInstallState(
                                packageName,
@@ -240,7 +240,7 @@ public final class CarrierAppUtils {
                                        == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                                        && (associatedApp.flags
                                        & ApplicationInfo.FLAG_INSTALLED) != 0) {
                                    Slog.i(TAG,
                                    Log.i(TAG,
                                            "Update associated state(" + associatedApp.packageName
                                                    + "): DISABLED_UNTIL_USED for user " + userId);
                                    packageManager.setSystemAppInstallState(
@@ -268,7 +268,7 @@ public final class CarrierAppUtils {
                packageManager.grantDefaultPermissionsToEnabledCarrierApps(packageNames, userId);
            }
        } catch (RemoteException e) {
            Slog.w(TAG, "Could not reach PackageManager", e);
            Log.w(TAG, "Could not reach PackageManager", e);
        }
    }

@@ -390,7 +390,7 @@ public final class CarrierAppUtils {
                return ai;
            }
        } catch (RemoteException e) {
            Slog.w(TAG, "Could not reach PackageManager", e);
            Log.w(TAG, "Could not reach PackageManager", e);
        }
        return null;
    }
+11 −11
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.internal.telephony;
import android.annotation.UnsupportedAppUsage;
import android.content.res.Resources;
import android.os.Build;
import android.telephony.Rlog;
import android.util.Log;
import android.text.TextUtils;
import android.util.SparseIntArray;

@@ -496,11 +496,11 @@ public class GsmAlphabet {
        StringBuilder ret = new StringBuilder(lengthSeptets);

        if (languageTable < 0 || languageTable > sLanguageTables.length) {
            Rlog.w(TAG, "unknown language table " + languageTable + ", using default");
            Log.w(TAG, "unknown language table " + languageTable + ", using default");
            languageTable = 0;
        }
        if (shiftTable < 0 || shiftTable > sLanguageShiftTables.length) {
            Rlog.w(TAG, "unknown single shift table " + shiftTable + ", using default");
            Log.w(TAG, "unknown single shift table " + shiftTable + ", using default");
            shiftTable = 0;
        }

@@ -510,11 +510,11 @@ public class GsmAlphabet {
            String shiftTableToChar = sLanguageShiftTables[shiftTable];

            if (languageTableToChar.isEmpty()) {
                Rlog.w(TAG, "no language table for code " + languageTable + ", using default");
                Log.w(TAG, "no language table for code " + languageTable + ", using default");
                languageTableToChar = sLanguageTables[0];
            }
            if (shiftTableToChar.isEmpty()) {
                Rlog.w(TAG, "no single shift table for code " + shiftTable + ", using default");
                Log.w(TAG, "no single shift table for code " + shiftTable + ", using default");
                shiftTableToChar = sLanguageShiftTables[0];
            }

@@ -554,7 +554,7 @@ public class GsmAlphabet {
                }
            }
        } catch (RuntimeException ex) {
            Rlog.e(TAG, "Error GSM 7 bit packed: ", ex);
            Log.e(TAG, "Error GSM 7 bit packed: ", ex);
            return null;
        }

@@ -811,7 +811,7 @@ public class GsmAlphabet {
        for (int i = 0; i < sz; i++) {
            char c = s.charAt(i);
            if (c == GSM_EXTENDED_ESCAPE) {
                Rlog.w(TAG, "countGsmSeptets() string contains Escape character, skipping.");
                Log.w(TAG, "countGsmSeptets() string contains Escape character, skipping.");
                continue;
            }
            if (charToLanguageTable.get(c, -1) != -1) {
@@ -890,7 +890,7 @@ public class GsmAlphabet {
        for (int i = 0; i < sz && !lpcList.isEmpty(); i++) {
            char c = s.charAt(i);
            if (c == GSM_EXTENDED_ESCAPE) {
                Rlog.w(TAG, "countGsmSeptets() string contains Escape character, ignoring!");
                Log.w(TAG, "countGsmSeptets() string contains Escape character, ignoring!");
                continue;
            }
            // iterate through enabled locking shift tables
@@ -1494,7 +1494,7 @@ public class GsmAlphabet {
        int numTables = sLanguageTables.length;
        int numShiftTables = sLanguageShiftTables.length;
        if (numTables != numShiftTables) {
            Rlog.e(TAG, "Error: language tables array length " + numTables +
            Log.e(TAG, "Error: language tables array length " + numTables +
                    " != shift tables array length " + numShiftTables);
        }

@@ -1504,7 +1504,7 @@ public class GsmAlphabet {

            int tableLen = table.length();
            if (tableLen != 0 && tableLen != 128) {
                Rlog.e(TAG, "Error: language tables index " + i +
                Log.e(TAG, "Error: language tables index " + i +
                        " length " + tableLen + " (expected 128 or 0)");
            }

@@ -1522,7 +1522,7 @@ public class GsmAlphabet {

            int shiftTableLen = shiftTable.length();
            if (shiftTableLen != 0 && shiftTableLen != 128) {
                Rlog.e(TAG, "Error: language shift tables index " + i +
                Log.e(TAG, "Error: language shift tables index " + i +
                        " length " + shiftTableLen + " (expected 128 or 0)");
            }

+16 −16
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.internal.telephony;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.telephony.Rlog;
import android.util.Log;

import com.android.internal.telephony.HbpcdLookup.ArbitraryMccSidMatch;
import com.android.internal.telephony.HbpcdLookup.MccIdd;
@@ -54,16 +54,16 @@ public final class HbpcdUtils {
        if (c2 != null) {
            int c2Counter = c2.getCount();
            if (DBG) {
                Rlog.d(LOG_TAG, "Query unresolved arbitrary table, entries are " + c2Counter);
                Log.d(LOG_TAG, "Query unresolved arbitrary table, entries are " + c2Counter);
            }
            if (c2Counter == 1) {
                if (DBG) {
                    Rlog.d(LOG_TAG, "Query Unresolved arbitrary returned the cursor " + c2);
                    Log.d(LOG_TAG, "Query Unresolved arbitrary returned the cursor " + c2);
                }
                c2.moveToFirst();
                tmpMcc = c2.getInt(0);
                if (DBG) {
                    Rlog.d(LOG_TAG, "MCC found in arbitrary_mcc_sid_match: " + tmpMcc);
                    Log.d(LOG_TAG, "MCC found in arbitrary_mcc_sid_match: " + tmpMcc);
                }
                c2.close();
                return tmpMcc;
@@ -85,18 +85,18 @@ public final class HbpcdUtils {
            int c3Counter = c3.getCount();
            if (c3Counter > 0) {
                if (c3Counter > 1) {
                    Rlog.w(LOG_TAG, "something wrong, get more results for 1 conflict SID: " + c3);
                    Log.w(LOG_TAG, "something wrong, get more results for 1 conflict SID: " + c3);
                }
                if (DBG) Rlog.d(LOG_TAG, "Query conflict sid returned the cursor " + c3);
                if (DBG) Log.d(LOG_TAG, "Query conflict sid returned the cursor " + c3);
                c3.moveToFirst();
                tmpMcc = c3.getInt(0);
                if (DBG) {
                    Rlog.d(LOG_TAG, "MCC found in mcc_lookup_table. Return tmpMcc = " + tmpMcc);
                    Log.d(LOG_TAG, "MCC found in mcc_lookup_table. Return tmpMcc = " + tmpMcc);
                }
                if (!isNitzTimeZone) {
                    // time zone is not accurate, it may get wrong mcc, ignore it.
                    if (DBG) {
                        Rlog.d(LOG_TAG, "time zone is not accurate, mcc may be " + tmpMcc);
                        Log.d(LOG_TAG, "time zone is not accurate, mcc may be " + tmpMcc);
                    }
                    tmpMcc = 0;
                }
@@ -115,18 +115,18 @@ public final class HbpcdUtils {
                null, null);
        if (c5 != null) {
            if (c5.getCount() > 0) {
                if (DBG) Rlog.d(LOG_TAG, "Query Range returned the cursor " + c5);
                if (DBG) Log.d(LOG_TAG, "Query Range returned the cursor " + c5);
                c5.moveToFirst();
                tmpMcc = c5.getInt(0);
                if (DBG) Rlog.d(LOG_TAG, "SID found in mcc_sid_range. Return tmpMcc = " + tmpMcc);
                if (DBG) Log.d(LOG_TAG, "SID found in mcc_sid_range. Return tmpMcc = " + tmpMcc);
                c5.close();
                return tmpMcc;
            }
            c5.close();
        }
        if (DBG) Rlog.d(LOG_TAG, "SID NOT found in mcc_sid_range.");
        if (DBG) Log.d(LOG_TAG, "SID NOT found in mcc_sid_range.");

        if (DBG) Rlog.d(LOG_TAG, "Exit getMccByOtherFactors. Return tmpMcc =  " + tmpMcc);
        if (DBG) Log.d(LOG_TAG, "Exit getMccByOtherFactors. Return tmpMcc =  " + tmpMcc);
        // If unknown MCC still could not be resolved,
        return tmpMcc;
    }
@@ -135,7 +135,7 @@ public final class HbpcdUtils {
     *  Gets country information with given MCC.
    */
    public String getIddByMcc(int mcc) {
        if (DBG) Rlog.d(LOG_TAG, "Enter getHbpcdInfoByMCC.");
        if (DBG) Log.d(LOG_TAG, "Enter getHbpcdInfoByMCC.");
        String idd = "";

        Cursor c = null;
@@ -145,19 +145,19 @@ public final class HbpcdUtils {
                MccIdd.MCC + "=" + mcc, null, null);
        if (cur != null) {
            if (cur.getCount() > 0) {
                if (DBG) Rlog.d(LOG_TAG, "Query Idd returned the cursor " + cur);
                if (DBG) Log.d(LOG_TAG, "Query Idd returned the cursor " + cur);
                // TODO: for those country having more than 1 IDDs, need more information
                // to decide which IDD would be used. currently just use the first 1.
                cur.moveToFirst();
                idd = cur.getString(0);
                if (DBG) Rlog.d(LOG_TAG, "IDD = " + idd);
                if (DBG) Log.d(LOG_TAG, "IDD = " + idd);

            }
            cur.close();
        }
        if (c != null) c.close();

        if (DBG) Rlog.d(LOG_TAG, "Exit getHbpcdInfoByMCC.");
        if (DBG) Log.d(LOG_TAG, "Exit getHbpcdInfoByMCC.");
        return idd;
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import android.os.UserHandle;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.telephony.PackageChangeReceiver;
import android.telephony.Rlog;
import android.util.Log;
import android.telephony.TelephonyManager;
import android.util.Log;

@@ -569,7 +569,7 @@ public final class SmsApplication {
            int mode = appOps.unsafeCheckOp(opStr, applicationData.mUid,
                    applicationData.mPackageName);
            if (mode != AppOpsManager.MODE_ALLOWED) {
                Rlog.e(LOG_TAG, applicationData.mPackageName + " lost "
                Log.e(LOG_TAG, applicationData.mPackageName + " lost "
                        + opStr + ": "
                        + (updateIfNeeded ? " (fixing)" : " (no permission to fix)"));
                if (updateIfNeeded) {
@@ -647,7 +647,7 @@ public final class SmsApplication {
                    int uid = packageManager.getPackageInfo(oldPackageName, 0).applicationInfo.uid;
                    setExclusiveAppops(oldPackageName, appOps, uid, AppOpsManager.MODE_DEFAULT);
                } catch (NameNotFoundException e) {
                    Rlog.w(LOG_TAG, "Old SMS package not found: " + oldPackageName);
                    Log.w(LOG_TAG, "Old SMS package not found: " + oldPackageName);
                }
            }

@@ -754,7 +754,7 @@ public final class SmsApplication {
        // the package signature matches system signature.
        final int result = packageManager.checkSignatures(context.getPackageName(), packageName);
        if (result != PackageManager.SIGNATURE_MATCH) {
            Rlog.e(LOG_TAG, packageName + " does not have system signature");
            Log.e(LOG_TAG, packageName + " does not have system signature");
            return;
        }
        try {
@@ -762,13 +762,13 @@ public final class SmsApplication {
            int mode = appOps.unsafeCheckOp(AppOpsManager.OPSTR_WRITE_SMS, info.applicationInfo.uid,
                    packageName);
            if (mode != AppOpsManager.MODE_ALLOWED) {
                Rlog.w(LOG_TAG, packageName + " does not have OP_WRITE_SMS:  (fixing)");
                Log.w(LOG_TAG, packageName + " does not have OP_WRITE_SMS:  (fixing)");
                setExclusiveAppops(packageName, appOps, info.applicationInfo.uid,
                        AppOpsManager.MODE_ALLOWED);
            }
        } catch (NameNotFoundException e) {
            // No whitelisted system app on this device
            Rlog.e(LOG_TAG, "Package not found: " + packageName);
            Log.e(LOG_TAG, "Package not found: " + packageName);
        }

    }
+56 −13
Original line number Diff line number Diff line
@@ -24,13 +24,16 @@ import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;

import com.android.internal.telephony.HbpcdLookup.MccIdd;
import com.android.internal.telephony.HbpcdLookup.MccLookup;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

@@ -143,7 +146,7 @@ public class SmsNumberUtils {

        // First check whether the number is a NANP number.
        int nanpState = checkNANP(numberEntry, allIDDs);
        if (DBG) Rlog.d(TAG, "NANP type: " + getNumberPlanType(nanpState));
        if (DBG) Log.d(TAG, "NANP type: " + getNumberPlanType(nanpState));

        if ((nanpState == NP_NANP_LOCAL)
            || (nanpState == NP_NANP_AREA_LOCAL)
@@ -173,7 +176,7 @@ public class SmsNumberUtils {

        int internationalState = checkInternationalNumberPlan(context, numberEntry, allIDDs,
                NANP_IDD);
        if (DBG) Rlog.d(TAG, "International type: " + getNumberPlanType(internationalState));
        if (DBG) Log.d(TAG, "International type: " + getNumberPlanType(internationalState));
        String returnNumber = null;

        switch (internationalState) {
@@ -272,7 +275,7 @@ public class SmsNumberUtils {
                }
            }
        } catch (SQLException e) {
            Rlog.e(TAG, "Can't access HbpcdLookup database", e);
            Log.e(TAG, "Can't access HbpcdLookup database", e);
        } finally {
            if (cursor != null) {
                cursor.close();
@@ -281,7 +284,7 @@ public class SmsNumberUtils {

        IDDS_MAPS.put(mcc, allIDDs);

        if (DBG) Rlog.d(TAG, "MCC = " + mcc + ", all IDDs = " + allIDDs);
        if (DBG) Log.d(TAG, "MCC = " + mcc + ", all IDDs = " + allIDDs);
        return allIDDs;
    }

@@ -472,7 +475,7 @@ public class SmsNumberUtils {
                int tempCC = allCCs[i];
                for (int j = 0; j < MAX_COUNTRY_CODES_LENGTH; j ++) {
                    if (tempCC == ccArray[j]) {
                        if (DBG) Rlog.d(TAG, "Country code = " + tempCC);
                        if (DBG) Log.d(TAG, "Country code = " + tempCC);
                        return tempCC;
                    }
                }
@@ -509,7 +512,7 @@ public class SmsNumberUtils {
                }
            }
        } catch (SQLException e) {
            Rlog.e(TAG, "Can't access HbpcdLookup database", e);
            Log.e(TAG, "Can't access HbpcdLookup database", e);
        } finally {
            if (cursor != null) {
                cursor.close();
@@ -561,10 +564,10 @@ public class SmsNumberUtils {
     * Filter the destination number if using VZW sim card.
     */
    public static String filterDestAddr(Context context, int subId, String destAddr) {
        if (DBG) Rlog.d(TAG, "enter filterDestAddr. destAddr=\"" + Rlog.pii(TAG, destAddr) + "\"" );
        if (DBG) Log.d(TAG, "enter filterDestAddr. destAddr=\"" + pii(TAG, destAddr) + "\"" );

        if (destAddr == null || !PhoneNumberUtils.isGlobalPhoneNumber(destAddr)) {
            Rlog.w(TAG, "destAddr" + Rlog.pii(TAG, destAddr) +
            Log.w(TAG, "destAddr" + pii(TAG, destAddr) +
                    " is not a global phone number! Nothing changed.");
            return destAddr;
        }
@@ -585,9 +588,9 @@ public class SmsNumberUtils {
        }

        if (DBG) {
            Rlog.d(TAG, "destAddr is " + ((result != null)?"formatted.":"not formatted."));
            Rlog.d(TAG, "leave filterDestAddr, new destAddr=\"" + (result != null ? Rlog.pii(TAG,
                    result) : Rlog.pii(TAG, destAddr)) + "\"");
            Log.d(TAG, "destAddr is " + ((result != null)?"formatted.":"not formatted."));
            Log.d(TAG, "leave filterDestAddr, new destAddr=\"" + (result != null ? pii(TAG,
                    result) : pii(TAG, destAddr)) + "\"");
        }
        return result != null ? result : destAddr;
    }
@@ -608,7 +611,7 @@ public class SmsNumberUtils {
                networkType = CDMA_HOME_NETWORK;
            }
        } else {
            if (DBG) Rlog.w(TAG, "warning! unknown mPhoneType value=" + phoneType);
            if (DBG) Log.w(TAG, "warning! unknown mPhoneType value=" + phoneType);
        }

        return networkType;
@@ -650,4 +653,44 @@ public class SmsNumberUtils {
        // by default this value is false
        return false;
    }

    /**
     * Redact personally identifiable information for production users.
     * @param tag used to identify the source of a log message
     * @param pii the personally identifiable information we want to apply secure hash on.
     * @return If tag is loggable in verbose mode or pii is null, return the original input.
     * otherwise return a secure Hash of input pii
     */
    private static String pii(String tag, Object pii) {
        String val = String.valueOf(pii);
        if (pii == null || TextUtils.isEmpty(val) || Log.isLoggable(tag, Log.VERBOSE)) {
            return val;
        }
        return "[" + secureHash(val.getBytes()) + "]";
    }

    /**
     * Returns a secure hash (using the SHA1 algorithm) of the provided input.
     *
     * @return "****" if the build type is user, otherwise the hash
     * @param input the bytes for which the secure hash should be computed.
     */
    private static String secureHash(byte[] input) {
        // Refrain from logging user personal information in user build.
        if (android.os.Build.IS_USER) {
            return "****";
        }

        MessageDigest messageDigest;

        try {
            messageDigest = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            return "####";
        }

        byte[] result = messageDigest.digest(input);
        return Base64.encodeToString(
                result, Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP);
    }
}
Loading