CopyPastor

Detecting plagiarism made easy.

Score: 1.846735417842865; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2025-05-13
by nicolas asinovich

Original Post

Original - Posted on 2025-05-13
by nicolas asinovich



            
Present in both answers; Present only in the new answer; Present only in the old answer;

The best way to detect it (kotlin):
``` fun isBatterySaveModeEnabled(context: Context): Boolean { val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager val manufacturer = Build.MANUFACTURER.orEmpty().lowercase() return when { manufacturer == "xiaomi" -> { try { Settings.System.getInt( context.contentResolver, "POWER_SAVE_MODE_OPEN", 0 ) == 1 } catch (e: Settings.SettingNotFoundException) { pm.isPowerSaveMode } }
manufacturer == "huawei" || manufacturer == "honor" -> { try { val status = Settings.System.getInt( context.contentResolver, "SmartModeStatus", -1 ) val status2 = Settings.System.getInt( context.contentResolver, "POWER_SAVE_MODE_OPEN", 0 ) if (manufacturer == "huawei") { status == 4 || status == 1 } else { status == 4 || status == 3 } } catch (e: Settings.SettingNotFoundException) { pm.isPowerSaveMode } }
else -> pm.isPowerSaveMode } } ```
You need to detect it for Xiaomi, Huawei and Honor like this:
``` fun isBatterySaveModeEnabled(context: Context): Boolean { val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager val manufacturer = Build.MANUFACTURER.orEmpty().lowercase() return when { manufacturer == "xiaomi" -> { try { Settings.System.getInt( context.contentResolver, "POWER_SAVE_MODE_OPEN", 0 ) == 1 } catch (e: Settings.SettingNotFoundException) { pm.isPowerSaveMode } }
manufacturer == "huawei" || manufacturer == "honor" -> { try { val status = Settings.System.getInt( context.contentResolver, "SmartModeStatus", -1 ) val status2 = Settings.System.getInt( context.contentResolver, "POWER_SAVE_MODE_OPEN", 0 ) if (manufacturer == "huawei") { status == 4 || status == 1 } else { status == 4 || status == 3 } } catch (e: Settings.SettingNotFoundException) { pm.isPowerSaveMode } }
else -> pm.isPowerSaveMode } } ```

        
Present in both answers; Present only in the new answer; Present only in the old answer;