模拟麦克风
声音输出设备
USB锁
应用锁
屏幕锁
触摸锁
电源按键
系统启动
定时开关机
应用开机自启动
集控
小窗口
无信号蓝屏
无信号待机
无信号返回
五指熄屏
三指跟随
定时休眠
定时关机
获取当前温度
光感调节亮度
//模拟麦克风
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.BuiltInMicEnable)
下面是设置模拟麦克风
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.BuiltInMicEnable, isChecked ? 1 : 0);//1-打开,0-关闭
TvControlManager.getInstance().TVMicSwitch(isChecked?1:2);
if(isChecked){
Log.d(TAG, "Mic open");
SystemProperties.set("persist.mic.state","open");
}else{
Log.d(TAG, "Mic close");
SystemProperties.set("persist.mic.state","close");
}
声音输出设备
public static final String ACTION_USB_ALSA_ADDED = "com.dazzle.intent.action.USB_ALSA_ADDED";
public static final String ACTION_USB_ALSA_REMOVED = "com.dazzle.intent.action.USB_ALSA_REMOVED";
public static final String EXTRA_DEVICE = "device";
public static final String ACTION_BLUETOOTH_A2DP_CONNECTED = "com.dazzle.intent.action.BLUETOOTH_A2DP_CONNECTED";
public static final String ACTION_BLUETOOTH_A2DP_DISCONNECTED = "com.dazzle.intent.action.BLUETOOTH_A2DP_DISCONNECTED";
public final String VOICE_OUTPUT_DEVICE = "voice_output_device";
public final String VOICE_INPUT_DEVICE = "voice_input_device";
public final int OUTPUT_DEVICE_TYPE = 0;
public final int INPUT_DEVICE_TYPE = 1;
private ListtabItemListOutput;
private ListtabItemListInput;
喇叭
无
同轴
AudioManager.DEVICE_OUT_SPEAKER ---喇叭
AudioManager.DEVICE_OUT_SPDIF --同轴
soundDevices = getResources().getStringArray(R.array.str_arr_sound_sounddevice_vals);
喇叭
同轴
蓝牙
USB模式
private void setSoundDevice(int device) {
Settings.Global.putInt(getActivity().getContentResolver(), "voice_device_type", device);
}
private int getSoundDevice() {
int device = Settings.Global.getInt(getActivity().getContentResolver(), "voice_device_type", 0);
if (device >= soundDevices.length) {
device = 0;
setSoundDevice(device);
}
return device;
}
//获取默认输入设备
private void updateInputDevice(int type) {
int pos=0;
String currentDevice = getVoiceDeviceInfo(1);
final String[] temp = currentDevice.split("@");
for (int position = 0; position < tabItemListInput.size(); position++) {
Object object = tabItemListInput.get(position).getObject();
if (object == null) {
if (type == OUTPUT_DEVICE_TYPE) {
if (temp.length == 6
&& position == 0
&& "none".equals(temp[0])) {
pos = position;
}
} else if (type == INPUT_DEVICE_TYPE) {
if (temp.length == 6
&& position == 0
&& "speaker".equals(temp[0])) {
pos = position;
}
}
} else if (object instanceof UsbDevice) {
UsbDevice usbDevice = (UsbDevice) object;
if (temp.length == 6
&& Integer.toHexString(usbDevice.getVendorId()).equals(temp[2])
&& Integer.toHexString(usbDevice.getProductId()).equals(temp[3])) {
pos = position;
}
} else if (object instanceof BluetoothDevice) {
BluetoothDevice bluetoothDevice = (BluetoothDevice) object;
if (temp.length == 6
&& bluetoothDevice.getAddress().equals(temp[2])) {
pos = position;
}
} else if (object instanceof SPDIFInfo) {
if (temp.length == 6
&& position == 1
&& "spdif".equals(temp[0])) {
pos = position;
}
}
}
if (pos==0){
tv_voice_input_device.setText(getString(R.string.system_voice_input_default));
}else {
tv_voice_input_device.setText(tabItemListInput.get(pos).getName());
}
}
//获取默认输出设备
private void updateOutputDevice() {
int output=SystemProperties.getInt("persist.sys.audio.device.output", AudioManager.DEVICE_OUT_SPEAKER);
switch (output){
case AudioManager.DEVICE_OUT_SPEAKER:
tv_voice_output_device.setText(getString(R.string.system_voice_output_default));//喇叭
break;
case AudioManager.DEVICE_OUT_SPDIF:
tv_voice_output_device.setText(getString(R.string.system_voice_output_spdif));//同轴
break;
case AudioManager.DEVICE_OUT_BLUETOOTH_A2DP:
tv_voice_output_device.setText(soundDevices[2]);//蓝牙
break;
case AudioManager.DEVICE_OUT_USB_HEADSET:
tv_voice_output_device.setText(soundDevices[3]);//USB模式
break;
}
}
//获取所有输入设备
private void initListInput() {
tabItemListInput = new ArrayList<>();
tabItemListInput.add(new VoiceDeviceItem(getString(R.string.system_voice_input_default), null));
HashMap
if(usbList.size()>0){
Setkeys = usbList.keySet();
Iteratoriterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
UsbDevice usbDevice = usbList.get(key);
boolean resultCapture = usbDevice.getHasAudioCapture();
boolean resultPlayback = usbDevice.getHasAudioPlayback();
Log.i(TAG, "[initListInput][USB] " + usbDevice.getProductName() + " resultCapture:" + resultCapture + " resultPlayback:" + resultPlayback);
if (resultCapture) {
tabItemListInput.add(new VoiceDeviceItem(usbDevice.getProductName(), usbDevice));
}
}
}
}
//获取所有输出设备
private void initListOutput() {
tabItemListOutput = new ArrayList<>();
tabItemListOutput.add(new VoiceDeviceItem(getString(R.string.system_voice_output_default), null)); //喇叭
tabItemListOutput.add(new VoiceDeviceItem(getString(R.string.system_voice_output_spdif), mSPDIFInfo)); //同轴
HashMap
if(usbList.size()>0){
Setkeys = usbList.keySet();
Iteratoriterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
UsbDevice usbDevice = usbList.get(key);
boolean resultCapture = usbDevice.getHasAudioCapture();
boolean resultPlayback = usbDevice.getHasAudioPlayback();
Log.i(TAG, "[initListOutput][USB] " + usbDevice.getProductName() + " resultCapture:" + resultCapture + " resultPlayback:" + resultPlayback);
if (resultPlayback) {
tabItemListOutput.add(new VoiceDeviceItem(usbDevice.getProductName(), usbDevice));
}
}
}
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
if (defaultAdapter != null) {
Setdevices = defaultAdapter.getBondedDevices();
for (BluetoothDevice bluetoothDevice : devices) {
BluetoothClass bluetoothClass = bluetoothDevice.getBluetoothClass();
final int deviceClass = bluetoothClass.getDeviceClass();
final int majorDeviceClass = bluetoothClass.getMajorDeviceClass();
Log.i(TAG, "[Bluetooth] " + bluetoothDevice.getName()
+ " address:" + bluetoothDevice.getAddress()
+ " deviceClass:0x" + Integer.toHexString(deviceClass)
+ " majorDeviceClass:0x" + Integer.toHexString(majorDeviceClass));
if ((deviceClass == BluetoothClass.Device.AUDIO_VIDEO_UNCATEGORIZED
|| deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
&& (majorDeviceClass == BluetoothClass.Device.Major.AUDIO_VIDEO
|| majorDeviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)) {
tabItemListOutput.add(new VoiceDeviceItem(bluetoothDevice.getName(), bluetoothDevice));
}
}
}
}getVoiceDeviceInfo
//public static final int OUTPUT_DEVICE_TYPE = 0;
//public static final int INPUT_DEVICE_TYPE = 1;
//String VOICE_OUTPUT_DEVICE = "voice_output_device";
//String VOICE_INPUT_DEVICE = "voice_input_device";
public String getVoiceDeviceInfo(int type) {
String device = "none@none@none@none@none@none";
if (type == INPUT_DEVICE_TYPE) {
device = Settings.Global.getStringForUser(context.getContentResolver(), VOICE_INPUT_DEVICE, UserHandle.USER_SYSTEM);
if (TextUtils.isEmpty(device)) {
device = "none@none@none@none@none@none";
Settings.Global.putStringForUser(context.getContentResolver(), VOICE_INPUT_DEVICE, device, UserHandle.USER_SYSTEM);
}
} else if (type == OUTPUT_DEVICE_TYPE) {
device = Settings.Global.getStringForUser(context.getContentResolver(), VOICE_OUTPUT_DEVICE, UserHandle.USER_SYSTEM);
if (TextUtils.isEmpty(device)) {
device = "speaker@none@none@none@none@none";
Settings.Global.putStringForUser(context.getContentResolver(), VOICE_OUTPUT_DEVICE, device, UserHandle.USER_SYSTEM);
}
}
return device;
}
点击选择某个输出设备,
//String VoiceDeviceAdapter.VOICE_OUTPUT_DEVICE = "voice_output_device";
//String VoiceDeviceAdapter.VOICE_INPUT_DEVICE = "voice_input_device";
Object object=tabItemListOutput.get(pos).getObject();
String[] temp=getVoiceDeviceInfo().split("@");
if (object == null) {
if (mType == VoiceDeviceAdapter.INPUT_DEVICE_TYPE) {
if (temp.length == 6
&& "usb".equals(temp[0])
&& "true".equals(temp[4])) {
mUsbManager.deselectUsbAlsaDevice();
}
Settings.Global.putStringForUser(mContext.getContentResolver(), VoiceDeviceAdapter.VOICE_INPUT_DEVICE, "none@none@none@none@none@none", UserHandle.USER_SYSTEM);
} else if (mType == VoiceDeviceAdapter.OUTPUT_DEVICE_TYPE) {
if (temp.length == 6
&& "usb".equals(temp[0])
&& "true".equals(temp[5])) {
mUsbManager.deselectUsbAlsaDevice2("none", "speaker");
}
Settings.Global.putStringForUser(mContext.getContentResolver(), VoiceDeviceAdapter.VOICE_OUTPUT_DEVICE, "speaker@none@none@none@none@none", UserHandle.USER_SYSTEM);
disconnectBluetooth();
SystemProperties.set("persist.sys.audio.device.output", Integer.toString(AudioManager.DEVICE_OUT_SPEAKER));
}
} else if (object instanceof UsbDevice) {
UsbDevice usbDevice = (UsbDevice) object;
if (usbDevice.getHasAudioPlayback()) {
disconnectBluetooth();
SystemProperties.set("persist.sys.audio.device.output", Integer.toString(AudioManager.DEVICE_OUT_USB_HEADSET));
}
mUsbManager.selectUsbAlsaDevice(usbDevice);//Settings.Global.putStringForUser in UsbAlsaManager.java
} else if (object instanceof BluetoothDevice) {
BluetoothDevice bluetoothDevice = (BluetoothDevice) object;
if (temp.length == 6
&& "usb".equals(temp[0])
&& "true".equals(temp[5])) {
mUsbManager.deselectUsbAlsaDevice();
}
String currentDevice = "bluetooth"
+ "@"
+ bluetoothDevice.getName()
+ "@"
+ bluetoothDevice.getAddress()
+ "@"
+ "00"
+ "@"
+ "false"
+ "@"
+ "true";
Settings.Global.putStringForUser(mContext.getContentResolver(), VoiceDeviceAdapter.VOICE_OUTPUT_DEVICE, currentDevice, UserHandle.USER_SYSTEM);
bluetoothDevice.connect();
SystemProperties.set("persist.sys.audio.device.output", Integer.toString(AudioManager.DEVICE_OUT_BLUETOOTH_A2DP));
} else if (object instanceof SPDIFInfo) {
if (temp.length == 6
&& "usb".equals(temp[0])
&& "true".equals(temp[5])) {
mUsbManager.deselectUsbAlsaDevice2("none", "spdif");
}
Settings.Global.putStringForUser(mContext.getContentResolver(), VoiceDeviceAdapter.VOICE_OUTPUT_DEVICE, "spdif@none@none@none@none@none", UserHandle.USER_SYSTEM);
disconnectBluetooth();
SystemProperties.set("persist.sys.audio.device.output", Integer.toString(AudioManager.DEVICE_OUT_SPDIF));
mAudioManager.setWiredDeviceConnectionState(AudioManager.DEVICE_OUT_SPDIF, 1, "", "");
}
private void disconnectBluetooth() {
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
if (defaultAdapter != null) {
Setdevices = defaultAdapter.getBondedDevices();
for (BluetoothDevice bluetoothDevice : devices) {
BluetoothClass bluetoothClass = bluetoothDevice.getBluetoothClass();
final int deviceClass = bluetoothClass.getDeviceClass();
final int majorDeviceClass = bluetoothClass.getMajorDeviceClass();
if ((deviceClass == BluetoothClass.Device.AUDIO_VIDEO_UNCATEGORIZED
|| deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
&& (majorDeviceClass == BluetoothClass.Device.Major.AUDIO_VIDEO
|| majorDeviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)) {
bluetoothDevice.disconnect();
}
}
}
}
//广播监听usb和蓝牙插拔,更新声音输出设备列表
private void registerDazzleReceiver() {
mReceiver = new DazzleReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_USB_ALSA_ADDED);
filter.addAction(ACTION_USB_ALSA_REMOVED);
filter.addAction(ACTION_BLUETOOTH_A2DP_CONNECTED);
filter.addAction(ACTION_BLUETOOTH_A2DP_DISCONNECTED);
getActivity().registerReceiver(mReceiver, filter);
}
private void unregisterDazzleReceiver() {
getActivity().unregisterReceiver(mReceiver);
}
private class DazzleReceiver extends BroadcastReceiver {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "[onReceive] " + action);
if (ACTION_USB_ALSA_ADDED.equals(action)) {
UsbDevice usbDevice = intent.getParcelableExtra(EXTRA_DEVICE);
if (usbDevice != null) {
boolean resultCapture = usbDevice.getHasAudioCapture();
boolean resultPlayback = usbDevice.getHasAudioPlayback();
Log.i(TAG, "[onReceive][USB] " + usbDevice.getProductName() + " resultCapture:" + resultCapture + " resultPlayback:" + resultPlayback);
if (resultCapture) {
// initListInput();
// mInputAdapter.setTabItemList(tabItemListInput);
// mInputAdapter.notifyDataSetChanged();
}
if (resultPlayback) {
initListOutput(); mOutputAdapter.setTabItemList(tabItemListOutput);
mOutputAdapter.notifyDataSetChanged();
}
}
} else if (ACTION_USB_ALSA_REMOVED.equals(action)) {
UsbDevice usbDevice = intent.getParcelableExtra(EXTRA_DEVICE);
if (usbDevice != null) {
/*for (int i=0; i
UsbDevice temp = (UsbDevice)tabItemListInput.get(i).getObject();
if (usbDevice.getVendorId() == temp.getVendorId()
&& usbDevice.getProductId() == temp.getProductId()) {
// initListInput();
// mInputAdapter.setTabItemList(tabItemListInput);
// mInputAdapter.notifyDataSetChanged();
break;
}
}
}*/
for (int i=0; i
UsbDevice temp = (UsbDevice)tabItemListOutput.get(i).getObject();
if (usbDevice.getVendorId() == temp.getVendorId()
&& usbDevice.getProductId() == temp.getProductId()) {
initListOutput();
mOutputAdapter.setTabItemList(tabItemListOutput);
mOutputAdapter.notifyDataSetChanged();
break;
}
}
}
}
} else if (ACTION_BLUETOOTH_A2DP_CONNECTED.equals(action)) {
BluetoothDevice bluetoothDevice = intent.getParcelableExtra(EXTRA_DEVICE);
if (bluetoothDevice != null) {
initListOutput();
mOutputAdapter.setTabItemList(tabItemListOutput);
mOutputAdapter.notifyDataSetChanged();
}
} else if (ACTION_BLUETOOTH_A2DP_DISCONNECTED.equals(action)) {
BluetoothDevice bluetoothDevice = intent.getParcelableExtra(EXTRA_DEVICE);
if (bluetoothDevice != null) {
initListOutput();
mOutputAdapter.setTabItemList(tabItemListOutput);
mOutputAdapter.notifyDataSetChanged();
}
}
}
}
相关类VoiceDeviceItem,SPDIFInfo
public class VoiceDeviceItem {
private String name;
private Object object;
public VoiceDeviceItem(String name, Object object) {
this.name = name;
this.object = object;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getObject() {
return object;
}
}
public class SPDIFInfo implements Parcelable {
public SPDIFInfo() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
public static final CreatorCREATOR = new Creator() {
@Override
public SPDIFInfo createFromParcel(Parcel source) {
return null;
}
@Override
public SPDIFInfo[] newArray(int size) {
return new SPDIFInfo[0];
}
};
//usb锁
Constant.SysProp.USB_LOCK="persist.usb.lock"
SystemProperties.getBoolean(Constant.SysProp.USB_LOCK,false)
SystemProperties.set(Constant.SysProp.USB_LOCK, "true");//true打开,false关闭
//应用锁
Constant.SysProp.APP_LOCK="persist.app.lock"
public static final String SETTING_APP_LOCK = "setting_app_lock_";
SystemProperties.getBoolean(Constant.SysProp.APP_LOCK,false)
SystemProperties.set(Constant.SysProp.APP_LOCK, "true");//true打开,false关闭
Settings.Global.putInt(mContext.getContentResolver(), Constant.SETTING_APP_LOCK + appSettingListInfo.getPackageName(), isChosen() ? 1 : 0);//哪个应用需要锁,就把它的这个属性设为1,0为关闭
//屏幕锁
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ScreenLockEnable)获取屏幕锁
mTvFunctionManager.setOtherConfig(TvFunctionMa
nager.Config.ScreenLockEnable, isChecked ? 1 : 0);设置屏幕锁
其中1为打开,0为关闭
//触摸锁(android+pc触摸锁)
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.AllTouchLockEnable)获取触摸锁
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.AllTouchLockEnable, isChecked ? 1 : 0);设置触摸锁
其中1为打开,0为关闭
//电源按键
mMultiPowerState = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.PowerKeyMode);//index 0-关闭,1-二合一,2-三合一
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.PowerKeyMode, index);
//系统启动
mMultiPowerState = TvControlManager.getInstance().GetMcuPowerMode();//GetMcuPowerMode返回值1-上电开机,2-上电待机
TvControlManager.getInstance().SetMcuPowerMode(factoryPowerMode);//factoryPowerMode参数:1-上电开机,2-上电待机
//定时休眠
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.AutoECOEnable)获取自动休眠
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.AutoECOEnable, isChecked ? 1 : 0);设置自动休眠
其中1为打开,0为关闭
standbyTimeType = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.AutoECOMode);
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.AutoECOMode, index);//index休眠时间值,0-5分钟,1-10分钟,2-20分钟,3-30分钟,4-40分钟,5-50分钟,6-60分钟
//环境感光
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.LightSensorEnable)获取环境感光
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.LightSensorEnable, isChecked ? 1 : 0);设置环境感光
其中1为打开,0为关闭
//集控
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.UartControlEnable)获取集控
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.UartControlEnable, isChecked ? 1 : 0);设置集控
其中1为打开,0为关闭
//小窗口
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ShowFreeForm)获取小窗口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.ShowFreeForm, isChecked ? 1
: 0);设置小窗口
其中1为打开,0为关闭
app如果需要启动小窗口功能,其启动方法需要改为如下方法
public static boolean startAppByPackageName(Context context, String packName){
boolean ret = false;
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packName);
try {
if (intent != null) {
Log.i(TAG, "startFreeformByPackageName DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT :" + Settings.Global.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0));
Log.i(TAG, "startFreeformByPackageName ShowFreeForm :" + TvFunctionManager.getInstance().getOtherConfig(TvFunctionManager.Config.ShowFreeForm));
if (SystemProperties.getBoolean("fw.show_freeformui", false)) {
if (TvFunctionManager.getInstance().getOtherConfig(TvFunctionManager.Config.ShowFreeForm) == 1
&& 1 == Settings.Global.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0)) {
if (Utils.startFreeformByPackageName(context, packName)) {
return true;
}
} else {
if (Utils.exitFreeformByPackageName(context, packName)) {
return false;
}
}
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
context.startActivityAsUser(intent, UserHandle.CURRENT);
}
} catch (ActivityNotFoundException e) {
}
return ret;
}
Utils中方法:
public static boolean startFreeformByPackageName(Context context, String packName){
boolean ret = false;
Log.i(TAG, "1 startFreeformByPackageName:" + packName);
//String DazzleSettings = "com.dazzleviewtech.cssettings";
//String MAGNIFIER = "com.dazzlewisdom.zoomtool";
//String Spotlight = "com.dazzleviewtech.spotlight";
if (Constant.Package.DazzleSettings.equals(packName)
|| Constant.Package.MAGNIFIER.equals(packName)
|| Constant.Package.Spotlight.equals(packName)) {
return false;
}
Log.i(TAG, "startFreeformByPackageName-->1:" + packName);
if (!isFreeformWhitelist(context, packName)) {
return exitFreeformByPackageName(context, packName);
}
Log.i(TAG, "startFreeformByPackageName-->2:" + packName);
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packName);
if(intent != null) {
if (intent.resolveActivity(context.getPackageManager()) != null) {
try {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
/*| Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT*/);
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
DisplayMetrics metric = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metric);
int screenWidth = metric.widthPixels;
int screenHeight = metric.heightPixels;
int freeformWidth = dp2px(context, 960);
int freeformHeight = dp2px(context, 640);
int left = screenWidth / 5;
int top = screenHeight / 5;
int right = freeformWidth;
int bottom = freeformHeight;
options.setLaunchBounds(new Rect(left,top,right,bottom));
Bundle bundle = options.toBundle();
int currentUserId = ActivityManagerWrapper.getInstance().getCurrentUserId();
// List
ActivityManager.RunningTaskInfo[] recentTasks = ActivityManagerWrapper.getInstance().getRunningTasks(false);
ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(context.getPackageManager(), 0);
// Log.i(TAG, "[start][Freeform] recentTasks size:" + recentTasks.size());
// for (ActivityManager.RecentTaskInfo info : recentTasks) {
for (ActivityManager.RunningTaskInfo info : recentTasks) {
Intent intent2 = new Intent(info.baseIntent);
Log.i(TAG, "[start][Freeform] recentTasks:" + intent2.getComponent().getPackageName());
if (homeInfo != null) {
if (homeInfo.packageName.equals(intent2.getComponent().getPackageName())
&& homeInfo.name.equals(intent2.getComponent().getClassName())) {
continue;
}
}
if (intent2.getComponent().getPackageName().equals(packName)) {
/*if (ActivityManagerWrapper.getInstance().startActivityFromRecents(info.taskId, options)) {
Log.i(TAG, "[start][Freeform] startActivityFromRecents taskId:" + info.taskId);
}
return true;*/
}
}
if (packName.equals(Constant.Package.Wps)) {
intent.setClassName(Constant.Package.Wps, "cn.wps.moffice.main.StartPublicActivity");
}
/*context.startActivity(intent, bundle);
ret = true;*/
try {
ret = WindowManagerGlobal.getWindowSession().startFreedomMode(intent, 0, 0, 0, 0);
} catch (RemoteException e) {
Log.w(TAG, "Failed to start Freedom Mode", e);
}
} catch (ActivityNotFoundException e) {
}
}
}
return ret;
}
public static boolean exitFreeformByPackageName(Context context, String packName){
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packName);
boolean ret = false;
if(intent != null) {
if (intent.resolveActivity(context.getPackageManager()) != null) {
try {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
/*| Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT*/);
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);//WINDOWING_MODE_UNDEFINED
DisplayMetrics metric = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metric);
int left = 0;
int top = 0;
int right = metric.widthPixels;
int bottom = metric.heightPixels;;
options.setLaunchBounds(new Rect(left,top,right,bottom));
Bundle bundle = options.toBundle();
int currentUserId = ActivityManagerWrapper.getInstance().getCurrentUserId();
ActivityManager.RunningTaskInfo[] recentTasks = ActivityManagerWrapper.getInstance().getRunningTasks(false);
ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(context.getPackageManager(), 0);
Log.i(TAG, "[exit][Freeform] recentTasks size:" + recentTasks.length);
for (ActivityManager.RunningTaskInfo info : recentTasks) {
Intent intent2 = new Intent(info.baseIntent);
Log.i(TAG, "[exit][Freeform] recentTasks:" + intent2.getComponent().getPackageName());
if (homeInfo != null) {
if (homeInfo.packageName.equals(intent2.getComponent().getPackageName())
&& homeInfo.name.equals(intent2.getComponent().getClassName())) {
continue;
}
}
if (intent2.getComponent().getPackageName().equals(packName)) {
if (ActivityManagerWrapper.getInstance().startActivityFromRecents(info.taskId, options)) {
}
return true;
}
}
if (packName.equals(Constant.Package.Wps)) {
intent.setClassName(Constant.Package.Wps, "cn.wps.moffice.main.StartPublicActivity");
}
context.startActivity(intent, bundle);
ret = true;
} catch (ActivityNotFoundException e) {
}
}
}
return ret;
}
//哪个应用想拥有小窗口功能,需要加在isFreeformWhitelist白名单里面,类似我们的白板,wps这些app,
//String WHITEBOARD4K = "com.dazzle.whiteboard";
//String Chrome = "com.android.chrome";
//String Wps = "cn.wps.moffice_eng";
//String EShareService = "com.ecloud.eshare.server";
//String YouTuBe = "com.google.android.youtube";
//String GooglePlay = "com.android.vending";
public static boolean isFreeformWhitelist(Context context, String packName) {
final ArrayListfreeformWhitelist = new ArrayList();
freeformWhitelist.add(Constant.Package.WHITEBOARD4K);
freeformWhitelist.add(Constant.Package.Chrome);
freeformWhitelist.add(Constant.Package.Opera);
freeformWhitelist.add(Constant.Package.Wps);
freeformWhitelist.add(Constant.Package.EShareService);
freeformWhitelist.add(Constant.Package.YouTuBe);
freeformWhitelist.add(Constant.Package.GooglePlay);
if (freeformWhitelist.contains(packName)) {
return true;
}
try {
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(packName, 0);
boolean isSystemApp = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
|| (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
if (!isSystemApp) {
// return true;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return false;
}
-----------------------------------------------------------------------------
//无信号蓝屏
public static final String CHANNEL_NO_SIGNAL_BLUESCREEN = "persist.no.signal.bluescreen";
SystemProperties.getInt(Constant.CHANNEL_NO_SIGNAL_BLUESCREEN, 0);
SystemProperties.set(Constant.CHANNEL_NO_SIGNAL_BLUESCREEN, String.valueOf(isChecked ? 1 : 0));//1打开,0关闭
//无信号返回
mNoSignalReturn = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.NoSignalReturn)//返回值0关闭,1返回主页,2返回上一个通道
TvFunctionManager.getInstance().setOtherConfig(TvFunctionManager.Config.NoSignalReturn, type);
//无信号待机
mNoSignalReturn = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.NoSignalStandby)//0关闭,1-1分钟,2-3分钟,3-5分钟,4-10分钟
TvFunctionManager.getInstance().setOtherConfig(TvFunctionManager.Config.NoSignalStandby, type);
//定时关机
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.TimeShutDownEnable);//返回值1打开,0-关闭
mOffRepetitiveID = mTvFunctionManager.getTimingShutdownRepeat();//定时模式7自定义,1仅一次
mTvFunctionManager.getShutDownTimeCustom()//已选择的关机时间,跟后面的设置周日到周一对应
打开关闭关机接口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.TimeShutDownEnable, isChecked ? 1 : 0);//1打开,0-关闭
mTvFunctionManager.setTimingShutdown(isChecked, isChecked?1:0, mTvFunctionManager.getTimingShutdownSeconds());
选择周日到周一时间后点确定,
setShutDownTimeCustom参数周日到周一是"1","2","3","4","5","6","7"拼接而成,如果未选中则相应位填”0“,比如1,1,0,0,0,0,0表示只选择了周日,周一,一个未选择是0,0,0,0,0,0,0,
mTvFunctionManager.setShutDownTimeCustom(buffer.toString());
如果有选择任何一个,参数为7自定义,如果未选参数1,表示仅一次,onTotalSeconds为总秒数
mTvFunctionManager.setTimingShutdown(true, isSelect ? 7 : 1, onTotalSeconds);
//String SETTING_POWEROFF_REMINDER = "setting_poweron_reminder"
Utils.putSystemSettingsInt(mContext.getContentResolver(), Constant.SETTING_POWEROFF_REMINDER, mWvShutdownReminder.getSelectedPosition());
//上面的方法是调用Settings.System.putInt(contentResolver,"setting_poweron_reminder",index)mWvShutdownReminder.getSelectedPosition()设置关机提醒选项,0是不提醒,1-1分钟提醒,2-5分钟提醒,3-10分钟提醒,在关机时间前多久时间弹倒计时弹窗,提醒客户即将关机,默认是不提醒
//定时开机
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.TimeBootEnable);//返回值1打开,0-关闭
mOffRepetitiveID = mTvFunctionManager.getTimingBootRepeat();//定时模式7自定义,1仅一次
mTvFunctionManager.getBootTimeCustom()//已选择的开机时间,跟后面的设置周日到周一对应
打开关闭开机接口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.TimeBootEnable, isChecked ? 1 : 0);//1打开,0-关闭
mTvFunctionManager.setTimingBoot(isChecked, isChecked?1:0, mTvFunctionManager.getTimingBootSeconds());
选择周日到周一时间后点确定,
setBootTimeCustom参数周日到周一是"1","2","3","4","5","6","7"拼接而成,如果未选中则相应位填”0“,比如1,1,0,0,0,0,0表示只选择了周日,周一,一个未选择是0,0,0,0,0,0,0,
mTvFunctionManager.setBootTimeCustom(buffer.toString());
如果有选择任何一个,参数为7自定义,如果未选参数1,表示仅一次,onTotalSeconds为总秒数
mTvFunctionManager.setTimingBoot(true, isSelect ? 7 : 1, onTotalSeconds);
开机OPS跟随启动(开关)--没有开关,只有加不加
if(mBootInputSource == TvFunctionManager.VirtualSourceInput.OPS.toInt()){
Log.d(TAG, "checkTv OPScheck = "+(TvControlManager.getInstance().handleGPIO(63, false, 0)));
if(!TvFunctionManager.getInstance().checkOPSPowerOn()){
Log.d(TAG, "checkTv OPS is Power on");
TvFunctionManager.getInstance().OPSPowerOn();
}
}如果要加,加在checkTv方法里,启动通道之前
11.mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.FiveFingerEnable)获取五指息屏
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.FiveFingerEnable, isChecked ? 1 : 0);设置五指息屏
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ThreeFingerEnable)获取三指跟随
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.ThreeFingerEnable, isChecked ? 1 : 0);设置三指跟随
其中1为打开,0为关闭
//色温调节
import android.os.RkDisplayOutputManager;
public static final String IMAGE_COLOR_TEMPERATURE = "image.color.temperature";
private int mCurDpy = 0;
private RkDisplayOutputManager mRkDisplayOutputManager;
private ArrayListmConnectorList;
private final int[] COLOR_TEMPERATURE_VALUE = {
3500,6500 ,9500
};
初始化
mRkDisplayOutputManager.updateDispHeader();
mConnectorList = new ArrayList();
String[] info = mRkDisplayOutputManager.getConnectorInfo();
for(int i = 0; i < info.length; i++){
ConnectorInfo connectorInfo = new ConnectorInfo(info[i], i);
if(connectorInfo != null && connectorInfo.getState() == 1){
mConnectorList.add(connectorInfo);
}
}
mCurDpy = mConnectorList.get(0).getDpy();
sbDisplayColorTemperature.setProgress(Integer.parseInt(SystemProperties.get(IMAGE_COLOR_TEMPERATURE, "1")));
sbDisplayColorTemperature.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int[][] rgb = ColorTempUtil.colorTemperatureToRGB(1024, COLOR_TEMPERATURE_VALUE[progress]);
mRkDisplayOutputManager.setGamma(mCurDpy, 1024, rgb[0], rgb[1], rgb[2]);
SystemProperties.set(IMAGE_COLOR_TEMPERATURE, String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
package com.dazzleviewtech.cssettings.utils;
public class ColorTempUtil {
private static double blackbody_color[] = {
1.00000000, 0.18172716, 0.00000000, /* 1000K */
1.00000000, 0.25503671, 0.00000000, /* 1100K */
1.00000000, 0.30942099, 0.00000000, /* 1200K */
1.00000000, 0.35357379, 0.00000000, /* ... */
1.00000000, 0.39091524, 0.00000000,
1.00000000, 0.42322816, 0.00000000,
1.00000000, 0.45159884, 0.00000000,
1.00000000, 0.47675916, 0.00000000,
1.00000000, 0.49923747, 0.00000000,
1.00000000, 0.51943421, 0.00000000,
1.00000000, 0.54360078, 0.08679949,
1.00000000, 0.56618736, 0.14065513,
1.00000000, 0.58734976, 0.18362641,
1.00000000, 0.60724493, 0.22137978,
1.00000000, 0.62600248, 0.25591950,
1.00000000, 0.64373109, 0.28819679,
1.00000000, 0.66052319, 0.31873863,
1.00000000, 0.67645822, 0.34786758,
1.00000000, 0.69160518, 0.37579588,
1.00000000, 0.70602449, 0.40267128,
1.00000000, 0.71976951, 0.42860152,
1.00000000, 0.73288760, 0.45366838,
1.00000000, 0.74542112, 0.47793608,
1.00000000, 0.75740814, 0.50145662,
1.00000000, 0.76888303, 0.52427322,
1.00000000, 0.77987699, 0.54642268,
1.00000000, 0.79041843, 0.56793692,
1.00000000, 0.80053332, 0.58884417,
1.00000000, 0.81024551, 0.60916971,
1.00000000, 0.81957693, 0.62893653,
1.00000000, 0.82854786, 0.64816570,
1.00000000, 0.83717703, 0.66687674,
1.00000000, 0.84548188, 0.68508786,
1.00000000, 0.85347859, 0.70281616,
1.00000000, 0.86118227, 0.72007777,
1.00000000, 0.86860704, 0.73688797,
1.00000000, 0.87576611, 0.75326132,
1.00000000, 0.88267187, 0.76921169,
1.00000000, 0.88933596, 0.78475236,
1.00000000, 0.89576933, 0.79989606,
1.00000000, 0.90198230, 0.81465502,
1.00000000, 0.90963069, 0.82838210,
1.00000000, 0.91710889, 0.84190889,
1.00000000, 0.92441842, 0.85523742,
1.00000000, 0.93156127, 0.86836903,
1.00000000, 0.93853986, 0.88130458,
1.00000000, 0.94535695, 0.89404470,
1.00000000, 0.95201559, 0.90658983,
1.00000000, 0.95851906, 0.91894041,
1.00000000, 0.96487079, 0.93109690,
1.00000000, 0.97107439, 0.94305985,
1.00000000, 0.97713351, 0.95482993,
1.00000000, 0.98305189, 0.96640795,
1.00000000, 0.98883326, 0.97779486,
1.00000000, 0.99448139, 0.98899179,
1.00000000, 1.00000000, 1.00000000, /* 6500K */
0.98947904, 0.99348723, 1.00000000,
0.97940448, 0.98722715, 1.00000000,
0.96975025, 0.98120637, 1.00000000,
0.96049223, 0.97541240, 1.00000000,
0.95160805, 0.96983355, 1.00000000,
0.94303638, 0.96443333, 1.00000000,
0.93480451, 0.95923080, 1.00000000,
0.92689056, 0.95421394, 1.00000000,
0.91927697, 0.94937330, 1.00000000,
0.91194747, 0.94470005, 1.00000000,
0.90488690, 0.94018594, 1.00000000,
0.89808115, 0.93582323, 1.00000000,
0.89151710, 0.93160469, 1.00000000,
0.88518247, 0.92752354, 1.00000000,
0.87906581, 0.92357340, 1.00000000,
0.87315640, 0.91974827, 1.00000000,
0.86744421, 0.91604254, 1.00000000,
0.86191983, 0.91245088, 1.00000000,
0.85657444, 0.90896831, 1.00000000,
0.85139976, 0.90559011, 1.00000000,
0.84638799, 0.90231183, 1.00000000,
0.84153180, 0.89912926, 1.00000000,
0.83682430, 0.89603843, 1.00000000,
0.83225897, 0.89303558, 1.00000000,
0.82782969, 0.89011714, 1.00000000,
0.82353066, 0.88727974, 1.00000000,
0.81935641, 0.88452017, 1.00000000,
0.81530175, 0.88183541, 1.00000000,
0.81136180, 0.87922257, 1.00000000,
0.80753191, 0.87667891, 1.00000000,
0.80380769, 0.87420182, 1.00000000,
0.80018497, 0.87178882, 1.00000000,
0.79665980, 0.86943756, 1.00000000,
0.79322843, 0.86714579, 1.00000000,
0.78988728, 0.86491137, 1.00000000, /* 10000K */
0.78663296, 0.86273225, 1.00000000,
0.78346225, 0.86060650, 1.00000000,
0.78037207, 0.85853224, 1.00000000,
0.77735950, 0.85650771, 1.00000000,
0.77442176, 0.85453121, 1.00000000,
0.77155617, 0.85260112, 1.00000000,
0.76876022, 0.85071588, 1.00000000,
0.76603147, 0.84887402, 1.00000000,
0.76336762, 0.84707411, 1.00000000,
0.76076645, 0.84531479, 1.00000000,
0.75822586, 0.84359476, 1.00000000,
0.75574383, 0.84191277, 1.00000000,
0.75331843, 0.84026762, 1.00000000,
0.75094780, 0.83865816, 1.00000000,
0.74863017, 0.83708329, 1.00000000,
0.74636386, 0.83554194, 1.00000000,
0.74414722, 0.83403311, 1.00000000,
0.74197871, 0.83255582, 1.00000000,
0.73985682, 0.83110912, 1.00000000,
0.73778012, 0.82969211, 1.00000000,
0.73574723, 0.82830393, 1.00000000,
0.73375683, 0.82694373, 1.00000000,
0.73180765, 0.82561071, 1.00000000,
0.72989845, 0.82430410, 1.00000000,
0.72802807, 0.82302316, 1.00000000,
0.72619537, 0.82176715, 1.00000000,
0.72439927, 0.82053539, 1.00000000,
0.72263872, 0.81932722, 1.00000000,
0.72091270, 0.81814197, 1.00000000,
0.71922025, 0.81697905, 1.00000000,
0.71756043, 0.81583783, 1.00000000,
0.71593234, 0.81471775, 1.00000000,
0.71433510, 0.81361825, 1.00000000,
0.71276788, 0.81253878, 1.00000000,
0.71122987, 0.81147883, 1.00000000,
0.70972029, 0.81043789, 1.00000000,
0.70823838, 0.80941546, 1.00000000,
0.70678342, 0.80841109, 1.00000000,
0.70535469, 0.80742432, 1.00000000,
0.70395153, 0.80645469, 1.00000000,
0.70257327, 0.80550180, 1.00000000,
0.70121928, 0.80456522, 1.00000000,
0.69988894, 0.80364455, 1.00000000,
0.69858167, 0.80273941, 1.00000000,
0.69729688, 0.80184943, 1.00000000,
0.69603402, 0.80097423, 1.00000000,
0.69479255, 0.80011347, 1.00000000,
0.69357196, 0.79926681, 1.00000000,
0.69237173, 0.79843391, 1.00000000,
0.69119138, 0.79761446, 1.00000000, /* 15000K */
0.69003044, 0.79680814, 1.00000000,
0.68888844, 0.79601466, 1.00000000,
0.68776494, 0.79523371, 1.00000000,
0.68665951, 0.79446502, 1.00000000,
0.68557173, 0.79370830, 1.00000000,
0.68450119, 0.79296330, 1.00000000,
0.68344751, 0.79222975, 1.00000000,
0.68241029, 0.79150740, 1.00000000,
0.68138918, 0.79079600, 1.00000000,
0.68038380, 0.79009531, 1.00000000,
0.67939381, 0.78940511, 1.00000000,
0.67841888, 0.78872517, 1.00000000,
0.67745866, 0.78805526, 1.00000000,
0.67651284, 0.78739518, 1.00000000,
0.67558112, 0.78674472, 1.00000000,
0.67466317, 0.78610368, 1.00000000,
0.67375872, 0.78547186, 1.00000000,
0.67286748, 0.78484907, 1.00000000,
0.67198916, 0.78423512, 1.00000000,
0.67112350, 0.78362984, 1.00000000,
0.67027024, 0.78303305, 1.00000000,
0.66942911, 0.78244457, 1.00000000,
0.66859988, 0.78186425, 1.00000000,
0.66778228, 0.78129191, 1.00000000,
0.66697610, 0.78072740, 1.00000000,
0.66618110, 0.78017057, 1.00000000,
0.66539706, 0.77962127, 1.00000000,
0.66462376, 0.77907934, 1.00000000,
0.66386098, 0.77854465, 1.00000000,
0.66310852, 0.77801705, 1.00000000,
0.66236618, 0.77749642, 1.00000000,
0.66163375, 0.77698261, 1.00000000,
0.66091106, 0.77647551, 1.00000000,
0.66019791, 0.77597498, 1.00000000,
0.65949412, 0.77548090, 1.00000000,
0.65879952, 0.77499315, 1.00000000,
0.65811392, 0.77451161, 1.00000000,
0.65743716, 0.77403618, 1.00000000,
0.65676908, 0.77356673, 1.00000000,
0.65610952, 0.77310316, 1.00000000,
0.65545831, 0.77264537, 1.00000000,
0.65481530, 0.77219324, 1.00000000,
0.65418036, 0.77174669, 1.00000000,
0.65355332, 0.77130560, 1.00000000,
0.65293404, 0.77086988, 1.00000000,
0.65232240, 0.77043944, 1.00000000,
0.65171824, 0.77001419, 1.00000000,
0.65112144, 0.76959404, 1.00000000,
0.65053187, 0.76917889, 1.00000000,
0.64994941, 0.76876866, 1.00000000, /* 20000K */
0.64937392, 0.76836326, 1.00000000,
0.64880528, 0.76796263, 1.00000000,
0.64824339, 0.76756666, 1.00000000,
0.64768812, 0.76717529, 1.00000000,
0.64713935, 0.76678844, 1.00000000,
0.64659699, 0.76640603, 1.00000000,
0.64606092, 0.76602798, 1.00000000,
0.64553103, 0.76565424, 1.00000000,
0.64500722, 0.76528472, 1.00000000,
0.64448939, 0.76491935, 1.00000000,
0.64397745, 0.76455808, 1.00000000,
0.64347129, 0.76420082, 1.00000000,
0.64297081, 0.76384753, 1.00000000,
0.64247594, 0.76349813, 1.00000000,
0.64198657, 0.76315256, 1.00000000,
0.64150261, 0.76281076, 1.00000000,
0.64102399, 0.76247267, 1.00000000,
0.64055061, 0.76213824, 1.00000000,
0.64008239, 0.76180740, 1.00000000,
0.63961926, 0.76148010, 1.00000000,
0.63916112, 0.76115628, 1.00000000,
0.63870790, 0.76083590, 1.00000000,
0.63825953, 0.76051890, 1.00000000,
0.63781592, 0.76020522, 1.00000000,
0.63737701, 0.75989482, 1.00000000,
0.63694273, 0.75958764, 1.00000000,
0.63651299, 0.75928365, 1.00000000,
0.63608774, 0.75898278, 1.00000000,
0.63566691, 0.75868499, 1.00000000,
0.63525042, 0.75839025, 1.00000000,
0.63483822, 0.75809849, 1.00000000,
0.63443023, 0.75780969, 1.00000000,
0.63402641, 0.75752379, 1.00000000,
0.63362667, 0.75724075, 1.00000000,
0.63323097, 0.75696053, 1.00000000,
0.63283925, 0.75668310, 1.00000000,
0.63245144, 0.75640840, 1.00000000,
0.63206749, 0.75613641, 1.00000000,
0.63168735, 0.75586707, 1.00000000,
0.63131096, 0.75560036, 1.00000000,
0.63093826, 0.75533624, 1.00000000,
0.63056920, 0.75507467, 1.00000000,
0.63020374, 0.75481562, 1.00000000,
0.62984181, 0.75455904, 1.00000000,
0.62948337, 0.75430491, 1.00000000,
0.62912838, 0.75405319, 1.00000000,
0.62877678, 0.75380385, 1.00000000,
0.62842852, 0.75355685, 1.00000000,
0.62808356, 0.75331217, 1.00000000,
0.62774186, 0.75306977, 1.00000000, /* 25000K */
0.62740336, 0.75282962, 1.00000000 /* 25100K */
};
private static double[] white_point = new double[3];
private static double F(double Y, int C) {
return (Math.pow(Y * white_point[C], 1.0 / 1));
}
public static int[][] colorTemperatureToRGB(int lutsize, int tmp) {
int[][] ret = new int[3][lutsize];
int[] red = new int[lutsize];
int[] green = new int[lutsize];
int[] blue = new int[lutsize];
double alpha = (tmp % 100 / 100.0);
int temp_index = ((tmp - 1000) / 100) * 3;
white_point[0] = ((1.0 - alpha) * blackbody_color[temp_index] + alpha * blackbody_color[temp_index + 3]);
white_point[1] = ((1.0 - alpha) * blackbody_color[temp_index + 1] + alpha * blackbody_color[temp_index + 4]);
white_point[2] = ((1.0 - alpha) * blackbody_color[temp_index + 2] + alpha * blackbody_color[temp_index + 5]);
for (int i = 0; i < lutsize; i++) {
double temp = i * 65535 / (lutsize - 1);
red[i] = (int) (F((double) (temp / 65536.0), 0) * 65536);
green[i] = (int) (F((double) (temp / (65536.0)), 1) * 65536);
blue[i] = (int) (F((double) (temp / (65536.0)), 2) * 65536);
}
ret[0] = red;
ret[1] = green;
ret[2] = blue;
return ret;
}
}
import android.util.Log;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ConnectorInfo {
public static final String[] CONNECTOR_TYPE = {"Unknown", "VGA", "DVII", "DVID", "DVIA", "Composite", "SVIDEO", "LVDS", "Component",
"9PinDIN", "DisplayPort", "HDMIA", "HDMIB", "TV", "eDP", "VIRTUAL", "DSI", "DPI"
};
private int type;
private int id;
private int state;
private int dpy;
private static final String REGEX_TYPE = "type:(\\d+)";
private static final String REGEX_ID = "id:(\\d+)";
private static final String REGEX_STATE = "state:(\\d+)";
public ConnectorInfo(String info, int dpy) {
Pattern p = Pattern.compile(REGEX_TYPE);
Matcher m = p.matcher(info);
if (m.find()) {
type = Integer.parseInt(m.group(1));
}
p = Pattern.compile(REGEX_ID);
m = p.matcher(info);
if (m.find()) {
id = Integer.parseInt(m.group(1));
}
p = Pattern.compile(REGEX_STATE);
m = p.matcher(info);
if (m.find()) {
state = Integer.parseInt(m.group(1));
}
this.dpy = dpy;
}
public int getDpy() {
return dpy;
}
public int getType() {
return type;
}
public int getId() {
return id;
}
public int getState() {
return state;
}
@Override
public String toString() {
return "ConnectorInfo{" +
"dpy=" + dpy +
"type=" + type +
", id=" + id +
", state=" + state +
'}';
}
}
//护眼模式功能
import android.os.RkDisplayOutputManager;
private int mCurDpy = 0;
private RkDisplayOutputManager mRkDisplayOutputManager;
private ArrayListmConnectorList;
初始化
mRkDisplayOutputManager = new RkDisplayOutputManager();
mRkDisplayOutputManager.updateDispHeader();
mConnectorList = new ArrayList();
String[] info = mRkDisplayOutputManager.getConnectorInfo();
for(int i = 0; i < info.length; i++){
ConnectorInfo connectorInfo = new ConnectorInfo(info[i], i);
if(connectorInfo != null && connectorInfo.getState() == 1){
mConnectorList.add(connectorInfo);
}
}
mCurDpy = mConnectorList.get(0).getDpy();
mRkDisplayOutputManager.setBGain(mCurDpy,208);//护眼模式打开
mRkDisplayOutputManager.setBGain(mCurDpy,256);//护眼模式关闭
梦派集团正在全国招募合作伙伴,欢迎大家来电咨询。
地址:深圳市宝安区前进二路宝华森国际中心A座3楼
官网:www.menpad.com
公众号:梦派集团
联系人:
陈艳 Candy 电话:158 1386 1033 邮箱: candychen@menpad.com
陈茂林 Annie 电话:135 1099 2891 邮箱:anniechen@menpad.com
黄地东 Dragon 电话:150 9990 3131 邮箱:dragonwong@menpad.com
陈春 Sunny 电话:136 4236 3682 邮箱: sunnychen@menpad.com