[高通SDM450][Android9.0]CTA认证--去掉录音功能

文章目录

    • 开发平台基本信息
    • 问题描述
    • 解决方法

开发平台基本信息

芯片: SDM450
版本: Android 9.0
kernel: msm-4.9

问题描述

设备在进行入网认证的时候,公司为了尽快拿到入网证书,会将一些不必要的功能砍掉,这样实验室就不会去测试这些功能,就能少掉很多不必要的麻烦,而录音功能就是个不必要的功能。所以,在系统里面将录音功能移除掉,让实验室无法调用录音功能即可。

解决方法

diff --git a/frameworks/av/media/libmediaplayerservice/MediaRecorderClient.cpp b/frameworks/av/media/libmediaplayerservice/MediaRecorderClient.cpp
index 09be2f4..9fa2641 100644
--- a/frameworks/av/media/libmediaplayerservice/MediaRecorderClient.cpp
+++ b/frameworks/av/media/libmediaplayerservice/MediaRecorderClient.cpp
@@ -49,7 +49,8 @@ const char* recordAudioPermission = "android.permission.RECORD_AUDIO";
 
 static bool checkPermission(const char* permissionString) {
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
-    bool ok = checkCallingPermission(String16(permissionString));
+   // bool ok = checkCallingPermission(String16(permissionString));
+    bool ok = false;
     if (!ok) ALOGE("Request requires %s", permissionString);
     return ok;
 }
diff --git a/frameworks/base/media/java/android/media/AudioRecord.java b/frameworks/base/media/java/android/media/AudioRecord.java
index 4356296..de8b41a 100644
--- a/frameworks/base/media/java/android/media/AudioRecord.java
+++ b/frameworks/base/media/java/android/media/AudioRecord.java
@@ -275,18 +275,8 @@ public class AudioRecord implements AudioRouting
     public AudioRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat,
             int bufferSizeInBytes)
     throws IllegalArgumentException {
-        this((new AudioAttributes.Builder())
-                    .setInternalCapturePreset(audioSource)
-                    .build(),
-                (new AudioFormat.Builder())
-                    .setChannelMask(getChannelMaskFromLegacyConfig(channelConfig,
-                                        true/*allow legacy configurations*/))
-                    .setEncoding(audioFormat)
-                    .setSampleRate(sampleRateInHz)
-                    .build(),
-                bufferSizeInBytes,
-                AudioManager.AUDIO_SESSION_ID_GENERATE);
-    }
+
+   }
 
     /**
      * @hide
@@ -981,7 +971,10 @@ public class AudioRecord implements AudioRouting
      */
     public void startRecording()
     throws IllegalStateException {
-        android.util.SeempLog.record(70);
+          throw new IllegalStateException("startRecording() called on an "
+                    + "uninitialized AudioRecord.");
+
+      /*  android.util.SeempLog.record(70);
         if (mState != STATE_INITIALIZED) {
             throw new IllegalStateException("startRecording() called on an "
                     + "uninitialized AudioRecord.");
@@ -994,6 +987,7 @@ public class AudioRecord implements AudioRouting
                 mRecordingState = RECORDSTATE_RECORDING;
             }
         }
+       */
     }
 
     /**
diff --git a/frameworks/base/media/java/android/media/MediaRecorder.java b/frameworks/base/media/java/android/media/MediaRecorder.java
index c5a16c0..6c31ba0 100755
--- a/frameworks/base/media/java/android/media/MediaRecorder.java
+++ b/frameworks/base/media/java/android/media/MediaRecorder.java
@@ -847,7 +847,9 @@ public class MediaRecorder
      */
     public void prepare() throws IllegalStateException, IOException
     {
-        if (mPath != null) {
+
+          throw new IOException("No valid output file");
+       /* if (mPath != null) {
             RandomAccessFile file = new RandomAccessFile(mPath, "rws");
             try {
                 _setOutputFile(file.getFD(), 0, 0);
@@ -861,6 +863,7 @@ public class MediaRecorder
         }
 
         _prepare();
+        */
     }
 
     /**
diff --git a/frameworks/base/media/jni/android_media_MediaCodec.cpp b/frameworks/base/media/jni/android_media_MediaCodec.cpp
index 810996e..b471f19 100644
--- a/frameworks/base/media/jni/android_media_MediaCodec.cpp
+++ b/frameworks/base/media/jni/android_media_MediaCodec.cpp
@@ -1168,7 +1168,7 @@ static void android_media_MediaCodec_start(JNIEnv *env, jobject thiz) {
     ALOGV("android_media_MediaCodec_start");
 
     sp codec = getMediaCodec(env, thiz);
-
+   /*
     if (codec == NULL) {
         throwExceptionAsNecessary(env, INVALID_OPERATION);
         return;
@@ -1177,6 +1177,8 @@ static void android_media_MediaCodec_start(JNIEnv *env, jobject thiz) {
     status_t err = codec->start();
 
     throwExceptionAsNecessary(env, err, ACTION_CODE_FATAL, "start failed");
+   */   
+
 }
 
 static void android_media_MediaCodec_stop(JNIEnv *env, jobject thiz) {
diff --git a/frameworks/base/media/jni/android_media_MediaRecorder.cpp b/frameworks/base/media/jni/android_media_MediaRecorder.cpp
index 922ad79..7a83dc6 100644
--- a/frameworks/base/media/jni/android_media_MediaRecorder.cpp
+++ b/frameworks/base/media/jni/android_media_MediaRecorder.cpp
@@ -386,7 +386,7 @@ android_media_MediaRecorder_start(JNIEnv *env, jobject thiz)
 {
     ALOGV("start");
     sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
-    process_media_recorder_call(env, mr->start(), "java/lang/RuntimeException", "start failed.");
+   // process_media_recorder_call(env, mr->start(), "java/lang/RuntimeException", "start failed.");
 }
 
 static void
 

你可能感兴趣的:(CTA认证-A9,Android9.0,framework,Android9.0,CTA,去掉录音功能,入网认证)