Search in sources :

Example 46 with BitSet

use of java.util.BitSet in project android_frameworks_base by ResurrectionRemix.

the class GlobalActions method setupAirplaneModeListeners.

/**
     * Since there are two ways of handling airplane mode (with telephony, we depend on the internal
     * device telephony state), and MSIM devices do not report phone state for missing SIMs, we
     * need to dynamically setup listeners based on subscription changes.
     *
     * So if there is _any_ active SIM in the device, we can depend on the phone state,
     * otherwise fall back to {@link Settings.Global#AIRPLANE_MODE_ON}.
     */
private void setupAirplaneModeListeners() {
    TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    for (PhoneStateListener listener : mPhoneStateListeners) {
        telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
    }
    mPhoneStateListeners.clear();
    final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(mContext).getActiveSubscriptionInfoList();
    if (subInfoList != null) {
        mHasTelephony = true;
        mAirplaneModeBits = new BitSet(subInfoList.size());
        for (int i = 0; i < subInfoList.size(); i++) {
            final int finalI = i;
            PhoneStateListener subListener = new PhoneStateListener(subInfoList.get(finalI).getSubscriptionId()) {

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
                    mAirplaneModeBits.set(finalI, inAirplaneMode);
                    // we're in airplane mode if _any_ of the subscriptions say we are
                    mAirplaneState = mAirplaneModeBits.cardinality() > 0 ? ToggleAction.State.On : ToggleAction.State.Off;
                    mAirplaneModeOn.updateState(mAirplaneState);
                    if (mAdapter != null) {
                        mAdapter.notifyDataSetChanged();
                    }
                }
            };
            mPhoneStateListeners.add(subListener);
            telephonyManager.listen(subListener, PhoneStateListener.LISTEN_SERVICE_STATE);
        }
    } else {
        mHasTelephony = false;
    }
    // Set the initial status of airplane mode toggle
    mAirplaneState = getUpdatedAirplaneToggleState();
}
Also used : ServiceState(android.telephony.ServiceState) TelephonyManager(android.telephony.TelephonyManager) PhoneStateListener(android.telephony.PhoneStateListener) BitSet(java.util.BitSet) SubscriptionInfo(android.telephony.SubscriptionInfo) Paint(android.graphics.Paint)

Example 47 with BitSet

use of java.util.BitSet in project Railcraft by Railcraft.

the class TrackKitLocking method readPacketData.

@Override
public void readPacketData(DataInputStream data) throws IOException {
    super.readPacketData(data);
    LockingProfileType p = LockingProfileType.fromOrdinal(data.readByte());
    if (profile != p) {
        profile = p;
        profileInstance = p.create(this);
    }
    BitSet bits = BitSet.valueOf(new byte[] { data.readByte() });
    redstone = bits.get(0);
    locked = bits.get(1);
    justLoaded = bits.get(2);
    profileInstance.readPacketData(data);
    markBlockNeedsUpdate();
}
Also used : BitSet(java.util.BitSet)

Example 48 with BitSet

use of java.util.BitSet in project android_frameworks_base by ResurrectionRemix.

the class WifiConfiguration method readBitSet.

private static BitSet readBitSet(Parcel src) {
    int cardinality = src.readInt();
    BitSet set = new BitSet();
    for (int i = 0; i < cardinality; i++) {
        set.set(src.readInt());
    }
    return set;
}
Also used : BitSet(java.util.BitSet)

Example 49 with BitSet

use of java.util.BitSet in project android_frameworks_base by ResurrectionRemix.

the class ModelTest method testModelIdIsUnique.

// Tests multiple authorities with clashing document IDs.
public void testModelIdIsUnique() {
    MatrixCursor cIn1 = new MatrixCursor(COLUMNS);
    MatrixCursor cIn2 = new MatrixCursor(COLUMNS);
    // Make two sets of items with the same IDs, under different authorities.
    final String AUTHORITY0 = "auth0";
    final String AUTHORITY1 = "auth1";
    for (int i = 0; i < ITEM_COUNT; ++i) {
        MatrixCursor.RowBuilder row0 = cIn1.newRow();
        row0.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY0);
        row0.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
        MatrixCursor.RowBuilder row1 = cIn2.newRow();
        row1.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY1);
        row1.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
    }
    Cursor cIn = new MergeCursor(new Cursor[] { cIn1, cIn2 });
    // Update the model, then make sure it contains all the expected items.
    DirectoryResult r = new DirectoryResult();
    r.cursor = cIn;
    model.update(r);
    assertEquals(ITEM_COUNT * 2, model.getItemCount());
    BitSet b0 = new BitSet(ITEM_COUNT);
    BitSet b1 = new BitSet(ITEM_COUNT);
    for (String id : model.getModelIds()) {
        Cursor cOut = model.getItem(id);
        String authority = DocumentInfo.getCursorString(cOut, RootCursorWrapper.COLUMN_AUTHORITY);
        String docId = DocumentInfo.getCursorString(cOut, Document.COLUMN_DOCUMENT_ID);
        switch(authority) {
            case AUTHORITY0:
                b0.set(Integer.parseInt(docId));
                break;
            case AUTHORITY1:
                b1.set(Integer.parseInt(docId));
                break;
            default:
                fail("Unrecognized authority string");
        }
    }
    assertEquals(ITEM_COUNT, b0.cardinality());
    assertEquals(ITEM_COUNT, b1.cardinality());
}
Also used : DirectoryResult(com.android.documentsui.DirectoryResult) MergeCursor(android.database.MergeCursor) BitSet(java.util.BitSet) MergeCursor(android.database.MergeCursor) MatrixCursor(android.database.MatrixCursor) Cursor(android.database.Cursor) MatrixCursor(android.database.MatrixCursor)

Example 50 with BitSet

use of java.util.BitSet in project UltimateAndroid by cymcsg.

the class AbstractSlideExpandableListAdapter method readBitSet.

/**
     * Utility methods to read and write a bitset from and to a Parcel
     */
private static BitSet readBitSet(Parcel src) {
    BitSet set = new BitSet();
    if (src == null) {
        return set;
    }
    int cardinality = src.readInt();
    for (int i = 0; i < cardinality; i++) {
        set.set(src.readInt());
    }
    return set;
}
Also used : BitSet(java.util.BitSet)

Aggregations

BitSet (java.util.BitSet)2037 Test (org.junit.Test)294 ArrayList (java.util.ArrayList)224 List (java.util.List)83 HashMap (java.util.HashMap)76 Map (java.util.Map)70 IOException (java.io.IOException)60 HashSet (java.util.HashSet)52 Test (org.junit.jupiter.api.Test)47 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)45 Random (java.util.Random)42 Configuration (org.apache.hadoop.conf.Configuration)40 Path (org.apache.hadoop.fs.Path)39 ValidReadTxnList (org.apache.hadoop.hive.common.ValidReadTxnList)33 BlockNode (jadx.core.dex.nodes.BlockNode)29 File (java.io.File)27 LinkedList (java.util.LinkedList)27 RexNode (org.apache.calcite.rex.RexNode)27 ByteBuffer (java.nio.ByteBuffer)25 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)25