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

Commit 2cffc7da authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Warn user when build fingerprints differ.

We're now shipping devices with several partitions which may end up
mismatched, causing subtle runtime issues.  To help manufacturers and
users catch this case, show wanring when we detected mismatched
fingerprints.

Bug: 18357469
Change-Id: I897d7ee8cbf3b8042d3d7d282afab277d242ed3f
parent 8977c1da
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -20,8 +20,11 @@ import android.text.TextUtils;
import android.util.Slog;
import android.util.Slog;


import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.TelephonyProperties;

import dalvik.system.VMRuntime;
import dalvik.system.VMRuntime;


import java.util.Objects;

/**
/**
 * Information about the current build, extracted from system properties.
 * Information about the current build, extracted from system properties.
 */
 */
@@ -640,6 +643,32 @@ public class Build {
        }
        }
    }
    }


    /**
     * Check that device fingerprint is defined and that it matches across
     * various partitions.
     *
     * @hide
     */
    public static boolean isFingerprintConsistent() {
        final String system = SystemProperties.get("ro.build.fingerprint");
        final String vendor = SystemProperties.get("ro.vendor.build.fingerprint");

        if (TextUtils.isEmpty(system)) {
            Slog.e(TAG, "Required ro.build.fingerprint is empty!");
            return false;
        }

        if (!TextUtils.isEmpty(vendor)) {
            if (!Objects.equals(system, vendor)) {
                Slog.e(TAG, "Mismatched fingerprints; system reported " + system
                        + " but vendor reported " + vendor);
                return false;
            }
        }

        return true;
    }

    // The following properties only make sense for internal engineering builds.
    // The following properties only make sense for internal engineering builds.
    public static final long TIME = getLong("ro.build.date.utc") * 1000;
    public static final long TIME = getLong("ro.build.date.utc") * 1000;
    public static final String USER = getString("ro.build.user");
    public static final String USER = getString("ro.build.user");
+6 −0
Original line number Original line Diff line number Diff line
@@ -5121,4 +5121,10 @@


    <!-- Indication that the current volume and other effects (vibration) are being suppressed by a third party, such as a notification listener. [CHAR LIMIT=30] -->
    <!-- Indication that the current volume and other effects (vibration) are being suppressed by a third party, such as a notification listener. [CHAR LIMIT=30] -->
    <string name="muted_by">Muted by <xliff:g id="third_party">%1$s</xliff:g></string>
    <string name="muted_by">Muted by <xliff:g id="third_party">%1$s</xliff:g></string>

    <!-- Error message shown when there is a system error which can be solved by user performing factory reset. [CHAR LIMIT=NONE] -->
    <string name="system_error_wipe_data">There\'s an internal problem with your device, and it may be unstable until you factory data reset.</string>
    <!-- Error message shown when there is a system error which can be solved by the manufacturer. [CHAR LIMIT=NONE] -->
    <string name="system_error_manufacturer">There\'s an internal problem with your device. Contact your manufacturer for details.</string>

</resources>
</resources>
+5 −0
Original line number Original line Diff line number Diff line
@@ -2105,4 +2105,9 @@


  <!-- From SignalStrength -->
  <!-- From SignalStrength -->
  <java-symbol type="integer" name="config_LTE_RSRP_threshold_type" />
  <java-symbol type="integer" name="config_LTE_RSRP_threshold_type" />

  <java-symbol type="string" name="android_system_label" />
  <java-symbol type="string" name="system_error_wipe_data" />
  <java-symbol type="string" name="system_error_manufacturer" />

</resources>
</resources>
+34 −21
Original line number Original line Diff line number Diff line
@@ -1183,7 +1183,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int SERVICE_TIMEOUT_MSG = 12;
    static final int SERVICE_TIMEOUT_MSG = 12;
    static final int UPDATE_TIME_ZONE = 13;
    static final int UPDATE_TIME_ZONE = 13;
    static final int SHOW_UID_ERROR_MSG = 14;
    static final int SHOW_UID_ERROR_MSG = 14;
    static final int IM_FEELING_LUCKY_MSG = 15;
    static final int SHOW_FINGERPRINT_ERROR_MSG = 15;
    static final int PROC_START_TIMEOUT_MSG = 20;
    static final int PROC_START_TIMEOUT_MSG = 20;
    static final int DO_PENDING_ACTIVITY_LAUNCHES_MSG = 21;
    static final int DO_PENDING_ACTIVITY_LAUNCHES_MSG = 21;
    static final int KILL_APPLICATION_MSG = 22;
    static final int KILL_APPLICATION_MSG = 22;
@@ -1212,13 +1212,13 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int FINISH_BOOTING_MSG = 45;
    static final int FINISH_BOOTING_MSG = 45;
    static final int START_USER_SWITCH_MSG = 46;
    static final int START_USER_SWITCH_MSG = 46;
    static final int SEND_LOCALE_TO_MOUNT_DAEMON_MSG = 47;
    static final int SEND_LOCALE_TO_MOUNT_DAEMON_MSG = 47;
    static final int DISMISS_DIALOG_MSG = 48;
    static final int FIRST_ACTIVITY_STACK_MSG = 100;
    static final int FIRST_ACTIVITY_STACK_MSG = 100;
    static final int FIRST_BROADCAST_QUEUE_MSG = 200;
    static final int FIRST_BROADCAST_QUEUE_MSG = 200;
    static final int FIRST_COMPAT_MODE_MSG = 300;
    static final int FIRST_COMPAT_MODE_MSG = 300;
    static final int FIRST_SUPERVISOR_STACK_MSG = 100;
    static final int FIRST_SUPERVISOR_STACK_MSG = 100;
    AlertDialog mUidAlert;
    CompatModeDialog mCompatModeDialog;
    CompatModeDialog mCompatModeDialog;
    long mLastMemUsageReportTime = 0;
    long mLastMemUsageReportTime = 0;
@@ -1447,27 +1447,27 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
                }
            } break;
            } break;
            case SHOW_UID_ERROR_MSG: {
            case SHOW_UID_ERROR_MSG: {
                String title = "System UIDs Inconsistent";
                String text = "UIDs on the system are inconsistent, you need to wipe your"
                        + " data partition or your device will be unstable.";
                Log.e(TAG, title + ": " + text);
                if (mShowDialogs) {
                if (mShowDialogs) {
                    // XXX This is a temporary dialog, no need to localize.
                    AlertDialog d = new BaseErrorDialog(mContext);
                    AlertDialog d = new BaseErrorDialog(mContext);
                    d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
                    d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
                    d.setCancelable(false);
                    d.setCancelable(false);
                    d.setTitle(title);
                    d.setTitle(mContext.getText(R.string.android_system_label));
                    d.setMessage(text);
                    d.setMessage(mContext.getText(R.string.system_error_wipe_data));
                    d.setButton(DialogInterface.BUTTON_POSITIVE, "I'm Feeling Lucky",
                    d.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.ok),
                            mHandler.obtainMessage(IM_FEELING_LUCKY_MSG));
                            mHandler.obtainMessage(DISMISS_DIALOG_MSG, d));
                    mUidAlert = d;
                    d.show();
                    d.show();
                }
                }
            } break;
            } break;
            case IM_FEELING_LUCKY_MSG: {
            case SHOW_FINGERPRINT_ERROR_MSG: {
                if (mUidAlert != null) {
                if (mShowDialogs) {
                    mUidAlert.dismiss();
                    AlertDialog d = new BaseErrorDialog(mContext);
                    mUidAlert = null;
                    d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
                    d.setCancelable(false);
                    d.setTitle(mContext.getText(R.string.android_system_label));
                    d.setMessage(mContext.getText(R.string.system_error_manufacturer));
                    d.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.ok),
                            mHandler.obtainMessage(DISMISS_DIALOG_MSG, d));
                    d.show();
                }
                }
            } break;
            } break;
            case PROC_START_TIMEOUT_MSG: {
            case PROC_START_TIMEOUT_MSG: {
@@ -1727,6 +1727,11 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
                }
                break;
                break;
            }
            }
            case DISMISS_DIALOG_MSG: {
                final Dialog d = (Dialog) msg.obj;
                d.dismiss();
                break;
            }
            }
            }
        }
        }
    };
    };
@@ -1776,7 +1781,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                    }
                    }
                }
                }
                int i=0, num=0;
                int i = 0;
                int num = 0;
                long[] tmp = new long[1];
                long[] tmp = new long[1];
                do {
                do {
                    ProcessRecord proc;
                    ProcessRecord proc;
@@ -11249,13 +11255,18 @@ public final class ActivityManagerService extends ActivityManagerNative
            try {
            try {
                if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
                if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
                    Message msg = Message.obtain();
                    Slog.e(TAG, "UIDs on the system are inconsistent, you need to wipe your"
                    msg.what = SHOW_UID_ERROR_MSG;
                            + " data partition or your device will be unstable.");
                    mHandler.sendMessage(msg);
                    mHandler.obtainMessage(SHOW_UID_ERROR_MSG).sendToTarget();
                }
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
            }
            }
            if (!Build.isFingerprintConsistent()) {
                Slog.e(TAG, "Build fingerprint is not consistent, warning user");
                mHandler.obtainMessage(SHOW_FINGERPRINT_ERROR_MSG).sendToTarget();
            }
            long ident = Binder.clearCallingIdentity();
            long ident = Binder.clearCallingIdentity();
            try {
            try {
                Intent intent = new Intent(Intent.ACTION_USER_STARTED);
                Intent intent = new Intent(Intent.ACTION_USER_STARTED);
@@ -13961,7 +13972,9 @@ public final class ActivityManagerService extends ActivityManagerNative
        ArrayList<MemItem> procMems = new ArrayList<MemItem>();
        ArrayList<MemItem> procMems = new ArrayList<MemItem>();
        final SparseArray<MemItem> procMemsMap = new SparseArray<MemItem>();
        final SparseArray<MemItem> procMemsMap = new SparseArray<MemItem>();
        long nativePss=0, dalvikPss=0, otherPss=0;
        long nativePss = 0;
        long dalvikPss = 0;
        long otherPss = 0;
        long[] miscPss = new long[Debug.MemoryInfo.NUM_OTHER_STATS];
        long[] miscPss = new long[Debug.MemoryInfo.NUM_OTHER_STATS];
        long oomPss[] = new long[DUMP_MEM_OOM_LABEL.length];
        long oomPss[] = new long[DUMP_MEM_OOM_LABEL.length];