use of androidx.annotation.RequiresPermission in project AndroidUtilCode by Blankj.
the class DeviceUtils method isSameDevice.
@RequiresPermission(allOf = { ACCESS_WIFI_STATE, INTERNET, CHANGE_WIFI_STATE })
public static boolean isSameDevice(final String uniqueDeviceId) {
// {prefix}{type}{32id}
if (TextUtils.isEmpty(uniqueDeviceId) && uniqueDeviceId.length() < 33)
return false;
if (uniqueDeviceId.equals(udid))
return true;
final String cachedId = UtilsBridge.getSpUtils4Utils().getString(KEY_UDID, null);
if (uniqueDeviceId.equals(cachedId))
return true;
int st = uniqueDeviceId.length() - 33;
String type = uniqueDeviceId.substring(st, st + 1);
if (type.startsWith("1")) {
String macAddress = getMacAddress();
if (macAddress.equals("")) {
return false;
}
return uniqueDeviceId.substring(st + 1).equals(getUdid("", macAddress));
} else if (type.startsWith("2")) {
final String androidId = getAndroidID();
if (TextUtils.isEmpty(androidId)) {
return false;
}
return uniqueDeviceId.substring(st + 1).equals(getUdid("", androidId));
}
return false;
}
use of androidx.annotation.RequiresPermission in project Moneycim by volkansahin45.
the class CameraSourcePreview method startIfReady.
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
if (mStartRequested && mSurfaceAvailable) {
mCameraSource.start(mSurfaceView.getHolder());
if (mOverlay != null) {
Size size = mCameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by
// 90 degrees
mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
} else {
mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
}
mOverlay.clear();
}
mStartRequested = false;
}
}
use of androidx.annotation.RequiresPermission in project mopub-android-mediation by mopub.
the class CameraSource method start.
/**
* Opens the camera and starts sending preview frames to the underlying detector. The preview
* frames are not displayed.
*
* @throws IOException if the camera's preview texture or display could not be initialized
*/
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
synchronized (mCameraLock) {
if (mCamera != null) {
return this;
}
mCamera = createCamera();
// old version of Android. fall back to use SurfaceView.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
mCamera.setPreviewTexture(mDummySurfaceTexture);
} else {
mDummySurfaceView = new SurfaceView(mContext);
mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
}
mCamera.startPreview();
mProcessingThread = new Thread(mFrameProcessor);
mFrameProcessor.setActive(true);
mProcessingThread.start();
}
return this;
}
use of androidx.annotation.RequiresPermission in project mopub-android-mediation by mopub.
the class CameraSourcePreview method startIfReady.
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
if (mStartRequested && mSurfaceAvailable) {
mCameraSource.start(mSurfaceView.getHolder());
if (mOverlay != null) {
Size size = mCameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by
// 90 degrees
mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
} else {
mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
}
mOverlay.clear();
}
mStartRequested = false;
}
}
use of androidx.annotation.RequiresPermission in project react-native-app-upgrade by songxiaoliang.
the class ApkInstallUtils method installAppSilentBelow24.
/**
* 静默安装 App 在Android7.0以下起作用
* <p>非 root 需添加权限
* {@code <uses-permission android:name="android.permission.INSTALL_PACKAGES" />}</p>
*
* @param filePath 文件路径
* @return {@code true}: 安装成功<br>{@code false}: 安装失败
*/
@RequiresPermission(INSTALL_PACKAGES)
private static boolean installAppSilentBelow24(Context context, String filePath) {
File file = FileUtils.getFileByPath(filePath);
if (!FileUtils.isFileExists(context, file)) {
return false;
}
String pmParams = " -r " + getInstallLocationParams();
StringBuilder command = new StringBuilder().append("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install ").append(pmParams).append(" ").append(filePath.replace(" ", "\\ "));
ShellUtils.CommandResult commandResult = ShellUtils.execCommand(command.toString(), !isSystemApplication(context), true);
return commandResult.successMsg != null && (commandResult.successMsg.contains("Success") || commandResult.successMsg.contains("success"));
}
Aggregations