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
6 changes: 6 additions & 0 deletions .idea/copyright/Apache_License_2_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib

import android.Manifest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib

import android.Manifest
Expand All @@ -12,6 +28,7 @@ import com.udfsoft.androidinfo.lib.command.general.GetGeneralInformationCommand
import com.udfsoft.androidinfo.lib.command.network.GetNetworkTechnologiesInformationCommand
import com.udfsoft.androidinfo.lib.command.os.GetOSInformationCommand
import com.udfsoft.androidinfo.lib.command.sim.GetSIMCardInformationCommand
import com.udfsoft.androidinfo.lib.command.storage.GetStorageInformation
import com.udfsoft.androidinfo.lib.di.NetworkFactory
import com.udfsoft.androidinfo.lib.entity.*

Expand Down Expand Up @@ -60,9 +77,7 @@ object DeviceInformationFactory : DeviceInformation {
return getRAMInformationCommand(Unit)
}

override fun getStorageInformation(): StorageInformation {
TODO("Not yet implemented")
}
override fun getStorageInformation() = GetStorageInformation(api).invoke(Unit)

override fun getDisplayInformation(context: Context): DisplayInformation {
val getDisplayInformationCommand = GetDisplayInformationCommand(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.udfsoft.androidinfo.lib.command

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

abstract class BaseGetLocalInformationCommand<P : MutableEntity<*>> : CommandInterface<P, P>
abstract class BaseGetLocalInformationCommand<P : MutableEntity<*>> : CommandInterface<P,Unit>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.command.entity.storage

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

data class MutableStorageInformation(
var totalInternalMemorySize: Long = 0,
var availableInternalMemorySize: Long = 0,
var declaredInternalMemoryCharacteristics: String? = null,
var supportsMemoryCards: String? = null
) : MutableEntity<StorageInformation> {

override fun build() = StorageInformation(
totalInternalMemorySize,
availableInternalMemorySize,
declaredInternalMemoryCharacteristics,
supportsMemoryCards
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.udfsoft.androidinfo.lib.command.entity.storage

enum class StorageIds(val id: Int) {
InternalMemory(8330),
MemoryCards(8340)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ class GetLocalNetworkTechnologiesInformationCommand(
@RequiresPermission(
allOf = [Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE]
)
override fun invoke(param: MutableNetworkTechnologiesInformation): MutableNetworkTechnologiesInformation {
override fun invoke(param: 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 @@ -11,14 +11,12 @@ class GetLocalOSInformationCommand : BaseGetLocalInformationCommand<MutableOSInf
@RequiresPermission(
allOf = [Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE]
)
override fun invoke(param: MutableOSInformation): MutableOSInformation {
override fun invoke(param: MutableOSInformation) {
param.manufacturer = Build.MANUFACTURER
param.version = Build.VERSION.SDK_INT
param.versionRelease = Build.VERSION.RELEASE
param.incremental = Build.VERSION.INCREMENTAL
param.codeName = Build.VERSION.CODENAME
param.linuxVersion = System.getProperty("os.version")

return param
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.command.storage

import com.udfsoft.androidinfo.lib.command.BaseGetCloudInformationCommand
import com.udfsoft.androidinfo.lib.command.entity.MenuIds
import com.udfsoft.androidinfo.lib.command.entity.storage.MutableStorageInformation
import com.udfsoft.androidinfo.lib.command.entity.storage.StorageIds
import com.udfsoft.androidinfo.lib.network.AndroidInfoApi
import com.udfsoft.androidinfo.lib.network.entity.DeviceInformationItemNetwork

class GetCloudStorageInformation(
val api: AndroidInfoApi
) : BaseGetCloudInformationCommand<MutableStorageInformation>(api, MenuIds.MENU_ID_STORAGE) {

override fun processInfo(
item: DeviceInformationItemNetwork,
entity: MutableStorageInformation
) {
when (item.id) {
StorageIds.InternalMemory.id ->
entity.declaredInternalMemoryCharacteristics = item.value
StorageIds.MemoryCards.id -> entity.supportsMemoryCards = item.value
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.command.storage

import com.udfsoft.androidinfo.lib.command.BaseGetLocalInformationCommand
import com.udfsoft.androidinfo.lib.command.entity.storage.MutableStorageInformation
import com.udfsoft.androidinfo.lib.util.MemoryUtils

class GetLocalStorageInformation : BaseGetLocalInformationCommand<MutableStorageInformation>() {

override fun invoke(param: MutableStorageInformation) {
param.totalInternalMemorySize = MemoryUtils.getTotalInternalMemorySize()
param.availableInternalMemorySize = MemoryUtils.getAvailableInternalMemorySize()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.command.storage

import com.udfsoft.androidinfo.lib.command.CommandInterface
import com.udfsoft.androidinfo.lib.command.entity.storage.MutableStorageInformation
import com.udfsoft.androidinfo.lib.entity.StorageInformation
import com.udfsoft.androidinfo.lib.network.AndroidInfoApi

class GetStorageInformation(
private val api: AndroidInfoApi
) : CommandInterface<Unit, StorageInformation> {

override fun invoke(param: Unit): StorageInformation {
val mutableEntity = MutableStorageInformation()

GetLocalStorageInformation().invoke(mutableEntity)
GetCloudStorageInformation(api).invoke(mutableEntity)

return mutableEntity.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.udfsoft.androidinfo.lib.entity
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class StorageInformation {
package com.udfsoft.androidinfo.lib.entity

}
data class StorageInformation(
val totalInternalMemorySize: Long,
val availableInternalMemorySize: Long,
val declaredInternalMemoryCharacteristics: String?,
val supportsMemoryCards: String?
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.network.entity

import com.google.gson.annotations.SerializedName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.util

import android.os.Environment
import android.os.StatFs

object MemoryUtils {

fun getAvailableInternalMemorySize(): Long {
val path = Environment.getDataDirectory()
val stat = StatFs(path.path)
val blockSize = stat.blockSizeLong
val availableBlocks = stat.availableBlocksLong
return availableBlocks * blockSize
}

fun getTotalInternalMemorySize(): Long {
val path = Environment.getDataDirectory()
val stat = StatFs(path.path)
val blockSize = stat.blockSizeLong
val totalBlocks = stat.blockCountLong
return totalBlocks * blockSize
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.sample

import android.os.Bundle
Expand Down
Loading