Skip to content

Commit 79d6198

Browse files
committed
Renamed device Id to androidId
1 parent 8638374 commit 79d6198

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

packages/device_info/android/src/main/java/io/flutter/plugins/deviceinfo/DeviceInfoPlugin.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package io.flutter.plugins.deviceinfo;
66

77
import android.annotation.SuppressLint;
8-
import android.app.Activity;
8+
import android.content.Context;
99
import android.os.Build;
1010
import android.os.Build.VERSION;
1111
import android.os.Build.VERSION_CODES;
@@ -21,7 +21,7 @@
2121

2222
/** DeviceInfoPlugin */
2323
public class DeviceInfoPlugin implements MethodCallHandler {
24-
private final Activity activity;
24+
private final Context context;
2525

2626
/** Substitute for missing values. */
2727
private static final String[] EMPTY_STRING_LIST = new String[] {};
@@ -34,8 +34,8 @@ public static void registerWith(Registrar registrar) {
3434
}
3535

3636
/** Do not allow direct instantiation. */
37-
private DeviceInfoPlugin(Activity activity) {
38-
this.activity = activity;
37+
private DeviceInfoPlugin(Context context) {
38+
this.context = context;
3939
}
4040

4141
@Override
@@ -66,7 +66,7 @@ public void onMethodCall(MethodCall call, Result result) {
6666
build.put("tags", Build.TAGS);
6767
build.put("type", Build.TYPE);
6868
build.put("isPhysicalDevice", !isEmulator());
69-
build.put("deviceId", getDeviceId());
69+
build.put("androidId", getAndroidId());
7070

7171
Map<String, Object> version = new HashMap<>();
7272
if (VERSION.SDK_INT >= VERSION_CODES.M) {
@@ -87,15 +87,15 @@ public void onMethodCall(MethodCall call, Result result) {
8787
}
8888

8989
/**
90-
* Simple call to get the android hardware device Id that is unique between the device + user and
90+
* Returns the Android hardware device ID that is unique between the device + user and
9191
* app signing. This key will change if the app is uninstalled or its data is cleared. Device
92-
* factory reset will also result in a value change
92+
* factory reset will also result in a value change.
9393
*
94-
* @return The device ID
94+
* @return The android ID
9595
*/
9696
@SuppressLint("HardwareIds")
97-
private String getDeviceId() {
98-
return Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID);
97+
private String getAndroidId() {
98+
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
9999
}
100100

101101
/**

packages/device_info/example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class _MyAppState extends State<MyApp> {
8282
'tags': build.tags,
8383
'type': build.type,
8484
'isPhysicalDevice': build.isPhysicalDevice,
85-
'device_id': build.deviceId,
85+
'androidId': build.androidId,
8686
};
8787
}
8888

packages/device_info/lib/device_info.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AndroidDeviceInfo {
5858
this.tags,
5959
this.type,
6060
this.isPhysicalDevice,
61-
this.deviceId,
61+
this.androidId,
6262
}) : supported32BitAbis = new List<String>.unmodifiable(supported32BitAbis),
6363
supported64BitAbis = new List<String>.unmodifiable(supported64BitAbis),
6464
supportedAbis = new List<String>.unmodifiable(supportedAbis);
@@ -120,8 +120,8 @@ class AndroidDeviceInfo {
120120
/// `false` if the application is running in an emulator, `true` otherwise.
121121
final bool isPhysicalDevice;
122122

123-
///
124-
final String deviceId;
123+
/// The Android hardware device ID that is unique between the device + user and app signing.
124+
final String androidId;
125125

126126
/// Deserializes from the message received from [_kChannel].
127127
static AndroidDeviceInfo _fromMap(dynamic message) {
@@ -146,7 +146,7 @@ class AndroidDeviceInfo {
146146
tags: map['tags'],
147147
type: map['type'],
148148
isPhysicalDevice: map['isPhysicalDevice'],
149-
deviceId: map['deviceId'],
149+
androidId: map['androidId'],
150150
);
151151
}
152152

0 commit comments

Comments
 (0)