switch to using ANDROID_ID instead of IMEI to identify a device across app installs
This commit is contained in:
parent
b01b0bc97b
commit
0796c08fbd
@ -303,7 +303,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
||||
{
|
||||
QVariantMap newRequest = request;
|
||||
newRequest.insert("token", m_token);
|
||||
// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||
qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
||||
}
|
||||
|
||||
|
||||
@ -13,23 +13,17 @@ PlatformHelperAndroid::PlatformHelperAndroid(QObject *parent) : PlatformHelper(p
|
||||
|
||||
void PlatformHelperAndroid::requestPermissions()
|
||||
{
|
||||
QtAndroid::requestPermissions({"android.permission.READ_PHONE_STATE"}, &PlatformHelperAndroid::permissionRequestFinished);
|
||||
// Not using any fancy permissions in android yet...
|
||||
}
|
||||
|
||||
bool PlatformHelperAndroid::hasPermissions() const
|
||||
{
|
||||
QtAndroid::PermissionResult r = QtAndroid::checkPermission("android.permission.READ_PHONE_STATE");
|
||||
return r == QtAndroid::PermissionResult::Granted;
|
||||
// Not using any fancy permissions in android yet...
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PlatformHelperAndroid::deviceSerial() const
|
||||
{
|
||||
QtAndroid::PermissionResult r = QtAndroid::checkPermission("android.permission.READ_PHONE_STATE");
|
||||
if (r != QtAndroid::PermissionResult::Granted) {
|
||||
qWarning() << "Cannot read device serial. No permissions";
|
||||
return "";
|
||||
}
|
||||
|
||||
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
|
||||
return activity.callObjectMethod<jstring>("deviceSerial").toString();
|
||||
}
|
||||
|
||||
@ -85,6 +85,4 @@
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
</manifest>
|
||||
|
||||
@ -5,6 +5,8 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.provider.Settings.Secure;
|
||||
|
||||
//import com.google.firebase.messaging.MessageForwardingService;
|
||||
|
||||
|
||||
@ -12,32 +14,18 @@ public class NymeaAppActivity extends org.qtproject.qt5.android.bindings.QtActiv
|
||||
{
|
||||
public String deviceSerial()
|
||||
{
|
||||
TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
// IMEI No.
|
||||
String imeiNo = TM.getDeviceId();
|
||||
|
||||
// IMSI No.
|
||||
String imsiNo = TM.getSubscriberId();
|
||||
|
||||
// SIM Serial No.
|
||||
String simSerialNo = TM.getSimSerialNumber();
|
||||
|
||||
// Android Unique ID
|
||||
// String androidId = System.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
|
||||
|
||||
return imeiNo;
|
||||
return Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
public static String deviceManufacturer()
|
||||
{
|
||||
return Build.MANUFACTURER;
|
||||
}
|
||||
public static String deviceManufacturer()
|
||||
{
|
||||
return Build.MANUFACTURER;
|
||||
}
|
||||
|
||||
public static String deviceModel()
|
||||
{
|
||||
return Build.MODEL;
|
||||
}
|
||||
public static String deviceModel()
|
||||
{
|
||||
return Build.MODEL;
|
||||
}
|
||||
|
||||
// // The key in the intent's extras that maps to the incoming message's message ID. Only sent by
|
||||
// // the server, GmsCore sends EXTRA_MESSAGE_ID_KEY below. Server can't send that as it would get
|
||||
|
||||
Reference in New Issue
Block a user