Java Code Examples for roboguice.util.Ln#w()

The following examples show how to use roboguice.util.Ln#w() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Asks the server to leave an channel
 */
public void leaveChannel(Chatroom chatroom) {
    // TODO: Leave private chat without deleting "log"
    if (!chatroom.isPrivateChat()) {
        JSONObject data = new JSONObject();
        try {
            data.put("channel", chatroom.getChannel().getChannelId());
            sendMessage(ClientToken.LCH, data);
        } catch (JSONException e) {
            Ln.w("exception occurred while leaving channel: " + e.getMessage());
        }
    } else {
        // Private chats will just be removed.
        boolean wasActive = chatroomManager.isActiveChat(chatroom);

        chatroomManager.removeChatroom(chatroom.getChannel());
        eventManager.fire(chatroom, ChatroomEventType.LEFT);

        if (wasActive) {
            List<Chatroom> chatrooms = chatroomManager.getChatRooms();
            chatroomManager.setActiveChat(chatrooms.get(chatrooms.size() - 1));
        }
    }
}
 
Example 2
Source File: Security.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Verifies that the data was signed with the given signature, and returns
 * the verified purchase. The data is in JSON format and signed
 * with a private key. The data also contains the {@link PurchaseState}
 * and product ID of the purchase.
 *
 * @param base64PublicKey the base64-encoded public key to use for verifying.
 * @param signedData      the signed JSON string (signed, not encrypted)
 * @param signature       the signature for the data, signed with the private key
 */
public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
    if (signedData == null) {
        Ln.e(TAG, "data is null");
        return false;
    }

    boolean verified = false;
    if (!TextUtils.isEmpty(signature)) {
        PublicKey key = Security.generatePublicKey(base64PublicKey);
        verified = Security.verify(key, signedData, signature);
        if (!verified) {
            Ln.w(TAG, "signature does not match data.");
            return false;
        }
    }
    return true;
}
 
Example 3
Source File: HelpFragment.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public void openAcsSettings(final Context ctx, boolean forceShowOnboarding) {
    mPrevAccessibilitySettingsOn = AndroidIntegration
            .isAccessibilitySettingsOnAndServiceRunning(ctx);

    Intent intent = new Intent(
            Settings.ACTION_ACCESSIBILITY_SETTINGS);

    PackageManager packageManager = getActivity().getPackageManager();
    if (intent.resolveActivity(packageManager) != null) {
        startActivityForResult(
                intent,
                0);
        if (!GotItPreferences.Companion.getPreferences(ctx).isTooltipConfirmed(getString(R.string.tooltipid_onboarding))
                || forceShowOnboarding) {
            vgBoss.postDelayed(new Runnable() {
                @Override
                public void run() {
                    OnboardingActivity.show(ctx);
                }
            }, 500);
        }
    } else {
        Ln.w("No Intent available to handle ACTION_ACCESSIBILITY_SETTINGS");
        ActionAccessibilitySettingsNotResolvableActivity.show(ctx);
    }
}
 
Example 4
Source File: Db.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private synchronized void setIntValue(String col, String packagename, int value) {

        if (packagename == null) {
            Ln.w("got null packagename, ignoring this call");
            return;
        }
        PackageCache packageCache = getOrCreatePackageCache(packagename);

        Integer curValue = packageCache.mIntCache.get(col);
        if (curValue == null || curValue != value) {
            ContentValues values = new ContentValues();
            values.put(COL_NAME, packagename);
            values.put(col, value);
            int r = mDb.update(TABLE_PACKAGES, values, COL_NAME + "=?",
                    new String[]{packagename});
            if (r == 0) {
                mDb.insert(TABLE_PACKAGES, null, values);
            }
        }

        packageCache.mIntCache.put(col, value);
    }
 
Example 5
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sends a message to an channel.
 */
public void sendMessageToChannel(Chatroom chatroom, String msg) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("character", sessionData.getCharacterName());
        data.put("message", msg);
        sendMessage(ClientToken.MSG, data);
        msg =  Html.toHtml(new SpannableString(msg.trim())).trim();
        String[] firstcut = msg.split(">", 2);
        int i = firstcut[1].lastIndexOf("<");
        String[] secondcut =  {firstcut[1].substring(0, i), firstcut[1].substring(i)};
        Ln.i(secondcut[0]);
        ChatEntry entry = entryFactory.getMessage(characterManager.findCharacter(sessionData.getCharacterName()), secondcut[0]);
        chatroomManager.addChat(chatroom, entry);

    } catch (JSONException e) {
        Ln.w("exception occurred while sending message: " + e.getMessage());
    }
}
 
Example 6
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private void sendScrapeSubtreeMessage(AccessibilityNodeInfo node, PerformNodeAction nodeAction) {
    if (node == null) {
        Ln.w("SKRAPE: node == null!");
        return;
    }
    NodeAndFlag nf = new NodeAndFlag(node, nodeAction);

    //mark as cancelled all pending items
    synchronized (mScrapeSubtreeBag) {
        int n = mScrapeSubtreeBag.size();
        for (int i = 0; i < n; i++) {
            NodeAndFlag item = mScrapeSubtreeBag.get(i);
            if (item != null && item.nodeHash == nf.nodeHash) {
                item.cancelled = true;
            }
        }
    }


    mScrapeSubtreeBag.add(nf);
    mHandler.sendMessage(Message.obtain(mHandler, WHAT_SCRAPE_SUBTREE, nf));

    triggerHousekeeping();
}
 
Example 7
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void ban(String username, Chatroom chatroom) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("character", username);
        sendMessage(ClientToken.CBU, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending CBU: " + e.getMessage());
    }
}
 
Example 8
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Asks the server for permission to enter a channel.
 */
public void joinChannel(String channel) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", channel);
        sendMessage(ClientToken.JCH, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while joining channel: " + e.getMessage());
    }
}
 
Example 9
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void closeChannel(Chatroom chatroom) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("status", "private");
        sendMessage(ClientToken.RST, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending RST: " + e.getMessage());
    }
}
 
Example 10
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void unignore(String character) {
    JSONObject data = new JSONObject();
    try {
        data.put("action", "delete");
        data.put("character", character);
        sendMessage(ClientToken.IGN, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending IGN: " + e.getMessage());
    }
}
 
Example 11
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void openChannel(Chatroom chatroom) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("status", "public");
        sendMessage(ClientToken.RST, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending RST: " + e.getMessage());
    }
}
 
Example 12
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void setDescription(Chatroom chatroom, String text) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("description", text);
        sendMessage(ClientToken.CDS, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending CDS: " + e.getMessage());
    }
}
 
Example 13
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
private void sendRefreshNodeMessage(AccessibilityNodeInfo node) {
        if (node == null) {
            Ln.w("SKRAPE: dòh, got a null node!");
            return;
        }


        //TODO: optionally generally throttle (Delay subtree scrapes)

//        avoid excess subtree rescrapes triggered by the system.
//           they may arrive while the system is still scraping a previous event.

        NodeAndFlag nf = new NodeAndFlag(node, null);

        //mark as cancelled all pending items
        synchronized (mRefreshNodeBag) {
            int n = mRefreshNodeBag.size();
            for (int i = 0; i < n; i++) {
                NodeAndFlag item = mRefreshNodeBag.get(i);
                if (item.nodeHash == nf.nodeHash) {
                    item.cancelled = true;
                }
            }
        }

        mRefreshNodeBag.add(nf);
        if (mDb.isHqScrape(node.getPackageName().toString())) {
            mHandler.sendMessage(Message.obtain(mHandler, WHAT_REFRESH_NODE, nf));
        } else {
            mHandler.sendMessageDelayed(Message.obtain(mHandler, WHAT_REFRESH_NODE, nf), DELAY_SUBTREE);
        }


    }
 
Example 14
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
private void setMonitorEventTypes(int eventTypes, boolean includeNotImporantViews, boolean requestEnhancedWebAccessibility) {
    if (eventTypes != mLastMonitoredEventTypes || includeNotImporantViews != mLastIncludeNotImporantViews || requestEnhancedWebAccessibility != mLastRequestEnhancedWebAccessibility) {

        Ln.d("SERVICE: mLastMonitoredEventTypes=%s, eventTypes=%s", mLastMonitoredEventTypes, eventTypes);

        mLastMonitoredEventTypes = eventTypes;
        mLastIncludeNotImporantViews = includeNotImporantViews;
        mLastRequestEnhancedWebAccessibility = requestEnhancedWebAccessibility;
        AccessibilityServiceInfo params = getServiceInfo();
        if (params == null) {
            Ln.w("DAMNIT, somethimes this shit happens: serviceparams returned are null!");
        } else {
            params.eventTypes = mLastMonitoredEventTypes;
            if (includeNotImporantViews) {
                params.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
            } else {
                params.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
            }

            if (mLastRequestEnhancedWebAccessibility) {
                params.flags |= AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
            } else {
                params.flags &= ~AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
            }

            setServiceInfo(params);
        }
    }
}
 
Example 15
Source File: Core.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
public boolean isTemporaryHidden(String packageName) {
    if (packageName == null) {
        Ln.w("got null packageName");
        return false;
    }

    Boolean r = mUiThreadVars.isTemporaryHidden(packageName);
    if (r == null) {
        r = false;
    }
    return r;
}
 
Example 16
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void setOwner(Chatroom chatroom, String character) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("character", character);
        sendMessage(ClientToken.CSO, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending CSO: " + e.getMessage());
    }
}
 
Example 17
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void demote(Chatroom chatroom, String character) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("character", character);
        sendMessage(ClientToken.COR, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending COR: " + e.getMessage());
    }
}
 
Example 18
Source File: FlistWebSocketConnection.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
public void setMode(Chatroom chatroom, String value) {
    JSONObject data = new JSONObject();
    try {
        data.put("channel", chatroom.getId());
        data.put("mode", value);
        sendMessage(ClientToken.RMO, data);
    } catch (JSONException e) {
        Ln.w("exception occurred while sending RMO: " + e.getMessage());
    }
}
 
Example 19
Source File: Db.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
private synchronized String getStringValue(String col, String packagename, String def) {
    if (packagename == null) {
        Ln.w("got null packagename, return default value");
        return def;
    }

    // Ln.d("getIntValue %s   %s",col,packagename);

    PackageCache packageCache = getOrCreatePackageCache(packagename);
    if (!packageCache.mStringCache.containsKey(col)) {
        Cursor query = mDb.query(TABLE_PACKAGES, new String[]{col}, COL_NAME
                + "=?", new String[]{packagename}, null, null, null);
        try {
            if (query.moveToFirst()) {
                if (!query.isNull(0)) {
                    String r = query.getString(0);
                    // Ln.d("getIntValue return "+r+" from query");
                    packageCache.mStringCache.put(col, r);
                    return r;
                } else {
                    //  Ln.d("getIntValue return DEFAULT value from query A");
                    packageCache.mStringCache.put(col, null);
                    return def;
                }
            } else {
                // Ln.d("getIntValue return DEFAULT value from query B");
                packageCache.mStringCache.put(col, null);
                return def;
            }
        } finally {
            // Ln.d("getIntValue closeQuery");
            query.close();
        }
    } else {
        String curValue = packageCache.mStringCache.get(col);
        if (curValue == null) {
            // Ln.d("getIntValue return DEFAULT value from x cache");
            return def;
        } else {
            // Ln.d("getIntValue return "+curValue+" from x cache");
            return curValue;
        }
    }


}
 
Example 20
Source File: Db.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
private synchronized int getIntValue(String col, String packagename, int def) {
    if (packagename == null) {
        Ln.w("got null packagename, return default value");
        return def;
    }

    // Ln.d("getIntValue %s   %s",col,packagename);

    PackageCache packageCache = getOrCreatePackageCache(packagename);
    if (!packageCache.mIntCache.containsKey(col)) {
        Cursor query = mDb.query(TABLE_PACKAGES, new String[]{col}, COL_NAME
                + "=?", new String[]{packagename}, null, null, null);
        try {
            if (query.moveToFirst()) {
                if (!query.isNull(0)) {
                    int r = query.getInt(0);
                    // Ln.d("getIntValue return "+r+" from query");
                    packageCache.mIntCache.put(col, r);
                    return r;
                } else {
                    //  Ln.d("getIntValue return DEFAULT value from query A");
                    packageCache.mIntCache.put(col, null);
                    return def;
                }
            } else {
                // Ln.d("getIntValue return DEFAULT value from query B");
                packageCache.mIntCache.put(col, null);
                return def;
            }
        } finally {
            // Ln.d("getIntValue closeQuery");
            query.close();
        }
    } else {
        Integer curValue = packageCache.mIntCache.get(col);
        if (curValue == null) {
            // Ln.d("getIntValue return DEFAULT value from x cache");
            return def;
        } else {
            // Ln.d("getIntValue return "+curValue+" from x cache");
            return curValue;
        }
    }


}