aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/cyanogenmod/app
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-12-18 09:37:00 -0800
committerRoman Birg <roman@cyngn.com>2015-12-21 10:30:15 -0800
commitcb4a990216b9e0960a6c927651eba8649f8d9619 (patch)
treeeed8e6f238926fa316ea8b60699168620af55262 /src/java/cyanogenmod/app
parentc81519d31be8a2adac3d51f2656bcb1708919e57 (diff)
downloadvendor_cmsdk-cb4a990216b9e0960a6c927651eba8649f8d9619.zip
vendor_cmsdk-cb4a990216b9e0960a6c927651eba8649f8d9619.tar.gz
vendor_cmsdk-cb4a990216b9e0960a6c927651eba8649f8d9619.tar.bz2
Profiles: add isEnabled(); send state changes
Ref: CYNGNOS-1461 Change-Id: Idee9417a2f0b181c8d15cd763859c0a0e581dce6 Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'src/java/cyanogenmod/app')
-rw-r--r--src/java/cyanogenmod/app/IProfileManager.aidl1
-rw-r--r--src/java/cyanogenmod/app/ProfileManager.java64
2 files changed, 28 insertions, 37 deletions
diff --git a/src/java/cyanogenmod/app/IProfileManager.aidl b/src/java/cyanogenmod/app/IProfileManager.aidl
index 21e68cd..091ba55 100644
--- a/src/java/cyanogenmod/app/IProfileManager.aidl
+++ b/src/java/cyanogenmod/app/IProfileManager.aidl
@@ -47,4 +47,5 @@ interface IProfileManager
NotificationGroup getNotificationGroup(in ParcelUuid groupParcelUuid);
void resetAll();
+ boolean isEnabled();
}
diff --git a/src/java/cyanogenmod/app/ProfileManager.java b/src/java/cyanogenmod/app/ProfileManager.java
index fa50067..c211dc0 100644
--- a/src/java/cyanogenmod/app/ProfileManager.java
+++ b/src/java/cyanogenmod/app/ProfileManager.java
@@ -26,12 +26,12 @@ import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.provider.Settings;
import android.util.Log;
import cyanogenmod.app.IProfileManager;
import com.android.internal.R;
+import cyanogenmod.providers.CMSettings;
/**
@@ -68,8 +68,6 @@ public class ProfileManager {
private static final String TAG = "ProfileManager";
- private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled";
-
/**
* <p>Broadcast Action: A new profile has been selected. This can be triggered by the user
* or by calls to the ProfileManagerService / Profile.</p>
@@ -214,9 +212,6 @@ public class ProfileManager {
*/
public static final int PROFILES_STATE_ENABLED = 1;
- // A blank profile that is created to be returned if profiles disabled
- private static Profile mEmptyProfile;
-
private static ProfileManager sProfileManagerInstance;
private ProfileManager(Context context) {
Context appContext = context.getApplicationContext();
@@ -226,7 +221,6 @@ public class ProfileManager {
mContext = context;
}
sService = getService();
- mEmptyProfile = new Profile("EmptyProfile");
}
/**
@@ -253,14 +247,10 @@ public class ProfileManager {
@Deprecated
public void setActiveProfile(String profileName) {
- if (Settings.System.getInt(mContext.getContentResolver(),
- SYSTEM_PROFILES_ENABLED, 1) == 1) {
- // Profiles are enabled, return active profile
- try {
- getService().setActiveProfileByName(profileName);
- } catch (RemoteException e) {
- Log.e(TAG, e.getLocalizedMessage(), e);
- }
+ try {
+ getService().setActiveProfileByName(profileName);
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
}
}
@@ -269,14 +259,10 @@ public class ProfileManager {
* @param profileUuid the {@link UUID} associated with the profile
*/
public void setActiveProfile(UUID profileUuid) {
- if (Settings.System.getInt(mContext.getContentResolver(),
- SYSTEM_PROFILES_ENABLED, 1) == 1) {
- // Profiles are enabled, return active profile
- try {
- getService().setActiveProfile(new ParcelUuid(profileUuid));
- } catch (RemoteException e) {
- Log.e(TAG, e.getLocalizedMessage(), e);
- }
+ try {
+ getService().setActiveProfile(new ParcelUuid(profileUuid));
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
}
}
@@ -285,21 +271,12 @@ public class ProfileManager {
* @return active {@link Profile}
*/
public Profile getActiveProfile() {
- if (Settings.System.getInt(mContext.getContentResolver(),
- SYSTEM_PROFILES_ENABLED, 1) == 1) {
- // Profiles are enabled, return active profile
- try {
- return getService().getActiveProfile();
- } catch (RemoteException e) {
- Log.e(TAG, e.getLocalizedMessage(), e);
- }
- return null;
-
- } else {
- // Profiles are not enabled, return the empty profile
- return mEmptyProfile;
+ try {
+ return getService().getActiveProfile();
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
}
-
+ return null;
}
/**
@@ -555,4 +532,17 @@ public class ProfileManager {
Log.e(TAG, e.getLocalizedMessage(), e);
}
}
+
+ /**
+ * Check if profiles are currently activated in the system
+ * @return whether profiles are enabled
+ */
+ public boolean isProfilesEnabled() {
+ try {
+ return getService().isEnabled();
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getLocalizedMessage(), e);
+ }
+ return false;
+ }
}