2024-11-22
深圳夢牌智能技術(shù)有限公司模擬麥克風(fēng)
聲音輸出設(shè)備
USB鎖
應(yīng)用鎖
屏幕鎖
觸摸鎖
電源按鍵
系統(tǒng)啟動
定時開關(guān)機(jī)
應(yīng)用開機(jī)自啟動
集控
小窗口
無信號藍(lán)屏
無信號待機(jī)
無信號返回
五指熄屏
三指跟隨
定時休眠
定時關(guān)機(jī)
獲取當(dāng)前溫度
光感調(diào)節(jié)亮度
//模擬麥克風(fēng)
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.BuiltInMicEnable)
下面是設(shè)置模擬麥克風(fēng)
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.BuiltInMicEnable, isChecked ? 1 : 0);//1-打開,0-關(guān)閉
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");
}
聲音輸出設(shè)備
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);
喇叭
同軸
藍(lán)牙
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;
}
//獲取默認(rèn)輸入設(shè)備
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());
}
}
//獲取默認(rèn)輸出設(shè)備
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]);//藍(lán)牙
break;
case AudioManager.DEVICE_OUT_USB_HEADSET:
tv_voice_output_device.setText(soundDevices[3]);//USB模式
break;
}
}
//獲取所有輸入設(shè)備
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));
}
}
}
}
//獲取所有輸出設(shè)備
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;
}
點(diǎn)擊選擇某個輸出設(shè)備,
//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();
}
}
}
}
//廣播監(jiān)聽usb和藍(lán)牙插拔,更新聲音輸出設(shè)備列表
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();
}
}
}
}
相關(guān)類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關(guān)閉
//應(yīng)用鎖
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關(guān)閉
Settings.Global.putInt(mContext.getContentResolver(), Constant.SETTING_APP_LOCK + appSettingListInfo.getPackageName(), isChosen() ? 1 : 0);//哪個應(yīng)用需要鎖,就把它的這個屬性設(shè)為1,0為關(guān)閉
//屏幕鎖
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ScreenLockEnable)獲取屏幕鎖
mTvFunctionManager.setOtherConfig(TvFunctionMa
nager.Config.ScreenLockEnable, isChecked ? 1 : 0);設(shè)置屏幕鎖
其中1為打開,0為關(guān)閉
//觸摸鎖(android+pc觸摸鎖)
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.AllTouchLockEnable)獲取觸摸鎖
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.AllTouchLockEnable, isChecked ? 1 : 0);設(shè)置觸摸鎖
其中1為打開,0為關(guān)閉
//電源按鍵
mMultiPowerState = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.PowerKeyMode);//index 0-關(guān)閉,1-二合一,2-三合一
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.PowerKeyMode, index);
//系統(tǒng)啟動
mMultiPowerState = TvControlManager.getInstance().GetMcuPowerMode();//GetMcuPowerMode返回值1-上電開機(jī),2-上電待機(jī)
TvControlManager.getInstance().SetMcuPowerMode(factoryPowerMode);//factoryPowerMode參數(shù):1-上電開機(jī),2-上電待機(jī)
//定時休眠
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.AutoECOEnable)獲取自動休眠
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.AutoECOEnable, isChecked ? 1 : 0);設(shè)置自動休眠
其中1為打開,0為關(guān)閉
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分鐘
//環(huán)境感光
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.LightSensorEnable)獲取環(huán)境感光
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.LightSensorEnable, isChecked ? 1 : 0);設(shè)置環(huán)境感光
其中1為打開,0為關(guān)閉
//集控
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.UartControlEnable)獲取集控
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.UartControlEnable, isChecked ? 1 : 0);設(shè)置集控
其中1為打開,0為關(guān)閉
//小窗口
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ShowFreeForm)獲取小窗口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.ShowFreeForm, isChecked ? 1
: 0);設(shè)置小窗口
其中1為打開,0為關(guān)閉
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;
}
//哪個應(yīng)用想擁有小窗口功能,需要加在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;
}
-----------------------------------------------------------------------------
//無信號藍(lán)屏
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關(guān)閉
//無信號返回
mNoSignalReturn = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.NoSignalReturn)//返回值0關(guān)閉,1返回主頁,2返回上一個通道
TvFunctionManager.getInstance().setOtherConfig(TvFunctionManager.Config.NoSignalReturn, type);
//無信號待機(jī)
mNoSignalReturn = mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.NoSignalStandby)//0關(guān)閉,1-1分鐘,2-3分鐘,3-5分鐘,4-10分鐘
TvFunctionManager.getInstance().setOtherConfig(TvFunctionManager.Config.NoSignalStandby, type);
//定時關(guān)機(jī)
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.TimeShutDownEnable);//返回值1打開,0-關(guān)閉
mOffRepetitiveID = mTvFunctionManager.getTimingShutdownRepeat();//定時模式7自定義,1僅一次
mTvFunctionManager.getShutDownTimeCustom()//已選擇的關(guān)機(jī)時間,跟后面的設(shè)置周日到周一對應(yīng)
打開關(guān)閉關(guān)機(jī)接口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.TimeShutDownEnable, isChecked ? 1 : 0);//1打開,0-關(guān)閉
mTvFunctionManager.setTimingShutdown(isChecked, isChecked?1:0, mTvFunctionManager.getTimingShutdownSeconds());
選擇周日到周一時間后點(diǎn)確定,
setShutDownTimeCustom參數(shù)周日到周一是"1","2","3","4","5","6","7"拼接而成,如果未選中則相應(yīng)位填”0“,比如1,1,0,0,0,0,0表示只選擇了周日,周一,一個未選擇是0,0,0,0,0,0,0,
mTvFunctionManager.setShutDownTimeCustom(buffer.toString());
如果有選擇任何一個,參數(shù)為7自定義,如果未選參數(shù)1,表示僅一次,onTotalSeconds為總秒數(shù)
mTvFunctionManager.setTimingShutdown(true, isSelect ? 7 : 1, onTotalSeconds);
//String SETTING_POWEROFF_REMINDER = "setting_poweron_reminder"
Utils.putSystemSettingsInt(mContext.getContentResolver(), Constant.SETTING_POWEROFF_REMINDER, mWvShutdownReminder.getSelectedPosition());
//上面的方法是調(diào)用Settings.System.putInt(contentResolver,"setting_poweron_reminder",index)mWvShutdownReminder.getSelectedPosition()設(shè)置關(guān)機(jī)提醒選項(xiàng),0是不提醒,1-1分鐘提醒,2-5分鐘提醒,3-10分鐘提醒,在關(guān)機(jī)時間前多久時間彈倒計(jì)時彈窗,提醒客戶即將關(guān)機(jī),默認(rèn)是不提醒
//定時開機(jī)
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.TimeBootEnable);//返回值1打開,0-關(guān)閉
mOffRepetitiveID = mTvFunctionManager.getTimingBootRepeat();//定時模式7自定義,1僅一次
mTvFunctionManager.getBootTimeCustom()//已選擇的開機(jī)時間,跟后面的設(shè)置周日到周一對應(yīng)
打開關(guān)閉開機(jī)接口
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.TimeBootEnable, isChecked ? 1 : 0);//1打開,0-關(guān)閉
mTvFunctionManager.setTimingBoot(isChecked, isChecked?1:0, mTvFunctionManager.getTimingBootSeconds());
選擇周日到周一時間后點(diǎn)確定,
setBootTimeCustom參數(shù)周日到周一是"1","2","3","4","5","6","7"拼接而成,如果未選中則相應(yīng)位填”0“,比如1,1,0,0,0,0,0表示只選擇了周日,周一,一個未選擇是0,0,0,0,0,0,0,
mTvFunctionManager.setBootTimeCustom(buffer.toString());
如果有選擇任何一個,參數(shù)為7自定義,如果未選參數(shù)1,表示僅一次,onTotalSeconds為總秒數(shù)
mTvFunctionManager.setTimingBoot(true, isSelect ? 7 : 1, onTotalSeconds);
開機(jī)OPS跟隨啟動(開關(guān))--沒有開關(guān),只有加不加
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);設(shè)置五指息屏
mTvFunctionManager.getOtherConfig(TvFunctionManager.Config.ThreeFingerEnable)獲取三指跟隨
mTvFunctionManager.setOtherConfig(TvFunctionManager.Config.ThreeFingerEnable, isChecked ? 1 : 0);設(shè)置三指跟隨
其中1為打開,0為關(guān)閉
//色溫調(diào)節(jié)
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 +
'}';
}
}
//護(hù)眼模式功能
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);//護(hù)眼模式打開
mRkDisplayOutputManager.setBGain(mCurDpy,256);//護(hù)眼模式關(guān)閉
夢派集團(tuán)正在全國招募合作伙伴,歡迎大家來電咨詢。
地址:深圳市寶安區(qū)前進(jìn)二路寶華森國際中心A座3樓
官網(wǎng):www.yueda009.cn
公眾號:夢派集團(tuán)
聯(lián)系人:
陳艷 Candy 電話:158 1386 1033 郵箱: candychen@menpad.com
陳茂林 Annie 電話:135 1099 2891 郵箱:anniechen@menpad.com
王志勇 William 電話:199 2663 3188 郵箱: williamwang@menpad.com
陳春 Sunny 電話:136 4236 3682 郵箱: sunnychen@menpad.com