use of androidx.annotation.RequiresPermission in project react-native-app-upgrade by songxiaoliang.
the class ApkInstallUtils method installAppSilentAbove24.
// ===============================//
/**
* 静默安装 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 installAppSilentAbove24(Context context, String packageName, String filePath) {
File file = FileUtils.getFileByPath(filePath);
if (!FileUtils.isFileExists(context, file)) {
return false;
}
boolean isRoot = isDeviceRooted();
String command = "pm install -i " + packageName + " --user 0 " + filePath;
ShellUtils.CommandResult commandResult = ShellUtils.execCommand(command, isRoot);
return (commandResult.successMsg != null && commandResult.successMsg.toLowerCase().contains("success"));
}
use of androidx.annotation.RequiresPermission in project Signal-Android by signalapp.
the class Util method getDeviceNumber.
@RequiresPermission(anyOf = { android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_PHONE_NUMBERS })
@SuppressLint("MissingPermission")
public static Optional<Phonenumber.PhoneNumber> getDeviceNumber(Context context) {
try {
final String localNumber = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
final Optional<String> countryIso = getSimCountryIso(context);
if (TextUtils.isEmpty(localNumber))
return Optional.absent();
if (!countryIso.isPresent())
return Optional.absent();
return Optional.fromNullable(PhoneNumberUtil.getInstance().parse(localNumber, countryIso.get()));
} catch (NumberParseException e) {
Log.w(TAG, e);
return Optional.absent();
}
}
use of androidx.annotation.RequiresPermission in project Signal-Android by signalapp.
the class WallpaperImageSelectionActivity method getIntent.
@RequiresPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
public static Intent getIntent(@NonNull Context context, @Nullable RecipientId recipientId) {
Intent intent = new Intent(context, WallpaperImageSelectionActivity.class);
intent.putExtra(EXTRA_RECIPIENT_ID, recipientId);
return intent;
}
use of androidx.annotation.RequiresPermission in project prebid-mobile-android by prebid.
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 K6nele by Kaljurand.
the class WebSocketRecognitionService method configure.
@RequiresPermission(RECORD_AUDIO)
@Override
protected void configure(Intent recognizerIntent) throws IOException {
Bundle bundle = getExtras();
ChunkedWebRecSessionBuilder builder = new ChunkedWebRecSessionBuilder(this, bundle, null);
List<Pair<String, String>> list = QueryUtils.getQueryParams(recognizerIntent, builder);
list.add(new Pair<>("content-type", getAudioRecorder().getContentType()));
mUrl = QueryUtils.combine(getServerUrl(R.string.keyWsServer, R.string.defaultWsServer), QueryUtils.encodeKeyValuePairs(list, "UTF-8"));
// Extra overrides the preferences
boolean isUnlimitedDuration;
Object obj = bundle.get(Extras.EXTRA_UNLIMITED_DURATION);
if (obj == null) {
obj = bundle.get(Extras.EXTRA_DICTATION_MODE);
}
if (obj == null) {
isUnlimitedDuration = !PreferenceUtils.getPrefBoolean(getSharedPreferences(), getResources(), R.string.keyWsAutoStopAfterPause, R.bool.defaultWsAutoStopAfterPause);
} else {
isUnlimitedDuration = (Boolean) obj;
}
configureHandler(isUnlimitedDuration, bundle.getBoolean(RecognizerIntent.EXTRA_PARTIAL_RESULTS, false));
}
Aggregations