This source file includes following definitions.
- getUniqueId
- getAndroidId
package org.chromium.chrome.browser.identity;
import android.content.Context;
import android.provider.Settings;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.chrome.browser.util.HashUtil;
import javax.annotation.Nullable;
public class SettingsSecureBasedIdentificationGenerator implements UniqueIdentificationGenerator {
public static final String GENERATOR_ID = "SETTINGS_SECURE_ANDROID_ID";
private final Context mContext;
public SettingsSecureBasedIdentificationGenerator(Context context) {
mContext = context.getApplicationContext();
}
@Override
public String getUniqueId(@Nullable String salt) {
String androidId = getAndroidId();
if (androidId == null) {
return "";
}
String md5Hash = HashUtil.getMd5Hash(
new HashUtil.Params(androidId).withSalt(salt));
return md5Hash == null ? "" : md5Hash;
}
@VisibleForTesting
String getAndroidId() {
return Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
}
}