Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ object DeviceInformationFactory : DeviceInformation {
@RequiresPermission(
allOf = [Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE]
)
override fun getNetworkTechnologiesInformation(context: Context): NetworkTechnologiesInformation {
val getNetworkTechnologiesInformation = GetNetworkTechnologiesInformationCommand(context)
return getNetworkTechnologiesInformation(Unit)
}
override fun getNetworkTechnologiesInformation(context: Context) =
GetNetworkTechnologiesInformationCommand(context, api).invoke(Unit)

override fun getOSInformation(): OSInformation {
val getOSInformationCommand = GetOSInformationCommand()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.udfsoft.androidinfo.lib.command

import com.udfsoft.androidinfo.lib.command.entity.MenuIds
import com.udfsoft.androidinfo.lib.command.entity.MutableEntity
import com.udfsoft.androidinfo.lib.network.AndroidInfoApi
import com.udfsoft.androidinfo.lib.network.entity.DeviceInformationItemNetwork

abstract class BaseGetCloudInformationCommand<P : MutableEntity<*>>(
private val api: AndroidInfoApi,
private val menuId: MenuIds
) : CommandInterface<P, P> {

override fun invoke(param: P): P {
val deviceInformation = api.getDeviceInfo(menuId.menuId).execute().body()
deviceInformation?.deviceMenuItemList?.forEach {
processInfo(it, param)
}
return param
}

protected abstract fun processInfo(item: DeviceInformationItemNetwork, entity: P)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.udfsoft.androidinfo.lib.command

import com.udfsoft.androidinfo.lib.command.entity.MutableEntity

abstract class BaseGetLocalInformationCommand<P : MutableEntity<*>> : CommandInterface<P, P>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.udfsoft.androidinfo.lib.command.entity

interface MutableEntity<P> {
fun build(): P
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.udfsoft.androidinfo.lib.command.entity.general

enum class GeneralIds(val id: Int) {

BRAND(1010),
MODEL(1020),
MODEL_ALIAS(1030)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.udfsoft.androidinfo.lib.command.entity.network

import com.udfsoft.androidinfo.lib.command.entity.MutableEntity
import com.udfsoft.androidinfo.lib.entity.NetworkTechnologiesInformation
import com.udfsoft.androidinfo.lib.util.NetworkUtils

data class MutableNetworkTechnologiesInformation(
var networkType: NetworkUtils.NetworkType = NetworkUtils.NetworkType.UNKNOWN,
var localIp: String? = null,
var mac: String? = null,
var gsm: String? = null,
var lte: String? = null,
var mobileNetworkTechnologies: String? = null
) : MutableEntity<NetworkTechnologiesInformation> {

override fun build() = NetworkTechnologiesInformation(
networkType,
localIp,
mac,
gsm,
lte,
mobileNetworkTechnologies
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.udfsoft.androidinfo.lib.command.entity.network

enum class NetworkTechnologiesIds(val id: Int) {
GSM(4140),
LTE(4160),
NetworkTechnologies(4180)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.udfsoft.androidinfo.lib.command.network

import com.udfsoft.androidinfo.lib.command.BaseGetCloudInformationCommand
import com.udfsoft.androidinfo.lib.command.entity.MenuIds
import com.udfsoft.androidinfo.lib.command.entity.network.MutableNetworkTechnologiesInformation
import com.udfsoft.androidinfo.lib.command.entity.network.NetworkTechnologiesIds
import com.udfsoft.androidinfo.lib.network.AndroidInfoApi
import com.udfsoft.androidinfo.lib.network.entity.DeviceInformationItemNetwork

class GetCloudNetworkTechnologiesInformationCommand(
api: AndroidInfoApi
) : BaseGetCloudInformationCommand<MutableNetworkTechnologiesInformation>(
api,
MenuIds.MENU_ID_MOBILE_NETWORK
) {

override fun processInfo(
item: DeviceInformationItemNetwork,
entity: MutableNetworkTechnologiesInformation
) {
when (item.id) {
NetworkTechnologiesIds.GSM.id -> entity.gsm = item.value
NetworkTechnologiesIds.LTE.id -> entity.lte = item.value
NetworkTechnologiesIds.NetworkTechnologies.id ->
entity.mobileNetworkTechnologies = item.value
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.udfsoft.androidinfo.lib.command.network

import android.Manifest
import android.content.Context
import androidx.annotation.RequiresPermission
import com.udfsoft.androidinfo.lib.command.BaseGetLocalInformationCommand
import com.udfsoft.androidinfo.lib.command.entity.network.MutableNetworkTechnologiesInformation
import com.udfsoft.androidinfo.lib.util.NetworkUtils

class GetLocalNetworkTechnologiesInformationCommand(
private val context: Context
) : BaseGetLocalInformationCommand<MutableNetworkTechnologiesInformation>() {

@RequiresPermission(
allOf = [Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE]
)
override fun invoke(param: MutableNetworkTechnologiesInformation): MutableNetworkTechnologiesInformation {
param.networkType = NetworkUtils.getNetworkType(context)
param.localIp = NetworkUtils.getLocalIpAddress()
param.mac = NetworkUtils.getMACAddress(null)

return param
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import android.Manifest
import android.content.Context
import androidx.annotation.RequiresPermission
import com.udfsoft.androidinfo.lib.command.CommandInterface
import com.udfsoft.androidinfo.lib.command.entity.network.MutableNetworkTechnologiesInformation
import com.udfsoft.androidinfo.lib.entity.NetworkTechnologiesInformation
import com.udfsoft.androidinfo.lib.util.NetworkUtils
import com.udfsoft.androidinfo.lib.network.AndroidInfoApi

class GetNetworkTechnologiesInformationCommand(
private val context: Context
private val context: Context,
val api: AndroidInfoApi
) : CommandInterface<Unit, NetworkTechnologiesInformation> {

@RequiresPermission(
allOf = [Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE]
)
override fun invoke(param: Unit): NetworkTechnologiesInformation {
val networkType = NetworkUtils.getNetworkType(context)
val localIp = NetworkUtils.getLocalIpAddress()
val mac = NetworkUtils.getMACAddress(null)
return NetworkTechnologiesInformation(networkType, localIp, mac)
val mutableEntity = MutableNetworkTechnologiesInformation()
GetLocalNetworkTechnologiesInformationCommand(context).invoke(mutableEntity)
GetCloudNetworkTechnologiesInformationCommand(api).invoke(mutableEntity)
return mutableEntity.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package com.udfsoft.androidinfo.lib.entity

class NetworkInformation {

}
class NetworkInformation
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ import com.udfsoft.androidinfo.lib.util.NetworkUtils
data class NetworkTechnologiesInformation(
val networkType: NetworkUtils.NetworkType,
val localIp: String?,
val mac: String?
val mac: String?,
val gsm: String?,
val lte: String?,
val mobileNetworkTechnologies: String?
)