Created
April 3, 2018 06:04
-
-
Save iblinov65apps/ee2da410aee5af6cc5968e0329aa3707 to your computer and use it in GitHub Desktop.
Phone info provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.alexfitness.data.core; | |
import android.annotation.SuppressLint; | |
import android.content.ContentResolver; | |
import android.content.Context; | |
import android.os.Build; | |
import android.provider.Settings; | |
import android.support.annotation.Nullable; | |
import android.util.DisplayMetrics; | |
import javax.inject.Inject; | |
class DeviceInfoProviderImpl implements DeviceInfoProvider { | |
private final Context context; | |
@Inject | |
DeviceInfoProviderImpl(Context context) { | |
this.context = context; | |
} | |
@SuppressLint("HardwareIds") | |
@Override | |
public String getImei() { | |
ContentResolver contentResolver = context.getContentResolver(); | |
return Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID); | |
} | |
@Nullable | |
@Override | |
public String getModel() { | |
return Build.MODEL; | |
} | |
@Nullable | |
@Override | |
public String getOs() { | |
return "Android " + Build.VERSION.RELEASE; | |
} | |
@Nullable | |
@Override | |
public Integer getDimensionX() { | |
return getDisplayMetrics().widthPixels; | |
} | |
@Nullable | |
@Override | |
public Integer getDimensionY() { | |
return getDisplayMetrics().heightPixels; | |
} | |
private DisplayMetrics getDisplayMetrics() { | |
return context.getResources().getDisplayMetrics(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment