首页
论坛
课程
招聘
[原创]在lineageOS16.0 小米6 上 复现无人直播应用
2021-10-28 11:56 23151

[原创]在lineageOS16.0 小米6 上 复现无人直播应用

2021-10-28 11:56
23151

这是今年五月份时出于好奇研究了一翻.具体原理我也不解释了.直接贴代码.
附件中有所有用到的文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
project frameworks/av/
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 0a4e66566..40b194c4f 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -356,7 +356,7 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
     }
 
     // check calling permissions
-    if (!isTrustedCallingUid(callingUid) && !recordingAllowed(opPackageName, pid, uid)) {
+   /* if (!isTrustedCallingUid(callingUid) && !recordingAllowed(opPackageName, pid, uid)) {
         ALOGE("%s permission denied: recording not allowed for uid %d pid %d",
                 __func__, uid, pid);
         return PERMISSION_DENIED;
@@ -367,7 +367,7 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
         attr->source == AUDIO_SOURCE_VOICE_CALL) &&
         !captureAudioOutputAllowed(pid, uid)) {
         return PERMISSION_DENIED;
-    }
+    }*/
 
     if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed(pid, uid)) {
         return BAD_VALUE;
@@ -398,8 +398,9 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
                 // FIXME: use the same permission as for remote submix for now.
             case AudioPolicyInterface::API_INPUT_MIX_CAPTURE:
                 if (!isTrustedCallingUid(callingUid) && !captureAudioOutputAllowed(pid, uid)) {
-                    ALOGE("getInputForAttr() permission denied: capture not allowed");
-                    status = PERMISSION_DENIED;
+                    ALOGE("getInputForAttr() permission allowed: capture allowed");
+                    //ALOGE("getInputForAttr() permission denied: capture not allowed");
+                    //status = PERMISSION_DENIED;
                 }
                 break;
             case AudioPolicyInterface::API_INPUT_MIX_EXT_POLICY_REROUTE:
 
project frameworks/base/
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index b336e246511..eb9650187be 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -58,6 +58,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import android.hardware.mockcamera.MockCamera;
+
 
 /**
  * The Camera class is used to set image capture settings, start/stop preview,
@@ -275,6 +277,22 @@ public class Camera {
      */
     private static final int CAMERA_FACE_DETECTION_SW = 1;
 
+
+    // Virtual camera
+    private boolean mIsVC = true;
+    private boolean cameraReleased = false;
+
+    MockCamera.PreviewCallback mMockPreviewCallback = new MockCamera.PreviewCallback() {
+        @Override
+        public void onPreviewFrame(byte[] bArr) {
+            if (bArr != null && mPreviewCallback != null) {
+                mPreviewCallback.onPreviewFrame(bArr, Camera.this);
+            }
+        }
+    };
+
+
+
     /**
      * Returns the number of physical cameras available on this device.
      * The return value of this method might change dynamically if the device
@@ -335,6 +353,18 @@ public class Camera {
             throw new RuntimeException("Unknown camera ID");
         }
         _getCameraInfo(cameraId, cameraInfo);
+        String camera_rotation = SystemProperties.get("persist.sys.camera_rotation", "0");
+        Log.d(TAG, "VC get rotation:" + camera_rotation);
+        if ("1".equals(camera_rotation)) {
+            cameraInfo.orientation = 0;
+        } else if ("2".equals(camera_rotation)) {
+            cameraInfo.orientation = 90;
+        } else if ("3".equals(camera_rotation)) {
+            cameraInfo.orientation = 180;
+        } else if ("4".equals(camera_rotation)) {
+            cameraInfo.orientation = 270;
+        }
+        Log.d(TAG, "VC set rotation:" + cameraInfo.orientation);
         IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
         IAudioService audioService = IAudioService.Stub.asInterface(b);
         try {
@@ -528,6 +558,14 @@ public class Camera {
      * @param halVersion The HAL API version this camera device to be opened as.
      */
     private Camera(int cameraId, int halVersion) {
+        String virtual_camera_flag = SystemProperties.get("persist.sys.virtual_camera_flag", "1");
+        Log.d(TAG, "VC new Camera cameraId:" + cameraId + ", halVersion:" + halVersion + ", flag:" + virtual_camera_flag);
+        mIsVC = "0".equals(virtual_camera_flag) ^ true;
+        if (mIsVC) {
+            MockCamera.getInstance().setRefreshRate(60.0d);
+            MockCamera.getInstance().setPreviewCallback(mMockPreviewCallback);
+            MockCamera.getInstance().open();
+        }
         int err = cameraInitVersion(cameraId, halVersion);
         if (checkInitErrors(err)) {
             if (err == -EACCES) {
@@ -617,6 +655,15 @@ public class Camera {
         if(cameraId >= getNumberOfCameras()){
              throw new RuntimeException("Unknown camera ID");
         }
+        String virtual_camera_flag = SystemProperties.get("persist.sys.virtual_camera_flag", "1");
+        mIsVC = true ^ "0".equals(virtual_camera_flag);
+        Log.d(TAG, "VC - call camera open:" + cameraId + ", flag:" + virtual_camera_flag);
+        if (mIsVC) {
+            MockCamera.getInstance().setRefreshRate(60.0d);
+            MockCamera.getInstance().setPreviewCallback(mMockPreviewCallback);
+            MockCamera.getInstance().open();
+        }
+
         int err = cameraInitNormal(cameraId);
         if (checkInitErrors(err)) {
             if (err == -EACCES) {
@@ -696,6 +743,12 @@ public class Camera {
         native_release();
         mFaceDetectionRunning = false;
         releaseAppOps();
+        if (!cameraReleased && mIsVC) {
+            MockCamera.getInstance().release();
+            cameraReleased = true;
+            Log.d(TAG, "VC - release");
+        }
+
     }
 
     /**
@@ -793,7 +846,23 @@ public class Camera {
     /**
      * @hide
      */
-    public native final void setPreviewSurface(Surface surface) throws IOException;
+    public native final void setPreviewSurfaceN(Surface surface) throws IOException;
+
+   
+    public final void setPreviewSurface(Surface surface) throws IOException {
+        if (!mIsVC) {
+            setPreviewSurfaceN(surface);
+            return;
+        }
+        if (surface != null) {
+            Log.d(TAG, "VC-setPreviewSurface VCAA called:" + surface);
+            MockCamera.getInstance().setDisplaySurface(surface);
+        } else {
+            Log.d(TAG, "VC-setPreviewSurface VCAA surface null");
+        }
+        setPreviewSurfaceN(null);
+    }
+
 
     /**
      * Sets the {@link SurfaceTexture} to be used for live preview.
@@ -831,7 +900,23 @@ public class Camera {
      * @throws RuntimeException if release() has been called on this Camera
      *    instance.
      */
-    public native final void setPreviewTexture(SurfaceTexture surfaceTexture) throws IOException;
+    public native final void setPreviewTextureN(SurfaceTexture surfaceTexture) throws IOException;
+
+    public final void setPreviewTexture(SurfaceTexture surfaceTexture) throws IOException {
+        if (!mIsVC) {
+            setPreviewTextureN(surfaceTexture);
+            return;
+        }
+        if (surfaceTexture != null) {
+            Surface surface = new Surface(surfaceTexture);
+            Log.d(TAG, "VC-setPreviewTexture VCAA surfaceTexture:" + surfaceTexture + ", surface:" + surface);
+            MockCamera.getInstance().setDisplaySurface(surface);
+        } else {
+            Log.d(TAG, "VC-setPreviewTexture VCAA surface null");
+        }
+        setPreviewTextureN(null);
+    }
+
 
     /**
      * Callback interface used to deliver copies of preview frames as
@@ -1260,13 +1345,21 @@ public class Camera {
 
             case CAMERA_MSG_RAW_IMAGE:
                 if (mRawImageCallback != null) {
-                    mRawImageCallback.onPictureTaken((byte[])msg.obj, mCamera);
+                    if (mIsVC) {
+                        mRawImageCallback.onPictureTaken(MockCamera.getInstance().getRawImage(), mCamera);
+                    } else {
+                        mRawImageCallback.onPictureTaken((byte[])msg.obj, mCamera);
+                    }
                 }
                 return;
 
             case CAMERA_MSG_COMPRESSED_IMAGE:
                 if (mJpegCallback != null) {
-                    mJpegCallback.onPictureTaken((byte[])msg.obj, mCamera);
+                    if (mIsVC) {
+                        mJpegCallback.onPictureTaken(MockCamera.getInstance().getCompressedImage(), mCamera);
+                    } else {
+                        mJpegCallback.onPictureTaken((byte[])msg.obj, mCamera);
+                    }
                 }
                 return;
 
@@ -1284,13 +1377,21 @@ public class Camera {
                         // Set to oneshot mode again.
                         setHasPreviewCallback(true, false);
                     }
+                    if (!mIsVC){
                     pCb.onPreviewFrame((byte[])msg.obj, mCamera);
+                    }
                 }
                 return;
 
             case CAMERA_MSG_POSTVIEW_FRAME:
-                if (mPostviewCallback != null) {
-                    mPostviewCallback.onPictureTaken((byte[])msg.obj, mCamera);
+                // if (mIsVC) {
+                //mPostviewCallback.onPictureTaken(MockCamera.getInstance().getFrameData(), mCamera);
+                //     return;
+                // }
+
+                 if (mPostviewCallback != null) {
+                    mPostviewCallback.onPictureTaken(MockCamera.getInstance().getFrameData(), mCamera);
+                    // mPostviewCallback.onPictureTaken((byte[])msg.obj, mCamera);
                 }
                 return;
 
@@ -1631,18 +1732,31 @@ public class Camera {
         int msgType = 0;
         if (mShutterCallback != null) {
             msgType |= CAMERA_MSG_SHUTTER;
+            if (mIsVC && mEventHandler != null) {
+                mEventHandler.sendEmptyMessage(CAMERA_MSG_SHUTTER);
+            }
         }
         if (mRawImageCallback != null) {
             msgType |= CAMERA_MSG_RAW_IMAGE;
+            if (mIsVC && mEventHandler != null) {
+                mEventHandler.sendEmptyMessage(CAMERA_MSG_RAW_IMAGE);
+            }
         }
         if (mPostviewCallback != null) {
             msgType |= CAMERA_MSG_POSTVIEW_FRAME;
+            if (mIsVC && mEventHandler != null) {
+                mEventHandler.sendEmptyMessage(CAMERA_MSG_POSTVIEW_FRAME);
+            }
         }
         if (mJpegCallback != null) {
             msgType |= CAMERA_MSG_COMPRESSED_IMAGE;
+            if (mIsVC && mEventHandler != null) {
+                mEventHandler.sendEmptyMessage(CAMERA_MSG_COMPRESSED_IMAGE);
+            }
+        }
+        if (!mIsVC){
+            native_takePicture(msgType);
         }
-
-        native_takePicture(msgType);
         mFaceDetectionRunning = false;
     }
 
@@ -3164,6 +3278,7 @@ public class Camera {
          * @see #setPictureSize(int, int)
          * @see #setJpegThumbnailSize(int, int)
          */
+
         public void setPreviewSize(int width, int height) {
             String v = Integer.toString(width) + "x" + Integer.toString(height);
             set(KEY_PREVIEW_SIZE, v);
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index 4e122ec01ee..99d5d3d0ebf 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -1102,10 +1102,10 @@ static const JNINativeMethod camMethods[] = {
   { "native_release",
     "()V",
     (void*)android_hardware_Camera_release },
-  { "setPreviewSurface",
+  { "setPreviewSurfaceN",
     "(Landroid/view/Surface;)V",
     (void *)android_hardware_Camera_setPreviewSurface },
-  { "setPreviewTexture",
+  { "setPreviewTextureN",
     "(Landroid/graphics/SurfaceTexture;)V",
     (void *)android_hardware_Camera_setPreviewTexture },
   { "setPreviewCallbackSurface",
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index 2c67f3205eb..02e7a7a02ba 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -42,6 +42,7 @@ import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Log;
 import android.util.Pair;
+import android.os.SystemProperties;
 
 import com.android.internal.annotations.GuardedBy;
 
@@ -317,9 +318,21 @@ public class AudioRecord implements AudioRouting
     @SystemApi
     public AudioRecord(AudioAttributes attributes, AudioFormat format, int bufferSizeInBytes,
             int sessionId) throws IllegalArgumentException {
+       
+        AudioAttributes attributes2;
+        String vicam = SystemProperties.get("persist.sys.virtual_camera_flag", "1");
+        if (!"0".equals(vicam)) {
+            Log.d(TAG, "VCAR bufferSizeInBytes:" + bufferSizeInBytes + ",sessionId:" + sessionId + ",attributes:" + attributes.getCapturePreset() + ",format:" + format);
+            Log.d(TAG, "VCAR new AudioRecord audioSource:" + MediaRecorder.AudioSource.REMOTE_SUBMIX);
+            attributes2 = new AudioAttributes.Builder().setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX).addTag(SUBMIX_FIXED_VOLUME).build();
+        }
+        else{
+            attributes2 = attributes;
+        }
+
         mRecordingState = RECORDSTATE_STOPPED;
 
-        if (attributes == null) {
+        if (attributes2 == null) {
             throw new IllegalArgumentException("Illegal null AudioAttributes");
         }
         if (format == null) {
@@ -332,9 +345,9 @@ public class AudioRecord implements AudioRouting
         }
 
         // is this AudioRecord using REMOTE_SUBMIX at full volume?
-        if (attributes.getCapturePreset() == MediaRecorder.AudioSource.REMOTE_SUBMIX) {
+        if (attributes2.getCapturePreset() == MediaRecorder.AudioSource.REMOTE_SUBMIX) {
             final AudioAttributes.Builder filteredAttr = new AudioAttributes.Builder();
-            final Iterator<String> tagsIter = attributes.getTags().iterator();
+            final Iterator<String> tagsIter = attributes2.getTags().iterator();
             while (tagsIter.hasNext()) {
                 final String tag = tagsIter.next();
                 if (tag.equalsIgnoreCase(SUBMIX_FIXED_VOLUME)) {
@@ -344,10 +357,10 @@ public class AudioRecord implements AudioRouting
                     filteredAttr.addTag(tag);
                 }
             }
-            filteredAttr.setInternalCapturePreset(attributes.getCapturePreset());
+            filteredAttr.setInternalCapturePreset(attributes2.getCapturePreset());
             mAudioAttributes = filteredAttr.build();
         } else {
-            mAudioAttributes = attributes;
+            mAudioAttributes = attributes2;
         }
 
         int rate = format.getSampleRate();
@@ -361,7 +374,7 @@ public class AudioRecord implements AudioRouting
             encoding = format.getEncoding();
         }
 
-        audioParamCheck(attributes.getCapturePreset(), rate, encoding);
+        audioParamCheck(attributes2.getCapturePreset(), rate, encoding);
 
         if ((format.getPropertySetMask()
                 & AudioFormat.AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK) != 0) {
@@ -613,8 +626,11 @@ public class AudioRecord implements AudioRouting
                 }
             }
             if (mAttributes == null) {
+                Log.d(TAG, "VCAR create mAttributes:");
+                String vicam = SystemProperties.get("persist.sys.virtual_camera_flag", "1");
+                Log.d(TAG, "VC new build, flag" + vicam);
                 mAttributes = new AudioAttributes.Builder()
-                        .setInternalCapturePreset(MediaRecorder.AudioSource.DEFAULT)
+                        .setInternalCapturePreset("0".equals(vicam) ^ true ? MediaRecorder.AudioSource.REMOTE_SUBMIX : MediaRecorder.AudioSource.DEFAULT)
                         .build();
             }
             try {
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
index 208fb105325..109bb83490d 100644
--- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java
+++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
@@ -101,9 +101,9 @@ public class NetworkMonitor extends StateMachine {
     // Default configuration values for captive portal detection probes.
     // TODO: append a random length parameter to the default HTTPS url.
     // TODO: randomize browser version ids in the default User-Agent String.
-    private static final String DEFAULT_HTTPS_URL     = "https://www.google.com/generate_204";
+    private static final String DEFAULT_HTTPS_URL     = "http://connect.rom.miui.com/generate_204";
     private static final String DEFAULT_HTTP_URL      =
-            "http://connectivitycheck.gstatic.com/generate_204";
+            "https://connect.rom.miui.com/generate_204";
     private static final String DEFAULT_FALLBACK_URL  = "http://www.google.com/gen_204";
     private static final String DEFAULT_OTHER_FALLBACK_URLS =
             "http://play.googleapis.com/generate_204";
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index b67c87e6c41..4571663860e 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -1039,8 +1039,8 @@ public class UsbDeviceManager implements ActivityManagerInternal.ScreenObserver
 
                 // make sure the ADB_ENABLED setting value matches the current state
                 try {
-                    putGlobalSettings(mContentResolver, Settings.Global.ADB_ENABLED,
-                            mAdbEnabled ? 1 : 0);
+                    putGlobalSettings(mContentResolver, Settings.Global.ADB_ENABLED,
+                    mAdbEnabled ? 1 : 0);
                 } catch (SecurityException e) {
                     // If UserManager.DISALLOW_DEBUGGING_FEATURES is on, that this setting can't
                     // be changed.
 
project packages/apps/Settings/
diff --git a/res/values-zh-rCN/cm_strings.xml b/res/values-zh-rCN/cm_strings.xml
index 0c07095e8a..1a39bdef86 100644
--- a/res/values-zh-rCN/cm_strings.xml
+++ b/res/values-zh-rCN/cm_strings.xml
@@ -307,4 +307,15 @@
     <string name="tethering_allow_vpn_upstreams_title">允许客户端使用 VPN</string>
     <string name="tethering_allow_vpn_upstreams_summary">允许热点客户端使用此设备\u2019的 VPN 连接到上游连接</string>
     <string name="network_settings_shortcut_title">移动网络</string>
+    <string name="virtual_camera_disable_flag">虚拟相机功能开关</string>
+    <string name="virtual_camera_disable_flagsummary">开启或关闭虚拟相机功能,立即生效</string>
+    <string name="camera_orientation_0">0</string>
+    <string name="camera_orientation_180">180</string>
+    <string name="camera_orientation_270">270</string>
+    <string name="camera_orientation_90">90</string>
+    <string name="camera_orientation_default">默认</string>
+    <string name="camera_orientation_preference_title">虚拟相机方向</string>
+    <string name="camera_player_type_android">系统</string>
+    <string name="camera_player_type_codec">自解码</string>
+    <string name="camera_player_type_preference_title">虚拟相机播放器</string>
 </resources>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 49959b9334..0f00191372 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -4153,4 +4153,5 @@
     <string name="pref_title_network_details" msgid="7186418845727358964">"网络详情"</string>
     <string name="about_phone_device_name_warning" msgid="8885670415541365348">"您的设备名称会显示在手机上的应用中。此外,当您连接到蓝牙设备或设置 WLAN 热点时,其他人可能也会看到您的设备名称。"</string>
     <string name="devices_title" msgid="7701726109334110391">"设备"</string>
+
 </resources>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 7d0b80d3c0..386d8b0815 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -398,4 +398,18 @@
 
     <!-- Label for settings shortcut: mobile network -->
     <string name="network_settings_shortcut_title">Mobile network</string>
+
+    <!-- Virtual camera -->
+    <string name="virtual_camera_disable_flag">Virtual Camera</string>
+    <string name="virtual_camera_disable_flagsummary">Enable Virtual Camera</string>
+    <string name="camera_orientation_0">0</string>
+    <string name="camera_orientation_180">180</string>
+    <string name="camera_orientation_270">270</string>
+    <string name="camera_orientation_90">90</string>
+    <string name="camera_orientation_default">default</string>
+    <string name="camera_orientation_preference_title">Camera Orientation</string>
+    <string name="camera_player_type_android">android</string>
+    <string name="camera_player_type_codec">codec</string>
+    <string name="camera_player_type_preference_title">Camera Player Type</string>
+
 </resources>
diff --git a/res/values/lineage_arrays.xml b/res/values/lineage_arrays.xml
index 0145438148..13b33b1465 100644
--- a/res/values/lineage_arrays.xml
+++ b/res/values/lineage_arrays.xml
@@ -410,4 +410,28 @@
         <item>@color/storage_color4</item>
     </array>
 
+         <!-- Virtual camera -->
+    <string-array name="camera_rotation_entries">
+        <item>@string/camera_orientation_default</item>
+        <item>@string/camera_orientation_0</item>
+        <item>@string/camera_orientation_90</item>
+        <item>@string/camera_orientation_180</item>
+        <item>@string/camera_orientation_270</item>
+    </string-array>
+    <string-array name="camera_rotation_values">
+        <item>0</item>
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+    </string-array>
+    <string-array name="camera_type_entries">
+        <item>@string/camera_player_type_android</item>
+        <item>@string/camera_player_type_codec</item>
+    </string-array>
+    <string-array name="camera_type_values">
+        <item>0</item>
+        <item>1</item>
+    </string-array>  
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 93f12039ec..36afbc9cdf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10100,4 +10100,5 @@
     <string name="bluetooth_phonebook_access_dialog_title">Allow access to contacts and call log?</string>
     <!-- Bluetooth phonebook permission alert for dialog content [CHAR LIMIT=none] -->
     <string name="bluetooth_phonebook_access_dialog_content">An untrusted Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
+
 </resources>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 8a8d2d4def..cdf9eb7394 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -23,6 +23,20 @@
         android:key="debug_misc_category"
         android:order="100">
 
+        <SwitchPreference
+            android:defaultValue="false"
+            android:title="@string/virtual_camera_disable_flag"
+            android:key="virtual_camera_disable_flag"
+            android:summary="@string/virtual_camera_disable_flagsummary"/>
+        <ListPreference
+            android:persistent="false"
+            android:title="@string/camera_player_type_preference_title"
+            android:key="camera_type"/>
+        <ListPreference
+            android:persistent="false"
+            android:title="@string/camera_orientation_preference_title"
+            android:key="camera_rotation"/>
+
         <Preference
             android:key="development_tools"
             android:icon="@drawable/ic_development"
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index f2011bc612..9c9003a2a8 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -407,6 +407,9 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
             Activity activity, Lifecycle lifecycle, DevelopmentSettingsDashboardFragment fragment,
             BluetoothA2dpConfigStore bluetoothA2dpConfigStore) {
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new DisableVirtualCameraPreferenceController(context));
+        controllers.add(new CameraTypePreferenceController(context, fragment));
+        controllers.add(new CameraRotationPreferenceController(context, fragment));
         controllers.add(new DefaultLaunchPreferenceController(context, "development_tools"));
         controllers.add(new MemoryUsagePreferenceController(context));
         controllers.add(new BugReportPreferenceController(context));

[2022夏季班]《安卓高级研修班(网课)》月薪两万班招生中~

最后于 2021-11-1 10:52 被open[xgc]编辑 ,原因:
上传的附件:
收藏
点赞4
打赏
分享
最新回复 (6)
雪    币: 472
活跃值: 活跃值 (39)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
瓦全heKun 活跃值 2021-10-28 12:04
2
0
求教具体怎么使用
雪    币: 227
活跃值: 活跃值 (308)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
jasonxgw 活跃值 2021-10-31 08:40
3
0
DisableVirtualCameraPreferenceController.java
CameraTypePreferenceController.java
CameraRotationPreferenceController.java
这个三个文件能否提供一下
雪    币: 253
活跃值: 活跃值 (329)
能力值: ( LV7,RANK:100 )
在线值:
发帖
回帖
粉丝
open[xgc] 活跃值 2 2021-11-1 10:53
4
0
jasonxgw DisableVirtualCameraPreferenceController.java CameraTypePreferenceController.java CameraRotationPr ...
嗯。附件己补上
雪    币: 219
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
cczheng 活跃值 2021-11-4 11:42
5
0
大佬好厉害,camera1 验证确实可行。 camera2 还需细细研究
雪    币: 201
活跃值: 活跃值 (26)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
无限经验 活跃值 2022-1-23 09:37
6
0
楼主厉害,这个其他机型能用吗?
雪    币: 244
活跃值: 活跃值 (178)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
数字云信息 活跃值 2022-4-3 20:24
7
0
楼主厉害
游客
登录 | 注册 方可回帖
返回