当前位置: 首页 > wzjs >正文

网站页面效果图怎么做北京网络公司有哪些

网站页面效果图怎么做,北京网络公司有哪些,网站建设代理怎么做,网站建设编辑部A13中,可以要求做一个开关来控制摄像头是否可用,约束所有使用摄像头的应用。思路:设置中增加开关设置一个属性值,在摄像头调用实现层增该值判断即可 一 开关的开发: 设置-安全中增加开关选项 代码部分&#x…

A13中,可以要求做一个开关来控制摄像头是否可用,约束所有使用摄像头的应用。思路:设置中增加开关设置一个属性值,在摄像头调用实现层增该值判断即可        

一 开关的开发:

设置-安全中增加开关选项

代码部分:

Settings/res/xml/security_dashboard_settings.xml

//........忽略代码  <Preferenceandroid:order="100"android:key="security_advanced_settings"android:title="@string/security_advanced_settings"android:summary="@string/summary_placeholder"android:fragment="com.android.settings.security.SecurityAdvancedSettings"settings:controller="com.android.settings.security.SecurityAdvancedSettingsController"settings:keywords="@string/security_advanced_settings_keywords" /><Preferenceandroid:order="90"android:title="@string/apk_install_setting"><intentandroid:targetPackage="com.android.settings"android:targetClass="com.android.settings.security.ApkInstallActivity" /></Preference>+ <Preference+    android:order="80"+    android:title="@string/custom_function_control_setting">+        <intent+        android:targetPackage="com.android.settings"+      +android:targetClass="com.android.settings.security.CustomFunctionSettingActivity" />+   </Preference> 
</PreferenceScreen>

 新增界面,如下,自定义属性字段,可以参考上一篇文章Android SystemProperties 读写机制详解和案例使用 。就是使用开关组件读写属性

package com.android.settings.security;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.app.Activity;
import java.io.IOException;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.android.settings.R;
import android.provider.Settings;
import android.widget.Toast;
import android.text.TextUtils;
import android.os.SystemProperties;import android.widget.CompoundButton;
import android.content.Context;import android.widget.Switch;/*** 自定义功能开关*/
public class CustomFunctionSettingActivity extends Activity implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {private Switch cameraSwbtn;    private static final String CAMERA_ENABLE_KEY = "persist.sys.flyscale.cam"; private Context mContext;@Overrideprotected void onCreate(Bundle savedInstanceState) {mContext = this;super.onCreate(savedInstanceState);setContentView(R.layout.custom_function_control);cameraSwbtn = findViewById(R.id.swbtn_camera);cameraSwbtn.setOnCheckedChangeListener(this);String propValue = SystemProperties.get(CAMERA_ENABLE_KEY, "1"); // 默认启用// String cameraEnable = Settings.Global.getString(getContentResolver(), Settings.Global.CUSTOM_FUNCTION_CAMERA_ENABLE);if ("1".equals(propValue)) {cameraSwbtn.setChecked(true);}else {cameraSwbtn.setChecked(false);}	cameraSwbtn.setOnClickListener(this);}@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {// switch (buttonView.getId()) {//     case R.id.toggle_button://         Toast.makeText(this, "toggle state changed : " + isChecked, Toast.LENGTH_SHORT).show();//         break;//     case R.id.switch_button://         Toast.makeText(this, "wlan state changed : " + isChecked, Toast.LENGTH_SHORT).show();//         break;//     default://         Toast.makeText(this, "no state changed", Toast.LENGTH_SHORT).show();// }if (buttonView== null) {return;}}@Overridepublic void onClick(View v) {if (  v == cameraSwbtn) {boolean isChecked = cameraSwbtn.isChecked();saveValue(isChecked);if (isChecked) {Toast.makeText(mContext, R.string.custom_function_camera_change_enable,Toast.LENGTH_SHORT).show();}else {Toast.makeText(mContext, R.string.custom_function_camera_change_disable,Toast.LENGTH_SHORT).show();}}}private void saveValue(boolean enabled) {String  value = "0";if (enabled) {value = "1";}else {value = "0";}try {SystemProperties.set(CAMERA_ENABLE_KEY, enabled ? "1" : "0");} catch (Exception e) {Log.e("CustomFunction", "Failed to set property", e);}// Settings.Global.putString(getContentResolver(), Settings.Global.CUSTOM_FUNCTION_CAMERA_ENABLE,value);}
}

布局如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:text="@string/custom_function_control_setting"android:textSize="24dp"android:layout_margin="10dp"android:gravity="center"android:textColor="@android:color/black"android:layout_width="match_parent"android:layout_height="wrap_content"/>
<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center_vertical"android:layout_marginTop="30dp"android:orientation="horizontal"><TextViewandroid:textSize="20dp"android:layout_marginLeft="10dp"android:text="@string/custom_function_control_camera_title"android:gravity="center"android:textColor="@android:color/black"android:layout_width="wrap_content"android:layout_height="wrap_content"/>            <View android:layout_height="1dp"android:layout_weight="1"android:layout_width="0dp"/><Switchandroid:id="@+id/swbtn_camera"android:layout_width="wrap_content"android:layout_height="wrap_content"android:switchMinWidth="0dp"android:layout_marginLeft="10dp"android:layout_marginRight="20dp"android:showText="false"android:switchPadding="10dp"android:textOff="close"android:textOn="open" /></LinearLayout></LinearLayout>

二 摄像头控制逻辑添加:

//framework/av/services/camera/libcameraservice/CameraService.cpp 下/*** 控制摄像头开关是否允许使用*/const bool USING_CAMERA_ENABLE_LOCK = false;。。。。。。。。。。。。忽略代码
Status CameraService::connectDevice(const sp<hardware::camera2::ICameraDeviceCallbacks>& cameraCb,const String16& cameraId,const String16& clientPackageName,const std::optional<String16>& clientFeatureId,int clientUid, int oomScoreOffset, int targetSdkVersion,/*out*/sp<hardware::camera2::ICameraDeviceUser>* device) {ATRACE_CALL();Status ret = Status::ok();String8 id = String8(cameraId);sp<CameraDeviceClient> client = nullptr;String16 clientPackageNameAdj = clientPackageName;int callingPid = CameraThreadState::getCallingPid();bool systemNativeClient = false;if (doesClientHaveSystemUid() && (clientPackageNameAdj.size() == 0)) {std::string systemClient =StringPrintf("client.pid<%d>", CameraThreadState::getCallingPid());clientPackageNameAdj = String16(systemClient.c_str());systemNativeClient = true;}if (oomScoreOffset < 0) {String8 msg =String8::format("Cannot increase the priority of a client %s pid %d for ""camera id %s", String8(clientPackageNameAdj).string(), callingPid,id.string());ALOGE("%s: %s", __FUNCTION__, msg.string());return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string());}+  if (USING_CAMERA_ENABLE_LOCK) {+      if (!isFlyscaleCameraEnabled()) {+          String8 msg =+              String8::format("flyscale camera not allow,Camera disabled by device +policy");+       ALOGE("%s: %s", __FUNCTION__, msg.string());+       return STATUS_ERROR(ERROR_DISABLED, msg.string());+       }++   }if (CameraServiceProxyWrapper::isCameraDisabled()) {String8 msg =String8::format("Camera disabled by device policy");ALOGE("%s: %s", __FUNCTION__, msg.string());return STATUS_ERROR(ERROR_DISABLED, msg.string());}// enforce system camera permissionsif (oomScoreOffset > 0 &&!hasPermissionsForSystemCamera(callingPid, CameraThreadState::getCallingUid())) {String8 msg =String8::format("Cannot change the priority of a client %s pid %d for ""camera id %s without SYSTEM_CAMERA permissions",String8(clientPackageNameAdj).string(), callingPid, id.string());ALOGE("%s: %s", __FUNCTION__, msg.string());return STATUS_ERROR(ERROR_PERMISSION_DENIED, msg.string());}
。。。。。。。。。。。。。忽略代码

OVER~

http://www.dtcms.com/wzjs/556010.html

相关文章:

  • 网站建设费用要分摊多长时间漂亮大气网站
  • 秦皇岛建设网站官网9377页游官网
  • 化妆品的网站建设深圳做网站公司有哪些企业
  • 个人建设网站教程订餐网站系统建设方案
  • 广西网站设计公司石家庄城乡建设厅网站
  • 做网站有兼职吗国家工商信息公示系统
  • 中海建筑建设有限公司网站建设网站怎样挣钱
  • 做外贸生意在哪个网站seo优化推荐
  • 做的网站有营销效果吗爱站工具包下载
  • 温州建网站公司哪家好做一个小程序要多少钱
  • 东营市住房和城乡建设管理局网站圣矢网络重庆网站建设优化推广公司
  • 网站可信度验证太原做网站公司运营
  • 南宁百度网站建设公司iis wordpress安装教程
  • 设计素材网站黄金烤肠做网站在哪里申请
  • 一个网站的建设流程图做网站注册验证码
  • 为什么公司要做网站wordpress功能图
  • 金华市建设技工学校教育培训网站优酷 嵌入 wordpress
  • 番禺网站制作哪里有网站推广策划的思路包括哪些内容
  • 东莞网站推广哪家好网站添加链接
  • 明薇通网站建设价格wordpress如何安装主题
  • redis做网站莒县建设局网站
  • 网站建设类文章要发多少片榆林建设网站
  • 怎么做ps4的视频网站wordpress手机验证注册
  • 做的网站怎么上传到网上运行广告宣传片公司
  • 网站备案拍照背景家居seo整站优化方案
  • 外贸网站推广软件上海网站建设口碑最好的公司
  • 莱阳有网站建设推广的吗旅游网站排名前十
  • 万网主机 网站重做网游开发成本
  • 东莞网站优化关键词费用h5小游戏制作教程
  • 上海网站制作多少钱智能网站建设公司