diff options
author | Matt Garnes <matt@cyngn.com> | 2015-09-05 14:25:07 -0700 |
---|---|---|
committer | Raj Yengisetty <rajesh@cyngn.com> | 2015-09-08 17:28:20 -0700 |
commit | eabd57572113efd495df052a3694442d0915f313 (patch) | |
tree | b0dd6f7e3c28a4fd4c31beff4ee4ab5d623e8b0c /cm/lib/main | |
parent | a458122384e38b638eae10f9f670b7f5345521b8 (diff) | |
download | vendor_cmsdk-eabd57572113efd495df052a3694442d0915f313.zip vendor_cmsdk-eabd57572113efd495df052a3694442d0915f313.tar.gz vendor_cmsdk-eabd57572113efd495df052a3694442d0915f313.tar.bz2 |
Add Broadcast action and query API for AudioSource.HOTWORD.
- Add ACTION_HOTWORD_INPUT_CHANGED broadcast action and related extras.
- Add getCurrentHotwordPackageName() API to SettingsManager to query the
current package name of the application that controls the HOTWORD
input.
- Rename SettingsManager to PartnerInterface.
Change-Id: I5987499cd32908c47a7e8e95d644c483dc32914c
Diffstat (limited to 'cm/lib/main')
-rw-r--r-- | cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java (renamed from cm/lib/main/java/org/cyanogenmod/platform/internal/SettingsManagerService.java) | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/SettingsManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java index ae50755..5cad50f 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/SettingsManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.media.IAudioService; import android.os.IBinder; import android.os.IPowerManager; @@ -33,8 +34,9 @@ import android.telephony.TelephonyManager; import android.util.Log; import com.android.server.SystemService; import cyanogenmod.app.CMContextConstants; -import cyanogenmod.app.ISettingsManager; -import cyanogenmod.app.SettingsManager; +import cyanogenmod.app.IPartnerInterface; +import cyanogenmod.app.PartnerInterface; +import cyanogenmod.media.MediaRecorder; import java.io.ByteArrayInputStream; import java.security.PublicKey; @@ -44,18 +46,19 @@ import java.security.cert.X509Certificate; import java.security.interfaces.RSAPublicKey; /** {@hide} */ -public class SettingsManagerService extends SystemService { +public class PartnerInterfaceService extends SystemService { private static final String TAG = "CMSettingsService"; private Context mContext; private TelephonyManager mTelephonyManager; private INotificationManager mNotificationManager; + private IAudioService mAudioService; - public SettingsManagerService(Context context) { + public PartnerInterfaceService(Context context) { super(context); mContext = context; - publishBinderService(CMContextConstants.CM_SETTINGS_SERVICE, mService); + publishBinderService(CMContextConstants.CM_PARTNER_INTERFACE, mService); } @Override @@ -64,15 +67,17 @@ public class SettingsManagerService extends SystemService { mContext.getSystemService(Context.TELEPHONY_SERVICE); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); + IBinder b = ServiceManager.getService(android.content.Context.AUDIO_SERVICE); + mAudioService = IAudioService.Stub.asInterface(b); } private void enforceModifyNetworkSettingsPermission() { - mContext.enforceCallingOrSelfPermission(SettingsManager.MODIFY_NETWORK_SETTINGS_PERMISSION, + mContext.enforceCallingOrSelfPermission(PartnerInterface.MODIFY_NETWORK_SETTINGS_PERMISSION, "You do not have permissions to change system network settings."); } private void enforceModifySoundSettingsPermission() { - mContext.enforceCallingOrSelfPermission(SettingsManager.MODIFY_SOUND_SETTINGS_PERMISSION, + mContext.enforceCallingOrSelfPermission(PartnerInterface.MODIFY_SOUND_SETTINGS_PERMISSION, "You do not have permissions to change system sound settings."); } @@ -81,7 +86,12 @@ public class SettingsManagerService extends SystemService { "You do not have permissions to shut down the device."); } - private final IBinder mService = new ISettingsManager.Stub() { + private void enforceCaptureHotwordPermission() { + mContext.enforceCallingOrSelfPermission(MediaRecorder.CAPTURE_AUDIO_HOTWORD_PERMISSION, + "You do not have permission to query the hotword input package name."); + } + + private final IBinder mService = new IPartnerInterface.Stub() { @Override public void setAirplaneModeEnabled(boolean enabled) { @@ -148,6 +158,15 @@ public class SettingsManagerService extends SystemService { restoreCallingIdentity(token); return success; } + + @Override + public String getCurrentHotwordPackageName() { + enforceCaptureHotwordPermission(); + long token = clearCallingIdentity(); + String packageName = getHotwordPackageNameInternal(); + restoreCallingIdentity(token); + return packageName; + } }; private void setAirplaneModeEnabledInternal(boolean enabled) { @@ -183,13 +202,13 @@ public class SettingsManagerService extends SystemService { ContentResolver contentResolver = mContext.getContentResolver(); int zenModeValue = -1; switch(mode) { - case SettingsManager.ZEN_MODE_IMPORTANT_INTERRUPTIONS: + case PartnerInterface.ZEN_MODE_IMPORTANT_INTERRUPTIONS: zenModeValue = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; break; - case SettingsManager.ZEN_MODE_OFF: + case PartnerInterface.ZEN_MODE_OFF: zenModeValue = Settings.Global.ZEN_MODE_OFF; break; - case SettingsManager.ZEN_MODE_NO_INTERRUPTIONS: + case PartnerInterface.ZEN_MODE_NO_INTERRUPTIONS: zenModeValue = Settings.Global.ZEN_MODE_NO_INTERRUPTIONS; break; default: @@ -211,5 +230,15 @@ public class SettingsManagerService extends SystemService { } return true; } + + public String getHotwordPackageNameInternal() { + String packageName = null; + try { + packageName = mAudioService.getCurrentHotwordInputPackageName(); + } catch (RemoteException e) { + Log.e(TAG, "getHotwordPackageName() failed."); + } + return packageName; + } } |