Android 系统APK-Camera 开机时自动检测摄像头,有显示相机图标,无就隐藏

路径:frameworks/base/services/core/java/com/android/server/am/UserController.java

设置是否显示摄像头图标(由有无摄像头决定)

++    public void setCamera(boolean state){
++       PackageManager p = mInjector.getContext().getPackageManager();
++        if(state){
++            p.setApplicationEnabledSetting("com.android.camera2", PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
++        }else{
++            p.setApplicationEnabledSetting("com.android.camera2", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
++        }
++    }

检查是否有摄像头

    private void finishUserUnlockedCompleted(UserState uss) {
        final int userId = uss.mHandle.getIdentifier();
        EventLog.writeEvent(EventLogTags.UC_FINISH_USER_UNLOCKED_COMPLETED, userId);

++        int n = android.hardware.Camera.getNumberOfCameras();
++        if (n==0){
++            setCamera(false);
++        }else if(n>0){
++            setCamera(true);
++        }
    }
上一篇:创建vue项目的时候报错,spawn yarn ENOENT


下一篇:Facebook 登录 获取秘钥散列