Search in sources :

Example 56 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by crdroidandroid.

the class TrustManagerService method refreshAgentList.

void refreshAgentList(int userIdOrAll) {
    if (DEBUG)
        Slog.d(TAG, "refreshAgentList(" + userIdOrAll + ")");
    if (!mTrustAgentsCanRun) {
        return;
    }
    if (userIdOrAll != UserHandle.USER_ALL && userIdOrAll < UserHandle.USER_SYSTEM) {
        Log.e(TAG, "refreshAgentList(userId=" + userIdOrAll + "): Invalid user handle," + " must be USER_ALL or a specific user.", new Throwable("here"));
        userIdOrAll = UserHandle.USER_ALL;
    }
    PackageManager pm = mContext.getPackageManager();
    List<UserInfo> userInfos;
    if (userIdOrAll == UserHandle.USER_ALL) {
        userInfos = mUserManager.getUsers(true);
    } else {
        userInfos = new ArrayList<>();
        userInfos.add(mUserManager.getUserInfo(userIdOrAll));
    }
    LockPatternUtils lockPatternUtils = mLockPatternUtils;
    ArraySet<AgentInfo> obsoleteAgents = new ArraySet<>();
    obsoleteAgents.addAll(mActiveAgents);
    for (UserInfo userInfo : userInfos) {
        if (userInfo == null || userInfo.partial || !userInfo.isEnabled() || userInfo.guestToRemove)
            continue;
        if (!userInfo.supportsSwitchToByUser())
            continue;
        if (!StorageManager.isUserKeyUnlocked(userInfo.id))
            continue;
        if (!mActivityManager.isUserRunning(userInfo.id))
            continue;
        if (!lockPatternUtils.isSecure(userInfo.id))
            continue;
        if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id))
            continue;
        DevicePolicyManager dpm = lockPatternUtils.getDevicePolicyManager();
        int disabledFeatures = dpm.getKeyguardDisabledFeatures(null, userInfo.id);
        final boolean disableTrustAgents = (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
        List<ComponentName> enabledAgents = lockPatternUtils.getEnabledTrustAgents(userInfo.id);
        if (enabledAgents == null) {
            continue;
        }
        List<ResolveInfo> resolveInfos = resolveAllowedTrustAgents(pm, userInfo.id);
        for (ResolveInfo resolveInfo : resolveInfos) {
            ComponentName name = getComponentName(resolveInfo);
            if (!enabledAgents.contains(name))
                continue;
            if (disableTrustAgents) {
                List<PersistableBundle> config = dpm.getTrustAgentConfiguration(null, /* admin */
                name, userInfo.id);
                // Disable agent if no features are enabled.
                if (config == null || config.isEmpty())
                    continue;
            }
            AgentInfo agentInfo = new AgentInfo();
            agentInfo.component = name;
            agentInfo.userId = userInfo.id;
            if (!mActiveAgents.contains(agentInfo)) {
                agentInfo.label = resolveInfo.loadLabel(pm);
                agentInfo.icon = resolveInfo.loadIcon(pm);
                agentInfo.settings = getSettingsComponentName(pm, resolveInfo);
                agentInfo.agent = new TrustAgentWrapper(mContext, this, new Intent().setComponent(name), userInfo.getUserHandle());
                mActiveAgents.add(agentInfo);
            } else {
                obsoleteAgents.remove(agentInfo);
            }
        }
    }
    boolean trustMayHaveChanged = false;
    for (int i = 0; i < obsoleteAgents.size(); i++) {
        AgentInfo info = obsoleteAgents.valueAt(i);
        if (userIdOrAll == UserHandle.USER_ALL || userIdOrAll == info.userId) {
            if (info.agent.isManagingTrust()) {
                trustMayHaveChanged = true;
            }
            info.agent.destroy();
            mActiveAgents.remove(info);
        }
    }
    if (trustMayHaveChanged) {
        if (userIdOrAll == UserHandle.USER_ALL) {
            updateTrustAll();
        } else {
            updateTrust(userIdOrAll, 0);
        }
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ArraySet(android.util.ArraySet) LockPatternUtils(com.android.internal.widget.LockPatternUtils) UserInfo(android.content.pm.UserInfo) Intent(android.content.Intent) ResolveInfo(android.content.pm.ResolveInfo) PersistableBundle(android.os.PersistableBundle) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 57 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by crdroidandroid.

the class SyncOperationTest method testConversionToExtras.

@SmallTest
public void testConversionToExtras() {
    Account account1 = new Account("account1", "type1");
    Bundle b1 = new Bundle();
    b1.putParcelable("acc", account1);
    b1.putString("str", "String");
    SyncOperation op1 = new SyncOperation(account1, 0, 1, "foo", 0, SyncOperation.REASON_PERIODIC, "authority1", b1, false);
    PersistableBundle pb = op1.toJobInfoExtras();
    SyncOperation op2 = SyncOperation.maybeCreateFromJobExtras(pb);
    assertTrue("Account fields in extras not persisted.", account1.equals(op2.extras.get("acc")));
    assertTrue("Fields in extras not persisted", "String".equals(op2.extras.getString("str")));
}
Also used : Account(android.accounts.Account) PersistableBundle(android.os.PersistableBundle) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 58 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by crdroidandroid.

the class PhoneNumberUtils method isVoiceMailNumber.

/**
     * isVoiceMailNumber: checks a given number against the voicemail
     *   number provided by the RIL and SIM card. The caller must have
     *   the READ_PHONE_STATE credential.
     *
     * @param context {@link Context}.
     * @param subId the subscription id of the SIM.
     * @param number the number to look up.
     * @return true if the number is in the list of voicemail. False
     * otherwise, including if the caller does not have the permission
     * to read the VM number.
     * @hide
     */
public static boolean isVoiceMailNumber(Context context, int subId, String number) {
    String vmNumber, mdn;
    try {
        final TelephonyManager tm;
        if (context == null) {
            tm = TelephonyManager.getDefault();
            if (DBG)
                log("isVoiceMailNumber: default tm");
        } else {
            tm = TelephonyManager.from(context);
            if (DBG)
                log("isVoiceMailNumber: tm from context");
        }
        vmNumber = tm.getVoiceMailNumber(subId);
        mdn = tm.getLine1Number(subId);
        if (DBG)
            log("isVoiceMailNumber: mdn=" + mdn + ", vmNumber=" + vmNumber + ", number=" + number);
    } catch (SecurityException ex) {
        if (DBG)
            log("isVoiceMailNumber: SecurityExcpetion caught");
        return false;
    }
    // Strip the separators from the number before comparing it
    // to the list.
    number = extractNetworkPortionAlt(number);
    if (TextUtils.isEmpty(number)) {
        if (DBG)
            log("isVoiceMailNumber: number is empty after stripping");
        return false;
    }
    // check if the carrier considers MDN to be an additional voicemail number
    boolean compareWithMdn = false;
    if (context != null) {
        CarrierConfigManager configManager = (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        if (configManager != null) {
            PersistableBundle b = configManager.getConfigForSubId(subId);
            if (b != null) {
                compareWithMdn = b.getBoolean(CarrierConfigManager.KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL);
                if (DBG)
                    log("isVoiceMailNumber: compareWithMdn=" + compareWithMdn);
            }
        }
    }
    if (compareWithMdn) {
        if (DBG)
            log("isVoiceMailNumber: treating mdn as additional vm number");
        return compare(number, vmNumber) || compare(number, mdn);
    } else {
        if (DBG)
            log("isVoiceMailNumber: returning regular compare");
        return compare(number, vmNumber);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle)

Example 59 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by crdroidandroid.

the class ActivityThread method callCallActivityOnSaveInstanceState.

private void callCallActivityOnSaveInstanceState(ActivityClientRecord r) {
    r.state = new Bundle();
    r.state.setAllowFds(false);
    if (r.isPersistable()) {
        r.persistentState = new PersistableBundle();
        mInstrumentation.callActivityOnSaveInstanceState(r.activity, r.state, r.persistentState);
    } else {
        mInstrumentation.callActivityOnSaveInstanceState(r.activity, r.state);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle)

Example 60 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by crdroidandroid.

the class RestrictionsReceiver method onReceive.

/**
     * Intercept standard Restrictions Provider broadcasts.  Implementations
     * should not override this method; it is better to implement the
     * convenience callbacks for each action.
     */
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (RestrictionsManager.ACTION_REQUEST_PERMISSION.equals(action)) {
        String packageName = intent.getStringExtra(RestrictionsManager.EXTRA_PACKAGE_NAME);
        String requestType = intent.getStringExtra(RestrictionsManager.EXTRA_REQUEST_TYPE);
        String requestId = intent.getStringExtra(RestrictionsManager.EXTRA_REQUEST_ID);
        PersistableBundle request = (PersistableBundle) intent.getParcelableExtra(RestrictionsManager.EXTRA_REQUEST_BUNDLE);
        onRequestPermission(context, packageName, requestType, requestId, request);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle)

Aggregations

PersistableBundle (android.os.PersistableBundle)321 CarrierConfigManager (android.telephony.CarrierConfigManager)87 ComponentName (android.content.ComponentName)67 Intent (android.content.Intent)63 ShortcutInfo (android.content.pm.ShortcutInfo)48 Test (org.junit.Test)35 Bundle (android.os.Bundle)28 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)25 IOException (java.io.IOException)21 Icon (android.graphics.drawable.Icon)17 JobInfo (android.app.job.JobInfo)15 IntentFilter (android.content.IntentFilter)15 Account (android.accounts.Account)14 Activity (android.app.Activity)12 TelephonyManager (android.telephony.TelephonyManager)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 XmlPullParser (org.xmlpull.v1.XmlPullParser)12 Before (org.junit.Before)11 PendingIntent (android.app.PendingIntent)9 PackageManager (android.content.pm.PackageManager)9