Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(android)!: Remove unused code #183

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 10 additions & 49 deletions src/android/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Licensed to the Apache Software Foundation (ASF) under one
*/
package org.apache.cordova.device;

import java.util.TimeZone;

import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
Expand All @@ -31,14 +29,10 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.provider.Settings;

public class Device extends CordovaPlugin {
public static final String TAG = "Device";

public static String platform; // Device OS
public static String uuid; // Device UUID

private static final String ANDROID_PLATFORM = "Android";
private static final String AMAZON_PLATFORM = "amazon-fireos";
private static final String AMAZON_DEVICE = "Amazon";

/**
* Constructor.
Expand All @@ -62,7 +56,7 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param args JSONArray of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return True if the action was valid, false if not.
*/
Expand Down Expand Up @@ -92,79 +86,46 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
/**
* Get the OS name.
*
* @return
* @return "Android"
*/
public String getPlatform() {
String platform;
if (isAmazonDevice()) {
platform = AMAZON_PLATFORM;
} else {
platform = ANDROID_PLATFORM;
}
return platform;
return ANDROID_PLATFORM;
}

/**
* Get the device's Universally Unique Identifier (UUID).
*
* @return
* @return android.provider.Settings.Secure.ANDROID_ID
*/
public String getUuid() {
String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
return uuid;
return Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
}

public String getModel() {
String model = android.os.Build.MODEL;
return model;
}

public String getProductName() {
String productname = android.os.Build.PRODUCT;
return productname;
return android.os.Build.MODEL;
}

public String getManufacturer() {
String manufacturer = android.os.Build.MANUFACTURER;
return manufacturer;
return android.os.Build.MANUFACTURER;
}

public String getSerialNumber() {
String serial = android.os.Build.SERIAL;
return serial;
return android.os.Build.SERIAL;
}

/**
* Get the OS version.
*
* @return
* @return android.os.Build.VERSION.RELEASE
*/
public String getOSVersion() {
String osversion = android.os.Build.VERSION.RELEASE;
return osversion;
return android.os.Build.VERSION.RELEASE;
}

public String getSDKVersion() {
return String.valueOf(android.os.Build.VERSION.SDK_INT);
}

public String getTimeZoneID() {
TimeZone tz = TimeZone.getDefault();
return (tz.getID());
}

/**
* Function to check if the device is manufactured by Amazon
*
* @return
*/
public boolean isAmazonDevice() {
if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) {
return true;
}
return false;
}

public boolean isVirtual() {
return android.os.Build.FINGERPRINT.contains("generic") ||
android.os.Build.PRODUCT.contains("sdk");
Expand Down