SetupWizard: Add helpers for multiuser

Change-Id: I37345661e451523ccc571069646054071381358d
This commit is contained in:
cretin45 2015-02-10 12:26:59 -08:00
parent ff2cc6d642
commit 86837945e9
2 changed files with 12 additions and 4 deletions

View File

@ -19,14 +19,12 @@ package com.cyanogenmod.setupwizard.ui;
import android.animation.Animator; import android.animation.Animator;
import android.app.Activity; import android.app.Activity;
import android.app.AppGlobals; import android.app.AppGlobals;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -112,8 +110,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
} catch (Settings.SettingNotFoundException e) { } catch (Settings.SettingNotFoundException e) {
// Continue with setup // Continue with setup
} }
UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE); mIsGuestUser = SetupWizardUtils.isGuestUser(this);
mIsGuestUser = userManager.isGuestUser();
if (mIsGuestUser) { if (mIsGuestUser) {
finishSetup(); finishSetup();
} }

View File

@ -27,6 +27,8 @@ import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
@ -140,6 +142,15 @@ public class SetupWizardUtils {
return true; return true;
} }
public static boolean isGuestUser(Context context) {
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
return userManager.isGuestUser();
}
public static boolean isOwner() {
return UserHandle.getCallingUserHandle().isOwner();
}
public static boolean hasGMS(Context context) { public static boolean hasGMS(Context context) {
return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) != return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) !=
ConnectionResult.SERVICE_MISSING; ConnectionResult.SERVICE_MISSING;