2G/3G Preferred Network Mode with root? - Java for Android App Development

I'm trying to access the hidden API for Phone.class to switch the preferred network mode via reflection.
I know this is not safe for porting to other android versions/roms and requires a system app to hold permission WRITE_SECURE_SETTINGS.
I Already managed to switch data via reflection and toggle gps via Settings.Secure.putString() by moving my app to system partition, so i think this should work too.
Does anyone have experience with reflection and/or root and is willing to help?
Of course I will share all my code/findings here.
Thanks in advance!
Links:
http://stackoverflow.com/questions/8607263/android-4-0-4g-toggle
http://stackoverflow.com/questions/5436251/how-to-access-setpreferrednetworktype-in-android-source

You can achieve this with a simple sqlite3 query instead of bothering with java reflection
Here's how :
In a terminal :
To enable 2G only
Code:
su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
insert into global values(null, 'preferred_network_mode', 1);
.exit
To enable 2G & 3G :
Code:
su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
insert into global values(null, 'preferred_network_mode', 0);
.exit
In java :
Example to enable 2G only (just replace the 1 with a 0 in the insert into to enable 2G & 3G)
Code:
try {
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("sqlite3 /data/data/com.android.providers.settings/databases/settings.db" + "\n");
os.writeBytes("insert into global values(null, 'preferred_network_mode', 1);" + "\n");
os.writeBytes(".exit" + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
It might require a reboot to be active though, not sure
If it doesn't work on your rom (tested on cm10.1), it might be a different row name, try investigating your settings.db like this :
Code:
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
.tables [COLOR="Green"]// returns all the tables[/COLOR]
select * from [I]tablename[/I]; [COLOR="green"]// in cm10.1 it's in [I]global[/I] but otherwise look in [I]secure[/I] and/or [I]system[/I]
// this command returns all the rows from the selected table, the names are usually explicit, so you should find the setting you're looking for[/COLOR]
Then, when you found it :
Code:
insert into [I]tablename[/I] values(null, [I]'row name'[/I], value);

Thanks, this is very helpful!
I think you are right, one will need to tell the system to update the settings or send a broadcast that this setting has changed (like for airplane mode).
I will look at the CM sources to find out what i can do.

superkoal said:
Thanks, this is very helpful!
I think you are right, one will need to tell the system to update the settings or send a broadcast that this setting has changed (like for airplane mode).
I will look at the CM sources to find out what i can do.
Click to expand...
Click to collapse
Glad it helped.
If you manage to find a way to make the settings read the db without a reboot, please share your findings, would be very useful.

Androguide.fr said:
Glad it helped.
If you manage to find a way to make the settings read the db without a reboot, please share your findings, would be very useful.
Click to expand...
Click to collapse
Of course i will!

Buddy... you can toggle network mode with intent, no root needed, nor permissions!!
HereĀ“s entire sample:
Code:
package com.serajr.togglenetworkmode;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.provider.Settings.SettingNotFoundException;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bnt = (Button) findViewById(R.id.button1);
bnt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// toggle
toggleNetworkMode();
}
});
}
private void toggleNetworkMode() {
int mode = getCurrentNetworkMode() + 1;
if (mode > 2) {
mode = 0;
}
// 0 = 3G_ONLY
// 1 = 3GSM_ONLY
// 2 = 3G_PREFERRED
// change mode
Intent intent = new Intent("com.android.phone.CHANGE_NETWORK_MODE");
intent.putExtra("com.android.phone.NEW_NETWORK_MODE", mode);
sendBroadcast(intent);
}
private int getCurrentNetworkMode() {
try {
int current = Secure.getInt(getContentResolver(), "preferred_network_mode");
return current;
} catch (SettingNotFoundException ex) {
return 0;
}
}
}
Try it and tell me later!!!

Thanks, but this will only work if your phone.apk has an exported receiver for this intent.
This is only the case if you or your rom dev modded it to be so.
Some custom ROMs also have this kind of "mod/bug" in the power widget, allowing you to toggle gps.
I tried it with slim bean 4.2 build 3 on i9000 and as expected it didn't work (and so will most likely in CM10.1 too).
Just too good to be true!

If youre following the root method Use RootTools for that

sak-venom1997 said:
If youre following the root method Use RootTools for that
Click to expand...
Click to collapse
Thanks, I already do.
Really helpful library!
And yes, I will do it by sql injection to settings.db
I only need to figure out what broadcasts have to be sent / methods called and if this is possible.

Argh I am kinda lost in CM sources.
Can anyone point me to the place where this is handled?
I managed to toggle flight mode by using this in a SU shell:
Code:
if(settingenabled)
{
executeCommand("settings put global airplane_mode_on 1");
executeCommand("am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true");
}
else
{
executeCommand("settings put global airplane_mode_on 0");
executeCommand("am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false");
}
Interstingly enough it didn't work if i manually injected the value and then sent the broadcast.
I have no idea why.
So atm I'm trying to do the same thing for preferred_network_mode. I can write the value to settings.db, but I just don't know what i have to do to make the system apply the setting yet.
EDIT: shell binary "settings" only works in android 4.2 (and probably upwards)

So i finally found it in CM Sources.
Seems like we need to get the currently running Instance of the Phone class to notify it about the change.
Also seems like we are back to reflection, as this is an internal system class.
I also killed com.android.phone process after updating the setting, but that didn't change anything.
EDIT:
1st step towards reflection:
I figured out that i need a jar file from the cm build to use system classes via reflection.
Does anyone have more information about this?

superkoal said:
So i finally found it in CM Sources.
Seems like we need to get the currently running Instance of the Phone class to notify it about the change.
Also seems like we are back to reflection, as this is an internal system class.
I also killed com.android.phone process after updating the setting, but that didn't change anything.
EDIT:
1st step towards reflection:
I figured out that i need a jar file from the cm build to use system classes via reflection.
Does anyone have more information about this?
Click to expand...
Click to collapse
Just a far fetched guess, but maybe try to add /system/framework/framework.jar from your rom to your app's build path
Is a reboot that unacceptable in your case ?

Maybe it's just the challenge, but i wanna change it like every other setting
A reboot is very far from what i call comfortable

superkoal said:
Maybe it's just the challenge, but i wanna change it like every other setting
A reboot is very far from what i call comfortable
Click to expand...
Click to collapse
Yeah, I get what you mean^^^
Here's a good (but old, 2009^^) official Android tutorial from the Android devs on reflection if it can help you : http://android-developers.blogspot.fr/2009/04/backward-compatibility-for-android.html

So i got some news
1. This setting is heavily protected by android system and can only be modified by the phone process itself
2. Some roms have a modified phone apk listening to a broadcast, enabling 3rd party apps to toggle
http://forum.xda-developers.com/showthread.php?t=1731187
3. His Majesty Chainfire started an app project which could amongst other features also toggle 2g/3g, but he gave up development. Regarding 2g/3g he implemented several methods, one of them being RIL injection, which he described as a really hard hack and highly experimental.
http://forum.xda-developers.com/showthread.php?t=807989
Seems this task is not that easy
But i found out that tasker can toggle 2g/3g on my phone (running slim bean 4.2.2), this is when i found out about the modified phone.apk from 2). So I'mcomfortable that it's working on my phone and i can at least develop an app for myself
Sent from my GT-I9000 using xda app-developers app

Related

[Q] How to switch Activity on IF statment

here is a code, i have a basic login screen and if username is correct it need to swiitch to AndroidTab.java view, i cant write a correct code for it any one can help ?
Code:
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]btnLogin[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setOnClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] OnClickListener() {[/SIZE]
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464] @Override[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] public [/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(View v) {[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] // Check Login[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2] String username =[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etUsername[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2] String password = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etPassword[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](username.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"User1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) && password.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"pass"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])){[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] lblResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login successful."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* ************************************[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]* ************************************[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* CODE TO GO TO AndoidTab VIEW Class[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* ************************************[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]**************************************/[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[/LEFT]
[SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] {[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]lblResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login failed. Username and/or password doesn't match."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2] }[/SIZE]
[SIZE=2] }[/SIZE][/LEFT]
[SIZE=2]});[/SIZE][/LEFT]
(if u full code neccessery i can add it)
Look up Intent & startActivity(); there are alot of examples out there.
jug6ernaut said:
Look up Intent & startActivity(); there are alot of examples out there.
Click to expand...
Click to collapse
i know and im looking for an answer online too,
but atm i really could do with a quick fix lol
one learns nothing if everything is handed to them
With that said xD.
Code:
Intent myIntent = new Intent();
//being package name & activity name
myIntent.setClassName("jug6ernaut.lwp.tetris", "jug6ernaut.lwp.settings.ColorSettings");
startActivity(myIntent);
note that the activity will have to be identified in you manifest file.
also note that if you are not going to use your life first activity anymore you will probably want to remove it from the activity stack so that when you press the back button it doesnt reopen it.

[app][root]SecHoleUtils.apk 1.1 Control GPS and PIN from your app. KitKat ready.

Google has always limited the access to several features like GPS on/off management, PIN control and more to third party applications. Sometimes the developers have taken advantage of certain security bugs to circonvent those limitations, but Google has fixed those bugs on the latest OS version.
There are certain functions that in my opinion should be allowed because the security risk is minimun, like GPS control and SIM PIN entering , so I've wr1tten a small app to open this possibility. It does nothing by itself and is not normally loaded but registers for specific intents and when received does those forbidden functions.
Any thir party application can take advantage of it, no need to ask for permisions. Simply broadcast and intent and voila!
Sample usage code:
Code:
public static final String TOOGLE_GPS = "com.beemer.secholeutils.TOOGLE_GPS";
public static final String ENTER_PIN = "com.beemer.secholeutils.ENTER_PIN";
public static final String EXTRA_PIN = "com.beemer.secholeutils.EXTRA_PIN";
public void toogleGPS() {
Intent intent = new Intent(TOOGLE_GPS);
sendBroadcast(intent);
}
public void enterPIN(String PIN) {
Intent intent = new Intent(ENTER_PIN);
intent.putExtra(EXTRA_PIN, PIN);
sendBroadcast(intent);
}
Disclaimer
I'm nor responsible of what happens to your device if you install this apk or while you install it.
Installing this app could allow any third party app to use it to turn on/off the GPS or enter your SIM PIN (if known) even try an brute force atack without asking for permission.
The app must be installed as a system app. You can do it manually but from kitkat on it has became somewhat difficult. I recomend installing busybox and systemappmover from Play store:
https://play.google.com/store/apps/details?id=stericson.busybox
https://play.google.com/store/apps/details?id=de.j4velin.systemappmover
Install secHoleUtils.apk as a normal app and use SystemAppMover to make it a system app.
DEBUG
In order to debug your app, SecHoleUtils will log the calls and errors if they happens:
Code:
pre-KitKat
Log.i("SecHoleUtils", "Received " + TOOGLE_GPS + " intent");
Kitkat:
Log.d("SecHoleUtils", "ToogleGPS. Current mode: " + currentMode + " newMode: " + newMode);
Log.e("SecHoleUtils", "Error toogling GPS");
Log.i("SecHoleUtils", "Received " + ENTER_PIN + " intent");
Log.e("SecHoleUtils", "Error inserting PIN");
Detection of the APK
In order to detect in your app if SecHoleUtils is installed and you can use it, there is a sample code:
Code:
//Test if SecHoleUtils.apk is installed
boolean bSecHoleUtils = false;
try {
getPackageManager().getPackageInfo("com.beemer.secholeutils",PackageManager.GET_META_DATA);
bSecHoleUtils = true;
}
catch (NameNotFoundException e1){}//Not installed. No need to do anything.
If I see interest in the app, I'll add more APIs to it.

[HELP] Native Toast Launcher

I was able to install the HTC Sprint Diagnosis app on my Nokia Lumia 1520 and also have the HTC CSDDiag app installed.
Interesting Part : I was able to run CSDDiag on the Lumia handset and all tests were completed.
Now what i would like to know is how do i run this code in the Native Toast Launcher :
Code:
// Type: DiagnosticTool_Sprint.MainPage
// Assembly: DiagnosticTool_Sprint, Version=1.3.2319.13220, Culture=neutral, PublicKeyToken=null
// MVID: B9415712-08FA-4E66-9A8E-A318594B96CD
// Assembly location: C:\Users\Joshua\Desktop\SPRINT\Data\programs\{E69A2877-59B8-43ED-898D-554FBC4B8B2B}\Install\DiagnosticTool_Sprint.dll
using HTCLogUtil;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Windows.System;
namespace DiagnosticTool_Sprint
{
public class MainPage : PhoneApplicationPage
{
public static string DIALER_CODE_CT_LAB = "0000";
public static string DIALER_CODE_EMBEDDED_TOOL = "634";
public static string DIALER_CODE_SERVICE_TOOL_1 = "778";
public static string DIALER_CODE_SERVICE_TOOL_2 = "786";
public static string DIALER_CODE_VZW_TOOL = "522";
public static string DIALER_CODE_CSDIAG_TOOL = "3424";
public static string DIALER_CODE_DEBUG = "33284";
public static string DIALER_CODE_ZONE_TOOL = "611";
public static string DIALER_CODE_DIAG = "3424";
public static string DIALER_CODE_SCRTN = "72786";
public static string DIALER_CODE_DATA = "3282";
public static string DIALER_CODE_UPDATE = "873283";
public static string strUri;
internal Grid LayoutRoot;
internal StackPanel TitlePanel;
internal Grid ContentPanel;
private bool _contentLoaded;
static MainPage()
{
}
public MainPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
DiagDebugLogUtil.DiagDebugLog(LOG_SEVERITY.LOG_INFO, "[PC Tools]: OnNavigatedTo()++++", new object[0]);
try
{
if (!PhoneApplicationService.Current.State.ContainsKey("VersionNumber"))
PhoneApplicationService.Current.State.Add("VersionNumber", (object) ((object) Assembly.GetExecutingAssembly().GetName().Version).ToString());
string str = "634";
if (this.NavigationContext.QueryString.TryGetValue("DialString", out str))
{
if (str.Equals(MainPage.DIALER_CODE_SERVICE_TOOL_1) || str.Equals(MainPage.DIALER_CODE_SERVICE_TOOL_2) || (str.Equals(MainPage.DIALER_CODE_DATA) || str.Equals(MainPage.DIALER_CODE_SCRTN)))
this.NavigationService.Navigate(new Uri("/ServiceToolLib;component/View/PageLists.xaml", UriKind.Relative));
else if (str.Equals(MainPage.DIALER_CODE_EMBEDDED_TOOL) || str.Equals(MainPage.DIALER_CODE_DEBUG))
{
if (!PhoneApplicationService.Current.State.ContainsKey("DialString"))
PhoneApplicationService.Current.State.Add("DialString", (object) "634");
this.NavigationService.Navigate(new Uri("/EmbeddedTool;component/EmbMainPage.xaml", UriKind.Relative));
}
else if (str.Equals(MainPage.DIALER_CODE_CSDIAG_TOOL))
this.NavigationService.Navigate(new Uri("/RedirectionTool;component/RedirectionPage.xaml?tool=CSDDiag", UriKind.Relative));
else if (str.Equals(MainPage.DIALER_CODE_VZW_TOOL))
this.NavigationService.Navigate(new Uri("/RedirectionTool;component/RedirectionPage.xaml?tool=LabApp", UriKind.Relative));
else if (str.Equals(MainPage.DIALER_CODE_ZONE_TOOL))
{
if (!App.bNoBackForLaunchAPP)
{
MainPage.strUri = "sprintzone:callintercept?code=" + str;
App.bNoBackForLaunchAPP = true;
this.LaunchSprintAP();
}
}
else if (str.Equals(MainPage.DIALER_CODE_UPDATE))
{
if (!App.bNoBackForLaunchAPP)
{
MainPage.strUri = "ms-settings-networkprofileupdate:";
App.bNoBackForLaunchAPP = true;
this.LaunchUpdate();
}
}
else
this.NavigationService.Navigate(new Uri("/EmbeddedTool;component/EmbMainPage.xaml", UriKind.Relative));
}
else
this.NavigationService.Navigate(new Uri("/EmbeddedTool;component/EmbMainPage.xaml", UriKind.Relative));
}
catch (Exception ex)
{
DiagDebugLogUtil.DiagDebugLog(LOG_SEVERITY.LOG_ERROR, "[MainPage] Get Exception msg :" + ((object) ex.Message).ToString(), new object[0]);
this.NavigationService.Navigate(new Uri("/EmbeddedTool;component/EmbMainPage.xaml", UriKind.Relative));
}
DiagDebugLogUtil.DiagDebugLog(LOG_SEVERITY.LOG_INFO, "[PC Tools]: OnNavigatedTo()----", new object[0]);
}
public async void LaunchUpdate()
{
Uri uri = new Uri(MainPage.strUri);
int num = await Launcher.LaunchUriAsync(uri) ? 1 : 0;
}
public async void LaunchSprintAP()
{
Uri uri = new Uri(MainPage.strUri);
int num = await Launcher.LaunchUriAsync(uri) ? 1 : 0;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
this.RemoveEntry("MainPage");
}
private void RemoveEntry(string sPageName)
{
foreach (JournalEntry journalEntry in this.NavigationService.BackStack)
{
if (journalEntry.Source.ToString().Contains(sPageName))
{
this.NavigationService.RemoveBackEntry();
break;
}
}
}
[DebuggerNonUserCode]
public void InitializeComponent()
{
if (this._contentLoaded)
return;
this._contentLoaded = true;
Application.LoadComponent((object) this, new Uri("/DiagnosticTool_Sprint;component/MainPage.xaml", UriKind.Relative));
this.LayoutRoot = (Grid) this.FindName("LayoutRoot");
this.TitlePanel = (StackPanel) this.FindName("TitlePanel");
this.ContentPanel = (Grid) this.FindName("ContentPanel");
}
}
}
I can reach the Main page by issuing :
Code:
app://E69A2877-59B8-43ED-898D-554FBC4B8B2B/_default
However I would like to run the Dialer commands to see if I can mod anything else on the phone. Could some with good brain explain how this will be possible.
I have tried install other platform Diag tools but was only able to install the two above using fiddler ( thanks ngame for your tutorial )
Who did you do that ? I Try it many times before to install these aps on RM-821 Nokia Lumia 920 but didn't work !
how did you do that ? Could you please P.M Me ?
ngame said:
Who did you do that ? I Try it many times before to install these aps on RM-821 Nokia Lumia 920 but didn't work !
how did you do that ? Could you please P.M Me ?
Click to expand...
Click to collapse
It wasnt hard to install those apps. Just followed the fiddler tutorial posted.
Then I connected the phone and installed SysPushApp onto the device and did an update for the SysPushApp to get the non_OEM files of Samsung and HTC . I couldnt install Samsung Diagnosis as it wasn't letting nor was I able to install HTC Hub ( I dont know why, may be they check some .dll specific to them in the phone before install ) .
Change the oSession in fiddler config file to the specific OEM you want to install the app. Example for HTC[ ->
oSession (NOKIA)
(NOKIA), (HTC) /B]
Mt device is Dev-Unlock.
tids2k said:
It wasnt hard to install those apps. Just followed the fiddler tutorial posted.
Then I connected the phone and installed SysPushApp onto the device and did an update for the SysPushApp to get the non_OEM files of Samsung and HTC . I couldnt install Samsung Diagnosis as it wasn't letting nor was I able to install HTC Hub ( I dont know why, may be they check some .dll specific to them in the phone before install ) .
Change the oSession in fiddler config file to the specific OEM you want to install the app. Example for HTC[ ->
oSession (NOKIA)
(NOKIA), (HTC) /B]
Mt device is Dev-Unlock.
Click to expand...
Click to collapse
Samsung diagnosis already removed from wp store so you can't install it easy
and diagnosis you can see in store may different from one in Samsung phones! If you check file sizes you will get what i say
Most of HTC apps only can install ID_Resolution_HD720p and WVGA devices i don't know how is it possible to deploy them on 1080 devices
maybe MS accept this resolution for all apps because the old apps have to add 1080 support?
ngame said:
Samsung diagnosis already removed from wp store so you can't install it easy
and diagnosis you can see in store may different from one in Samsung phones! If you check file sizes you will get what i say
Most of HTC apps only can install ID_Resolution_HD720p and WVGA devices i don't know how is it possible to deploy them on 1080 devices
maybe MS accept this resolution for all apps because the old apps have to add 1080 support?
Click to expand...
Click to collapse
correct some Samsung apps are Unpublished like Diagnosis. Can you tell me how to run the above codes in Native Launcher .. what to type after app://GUID/??
tids2k said:
correct some Samsung apps are Unpublished like Diagnosis. Can you tell me how to run the above codes in Native Launcher .. what to type after app://GUID/??
Click to expand...
Click to collapse
I don't have this xaps but you have to use .Net Reflector 8 or any .net Decompiler then u can see all hidden xamls after _default you have to enter a #/ then dll name without it's dll them a ; and then folder and xaml address
example :
app://GUID/_default#/dllname;Pages/ExamplePage.xaml
ngame said:
I don't have this xaps but you have to use .Net Reflector 8 or any .net Decompiler then u can see all hidden xamls after _default you have to enter a #/ then dll name without it's dll them a ; and then folder and xaml address
example :
app://GUID/_default#/dllname;Pages/ExamplePage.xaml
Click to expand...
Click to collapse
here is the XAP
tids2k said:
here is the XAP
Click to expand...
Click to collapse
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/DiagnosticTool_Sprint;Component/app.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/DiagnosticTool_Sprint;Component/MainPage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/app.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/dmswitchpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/embcheckspc.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/embmainpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/fieldtrialpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ft1xpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftactiveapnconnpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftbtpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftconfigpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftdatastatuspage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftehrpdpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftgpspage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/fthdrpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftltepage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/EmbeddedTool;Component/ftmemorypage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/RedirectionTool;Component/redirectionpage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/homepage.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/checkspc.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/grouplists.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/itemedit.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/itemlists.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/lteavailablefile.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/pagelists.xaml
app://e69a2877-59b8-43ed-898d-554fbc4b8b2b/_default#/ServiceToolLib;Component/view/rwchoice.xaml
OMG!!!!!!!! so many xamls !
If you can get a Screen Shot of each xaml is more useful I think
None of them works. We need to add Dialercodes in the end.
tids2k said:
None of them works. We need to add Dialercodes in the end.
Click to expand...
Click to collapse
Oh i'm Really sorry . I have to buy an Ativ S to be a bit useful for other users but I have no money to buy
I'm again sorry I don't know what's going wrong in the Uris I provided :|
ngame said:
Oh i'm Really sorry . I have to buy an Ativ S to be a bit useful for other users but I have no money to buy
I'm again sorry I don't know what's going wrong in the Uris I provided :|
Click to expand...
Click to collapse
its alright mate.thanks for your help. I will try tomorrow.
did you check the xap's i posted in the other thread. I hope they will be useful. Thanks.
btw my phone came with Hong Kong firmware but I have installed the Australian firmware. Im glad atleast this was possible.
tids2k said:
its alright mate.thanks for your help. I will try tomorrow.
did you check the xap's i posted in the other thread. I hope they will be useful. Thanks.
btw my phone came with Hong Kong firmware but I have installed the Australian firmware. Im glad atleast this was possible.
Click to expand...
Click to collapse
@nGage were you able to install those apps on your phone ?
@nGage there is some good news i was able to run the strings which you posted. It was all about changing 'Component' -> 'component' and some other tweaks. But the .dll library refers to something else and hence the data is not fetchable. I will post the screenshots tomorrow. @W_O_L_F can this file 'HTC Diagnostics_Sprint be hacked in any way as I was able to install this on Nokia 1520 via Windows App Store -> SysPush ( via Fiddler i.e chainging the OEMID=HTC )
tids2k said:
@nGage there is some good news i was able to run the strings which you posted. It was all about changing 'Component' -> 'component' and some other tweaks. But the .dll library refers to something else and hence the data is not fetchable. I will post the screenshots tomorrow. @W_O_L_F can this file 'HTC Diagnostics_Sprint be hacked in any way as I was able to install this on Nokia 1520 via Windows App Store -> SysPush ( via Fiddler i.e chainging the OEMID=HTC )
Click to expand...
Click to collapse
Not for Nokia.
Be very careful with the HTC Sprint tool, since it has the ability to change NV values, even if it is commented out. (don't know why.) but it sure does.
hutchinsane_ said:
Be very careful with the HTC Sprint tool, since it has the ability to change NV values, even if it is commented out. (don't know why.) but it sure does.
Click to expand...
Click to collapse
thanks for the advice. But the app is pointless on Nokia phones as i have tried it and it doesn't work ... It can go to the menu's bit cannot get the values either it needs Interop or the dll linked is not for the device.

How to search StorageFiles

I need a way to search in StorageFiles with dynamically pattern, which comes from a TextBox. The directive "Windows.Storage.Search" doesnt exist in windows phone 8.1 runtime, as i saw. Now my question is, how can i do this in alternative way?
The only way to do it with WP 8.1 since Microsoft ALWAYS fails to implement the important things are to query using LINQ.
Ex:
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(x => txtBox.Text));
That's about all you can do pretty much. (Thanks Microsoft).
Thank you for the example. But it wont work for me, it shows me the following error(s):
Code:
A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'parent or current' scope to denote something else
and
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
Thats really odd from Microsoft, that they havent implementet the search function like in WinRT (Windows Store App).
The first error is pretty simple. You already have the variable named "x" and it would be very bad if compiler didn't give you that error.
Change the name of the variable to something else that you don't use in that scope and it will work.
And for second problem, try this one:
Code:
private List<string> Result()
{
var result = ((List<Windows.Storage.Search.CommonFileQuery>)Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).Where(x => x.ToString().Contains(txtBox.Text));
return result as List<string>;
}
private async Task<List<string>> ResultAsync()
{
return await Task.Run(() => Result()).ConfigureAwait(continueOnCapturedContext: false);
}
You should call ResultAsync method and get the result in this way:
Code:
List<string> myList = ResultAsync().Result;
That's not going to work. You can't cast a StorageFile as a string.
To fix my code (simple lambda typo)
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(txtBox.Text));
if(result.Any())
{
// Do shtuff
}
Also, you should never access the .Result of an async task because you never know if it completed yet.
Ok, first error is done, but the second error is still here
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
You are missing the point of the TAP (Task Async Pattern).
Both main thread and async method will be in execution in the same time. When the async method finish his work, main thread will stop and catch the result trough the Result property.
TAP is the recommended way of asynchronous programming in C#. The only thing with TAP is to use ConfigureAwait method in non-console type of apps to avoid deadlock.
Sooner or later you will get the result from TAP method. Nothing will get in the conflict with the main thread.
Oh wait, @andy123456 I updated my response. I forgot String.Contains ISNT a lambda .
@Tonchi91, I know all about the TAP. I've been using it since it was CTP. I've seen the awkward situations with threading in WP .
Now... if he did
Code:
List<string> myList;
ResultAsync().ContinueWith(t=> { myList = t.Result; });
I wouldn't be worried .
Ok the errors are gone, but the debugger show me the following exception:
Code:
Value does not fall within the expected range
Is this search method case-sensitive? I tried with an exact input in the TextBox.
Hmmm. Let's see your full code.
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
andy123456 said:
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
Click to expand...
Click to collapse
Oh Camera Roll.. You MIGHT need to have the capability to view the camera roll enabled. I forget what it's called, but you need a specific cap in order to view from there. Also, I would try to see if you can use a generic folder instead.
I would try Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync() as your method after the await just to test whether you can read correctly.
Yes but in wp8.1 runtime app, there arent caps anymore. The capability for access to the pictures is simply calles pictures library and is enabled. I have tested it as you said, but it gives me the same exception.
A quick tip: another way to do this is to use the Win32 C runtime API. You can, for example, use the FindFirst/NextFile functions (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx) which support searches using wildcards (* and ? characters in the first parameter). These functions are wrapped in my NativeLibraries classes, but are also just publicly available for third0party developers to call from their own C++ DLLs.
Alternatively, you can use the .NET System.IO.Directory class, which has functions like EnumerateFiles(String path, String searchPattern). This is probably the better way to do it, actually.
Of course, if you want these operations to not block the current thread, you'll need to explicitly put them in their own thread or async function.
EDIT: This also assumes you have read access to the relevant directories. You application data directory works fine, for example (you can get its path from the relevant StorageFolder object). Other directories that can be accessed via WinRT functions may go through a broker function instead of being directly readable.
The point is, that i have an array with filenames. Now i need the StorageFile files which contains these filenames. My idea was to search for these files and return the files as StorageFile, so i can work with these. Or is there a simpler / another way?
http://msicc.net/?p=4182 <-- try this
Thank you, i have already done this and its working. But how can i compare the Files to read, with already read files and take only the not yet read files?

[FIX][CM11][XPOSED] Fix for Google Camera error on CM11

This Xposed module I made is a workaraound for the "Cannot connect to camera" problem on i9300 CM11 (Don't know if other devices has the same problem. However, the module may work on every device with Google Camera, because of the way it is implemented). I used the "Restart Camera" apk by temasek for some time, but I shortly got tired of making two or three taps every time I had to take a picture, so I kind of "reverse engineered" the temasek's apk and found out that it just kills the MediaServer process. Then, I build an Xposed module to do this automatically every time the user closes Google Camera app. I wrote that in few minutes so I haven't done a lot of testing, but it seem to work fine on my device and I think it can be shared with other users so everybody can get rid of this bug.
INSTRUCTIONS:
Code:
1. Install Xposed Framework (if you don't have it already)
2. Install the APK
3. Enable the module and reboot the device
4. Start Google Camera, wait until it loads the preview, then press the "Back" key to exit. When prompted, grant Google Camera root access for every future requests
5. Enjoy
SOURCE CODE:
Code:
package jager.cmcamerafix;
import java.io.DataOutputStream;
import java.io.IOException;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class CameraFix implements IXposedHookLoadPackage {
XC_MethodHook mMethodHook = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("killall mediaserver\n");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
} catch (IOException e) {
throw new Exception(e);
}
}
};
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.google.android.GoogleCamera"))
return;
findAndHookMethod("com.android.camera.CameraActivity", lpparam.classLoader, "onStopTasks", mMethodHook);
}
}
CREDITS:
Code:
- temasek for "Restart Camera" apk
- robv89 for Xposed Framework
@Moderators: I wrote here because I haven't got permissions to write in the Dev section. Sorry.
lollipop compability
This module that can be compatible with android 5.0?
Lollipop
Working great on Lollipop 5.1.1! HUGE THANK YOU
Edited Version for cm13
thanks jagger for your module
i tested it on cm13 rom but it does not work, so i edit it and makes some updates to get it work with cm13 stock camera ( cyanogenmod snap camera )
new version in attachments

Categories

Resources