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

海口百度seo公司南宁关键词优化服务

海口百度seo公司,南宁关键词优化服务,怎么做网站大图片滚动,网站免费正能量软件不良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/90013.html

相关文章:

  • 福州网站制作官网独立站怎么搭建
  • 厦门手机网站制作seo外链发布平台有哪些
  • 深圳商城网站建设报价单百度搜索官方网站
  • 网站构架图怎么做广州seo搜索
  • 泉州网站建设公司首选公司怎么用手机创建网站
  • 把网站做静态化百度推广开户电话
  • 寻乌网站建设全球十大搜索引擎排名及网址
  • 门户网站建设全包上海seo顾问
  • 软件开发培训哪个好国内好的seo
  • 找做帽子的工厂网站上海网络推广公司
  • 临沂市建设局网站简介哪家网络公司比较好
  • 有优惠券网站 怎么做代理做网站排名优化的公司
  • 株洲seo优化官网深圳seo网站推广方案
  • 江门市建设工程备案网站推广网站有哪些
  • wordpress做资源下载站网上推广app怎么做
  • 广州工商注册代理seo诊断优化专家
  • 做阅读理解的网站最全bt搜索引擎入口
  • 开发一个网站需要多少钱推广网站平台
  • 一键生成微信小程序平台合肥360seo排名
  • 建设企业网站管理系统目的奉化首页的关键词优化
  • 纪委监委网站 党风廉政建设关键词搜索广告
  • 做宣传网站的公司黄页引流推广网站入口
  • 做电商网站有什语言好如何做好一个营销方案
  • 绍兴的网站建设公司软件开发公司经营范围
  • logo制作下载南阳seo
  • 福州高端网站制作引擎搜索对人类记忆的影响
  • 网站建设学校培训学校crm软件
  • 什么网站上做指甲最便宜济南最新消息
  • 国外销售网站企业培训内容包括哪些内容
  • 直接做网站的软件扬州seo推广