Skip to content

Commit

Permalink
Added a method to create the profile manually, added a method to adju…
Browse files Browse the repository at this point in the history
…st the volume to the current profile preset.
  • Loading branch information
ltrudu committed Aug 22, 2024
1 parent 283cba3 commit 7de9d25
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hsdemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.zebra.hsdemo"
minSdk 33
targetSdk 34
versionCode 4
versionName "1.3"
versionCode 7
versionName "1.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
4 changes: 4 additions & 0 deletions hsdemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

<queries>
<package android:name="com.symbol.emdk.emdkservice" />
</queries>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
56 changes: 54 additions & 2 deletions hsdemo/src/main/java/com/zebra/hsdemo/EMDKUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,42 @@ public EMDKUtils(Context context)
mContext = context;
}

public void createAudioVolUIProfileToMAXIMUM(String audioProfileName, IResultCallbacks resultCallbacks)
{
mIResultCallbacks = resultCallbacks;
msProfileName = "AudioVolumeMgr-0";
msProfileData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<characteristic type=\"Profile\">\n" +
"<parm name=\"ProfileName\" value=\"" + msProfileName + "\"/>\n" +
" <characteristic version=\"11.6\" type=\"AudioVolUIMgr\">\n" +
" <parm name=\"MuteVibrateState\" value=\"3\" />\n" +
" <parm name=\"CurrentProfileAction\" value=\"1\" />\n" +
" <characteristic type=\"CurrentUIProfile\">\n" +
" <parm name=\"CurrentProfileName\" value=\"MAXIMUM\" />\n" +
" <parm name=\"SetCurrentProfileOption\" value=\"2\" />\n" +
" </characteristic>\n" +
" <parm name=\"UIProfileAction\" value=\"1\" />\n" +
" <characteristic type=\"UIProfile\">\n" +
" <parm name=\"ProfileName\" value=\"MAXIMUM\" />\n" +
" <characteristic type=\"UIProfile-streamconfig\">\n" +
" <parm name=\"STREAM_MUSIC_SPK_LEVEL\" value=\"15,15,15\" />\n" +
" <parm name=\"STREAM_MUSIC_WHS_LEVEL\" value=\"15,15,15\" />\n" +
" <parm name=\"STREAM_MUSIC_BTHS_LEVEL\" value=\"10,15,15\" />\n" +
" <parm name=\"STREAM_MUSIC_HDMI_LEVEL\" value=\"15,15,15\" />\n" +
" <parm name=\"STREAM_RING_SPK_LEVEL\" value=\"7,7,7\" />\n" +
" <parm name=\"STREAM_ALARM_SPK_LEVEL\" value=\"7,7,7\" />\n" +
" <parm name=\"STREAM_VOICECALL_SPK_LEVEL\" value=\"5,5,5\" />\n" +
" <parm name=\"STREAM_VOICECALL_RCVR_LEVEL\" value=\"5,5,5\" />\n" +
" <parm name=\"STREAM_VOICECALL_WHS_LEVEL\" value=\"5,5,5\" />\n" +
" <parm name=\"STREAM_VOICECALL_BTHS_LEVEL\" value=\"15,15,15\" />\n" +
" <parm name=\"STREAM_VVS_SPK_LEVEL\" value=\"10,10,10\" />\n" +
" </characteristic>\n" +
" </characteristic>\n" +
" </characteristic>\n" +
"</characteristic>\n";
processProfile();
}

public void activateVolumeProfile(String audioProfileName, IResultCallbacks resultCallbacks)
{
mIResultCallbacks = resultCallbacks;
Expand All @@ -163,10 +199,26 @@ public void activateVolumeProfile(String audioProfileName, IResultCallbacks resu
"</characteristic>\n";

// initialize profile manager processing
initializeEMDK();
processProfile();
}

public void adjustVolumeToCurrentPreset( IResultCallbacks resultCallbacks)
{
mIResultCallbacks = resultCallbacks;
// Create profile content
msProfileName = "AudioVolumeMgr-2";
msProfileData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<characteristic type=\"Profile\">\n" +
"<parm name=\"ProfileName\" value=\"" + msProfileName + "\"/>\n" +
" <characteristic version=\"11.6\" type=\"AudioVolUIMgr\">\n" +
" <parm name=\"CurrentProfileAction\" value=\"2\" />\n" +
" </characteristic>" +
"</characteristic>\n";
// initialize profile manager processing
processProfile();
}

private void initializeEMDK()
private void processProfile()
{
if(mEMDKManager == null)
{
Expand Down
74 changes: 73 additions & 1 deletion hsdemo/src/main/java/com/zebra/hsdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,27 @@ public void run() {
}
});

findViewById(R.id.btCreateVolumeProfile).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createMaximumAudioProfile();
}
});

findViewById(R.id.btActivateVolumeProfile).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
activateMaximumAudioProfile();
}
});

findViewById(R.id.btAdjustVolumeToPreset).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adjustVolumeToCurrentPreset();
}
});

setButtonVisibility(true);

TextView tvRecordingGain = findViewById(R.id.tvRecordingGain);
Expand Down Expand Up @@ -855,7 +869,65 @@ public void onDebugStatus(String message) {
}
else
{
Toast.makeText(MainActivity.this, "Activate MAXIMUM audio profile/n is already running", Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, "Please wait.\nProfileManager is already running.", Toast.LENGTH_SHORT).show();
}
}

private void createMaximumAudioProfile()
{
if(emdkUtils == null) {
emdkUtils = new EMDKUtils(this);
emdkUtils.createAudioVolUIProfileToMAXIMUM("MAXIMUM", new EMDKUtils.IResultCallbacks() {
@Override
public void onSuccess(String message, String resultXML) {
Toast.makeText(MainActivity.this, "Profile created with success", Toast.LENGTH_LONG).show();
emdkUtils = null;
}

@Override
public void onError(String message, String resultXML) {
Toast.makeText(MainActivity.this, "Error creating profile.\nCheck logcat.", Toast.LENGTH_LONG).show();
emdkUtils = null;
}

@Override
public void onDebugStatus(String message) {

}
});
}
else
{
Toast.makeText(MainActivity.this, "Please wait.\nProfileManager is already running.", Toast.LENGTH_SHORT).show();
}
}

private void adjustVolumeToCurrentPreset()
{
if(emdkUtils == null) {
emdkUtils = new EMDKUtils(this);
emdkUtils.adjustVolumeToCurrentPreset(new EMDKUtils.IResultCallbacks() {
@Override
public void onSuccess(String message, String resultXML) {
Toast.makeText(MainActivity.this, "Volume adjusted with success", Toast.LENGTH_LONG).show();
emdkUtils = null;
}

@Override
public void onError(String message, String resultXML) {
Toast.makeText(MainActivity.this, "Error adjusting volume.\nCheck logcat.", Toast.LENGTH_LONG).show();
emdkUtils = null;
}

@Override
public void onDebugStatus(String message) {

}
});
}
else
{
Toast.makeText(MainActivity.this, "Please wait.\nProfileManager is already running.", Toast.LENGTH_SHORT).show();
}
}
}
26 changes: 26 additions & 0 deletions hsdemo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@
android:layout_marginBottom="20dp"
android:background="@android:color/darker_gray" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/btCreateVolumeProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Create audio profile MAXIMUM" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -217,6 +230,19 @@
android:text="Activate audio profile MAXIMUM" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/btAdjustVolumeToPreset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Adjust Volume to current preset" />
</LinearLayout>

</LinearLayout>

<TextView
Expand Down

0 comments on commit 7de9d25

Please sign in to comment.