How I change my codename device on Android Device - android

I have a question. Some device has codename.
For example:
Redmi K20Pro has codename "raphael"
Samsung A02S has codename "A02q"
Bluestack 5 (my device need change android codename) has codename: "taimen"
...
So how I can change this codename through adb shell with root access, or terminal on mobile device, or something like this?
Cause I want to make my virtual device as real as possible. Some applications can only use login on previously logged in devices, but cannot log in on the second device except with the intervention of IT support. So I want to create a perfect 2nd instance to sign in on that device, making that device a perfect version of the first device.
private void writeSessionOS(String str) throws Exception {
final boolean isRooted = CommonUtils.isRooted(this.crashlyticsCore.getContext());
writeSessionPartFile(str, SESSION_OS_TAG, new CodedOutputStreamWriteAction() { // from class: com.crashlytics.android.core.CrashlyticsController.21
#Override // com.crashlytics.android.core.CrashlyticsController.CodedOutputStreamWriteAction
public void writeTo(CodedOutputStream codedOutputStream) throws Exception {
SessionProtobufHelper.writeSessionOS(codedOutputStream, Build.VERSION.RELEASE, Build.VERSION.CODENAME, isRooted);
}
});
writeFile(str, "SessionOS.json", new FileOutputStreamWriteAction() { // from class: com.crashlytics.android.core.CrashlyticsController.22
#Override // com.crashlytics.android.core.CrashlyticsController.FileOutputStreamWriteAction
public void writeTo(FileOutputStream fileOutputStream) throws Exception {
fileOutputStream.write(new JSONObject(new HashMap<String, Object>() { // from class: com.crashlytics.android.core.CrashlyticsController.22.1
{
put("version", Build.VERSION.RELEASE);
put("build_version", Build.VERSION.CODENAME);
put("is_rooted", Boolean.valueOf(isRooted));
}
}).toString().getBytes());
}
});
}
Any idea about this?

Related

How to know if a given device is in the list of supported devices for ARCore?

I am using Google CoreAR package in my React-Native app for AR support. There are some devices which support AR and some not. I am getting error while I run the application in non-supported devices. I want to render a message instead showing error on the screen. For this Google CoreAR package is providing the solution which is not working for me.
void maybeEnableArButton() {
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this);
if (availability.isTransient()) {
// Continue to query availability at 5Hz while compatibility is checked in the background.
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
maybeEnableArButton();
}
}, 200);
}
if (availability.isSupported()) {
mArButton.setVisibility(View.VISIBLE);
mArButton.setEnabled(true);
} else { // The device is unsupported or unknown.
mArButton.setVisibility(View.INVISIBLE);
mArButton.setEnabled(false);
}
}
The problem with above code snippet is that availability.isSupported() is always returning true and that's why else part of code is not running. Can you guys please help me with this?
Thank you.
I found solution for this problem. ArCoreApk.Availability has some methods which can be used. You can find these methods in the
documentation. The method ArCoreApk.Availability
return either SUPPORTED_INSTALLED or SUPPORTED_NOT_INSTALLED depending on device support. So based on this return value we can do the stuff.
I did like this.
#ReactMethod
public ArCoreApk.Availability getSupport(){
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this.getReactApplicationContext());
return availability.name();
}

JSONObject returns null in Android 10?

I have a private app for work installed on a phone running Android 8 and a tablet running Android 8.1 and it's working fine on both but when I installed it on my new phone running Android 10, it gives me an JSON error. The rest of the app works fine but it's showing a JSONObject as null. Is this just a setting or has something changed with Android 10?
#Override
protected Void doInBackground(Void... arg0) {
HttpJsonParser httpJsonParser = new HttpJsonParser();
Map<String, String> httpParams = new HashMap<>();
JSONObject jsonObject = httpJsonParser.makeHttpRequest(GET_VERSION_URL, "GET", httpParams);
if (jsonObject != null) { // <- Returns fine on Android 8.1 but not Android 10
try {
...
} catch (final JSONException e) {
...
}
} else {
MainActivity.this.runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(MainActivity.this,"Error.", Toast.LENGTH_LONG).show(); // <-Goes to this everytime
}
});
}
return null;
}
I don't think your problem is with JSONObject itself. More probably is has to do with changes and restrictions with how HTTP calls are made in Android. Some changes are introduced with newer version like:
Requiring all request to be made using HTTPS.
Deprecation of old HTTP Clients like Apache's one.
Some of those restrictions can be bypassed enabling a config flag, this will give you more time to update your implementation. But the recommended approach is to follow the new guidelines as stop using deprecated stuff.
Go here, and check the "Behavior changes for all apps" and "Behavior changes for apps targeting API XX+" pages for the version of Android where your app doesn't work. That will give you a clue about if this is the problem.

AudioDeviceCallback fails when sharedUserId="android.uid.system"

I am developing an app for an Android custom build.
This app needs to subscribe to AudioDeviceCallback in Android's AudioManager.
I'm using:
mAudioManager.registerAudioDeviceCallback(new MyDeviceCallback(), null);
where:
private class MyDeviceCallback extends AudioDeviceCallback {
#Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
Log.d(LOG_TAG, "onAudioDevicesAdded(): New devices detected");
updateAuxStatus();
}
#Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] devices) {
Log.d(LOG_TAG, "onAudioDevicesAdded(): devices removed");
updateAuxStatus();
}
private void updateAuxStatus() {
AudioDeviceInfo[] devices = mAudioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
boolean isPluggedIn = false;
for (AudioDeviceInfo device : devices) {
if (device.getType() == AudioDeviceInfo.TYPE_LINE_ANALOG) {
isPluggedIn = true;
}
}
onAuxPluggedInChanged(isPluggedIn);
}
}
This works fine when I run the app with normal user (u0_aXX) but when I run the app as system sharedUser (adding to the Manifest):
android:sharedUserId="android.uid.system"
This callback is being called only after subscribing, but never again. Even when other apps without system user are getting the call normally.
I've traced the call to the AudioManager code and found that postEventFromNative in the AudioPortEventHandler is never being called for my app when it is running as system sharedUser. Since that is a jni call I stopped because I don't fully understand how it works.
What really troubles me is that when running without system sharedUser the same code is working as intended. Is there some restriction to system sharedUser that might be causing this problem?
In the AudioPolicy, registerClient use uid as the key. When the phone booted, system_server or telecom already register notification, if your app run as system user, it will never working.
mNotificationClients.add(uid, notificationClient);

Unable to execute silent APK uninstallation due to permission on Lollipop

I'm developing a custom launcher for android based signage (using MiniPC not a device), and follow this thread -> uninstall app silently with system priveleges to enable silent uninstall of 3rd party APK, which is required to do remote install & uninstall by our signage admin.
My implementation that follows the code from the above thread is like below
private class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
#Override
public void packageDeleted(String packageName, int returnCode) throws RemoteException {
}
}
//.... other codes ... //
#Override
protected void onHandleIntent(Intent intent) {
//.... other codes ... //
for (int x = 0; x < compliances.size(); x++) {
deleteObserver = new PackageDeleteObserver();
packageManager = getPackageManager();
Class<?>[] uninstalltypes = new Class[] {String.class, IPackageDeleteObserver.class, int.class};
Method uninstallMethod = packageManager.getClass().getMethod("deletePackage", uninstalltypes);
AppShortcut asc = compliances.get(x);
if (existing.contains(asc) && !asc.isInstalled()) {
uninstallMethod.invoke(packageManager, new Object[] {asc.getName(), deleteObserver, 0});
}
}
}
While my manifest with error signs on permission is like below
But I ignore those error signs, and using Genymotion emulator I ran it and I got below error in logcat
Please if anybody had made this works help me...

android - Wifi Direct Group Owner intent not functioning

I am trying to connect two device to each other by wifi direct. I set the group owner intent to 15, like this :
config.groupOwnerIntent = 15;
but it does not work at all. Also I try to remove all of previous groups that are saved in devices in case of having impact on GO selection.
All the time the other device is getting to be GO. Do you have any idea what could be the problem?
Basically if you would want other device to be Group owner, then use the CreateGroup function to make a group on that device.
The problem is that config.groupOwnerIntent = 15; works with same brands (for example, if both your devices are Samsungs). With different devices sometimes this bug appears.
Also it depends on your connection:
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
#Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
#Override
public void onFailure(int reason) {
Toast.makeText(context, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
or
manager.createGroup(channel, new WifiP2pManager.ActionListener() {
#Override
public void onSuccess() {
// Device is ready to accept incoming connections from peers.
}
#Override
public void onFailure(int reason) {
Toast.makeText(WiFiDirectActivity.this, "P2P group creation failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
Your code doesn't help if you use the second one.
Having same problem with Samsung and Xiaomi now, always same group owner. If a test on both Samsungs everything is okay.

Categories

Resources