qcom_msm8916_64_android5.0/sources/qcom/bootable/recovery/updater/install.c
Value* ConfirmDevVariant(const char* name, State* state, int argc, Expr* argv[])
{
    //ro.product.device that was on the build that the update package was made
    //from
    char* package_dev_variant;
    //ro.product.device on the current hardware
    char current_dev_variant[PROPERTY_VALUE_MAX];
    int comparison_len;
    int package_dev_variant_len;
    int current_dev_variant_len;
    if (argc != 1) {
        return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
    }
    package_dev_variant = Evaluate(state, argv[0]);
    if (!package_dev_variant) goto error;
    property_get("ro.product.device", current_dev_variant, "n/a");
    if (!strncmp(current_dev_variant,"n/a",3)) {
          ErrorAbort(state, "Failed to get valid ro.product.device");
          goto error;
    }
    package_dev_variant_len = strlen(package_dev_variant);
    current_dev_variant_len = strlen(current_dev_variant);
    //Length of the largest string - 3(for _32/64)
    comparison_len =
	    (package_dev_variant_len >= current_dev_variant_len ?
	    package_dev_variant_len :
	    current_dev_variant_len) - 3;
    //Complete match
    if (!strncmp(current_dev_variant, package_dev_variant,
			    strlen(current_dev_variant)))
	    goto success;
    //Match except for the last 3 char's of either string which are _32 or _64
    if (!strncmp(current_dev_variant, package_dev_variant, comparison_len)) {
	    if (package_dev_variant_len >= current_dev_variant_len) {
		    if (!strncmp(&package_dev_variant[package_dev_variant_len-3],
					    "_32", 3) ||
                        !strncmp(&package_dev_variant[package_dev_variant_len-3],
					    "_64", 3))
			    goto success;
	    } else {
		    if (!strncmp(&current_dev_variant[current_dev_variant_len-3],
					    "_32", 3) ||
                        !strncmp(&current_dev_variant[current_dev_variant_len-3],
					    "_64", 3))
			    goto success;

	    }
	    ErrorAbort(state, "Invalid target for update package");
	    goto error;
    }
success:
    free(package_dev_variant);
    return StringValue(strdup("OK"));
error:
    if (package_dev_variant) {
          free(package_dev_variant);
    }
    return StringValue(strdup("ERROR"));
}
//Check to confirm if this is the same hardware as the one the package was
//generated on or not. 32 vs 64 bit variants are upgrade compatible but have
//names such as msmWXYZ msmWXYZ_32 vs msmWXYZ_64.Input to this
//function is the BuildProp value that gets stored in the update package
//at the time it it created.
Check to confirm if this is the same hardware as the one the package was
generated on or not. 32 vs 64 bit variants are upgrade compatible but have
names such as msmWXYZ msmWXYZ_32 vs msmWXYZ_64.Input to this
function is the BuildProp value that gets stored in the update package
at the time it it created.
Check to confirm if this is the same hardware as the one the package was generated on or not . 32 vs 64 bit variants are upgrade compatible but have names such as msmWXYZ msmWXYZ_32 vs msmWXYZ_64 . Input to this function is the BuildProp value that gets stored in the update package at the time it it created .
Value* ConfirmDevVariant(const char* name, State* state, int argc, Expr* argv[])
{
    char* package_dev_variant;
    char current_dev_variant[PROPERTY_VALUE_MAX];
    int comparison_len;
    int package_dev_variant_len;
    int current_dev_variant_len;
    if (argc != 1) {
        return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
    }
    package_dev_variant = Evaluate(state, argv[0]);
    if (!package_dev_variant) goto error;
    property_get("ro.product.device", current_dev_variant, "n/a");
    if (!strncmp(current_dev_variant,"n/a",3)) {
          ErrorAbort(state, "Failed to get valid ro.product.device");
          goto error;
    }
    package_dev_variant_len = strlen(package_dev_variant);
    current_dev_variant_len = strlen(current_dev_variant);
    comparison_len =
	    (package_dev_variant_len >= current_dev_variant_len ?
	    package_dev_variant_len :
	    current_dev_variant_len) - 3;
    if (!strncmp(current_dev_variant, package_dev_variant,
			    strlen(current_dev_variant)))
	    goto success;
    if (!strncmp(current_dev_variant, package_dev_variant, comparison_len)) {
	    if (package_dev_variant_len >= current_dev_variant_len) {
		    if (!strncmp(&package_dev_variant[package_dev_variant_len-3],
					    "_32", 3) ||
                        !strncmp(&package_dev_variant[package_dev_variant_len-3],
					    "_64", 3))
			    goto success;
	    } else {
		    if (!strncmp(&current_dev_variant[current_dev_variant_len-3],
					    "_32", 3) ||
                        !strncmp(&current_dev_variant[current_dev_variant_len-3],
					    "_64", 3))
			    goto success;
	    }
	    ErrorAbort(state, "Invalid target for update package");
	    goto error;
    }
success:
    free(package_dev_variant);
    return StringValue(strdup("OK"));
error:
    if (package_dev_variant) {
          free(package_dev_variant);
    }
    return StringValue(strdup("ERROR"));
}
Value * ConfirmDevVariant ( const char * name , State * state , int argc , Expr * argv [ ] ) { char * package_dev_variant ; char current_dev_variant [ PROPERTY_VALUE_MAX ] ; int comparison_len ; int package_dev_variant_len ; int current_dev_variant_len ; if ( argc != 1 ) { return ErrorAbort ( state , " " , name , argc ) ; } package_dev_variant = Evaluate ( state , argv [ 0 ] ) ; if ( ! package_dev_variant ) goto error ; property_get ( " " , current_dev_variant , " " ) ; if ( ! strncmp ( current_dev_variant , " " , 3 ) ) { ErrorAbort ( state , " " ) ; goto error ; } package_dev_variant_len = strlen ( package_dev_variant ) ; current_dev_variant_len = strlen ( current_dev_variant ) ; comparison_len = ( package_dev_variant_len >= current_dev_variant_len ? package_dev_variant_len : current_dev_variant_len ) - 3 ; if ( ! strncmp ( current_dev_variant , package_dev_variant , strlen ( current_dev_variant ) ) ) goto success ; if ( ! strncmp ( current_dev_variant , package_dev_variant , comparison_len ) ) { if ( package_dev_variant_len >= current_dev_variant_len ) { if ( ! strncmp ( & package_dev_variant [ package_dev_variant_len - 3 ] , " " , 3 ) || ! strncmp ( & package_dev_variant [ package_dev_variant_len - 3 ] , " " , 3 ) ) goto success ; } else { if ( ! strncmp ( & current_dev_variant [ current_dev_variant_len - 3 ] , " " , 3 ) || ! strncmp ( & current_dev_variant [ current_dev_variant_len - 3 ] , " " , 3 ) ) goto success ; } ErrorAbort ( state , " " ) ; goto error ; } success : free ( package_dev_variant ) ; return StringValue ( strdup ( " " ) ) ; error : if ( package_dev_variant ) { free ( package_dev_variant ) ; } return StringValue ( strdup ( " " ) ) ; }
Check to confirm if this is the same hardware as the one the package was
generated on or not.
Check to confirm if this is the same hardware as the one the package was generated on or not .
//ro.product.device that was on the build that the update package was made //from //ro.product.device on the current hardware //Length of the largest string - 3(for _32/64) //Complete match //Match except for the last 3 char's of either string which are _32 or _64