bigsinger / AndroidIdChanger

Xposed Module for Changing Android Device Info
http://repo.xposed.info/module/com.bigsing.changer
537 stars 152 forks source link

GoogleAdID & SimOperatorName "null" #33

Open lars18th opened 6 years ago

lars18th commented 6 years ago

Hi,

In the UI, in the Original section, I see that these two values are empty:

Also, I see the same result ('null') in the new "mydevice.htm" file.

These are the only values empty in my device. I feel we need to verify the code and check about how to recover these values. I'm using Stock Android 7.0.

lars18th commented 6 years ago

Hi @bigsinger ,

Identical behaviour in v1.20. Only for your information.

bigsinger commented 6 years ago

my SimOperatorName value is not empty.

how to get googlead_id?

lars18th commented 6 years ago

my SimOperatorName value is not empty.

Please, share the code you use for read it.

how to get googlead_id?

https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient?hl=vi

However, you need to add this to the AndroidManifest.xml:

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

Source example:

/** Retrieve the Android Advertising Id 
     * 
     * The device must be KitKat (4.4)+ 
     * This method must be invoked from a background thread.
     * 
     * */
    public static synchronized String getAdId (Context context) {

        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
            return null;
        }

        AdvertisingIdClient.Info idInfo = null;
        try {
            idInfo = AdvertisingIdClient.getAdvertisingIdInfo(context);
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String advertId = null;
        try{
            advertId = idInfo.getId();
        }catch (NullPointerException e){
            e.printStackTrace();
        }

        return advertId;
    }

And remember that in fact for hooking the value, you don't need to read it! :smile: