Java源码示例:android.util.Log

示例1
private void doPermissionCheck(Context context, ResultCollector collector, final String permission) {
    PackageManager pm = context.getPackageManager();
    try {
        PermissionInfo info = pm.getPermissionInfo(permission, 0);
        PermissionGroupInfo groupInfo = info.group != null ? pm.getPermissionGroupInfo(info.group, 0) : null;
        CharSequence permLabel = info.loadLabel(pm);
        CharSequence groupLabel = groupInfo != null ? groupInfo.loadLabel(pm) : permLabel;
        collector.addResult(context.getString(R.string.self_check_name_permission, permLabel),
                context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED ? Positive : Negative,
                context.getString(R.string.self_check_resolution_permission, groupLabel),
                new SelfCheckGroup.CheckResolver() {

                    @Override
                    public void tryResolve(Fragment fragment) {
                        fragment.requestPermissions(new String[]{permission}, 0);
                    }
                });
    } catch (PackageManager.NameNotFoundException e) {
        Log.w(TAG, e);
    }
}
 
示例2
private int deleteTreatments(Response<List<TreatmentsEndpoints.Treatment>> response) throws Exception {
    cheanupCheckCount++;
    int result = 0;
    if (response.isSuccessful()) {
        List<TreatmentsEndpoints.Treatment> list = response.body();
        for (TreatmentsEndpoints.Treatment item : list) {
            cheanupDeleteCount++;
            Response<ResponseBody> responseBody = dataStore.isNightscoutUseQuery()
                    ? treatmentsEndpoints.deleteID(item.getCreated_at(), item.get_id()).execute()
                    : treatmentsEndpoints.deleteID(item.get_id()).execute();
            if (responseBody.isSuccessful()) {
                Log.d(TAG, String.format("deleted treatment ID: %s with KEY: %s MAC: %s DATE: %s QUERY: %s",
                        item.get_id(), item.getKey600(), item.getPumpMAC600(), item.getCreated_at(), dataStore.isNightscoutUseQuery()));
            } else {
                Log.d(TAG, "no DELETE response from nightscout site");
                return -1;
            }
            result++;
        }
    } else return -1;
    return result;
}
 
示例3
static JSONObject getMobSimInfo(Context context) {
        SimCardBean simCardBean = new SimCardBean();
        try {
            simCardBean.setHaveCard(hasSimCard(context));
//            SimCardUtils.SimCardInfo simCardInfo = SimCardUtils.instance().getmSimCardInfo(context.getApplicationContext());
//            simCardBean.setSim1Imsi(simCardInfo.getSim1Imsi());
//            simCardBean.setSim2Imsi(simCardInfo.getSim2Imsi());
//            simCardBean.setOperator(getOperators(simCardInfo.getOperator(simSlotIndex)));
//            simCardBean.setSim1ImsiOperator(getOperators(simCardInfo.getSim1Imsi()));
//            simCardBean.setSim2ImsiOperator(getOperators(simCardInfo.getSim2Imsi()));

            MobCardUtils.mobGetCardInfo(context, simCardBean);


        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
        return simCardBean.toJSONObject();

    }
 
示例4
/**
 * Resume farming/idling
 */
private void resumeFarming() {
    if (paused || waiting) {
        return;
    }

    if (farming) {
        Log.i(TAG, "Resume farming");
        executor.execute(farmTask);
    } else if (currentGames.size() == 1) {
        Log.i(TAG, "Resume playing");
        new Handler(Looper.getMainLooper()).post(() -> idleSingle(currentGames.get(0)));
    } else if (currentGames.size() > 1) {
        Log.i(TAG, "Resume playing (multiple)");
        idleMultiple(currentGames);
    }
}
 
示例5
private boolean checkUsbDevice() {
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
        Log.e(TAG, "Device does not support USB OTG");
        statusNotification.updateNotification(StatusNotification.NOTIFICATION.ERROR);
        UserLogMessage.send(mContext, UserLogMessage.TYPE.WARN, R.string.ul_usb__no_support);
        return false;
    }

    UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);

    if (usbManager == null) {
        Log.e(TAG, "USB connection error. mUsbManager == null");
        statusNotification.updateNotification(StatusNotification.NOTIFICATION.ERROR);
        UserLogMessage.send(mContext, UserLogMessage.TYPE.WARN, R.string.ul_usb__no_connection);
        return false;
    }

    if (UsbHidDriver.getUsbDevice(usbManager, MedtronicCnlService.USB_VID, MedtronicCnlService.USB_PID) == null) {
        Log.w(TAG, "USB connection error. Is the CNL plugged in?");
        statusNotification.updateNotification(StatusNotification.NOTIFICATION.ERROR);
        UserLogMessage.send(mContext, UserLogMessage.TYPE.WARN, R.string.ul_usb__no_connection);
        return false;
    }

    return true;
}
 
示例6
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
    delegate.onDescriptorWrite(gatt, descriptor, status);
    if(canceled)
        return;
    if(descriptor.getCharacteristic() == readCharacteristic) {
        Log.d(TAG,"writing read characteristic descriptor finished, status="+status);
        if (status != BluetoothGatt.GATT_SUCCESS) {
            onSerialConnectError(new IOException("write descriptor failed"));
        } else {
            // onCharacteristicChanged with incoming data can happen after writeDescriptor(ENABLE_INDICATION/NOTIFICATION)
            // before confirmed by this method, so receive data can be shown before device is shown as 'Connected'.
            onSerialConnect();
            connected = true;
            Log.d(TAG, "connected");
        }
    }
}
 
示例7
private void getFullWiFiList() {

        Log.e(TAG, "Total count : " + totalCount + " and start index is : " + startIndex);

        if (totalCount < 4) {

            getWiFiScanList(0, totalCount);

        } else {

            int temp = totalCount - startIndex;

            if (temp > 0) {

                if (temp > 4) {
                    getWiFiScanList(startIndex, 4);
                } else {
                    getWiFiScanList(startIndex, temp);
                }

            } else {
                Log.d(TAG, "Nothing to do. Wifi list completed.");
                completeWifiList();
            }
        }
    }
 
示例8
void reportVisibility() {
    if (!mDestroyed) {
        mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState();
        boolean visible = mVisible && mDisplayState != Display.STATE_OFF;
        if (mReportedVisible != visible) {
            mReportedVisible = visible;
            if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible
                    + "): " + this);
            if (visible) {
                // If becoming visible, in preview mode the surface
                // may have been destroyed so now we need to make
                // sure it is re-created.
                doOffsetsChanged(false);
                updateSurface(false, false, false);
            }
            onVisibilityChanged(visible);
        }
    }
}
 
示例9
/**
 * Returns true if the specified Bluetooth device is connected.
 * Returns false if not connected, or if this proxy object is not
 * currently connected to the Map service.
 */
public boolean isConnected(BluetoothDevice device) {
    if (VDBG) Log.d(TAG, "isConnected(" + device + ")");
    final IBluetoothMapClient service = mService;
    if (service != null) {
        try {
            return service.isConnected(device);
        } catch (RemoteException e) {
            Log.e(TAG, e.toString());
        }
    } else {
        Log.w(TAG, "Proxy not attached to service");
        if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
    }
    return false;
}
 
示例10
public void shareToTimeLine() {
    generateShareImage();
    File file = new File(Config.EXT_DIR + "/share_image.jpg");
    try {
        Intent intent = new Intent();
        ComponentName comp = new ComponentName("com.tencent.mm",
                "com.tencent.mm.ui.tools.ShareToTimeLineUI");
        intent.setComponent(comp);
        intent.setAction("android.intent.action.SEND");
        intent.setType("image/*");
        //intent.setFlags(0x3000001);
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        startActivity(intent);
    } catch (Exception e) {
        Log.e("wechatmomentstat", "exception", e);
    }
}
 
示例11
public void measure() {
    if (!mIsInitialized) {
        init();
        mIsInitialized = true;
    } else {
        mFramesCounter++;
        if (mFramesCounter % STEP == 0) {
            long time = Core.getTickCount();
            double fps = STEP * mFrequency / (time - mprevFrameTime);
            mprevFrameTime = time;
            if (mWidth != 0 && mHeight != 0)
                mStrfps = FPS_FORMAT.format(fps) + " [email protected]" + Integer.valueOf(mWidth) + "x" + Integer.valueOf(mHeight);
            else
                mStrfps = FPS_FORMAT.format(fps) + " FPS";
            Log.i(TAG, mStrfps);
        }
    }
}
 
示例12
@Override
public void setValues(double[] y, double[] x) {
    if (x.length != y.length) {
        throw new IllegalArgumentException(String.format("The numbers of y and x values must be equal (%d != %d)", y.length, x.length));
    }
    double[][] xData = new double[x.length][];
    for (int i = 0; i < x.length; i++) {
        // the implementation determines how to produce a vector of predictors from a single x
        xData[i] = xVector(x[i]);
    }
    if (logY()) { // in some models we are predicting ln y, so we replace each y with ln y
        y = Arrays.copyOf(y, y.length); // user might not be finished with the array we were given
        for (int i = 0; i < x.length; i++) {
            y[i] = Math.log(y[i]);
        }
    }
    final OLSMultipleLinearRegression ols = new OLSMultipleLinearRegression();
    ols.setNoIntercept(true); // let the implementation include a constant in xVector if desired
    ols.newSampleData(y, xData); // provide the data to the model
    coef = MatrixUtils.createColumnRealMatrix(ols.estimateRegressionParameters()); // get our coefs
    last_error_rate = ols.estimateErrorVariance();
    Log.d(TAG, getClass().getSimpleName() + " Forecast Error rate: errorvar:"
            + JoH.qs(last_error_rate, 4)
            + " regssionvar:" + JoH.qs(ols.estimateRegressandVariance(), 4)
            + "  stderror:" + JoH.qs(ols.estimateRegressionStandardError(), 4));
}
 
示例13
void addDuck(@NonNull AudioPlaybackConfiguration apc, boolean skipRamp) {
    final int piid = new Integer(apc.getPlayerInterfaceId());
    if (mDuckedPlayers.contains(piid)) {
        if (DEBUG) { Log.v(TAG, "player piid:" + piid + " already ducked"); }
        return;
    }
    try {
        sEventLogger.log((new DuckEvent(apc, skipRamp)).printLog(TAG));
        apc.getPlayerProxy().applyVolumeShaper(
                DUCK_VSHAPE,
                skipRamp ? PLAY_SKIP_RAMP : PLAY_CREATE_IF_NEEDED);
        mDuckedPlayers.add(piid);
    } catch (Exception e) {
        Log.e(TAG, "Error ducking player piid:" + piid + " uid:" + mUid, e);
    }
}
 
示例14
private String getFFMPEGFileName(CPUArchitecture architecture){
    final String ffmpegFileName;
    switch (architecture){
        case X86:
            ffmpegFileName = "x86_ffmpeg";
            break;
        case ARMEABI_V7A:
            ffmpegFileName = "armeabi-v7a_ffmpeg";
            break;
        case ARMEABI_V7A_NEON:
            ffmpegFileName = "armeabi-v7a-neon_ffmpeg";
            break;
        default:
            ffmpegFileName = null;
            String message= "Could not determine your processor architecture correctly, no ffmpeg binary available.";
            Log.e(TAG,message);
            throw new Error(message);
    }
    return ffmpegFileName;
}
 
示例15
/**
 * 必须在主线程分享
 *
 * @param activity
 * @param params
 */
protected void doShareToQQ(final Activity activity, final Bundle params) {
    doOnMainThread(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "real start share");
            postProgressStart();
            onShare(activity, mTencent, params, mUiListener);
            if (activity != null && !isMobileQQSupportShare(activity.getApplicationContext())) {
                Log.d(TAG, "qq has not install");
                String msg = activity.getString(R.string.bili_share_sdk_not_install_qq);
                Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
                if (getShareListener() != null) {
                    getShareListener().onError(getShareMedia(), BiliShareStatusCode.ST_CODE_SHARE_ERROR_NOT_INSTALL, new ShareException(msg));
                }
            }
        }
    });
}
 
示例16
@Override
public View onCreateInputView() {
    Log.d(TAG, "onCreateInputView()");
    View mInputView = getLayoutInflater().inflate(R.layout.keyboard, null);

    if (mReceiver == null) {
        IntentFilter filter = new IntentFilter(IME_MESSAGE);
        filter.addAction(IME_CHARS);
        filter.addAction(IME_KEYCODE);
        filter.addAction(IME_EDITORCODE);
        mReceiver = new AdbReceiver();
        registerReceiver(mReceiver, filter);
    }

    return mInputView; 
}
 
示例17
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(ACTION_INCOMING_CALL)) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "VoiceBroadcastReceiver.onReceive ACTION_INCOMING_CALL. Intent "+ intent.getExtras());
        }
        handleIncomingCallIntent(intent);
    } else if (action.equals(ACTION_MISSED_CALL)) {
        SharedPreferences sharedPref = getReactApplicationContext().getSharedPreferences(PREFERENCE_KEY, Context.MODE_PRIVATE);
        SharedPreferences.Editor sharedPrefEditor = sharedPref.edit();
        sharedPrefEditor.remove(MISSED_CALLS_GROUP);
        sharedPrefEditor.commit();
    } else {
        Log.e(TAG, "received broadcast unhandled action " + action);
    }
}
 
示例18
/**
 * Marks a fragment as shown to be later animated in with
 * {@link #completeShowHideFragment(Fragment)}.
 *
 * @param fragment The fragment to be shown.
 */
public void showFragment(Fragment fragment) {
    if (DEBUG) Log.v(TAG, "show: " + fragment);
    if (fragment.mHidden) {
        fragment.mHidden = false;
        // Toggle hidden changed so that if a fragment goes through show/hide/show
        // it doesn't go through the animation.
        fragment.mHiddenChanged = !fragment.mHiddenChanged;
    }
}
 
示例19
@Override
public void onAdjustVolume(int direction) {
    super.onAdjustVolume(direction);
    if (direction != 0) {
        setPlayerVolume(getPlayerVolume() + direction);
        Log.v(TAG, "Volume adjusted: " + getPlayerVolume());
        notifyPlayerVolumeChanged(getPlayerVolume());
    }
}
 
示例20
@Test
public void testOCRInputPassport2() throws Exception {
    Bitmap mrzImage = BitmapFactory.decodeStream(InstrumentationRegistry.getInstrumentation().getTargetContext().getAssets().open(image2));
    assertNotNull(mrzImage);
    double similarity = stringSimilarity(image2Result, tesseractOCR.ocr(mrzImage).getText());
    Log.e(TAG, "Similarity passport2: " + similarity);
    assertTrue(similarity > MINIMUM_ACCURACY);
}
 
示例21
/** Rx Java **/

    private void startIncrementObserver(){

        _Incrementsubscriber=new DisposableSubscriber<Long>() {

            @Override
            public void onNext(Long aLong) {
                if(isLeftButtonLongPressed||isRightButtonLongPressed) {
                    IncrementAction();
                }
                else
                    _Incrementsubscriber.dispose();

            }

            @Override
            public void onError(Throwable t) {
                Log.i(TAG,t.getMessage());
            }

            @Override
            public void onComplete() {

            }
        };

        Flowable.interval(0,seconds, TimeUnit.MILLISECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(_Incrementsubscriber);

    }
 
示例22
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());

    setContentView(R.layout.credential_picker_layout);
    ButterKnife.bind(this);

    mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
    mCredentialView.setLayoutManager(new LinearLayoutManager(this));
}
 
示例23
public static boolean refreshDeviceCache(String thisTAG, BluetoothGatt gatt){
    try {
        final Method method = gatt.getClass().getMethod("refresh", new Class[0]);
        if (method != null) {
            return (Boolean) method.invoke(gatt, new Object[0]);
        }
    }
    catch (Exception e) {
        Log.e(thisTAG, "An exception occured while refreshing gatt device cache: "+e);
    }
    return false;
}
 
示例24
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
    if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
        // Bug being that Java Strings do not get converted to JS strings automatically.
        // This isn't hard to work-around on the JS side, but it's easier to just
        // use the prompt bridge instead.
        return;
    }
    X5ExposedJsApi exposedJsApi = new X5ExposedJsApi(bridge);
    webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}
 
示例25
@Override
protected JSONObject toJSONObject() {
    try {
        jsonObject.put(BaseData.Aduio.MAX_VOICE_CALL, maxVoiceCall);
        jsonObject.put(BaseData.Aduio.MIN_VOICE_CALL, minVoiceCall);
        jsonObject.put(BaseData.Aduio.CURRENT_VOICE_CALL, currentVoiceCall);
        jsonObject.put(BaseData.Aduio.MAX_SYSTEM, maxSystem);
        jsonObject.put(BaseData.Aduio.MIN_SYSTEM, minSystem);
        jsonObject.put(BaseData.Aduio.CURRENT_SYSTEM, currentSystem);
        jsonObject.put(BaseData.Aduio.MAX_RING, maxRing);
        jsonObject.put(BaseData.Aduio.MIN_RING, minRing);
        jsonObject.put(BaseData.Aduio.CURRENT_RING, currentRing);
        jsonObject.put(BaseData.Aduio.MAX_MUSIC, maxMusic);
        jsonObject.put(BaseData.Aduio.MIN_MUSIC, minMusic);
        jsonObject.put(BaseData.Aduio.CURRENT_MUSIC, currentMusic);
        jsonObject.put(BaseData.Aduio.MAX_ALARM, maxAlarm);
        jsonObject.put(BaseData.Aduio.MIN_ALARM, minAlarm);
        jsonObject.put(BaseData.Aduio.CURRENT_ALARM, currentAlarm);
        jsonObject.put(BaseData.Aduio.MAX_NOTIFICATIONS, maxNotifications);
        jsonObject.put(BaseData.Aduio.MIN_NOTIFICATIONS, minNotifications);
        jsonObject.put(BaseData.Aduio.CURRENT_NOTIFICATIONS, currentNotifications);
        jsonObject.put(BaseData.Aduio.MAX_ACCESSIBILITY, maxAccessibility);
        jsonObject.put(BaseData.Aduio.MIN_ACCESSIBILITY, minAccessibility);
        jsonObject.put(BaseData.Aduio.CURRENT_ACCESSIBILITY, currentAccessibility);
        jsonObject.put(BaseData.Aduio.MAX_DTMF, maxDTMF);
        jsonObject.put(BaseData.Aduio.MIN_DTMF, minDTMF);
        jsonObject.put(BaseData.Aduio.CURRENT_DTMF, currentDTMF);


    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
    return super.toJSONObject();
}
 
示例26
public ConnectThread(BluetoothDevice device) {
    mmDevice = device;
    BluetoothSocket tmp = null;

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
    } catch (IOException e) {
        Log.e(TAG, "create() failed", e);
    }
    mmSocket = tmp;
}
 
示例27
@Override
public void onPeekCardPositionUpdate(Rect bounds) {
    super.onPeekCardPositionUpdate(bounds);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onPeekCardPositionUpdate: " + bounds);
    }
    super.onPeekCardPositionUpdate(bounds);
    if (!bounds.equals(mCardBounds)) {
        mCardBounds.set(bounds);
        invalidate();
    }
}
 
示例28
public void startDrag(ViewHolder viewHolder) {
    if (!this.mCallback.hasDragFlag(this.mRecyclerView, viewHolder)) {
        Log.e(TAG, "Start drag has been called but swiping is not enabled");
    } else if (viewHolder.itemView.getParent() != this.mRecyclerView) {
        Log.e(TAG, "Start drag has been called with a view holder which is not a child of the RecyclerView which is controlled by this ItemTouchHelper.");
    } else {
        obtainVelocityTracker();
        this.mDy = 0.0f;
        this.mDx = 0.0f;
        select(viewHolder, 2);
    }
}
 
示例29
public static void logv(String tag, String msg) {
    if (disableAllLog()) {
        return;
    }
    Log.v(getCurrentAppTag() + POINT + tag, msg);
    saveLogIfNeeded(tag, msg, "V");
}
 
示例30
@Override
public void onParticipantJoined(Participant participant) {
    Log.d(TAG, "onParticipantJoined.");
    userJoinedTriggered = true;
    TestObserver participantObserver = new TestObserver(this.name, participant.id);
    participant.addObserver(participantObserver);
    participants.add(participant);
    participantObservers.put(participant.id, participantObserver);
    onResult();
}