Search in sources :

Example 51 with PersistableBundle

use of android.os.PersistableBundle in project platform_frameworks_base by android.

the class ShortcutManagerTest2 method testShortcutInfoCopyNonNullFieldsFrom.

public void testShortcutInfoCopyNonNullFieldsFrom() throws InterruptedException {
    PersistableBundle pb = new PersistableBundle();
    pb.putInt("k", 1);
    ShortcutInfo sorig = new ShortcutInfo.Builder(getTestContext()).setId("id").setActivity(new ComponentName("a", "b")).setIcon(Icon.createWithResource(mClientContext, 123)).setTitle("title").setText("text").setDisabledMessage("dismes").setCategories(set(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION, "xyz")).setIntent(makeIntent("action", ShortcutActivity.class, "key", "val")).setRank(123).setExtras(pb).build();
    sorig.addFlags(ShortcutInfo.FLAG_PINNED);
    sorig.setBitmapPath("abc");
    sorig.setIconResourceId(456);
    lookupAndFillInResourceNames(sorig);
    ShortcutInfo si;
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setActivity(new ComponentName("x", "y")).build());
    assertEquals("text", si.getText());
    assertEquals(123, si.getRank());
    assertEquals(new ComponentName("x", "y"), si.getActivity());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setIcon(Icon.createWithResource(mClientContext, 456)).build());
    assertEquals("text", si.getText());
    assertEquals(456, si.getIcon().getResId());
    assertEquals(0, si.getIconResourceId());
    assertEquals(null, si.getIconResName());
    assertEquals(null, si.getBitmapPath());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setTitle("xyz").build());
    assertEquals("text", si.getText());
    assertEquals("xyz", si.getTitle());
    assertEquals(0, si.getTitleResId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setTitleResId(123).build());
    assertEquals("text", si.getText());
    assertEquals(null, si.getTitle());
    assertEquals(123, si.getTitleResId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setText("xxx").build());
    assertEquals(123, si.getRank());
    assertEquals("xxx", si.getText());
    assertEquals(0, si.getTextResId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setTextResId(1111).build());
    assertEquals(123, si.getRank());
    assertEquals(null, si.getText());
    assertEquals(1111, si.getTextResId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setDisabledMessage("xxx").build());
    assertEquals(123, si.getRank());
    assertEquals("xxx", si.getDisabledMessage());
    assertEquals(0, si.getDisabledMessageResourceId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setDisabledMessageResId(11111).build());
    assertEquals(123, si.getRank());
    assertEquals(null, si.getDisabledMessage());
    assertEquals(11111, si.getDisabledMessageResourceId());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setCategories(set()).build());
    assertEquals("text", si.getText());
    assertEquals(set(), si.getCategories());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setCategories(set("x")).build());
    assertEquals("text", si.getText());
    assertEquals(set("x"), si.getCategories());
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setIntent(makeIntent("action2", ShortcutActivity.class)).build());
    assertEquals("text", si.getText());
    assertEquals("action2", si.getIntent().getAction());
    assertEquals(null, si.getIntent().getStringExtra("key"));
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setIntent(makeIntent("action3", ShortcutActivity.class, "key", "x")).build());
    assertEquals("text", si.getText());
    assertEquals("action3", si.getIntent().getAction());
    assertEquals("x", si.getIntent().getStringExtra("key"));
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setRank(999).build());
    assertEquals("text", si.getText());
    assertEquals(999, si.getRank());
    PersistableBundle pb2 = new PersistableBundle();
    pb2.putInt("x", 99);
    si = sorig.clone(/* flags=*/
    0);
    si.copyNonNullFieldsFrom(new ShortcutInfo.Builder(getTestContext()).setId("id").setExtras(pb2).build());
    assertEquals("text", si.getText());
    assertEquals(99, si.getExtras().getInt("x"));
}
Also used : PersistableBundle(android.os.PersistableBundle) ShortcutInfo(android.content.pm.ShortcutInfo) ComponentName(android.content.ComponentName)

Example 52 with PersistableBundle

use of android.os.PersistableBundle in project platform_frameworks_base by android.

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 53 with PersistableBundle

use of android.os.PersistableBundle in project platform_frameworks_base by android.

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)

Example 54 with PersistableBundle

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

the class ShortcutInfo method fixUpIntentExtras.

/**
     * Extract extras from {@link #mIntents} and set them to {@link #mIntentPersistableExtrases}
     * as {@link PersistableBundle}, and remove extras from the original intents.
     */
private void fixUpIntentExtras() {
    if (mIntents == null) {
        mIntentPersistableExtrases = null;
        return;
    }
    mIntentPersistableExtrases = new PersistableBundle[mIntents.length];
    for (int i = 0; i < mIntents.length; i++) {
        final Intent intent = mIntents[i];
        final Bundle extras = intent.getExtras();
        if (extras == null) {
            mIntentPersistableExtrases[i] = null;
        } else {
            mIntentPersistableExtrases[i] = new PersistableBundle(extras);
            intent.replaceExtras((Bundle) null);
        }
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent)

Example 55 with PersistableBundle

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

the class TrustAgentWrapper method updateDevicePolicyFeatures.

boolean updateDevicePolicyFeatures() {
    boolean trustDisabled = false;
    if (DEBUG)
        Slog.v(TAG, "updateDevicePolicyFeatures(" + mName + ")");
    try {
        if (mTrustAgentService != null) {
            DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
            if ((dpm.getKeyguardDisabledFeatures(null, mUserId) & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
                List<PersistableBundle> config = dpm.getTrustAgentConfiguration(null, mName, mUserId);
                trustDisabled = true;
                if (DEBUG)
                    Slog.v(TAG, "Detected trust agents disabled. Config = " + config);
                if (config != null && config.size() > 0) {
                    if (DEBUG) {
                        Slog.v(TAG, "TrustAgent " + mName.flattenToShortString() + " disabled until it acknowledges " + config);
                    }
                    mSetTrustAgentFeaturesToken = new Binder();
                    mTrustAgentService.onConfigure(config, mSetTrustAgentFeaturesToken);
                }
            } else {
                mTrustAgentService.onConfigure(Collections.EMPTY_LIST, null);
            }
            final long maxTimeToLock = dpm.getMaximumTimeToLockForUserAndProfiles(mUserId);
            if (maxTimeToLock != mMaximumTimeToLock) {
                // If the timeout changes, cancel the alarm and send a timeout event to have
                // the agent re-evaluate trust.
                mMaximumTimeToLock = maxTimeToLock;
                if (mAlarmPendingIntent != null) {
                    mAlarmManager.cancel(mAlarmPendingIntent);
                    mAlarmPendingIntent = null;
                    mHandler.sendEmptyMessage(MSG_TRUST_TIMEOUT);
                }
            }
        }
    } catch (RemoteException e) {
        onError(e);
    }
    if (mTrustDisabledByDpm != trustDisabled) {
        mTrustDisabledByDpm = trustDisabled;
        mTrustManagerService.updateTrust(mUserId, 0);
    }
    return trustDisabled;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) IBinder(android.os.IBinder) Binder(android.os.Binder) PersistableBundle(android.os.PersistableBundle) RemoteException(android.os.RemoteException)

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