i has decompile screen_capture_1.03 and i saw these code:
hookThread = new BackgroundWorker();
hookThread.DoWork += delegate (object o, DoWorkEventArgs e) {
while (true)
{
for (int j = 0; j < m_listenFor.Length; j++)
{
if ((DllImportCaller.lib.GetAsyncKeyState7(m_listenFor[j]) != 0) && (OnKeyDown != null))
{
OnKeyDown(null, (PhysicalKeys) m_listenFor[j]);
}
}
Thread.Sleep(500);
}
};
hookThread.RunWorkerAsync();
/////////////////////////////
so i use it and change it to a test code:
BackgroundWorker s=new BackgroundWorker();
S.DoWork+=delegate(object o,DoWorkEventArgs e)
{
while(true)
{
MessageBox.Show(i.ToString());//varible i has been declared before;
i++;
Thread.Sleep(500);
}
};
s.RunWorkAsync();
!!however,we i run it on my hdc device!nothing happened!WHY? AND
I have changed the DehydrateOnPause from 3 to 0.but it still can't work !
who can save me!!!!!!
kissmegodlike said:
i has decompile screen_capture_1.03 and i saw these code:
hookThread = new BackgroundWorker();
hookThread.DoWork += delegate (object o, DoWorkEventArgs e) {
while (true)
{
for (int j = 0; j < m_listenFor.Length; j++)
{
if ((DllImportCaller.lib.GetAsyncKeyState7(m_listenFor[j]) != 0) && (OnKeyDown != null))
{
OnKeyDown(null, (PhysicalKeys) m_listenFor[j]);
}
}
Thread.Sleep(500);
}
};
hookThread.RunWorkerAsync();
/////////////////////////////
so i use it and change it to a test code:
BackgroundWorker s=new BackgroundWorker();
S.DoWork+=delegate(object o,DoWorkEventArgs e)
{
while(true)
{
MessageBox.Show(i.ToString());//varible i has been declared before;
i++;
Thread.Sleep(500);
}
};
s.RunWorkAsync();
!!however,we i run it on my hdc device!nothing happened!WHY? AND
I have changed the DehydrateOnPause from 3 to 0.but it still can't work !
who can save me!!!!!!
Click to expand...
Click to collapse
You have to keep the for int in there, as it is constantly waiting for you to press the button.
TheMrBlue said:
You have to keep the for int in there, as it is constantly waiting for you to press the button.
Click to expand...
Click to collapse
In fact,i mean the backroundworker does't work at all.cound you tell me what errors result in my code's failure.
I have a modified wifidisplaysettings.java file that enables auto connect to wifi display but i need some help getting it into settings.apk. can anyone help with recompiling?
How did you decompile?
Sent from my Nexus 5 using Tapatalk
i used apk2java. i was also talking to someone on another forum who gave me the modified java file but said that the files I got from decompiling may not be useable for recompiling, so im not really sure how to get this back in to there.
I would recommend decompiling with apk tool, making the mods then recompiling with Apk tool. There are guides on xda
Sent from my Nexus 5 using Tapatalk
i decompiled with apk tool but i got smali files. i dont know how to make the changes i need in smali. the modified file i have is a java file.
Munkee915 said:
ii dont know how to make the changes i need in smali
Click to expand...
Click to collapse
If you're wanting to recompile, you'll need to work that out
Sent from my Nexus 5 using Tapatalk
well here are the steps ive taken so far. Keep in mind im not a programmer. Im doing everything from the seat of my pants and whatever i can find on here and google:
1. I have the modified wifidisplaysettings.java and settings.apk from the original author (JOK on appradio forums, he gave me permission to seek help compiling into something i can use) which is built off of CM 10.2 settings.apk.
2. Tried flashing his file, flash failed
3. Tried modifying his zip file with the META-INF from another mod i have on the phone. flash succeeds, but Settings is missing from my apps. i can see it in system/priv-app but when i click on it it asks to install and then fails.
4. I decompiled my settings.apk (stock kot49h) to java and changed my wifidisplaysettings.java w/ his edits but im told i cant recompile this back to a usable APK.
5. I decompiled his settings.apk and my settings.apk to smali and moved his wfd folder into my decompiled folder, recompiled my settings.apk, signed and flashed to my phone. Phone boots but again Settings is missing from my apps
6. Tried flashing CM 11 nightly and then flashing his settings file, no dice
7. Pulled the stock CM 11 settings.apk, decompiled to smali and swapped the wfd folder, recompiled, signed and flashed. i can open settings now but when i go to cast screen settings crashes.
8. Restored my nandroid backup and now im seeking help
When you recompile, don't forget to replace all the signature files from your original apk.
http://forum.xda-developers.com/showthread.php?t=1989533
Sent from my Nexus 5 using Tapatalk
is that not the same thing as resigning the apk? I've been using signapk for that part and then going to flash after that.
Rule it out
Sent from my Nexus 5 using Tapatalk
rootSU said:
Rule it out
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Same thing. Compiled and pulled the xml files and resources file and put them into the original apk and flashed. Phone boots but settings is nowhere to be found.
Munkee915 said:
Same thing. Compiled and pulled the xml files and resources file and put them into the original apk and flashed. Phone boots but settings is nowhere to be found.
Click to expand...
Click to collapse
You need to decompile and recompile with apktool or any other tool like that mate. You need to edit the smali if you want to make changes. But if i am not wrong you can decompile the settingsprovider and make the changes in bools to enable that option.
Sent from my Nexus 5 using XDA Premium 4 mobile app
maybe (or definitely) i dont understand what im doing. i am decompiling and compiling with apktool. when i decompile i see smali files and i make the changes there. i then recompile with apktool and in the resulting apk i only have xml files, so going with guide rootSU pointed me to i use winrar and pull them from teh new apk and drop them in the original apk along with resources.arsc and flash that. the original author has suggested i build the entire image again from source using his java file and it should work, but taht would mean i have to setup a build environment. i cant even get this right im not sure i can build an image from source lol.
Sometimes it's the modifications that cause the problem.
Is his settings.apk from the same phone? Same ROM? You can't build stock settings from source. Only aosp.
Sent from my Nexus 5 using Tapatalk
his mod was done on CM 10.2 on a GS4. Not the same but when we compared the source they were almost identical so we were hoping it was close enough that they would translate over.
Very doubtful
Sent from my Nexus 5 using Tapatalk
Well that's disappointing. It seems like a really useful mod that a lot of people ask for it's a shame we cant get it going. if anyone wants to take a crack at it here is the java code I was given. Hopefully someone can get this done.
Code:
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wfd;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.hardware.display.DisplayManager;
import android.hardware.display.IRemoteDisplayAdapter;
import android.hardware.display.WifiDisplay;
import android.hardware.display.WifiDisplayStatus;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.Html;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import com.android.settings.ProgressCategory;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
/**
* The Settings screen for WifiDisplay configuration and connection management.
*/
public final class WifiDisplaySettings extends SettingsPreferenceFragment {
private static final String TAG = "WifiDisplaySettings";
private static final int MENU_ID_SCAN = Menu.FIRST;
private DisplayManager mDisplayManager;
private boolean mWifiDisplayOnSetting;
private WifiDisplayStatus mWifiDisplayStatus;
private WifiDisplayStatus mRemoteDisplayStatus;
private IRemoteDisplayAdapter mRemoteDisplayAdapter;
private PreferenceGroup mPairedDevicesCategory;
private ProgressCategory mAvailableDevicesCategory;
private TextView mEmptyView;
private Switch mActionBarSwitch;
private CheckBoxPreference mDisableHDCP;
private static final String DISABLE_HDCP_PREF = "persist.sys.wfd.nohdcp";
public WifiDisplaySettings() {
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mDisplayManager = (DisplayManager)getActivity().getSystemService(Context.DISPLAY_SERVICE);
mRemoteDisplayAdapter = mDisplayManager.getRemoteDisplayAdapter();
addPreferencesFromResource(R.xml.wifi_display_settings);
setHasOptionsMenu(true);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Activity activity = getActivity();
mActionBarSwitch = new Switch(activity);
mActionBarSwitch.setOnCheckedChangeListener(mSwitchOnCheckedChangedListener);
final int padding = activity.getResources().getDimensionPixelSize(
R.dimen.action_bar_switch_padding);
mActionBarSwitch.setPaddingRelative(0, 0, padding, 0);
activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM);
activity.getActionBar().setCustomView(mActionBarSwitch,
new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.END));
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(mEmptyView);
update();
// JOK auto connect
autoConnect();
if (mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE) {
activity.finish();
}
}
@Override
public void onDestroyView() {
getActivity().getActionBar().setCustomView(null);
super.onDestroyView();
}
private void scanRemoteDisplays() {
try {
mRemoteDisplayAdapter.scanRemoteDisplays();
}
catch (RemoteException e) {
}
}
@Override
public void onResume() {
super.onResume();
Context context = getActivity();
IntentFilter filter = new IntentFilter();
filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
filter.addAction(DisplayManager.ACTION_REMOTE_DISPLAY_STATUS_CHANGED);
context.registerReceiver(mReceiver, filter);
getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
Settings.Global.WIFI_DISPLAY_ON), false, mSettingsObserver);
mDisplayManager.scanWifiDisplays();
scanRemoteDisplays();
update();
// JOK auto connect
autoConnect();
}
@Override
public void onPause() {
super.onPause();
Context context = getActivity();
context.unregisterReceiver(mReceiver);
getContentResolver().unregisterContentObserver(mSettingsObserver);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(Menu.NONE, MENU_ID_SCAN, 0,
mWifiDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_SCANNING ?
R.string.wifi_display_searching_for_devices :
R.string.wifi_display_search_for_devices);
item.setEnabled(mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON
&& mWifiDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_NOT_SCANNING);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_ID_SCAN:
if (mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
mDisplayManager.scanWifiDisplays();
}
if (mRemoteDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
scanRemoteDisplays();
}
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
if (preference instanceof WifiDisplayPreference) {
WifiDisplayPreference p = (WifiDisplayPreference)preference;
WifiDisplay display = p.getDisplay();
boolean isActive = false;
if (p.isRemoteDisplay()) {
isActive = display.equals(mRemoteDisplayStatus.getActiveDisplay());
} else {
isActive = display.equals(mWifiDisplayStatus.getActiveDisplay());
}
if (isActive) {
showDisconnectDialog(display, p.isRemoteDisplay());
} else if (!p.isRemoteDisplay()) {
mDisplayManager.connectWifiDisplay(display.getDeviceAddress());
} else {
try {
mRemoteDisplayAdapter.connectRemoteDisplay(display.getDeviceAddress());
}
catch (RemoteException e) {
}
}
}
else if (preference == mDisableHDCP) {
SystemProperties.set(DISABLE_HDCP_PREF, mDisableHDCP.isChecked() ? "1" : "0");
return true;
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
private void update() {
mWifiDisplayOnSetting = Settings.Global.getInt(getContentResolver(),
Settings.Global.WIFI_DISPLAY_ON, 0) != 0;
mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus();
try {
mRemoteDisplayStatus = mRemoteDisplayAdapter.getRemoteDisplayStatus();
}
catch (RemoteException e) {
}
applyState();
}
private void applyState() {
final int featureState = mWifiDisplayStatus.getFeatureState();
mActionBarSwitch.setEnabled(featureState != WifiDisplayStatus.FEATURE_STATE_DISABLED);
mActionBarSwitch.setChecked(mWifiDisplayOnSetting);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
if (featureState == WifiDisplayStatus.FEATURE_STATE_ON) {
final WifiDisplay[] pairedDisplays = mWifiDisplayStatus.getRememberedDisplays();
final WifiDisplay[] availableDisplays = mWifiDisplayStatus.getAvailableDisplays();
final WifiDisplay[] pairedRemoteDisplays = mRemoteDisplayStatus.getRememberedDisplays();
final WifiDisplay[] availableRemoteDisplays = mRemoteDisplayStatus.getAvailableDisplays();
mDisableHDCP = new CheckBoxPreference(getActivity().getApplicationContext());
mDisableHDCP.setTitle(R.string.pref_wifi_disable_hdcp_title);
mDisableHDCP.setSummary(R.string.pref_wifi_disable_hdcp_summary);
mDisableHDCP.setChecked(Integer.parseInt(SystemProperties.get(DISABLE_HDCP_PREF, "0")) != 0);
mDisableHDCP.setOrder(0);
preferenceScreen.addPreference(mDisableHDCP);
if (mPairedDevicesCategory == null) {
mPairedDevicesCategory = new PreferenceCategory(getActivity());
mPairedDevicesCategory.setTitle(R.string.wifi_display_paired_devices);
} else {
mPairedDevicesCategory.removeAll();
}
mPairedDevicesCategory.setOrder(1);
preferenceScreen.addPreference(mPairedDevicesCategory);
for (WifiDisplay d : pairedDisplays) {
mPairedDevicesCategory.addPreference(createWifiDisplayPreference(d, true, false));
}
for (WifiDisplay d : pairedRemoteDisplays) {
if (d.isHidden()) {
continue;
}
mPairedDevicesCategory.addPreference(createWifiDisplayPreference(d, true, true));
}
if (mPairedDevicesCategory.getPreferenceCount() == 0) {
preferenceScreen.removePreference(mPairedDevicesCategory);
}
if (mAvailableDevicesCategory == null) {
mAvailableDevicesCategory = new ProgressCategory(getActivity(), null,
R.string.wifi_display_no_devices_found);
mAvailableDevicesCategory.setTitle(R.string.wifi_display_available_devices);
} else {
mAvailableDevicesCategory.removeAll();
}
mAvailableDevicesCategory.setOrder(2);
preferenceScreen.addPreference(mAvailableDevicesCategory);
for (WifiDisplay d : availableDisplays) {
if (!contains(pairedDisplays, d.getDeviceAddress())) {
mAvailableDevicesCategory.addPreference(createWifiDisplayPreference(d, false, false));
}
}
for (WifiDisplay d : availableRemoteDisplays) {
if (!contains(pairedRemoteDisplays, d.getDeviceAddress())
&& !(d.getDeviceName().startsWith("hidden:"))) {
mAvailableDevicesCategory.addPreference(createWifiDisplayPreference(d, false, true));
}
}
if (mWifiDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_SCANNING ||
mRemoteDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_SCANNING) {
mAvailableDevicesCategory.setProgress(true);
} else {
mAvailableDevicesCategory.setProgress(false);
}
} else {
mEmptyView.setText(featureState == WifiDisplayStatus.FEATURE_STATE_OFF ?
R.string.wifi_display_settings_empty_list_wifi_display_off :
R.string.wifi_display_settings_empty_list_wifi_display_disabled);
}
getActivity().invalidateOptionsMenu();
}
private void autoConnect() {
final int featureState = mWifiDisplayStatus.getFeatureState();
/** mActionBarSwitch.setEnabled(featureState != WifiDisplayStatus.FEATURE_STATE_DISABLED);
mActionBarSwitch.setChecked(mWifiDisplayOnSetting);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll(); */
if (featureState == WifiDisplayStatus.FEATURE_STATE_ON) {
final WifiDisplay[] pairedDisplays = mWifiDisplayStatus.getRememberedDisplays();
final WifiDisplay[] availableDisplays = mWifiDisplayStatus.getAvailableDisplays();
final WifiDisplay[] pairedRemoteDisplays = mRemoteDisplayStatus.getRememberedDisplays();
final WifiDisplay[] availableRemoteDisplays = mRemoteDisplayStatus.getAvailableDisplays();
/** mDisableHDCP = new CheckBoxPreference(getActivity().getApplicationContext());
mDisableHDCP.setTitle(R.string.pref_wifi_disable_hdcp_title);
mDisableHDCP.setSummary(R.string.pref_wifi_disable_hdcp_summary);
mDisableHDCP.setChecked(Integer.parseInt(SystemProperties.get(DISABLE_HDCP_PREF, "0")) != 0);
mDisableHDCP.setOrder(0);
preferenceScreen.addPreference(mDisableHDCP);
if (mPairedDevicesCategory == null) {
mPairedDevicesCategory = new PreferenceCategory(getActivity());
mPairedDevicesCategory.setTitle(R.string.wifi_display_paired_devices);
} else {
mPairedDevicesCategory.removeAll();
}
mPairedDevicesCategory.setOrder(1);
preferenceScreen.addPreference(mPairedDevicesCategory); */
/** for (WifiDisplay d : pairedDisplays) {
mPairedDevicesCategory.addPreference(createWifiDisplayPreference(d, true, false));
}
for (WifiDisplay d : pairedRemoteDisplays) {
if (d.isHidden()) {
continue;
}
mPairedDevicesCategory.addPreference(createWifiDisplayPreference(d, true, true));
}
if (mPairedDevicesCategory.getPreferenceCount() == 0) {
preferenceScreen.removePreference(mPairedDevicesCategory);
}
if (mAvailableDevicesCategory == null) {
mAvailableDevicesCategory = new ProgressCategory(getActivity(), null,
R.string.wifi_display_no_devices_found);
mAvailableDevicesCategory.setTitle(R.string.wifi_display_available_devices);
} else {
mAvailableDevicesCategory.removeAll();
}
mAvailableDevicesCategory.setOrder(2);
preferenceScreen.addPreference(mAvailableDevicesCategory); */
for (WifiDisplay d : availableDisplays) {
/** if (!contains(pairedDisplays, d.getDeviceAddress())) {
mAvailableDevicesCategory.addPreference(createWifiDisplayPreference(d, false, false));
} */
// JOK check if there is an existing connection
boolean isActive = false;
isActive = d.equals(mWifiDisplayStatus.getActiveDisplay());
// JOK only connect, if there is no existing connection
if (!isActive) {
mDisplayManager.connectWifiDisplay(d.getDeviceAddress());
}
}
for (WifiDisplay d : availableRemoteDisplays) {
/** if (!contains(pairedRemoteDisplays, d.getDeviceAddress())
&& !(d.getDeviceName().startsWith("hidden:"))) {
mAvailableDevicesCategory.addPreference(createWifiDisplayPreference(d, false, true));
} */
// JOK check if there is an existing connection
boolean isActive = false;
isActive = d.equals(mRemoteDisplayStatus.getActiveDisplay());
// JOK only connect, if there is no existing connection
if (!isActive) {
try {
mRemoteDisplayAdapter.connectRemoteDisplay(d.getDeviceAddress());
}
catch (RemoteException e) {
}
}
}
/** if (mWifiDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_SCANNING ||
mRemoteDisplayStatus.getScanState() == WifiDisplayStatus.SCAN_STATE_SCANNING) {
mAvailableDevicesCategory.setProgress(true);
} else {
mAvailableDevicesCategory.setProgress(false);
}
} else {
mEmptyView.setText(featureState == WifiDisplayStatus.FEATURE_STATE_OFF ?
R.string.wifi_display_settings_empty_list_wifi_display_off :
R.string.wifi_display_settings_empty_list_wifi_display_disabled); */
}
//getActivity().invalidateOptionsMenu();
}
private Preference createWifiDisplayPreference(final WifiDisplay d, boolean paired, boolean isRemote) {
WifiDisplayPreference p = new WifiDisplayPreference(getActivity(), d, isRemote);
WifiDisplayStatus displayStatus = null;
if (isRemote) {
displayStatus = mRemoteDisplayStatus;
} else {
displayStatus = mWifiDisplayStatus;
}
if (d.equals(displayStatus.getActiveDisplay())) {
switch (displayStatus.getActiveDisplayState()) {
case WifiDisplayStatus.DISPLAY_STATE_CONNECTED:
p.setSummary(R.string.wifi_display_status_connected);
break;
case WifiDisplayStatus.DISPLAY_STATE_CONNECTING:
p.setSummary(R.string.wifi_display_status_connecting);
break;
}
} else if (paired && contains(displayStatus.getAvailableDisplays(),
d.getDeviceAddress())) {
p.setSummary(R.string.wifi_display_status_available);
}
if (paired) {
p.setWidgetLayoutResource(R.layout.wifi_display_preference);
}
return p;
}
private void showDisconnectDialog(final WifiDisplay display, final boolean isRemoteDisplay) {
DialogInterface.OnClickListener ok = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!isRemoteDisplay && display.equals(mWifiDisplayStatus.getActiveDisplay())) {
mDisplayManager.disconnectWifiDisplay();
} else if (isRemoteDisplay && display.equals(mRemoteDisplayStatus.getActiveDisplay())) {
try {
mRemoteDisplayAdapter.disconnectRemoteDisplay();
}
catch (RemoteException e) {
}
}
}
};
AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setTitle(R.string.wifi_display_disconnect_title)
.setMessage(Html.fromHtml(getResources().getString(
R.string.wifi_display_disconnect_text, display.getFriendlyDisplayName())))
.setPositiveButton(android.R.string.ok, ok)
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.show();
}
private void showOptionsDialog(final WifiDisplay display, final boolean isRemoteDisplay) {
View view = getActivity().getLayoutInflater().inflate(R.layout.wifi_display_options, null);
final EditText nameEditText = (EditText)view.findViewById(R.id.name);
nameEditText.setText(display.getFriendlyDisplayName());
DialogInterface.OnClickListener done = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = nameEditText.getText().toString().trim();
if (name.isEmpty() || name.equals(display.getDeviceName())) {
name = null;
}
if (!isRemoteDisplay) {
mDisplayManager.renameWifiDisplay(display.getDeviceAddress(), name);
} else {
try {
mRemoteDisplayAdapter.renameRemoteDisplay(display.getDeviceAddress(), name);
}
catch (RemoteException e) {
}
}
}
};
DialogInterface.OnClickListener forget = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!isRemoteDisplay) {
mDisplayManager.forgetWifiDisplay(display.getDeviceAddress());
} else {
try {
mRemoteDisplayAdapter.forgetRemoteDisplay(display.getDeviceAddress());
}
catch (RemoteException e) {
}
}
}
};
AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setTitle(R.string.wifi_display_options_title)
.setView(view)
.setPositiveButton(R.string.wifi_display_options_done, done)
.setNegativeButton(R.string.wifi_display_options_forget, forget)
.create();
dialog.show();
}
private static boolean contains(WifiDisplay[] displays, String address) {
for (WifiDisplay d : displays) {
if (d.getDeviceAddress().equals(address)) {
return true;
}
}
return false;
}
private final CompoundButton.OnCheckedChangeListener mSwitchOnCheckedChangedListener =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mWifiDisplayOnSetting = isChecked;
Settings.Global.putInt(getContentResolver(),
Settings.Global.WIFI_DISPLAY_ON, isChecked ? 1 : 0);
}
};
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED)) {
WifiDisplayStatus status = (WifiDisplayStatus)intent.getParcelableExtra(
DisplayManager.EXTRA_WIFI_DISPLAY_STATUS);
mWifiDisplayStatus = status;
applyState();
// JOK auto connect
autoConnect();
} else if (action.equals(DisplayManager.ACTION_REMOTE_DISPLAY_STATUS_CHANGED)) {
WifiDisplayStatus status = (WifiDisplayStatus)intent.getParcelableExtra(
DisplayManager.EXTRA_REMOTE_DISPLAY_STATUS);
mRemoteDisplayStatus = status;
applyState();
// JOK auto connect
autoConnect();
}
}
};
private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange, Uri uri) {
update();
}
};
private final class WifiDisplayPreference extends Preference
implements View.OnClickListener {
private final WifiDisplay mDisplay;
private final boolean mIsRemoteDisplay;
public WifiDisplayPreference(Context context,
WifiDisplay display, boolean isRemoteDisplay) {
super(context);
mDisplay = display;
mIsRemoteDisplay = isRemoteDisplay;
setTitle(display.getFriendlyDisplayName());
}
public WifiDisplay getDisplay() {
return mDisplay;
}
public boolean isRemoteDisplay() {
return mIsRemoteDisplay;
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
ImageView deviceDetails = (ImageView) view.findViewById(R.id.deviceDetails);
if (deviceDetails != null) {
deviceDetails.setOnClickListener(this);
if (!isEnabled()) {
TypedValue value = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
value, true);
deviceDetails.setImageAlpha((int)(value.getFloat() * 255));
}
}
}
@Override
public void onClick(View v) {
showOptionsDialog(mDisplay, mIsRemoteDisplay);
}
}
}
So, I took the time to write (poorly) a program to brute force an android bootloader password. I was bored. It would take years, but if you feel like not being able to use your phone for that long, or maybe you want to use it in something else or improve it, here it is:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/*----------------------------------------------------------------*/
/* Broot-force: An android brute-force boorloader unlocker */
/* By Jonathan Schuett */
/* You download or use this software at your own risk, and the */
/* creator assumes no liability for damage, failure, unexpected */
/* outcomes, boogeymen, or timey-wimey nonsense. Your usage of */
/* this software is to be interpreted as an acceptance of these */
/* terms. You may freely distribute, modify, or reuse this code */
/* or any part herein, as long as you state that you've done so */
/*----------------------------------------------------------------*/
int success = 1;
int recurse = 1;
char update(char sign)
{
recurse=1;
if(sign=='Z') {
sign='0';
recurse=0;
return(sign);
}
if(sign=='Y')
sign='Z';
if(sign=='X')
sign='Y';
if(sign=='W')
sign='X';
if(sign=='V')
sign='W';
if(sign=='U')
sign='V';
if(sign=='T')
sign='U';
if(sign=='S')
sign='T';
if(sign=='R')
sign='S';
if(sign=='Q')
sign='R';
if(sign=='P')
sign='Q';
if(sign=='O')
sign='P';
if(sign=='N')
sign='O';
if(sign=='M')
sign='N';
if(sign=='L')
sign='M';
if(sign=='K')
sign='L';
if(sign=='J')
sign='K';
if(sign=='I')
sign='J';
if(sign=='H')
sign='I';
if(sign=='G')
sign='H';
if(sign=='F')
sign='G';
if(sign=='E')
sign='F';
if(sign=='D')
sign='E';
if(sign=='C')
sign='D';
if(sign=='B')
sign='C';
if(sign=='A')
sign='B';
if(sign=='9')
sign='A';
if(sign=='8')
sign='9';
if(sign=='7')
sign='8';
if(sign=='6')
sign='7';
if(sign=='5')
sign='6';
if(sign=='4')
sign='5';
if(sign=='3')
sign='4';
if(sign=='2')
sign='3';
if(sign=='1')
sign='2';
if(sign=='0')
sign='1';
return(sign);
}
/*
char update(char sign)
{
sign = ++sign % 'F';
if(sign == '9' + 1)
sign = 'A';
if(sign == 'F')
recurse = 0;
return sign;
}
*/
void main(void)
{
char bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10, bt11, bt12, bt13, bt14, bt15, bt16;
bt1 = bt2 = bt3 = bt4 = bt5 = bt6 = bt7 = bt8 = bt9 = bt10 = bt11 = bt12 = bt13 = bt14 = bt15 = bt16 = '0';
char attempt[37];
printf("Sequential number generator for brute forcing android bootloaders. Version 0.05\n");
getchar();
while(success==1)
{
getchar();
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
while(success==1&&recurse==1)
{
char attempt[37] = {'f', 'a', 's', 't', 'b', 'o', 'o', 't', ' ', 'o', 'e', 'm', ' ', 'u', 'n', 'l', 'o', 'c', 'k', ' ', bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10, bt11, bt12, bt13, bt14, bt15, bt16, '\0' };
system(attempt);
bt16 = update(bt16);
}
bt15 = update(bt15);
}
bt14 = update(bt14);
}
bt13 = update(bt13);
}
bt12 = update(bt12);
}
bt11 = update(bt11);
}
bt10 = update(bt10);
}
bt9 = update(bt9);
}
bt8 = update(bt8);
}
bt7 = update(bt7);
}
bt6 = update(bt6);
}
bt5 =update(bt5);
}
bt4 = update(bt4);
}
bt3 = update(bt3);
}
bt2 = update(bt2);
}
if(bt1!='Z')
{
bt1 = update(bt1);
} else if(bt1=='Z') {
printf("\n\n\nAll 16 character RSA strings attempted. If your device is unlocked and you're seeing this, notify the author, as the detection function has failed. If your device is not unlocked, notify the author in the forum thread you downloaded this from. Please include your device model, and the version of this script attempted.");
}
}
}
Hello,
I have a trouble with a string text encode after decompile an APK file.
I used APK Tool decompile. The origin file http_//file.9app.info/files/tuan/tuan2india/9-apps.apk
The code was encoded here:
Code:
public class API
extends Activity
{
public static String a = "081b11458016006d513b0290cc7be0b39c28626ea506b9ed291b125114f2a38369a42e77a066a7789e5883ed47113fc3";
public static String b = "081b11458016006d513b0290cc7be0b36f01584bcfccde8bd9e2bd628ca804e7056b175ad6a1fa1bf3cf31d8a28b94e9";
public static String c = "081b11458016006d513b0290cc7be0b36f01584bcfccde8bd9e2bd628ca804e7056b175ad6a1fa1bf3cf31d8a28b94e9";
public static JSONObject d = new JSONObject();
public static String e = "";
private static int h = 0;
private boolean f = false;
private ProgressDialog g;
private JSONObject a(JSONObject paramJSONObject)
{
int i = 0;
Iterator localIterator = paramJSONObject.keys();
int[] arrayOfInt = new int[paramJSONObject.length()];
int j = 0;
JSONObject localJSONObject1;
int m;
if (!localIterator.hasNext())
{
Arrays.sort(arrayOfInt);
localJSONObject1 = new JSONObject();
m = arrayOfInt.length;
}
for (;;)
{
if (i >= m)
{
return localJSONObject1;
int k = j + 1;
arrayOfInt[j] = Integer.parseInt(((String)localIterator.next()).toString());
j = k;
break;
}
String str1 = Integer.toString(arrayOfInt[i]);
try
{
JSONObject localJSONObject2 = (JSONObject)paramJSONObject.get(str1);
if (((paramJSONObject.get(str1) instanceof JSONObject)) && (!a(localJSONObject2.get("package").toString())))
{
String str2 = localJSONObject2.get("package").toString();
if (!getApplicationContext().getSharedPreferences("listpacks", 0).getBoolean(str2, false)) {
if (localJSONObject2.get("type").toString().equals("1"))
{
if (!this.f)
{
this.f = true;
d = localJSONObject2;
}
}
else
{
e = e + localJSONObject2.get("package").toString() + "|";
localJSONObject1.put(str1, localJSONObject2);
}
}
}
}
catch (JSONException localJSONException)
{
localJSONException.printStackTrace();
}
i++;
}
}
Anybody can help me decode 3 text string a,b,c please?
Hello,
Try posting your question in the forum linked below.
http://forum.xda-developers.com/android/help
The experts there may be able to help. Good luck.
Hello,
I'm newbie so I don't know where to post right. Thank you for your advice!