1
0
mirror of https://github.com/danog/termux-api.git synced 2024-12-14 02:17:25 +01:00
termux-api/app/src/main/java/com/termux/api/BrightnessAPI.java

27 lines
787 B
Java
Raw Normal View History

2018-06-14 23:41:50 +02:00
package com.termux.api;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import com.termux.api.util.ResultReturner;
public class BrightnessAPI {
public static void onReceive(final TermuxApiReceiver receiver, final Context context, final Intent intent) {
final ContentResolver contentResolver = context.getContentResolver();
int brightness = intent.getIntExtra("brightness", 0);
if (brightness <= 0) {
brightness = 0;
} else if (brightness >= 255) {
brightness = 255;
}
Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS, brightness);
ResultReturner.noteDone(receiver, intent);
}
}