From d2455e36428ebdea4b660ff8dfd824a78676f48b Mon Sep 17 00:00:00 2001 From: ewt45 <79033456+ewt45@users.noreply.github.com> Date: Mon, 27 Nov 2023 14:41:36 +0800 Subject: [PATCH] =?UTF-8?q?exa=E5=8C=85=20compiledsdk=E6=94=B9=E4=B8=BA29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../containerSettings/ConSetOtherArgv.java | 3 +- app/src/main/java/com/example/test.java | 41 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 37318d0e..59ed2499 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { android { namespace 'com.eltechs.ed' - compileSdk 28 + compileSdk 29 defaultConfig { applicationId "com.eltechs.ed" diff --git a/app/src/main/java/com/example/datainsert/exagear/containerSettings/ConSetOtherArgv.java b/app/src/main/java/com/example/datainsert/exagear/containerSettings/ConSetOtherArgv.java index 8f51bb8a..9b01fc3e 100644 --- a/app/src/main/java/com/example/datainsert/exagear/containerSettings/ConSetOtherArgv.java +++ b/app/src/main/java/com/example/datainsert/exagear/containerSettings/ConSetOtherArgv.java @@ -4,8 +4,8 @@ import static android.text.InputType.TYPE_TEXT_VARIATION_NORMAL; import static android.widget.LinearLayout.HORIZONTAL; import static android.widget.LinearLayout.VERTICAL; -import static com.example.datainsert.exagear.RR.getS; import static com.example.datainsert.exagear.RR.dimen.margin8Dp; +import static com.example.datainsert.exagear.RR.getS; import static com.example.datainsert.exagear.RR.getSArr; import static com.example.datainsert.exagear.containerSettings.otherargv.Argument.POS_EARLIER; import static com.example.datainsert.exagear.containerSettings.otherargv.Argument.POS_FRONT; @@ -43,7 +43,6 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** diff --git a/app/src/main/java/com/example/test.java b/app/src/main/java/com/example/test.java index 5fd3227b..067aa272 100644 --- a/app/src/main/java/com/example/test.java +++ b/app/src/main/java/com/example/test.java @@ -1,11 +1,19 @@ package com.example; +import android.annotation.SuppressLint; +import android.app.AlertDialog; import android.content.Context; +import android.media.AudioAttributes; +import android.media.AudioManager; +import android.media.AudioPlaybackCaptureConfiguration; +import android.media.AudioPlaybackConfiguration; import android.os.AsyncTask; +import android.os.Build; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.eltechs.axs.Globals; +import com.eltechs.axs.applicationState.ApplicationStateBase; import com.eltechs.ed.R; import com.eltechs.ed.fragments.ManageContainersFragment; import com.eltechs.ed.guestContainers.GuestContainer; @@ -18,6 +26,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -31,6 +40,38 @@ public test() { } + public static void test_call_audioset(){ + test.setAllowAudioRecord(); + test.viewNowPlayback(); + } + + @SuppressLint("WrongConstant") + public static void setAllowAudioRecord(){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + AudioManager manager = Globals.getAppContext().getSystemService(AudioManager.class); + manager.setAllowedCapturePolicy(AudioAttributes.ALLOW_CAPTURE_BY_ALL); + //这个应该是此时正在播放的音频的设置? +// manager.getActivePlaybackConfigurations(); + } + } + + public static void viewNowPlayback(){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + AudioManager manager = Globals.getAppContext().getSystemService(AudioManager.class); + //这个应该是此时正在播放的音频的设置? + List list = manager.getActivePlaybackConfigurations(); + StringBuilder builder = new StringBuilder(); + for(AudioPlaybackConfiguration c:list){ + AudioAttributes attr = c.getAudioAttributes(); + builder.append("Usage: ").append(attr.getUsage()).append(", AllowedCapturePolicy").append(attr.getAllowedCapturePolicy()).append("\n"); + } + if(list.size()==0) + builder.append("no active playback right now"); + new AlertDialog.Builder(((ApplicationStateBase)Globals.getApplicationState()).getCurrentActivity()) + .setMessage(builder.toString()).show(); + } + } + private void test_get_string_from_context_with_resid(){ int stringId = 0x7f09452; String str = Globals.getAppContext().getString(stringId);