Tag Archives: bar

Sony Xperia Illumination Bar Code(Some Code that May Interest you)

Here in this blog I am adding the illumination bar control activity class which I hacked and got from the famous Illumination bar App for Sony Xperia Android Phones. Hope you can get the basic Idea of the classes you have to access to take control of the lights Happy Coding.

If you are new to Illumination Bar App try it in the Google Play App Store

If you want to know how to hack an Android App step by step, please check my Blog on Android App Hacking

Thank You

illuminationcontrol.java

package com.rundgong.illuminationcontrol;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Iterator;

public class IlluminationControlActivity extends Activity
{
public static final int LED_RGB = 1;
public static final int LED_WHITE = 0;
public static boolean sAccessibilityIsMissing = false;
public static final int sWhitePos = 6;
public static int testBlinkCounter = 0;
BooleanItemSummary mAlwaysOnSummary;
ArrayList mAppConfigs;
ArrayList mAppNotificationDatas = getDefaultApps();
GeneralSettingsSummary mGeneralSettingsSummary;
LinearLayout.LayoutParams mLayoutParams;
View mMainView;
NightModeSummary mNightModeSummary;
ArrayList mPhoneConfigs;
SelectThemeColorSummary mSelectThemeColorSummary;
BooleanItemSummary mTempDisable;

static
{
sAccessibilityIsMissing = true;
}

private void addAppNotifications()
{
LinearLayout localLinearLayout = (LinearLayout)this.mMainView.findViewById(2131165198);
localLinearLayout.removeAllViews();
localLinearLayout.addView(getHeadlineView(getString(2131034117)), this.mLayoutParams);
Iterator localIterator1 = this.mAppNotificationDatas.iterator();
Iterator localIterator2;
if (!localIterator1.hasNext())
localIterator2 = new UserApps(this).mUserApps.iterator();
while (true)
{
if (!localIterator2.hasNext())
{
return;
AppNotificationData localAppNotificationData1 = (AppNotificationData)localIterator1.next();
ConfigItemSummary localConfigItemSummary1 = new ConfigItemSummary(this, localAppNotificationData1.displayName, localAppNotificationData1.packageId, true);
localLinearLayout.addView(localConfigItemSummary1, this.mLayoutParams);
this.mAppConfigs.add(localConfigItemSummary1);
break;
}
AppNotificationData localAppNotificationData2 = (AppNotificationData)localIterator2.next();
ConfigItemSummary localConfigItemSummary2 = new ConfigItemSummary(this, localAppNotificationData2.displayName, localAppNotificationData2.packageId, true);
localLinearLayout.addView(localConfigItemSummary2, this.mLayoutParams);
this.mAppConfigs.add(localConfigItemSummary2);
}
}

static void fileLog(CharSequence paramCharSequence)
{
}

static int getBaseIntensity(int paramInt)
{
int i = 255;
switch (paramInt)
{
case 6:
default:
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
}
while (true)
{
return i;
i = 4;
continue;
i = 8;
continue;
i = 17;
continue;
i = 34;
continue;
i = 79;
continue;
i = 143;
}
}

static BlinkData getBlinkTimeFromPosition(int paramInt)
{
BlinkData localBlinkData;
switch (paramInt)
{
default:
localBlinkData = new BlinkData(0, 0);
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
}
while (true)
{
return localBlinkData;
localBlinkData = new BlinkData(0, 0);
continue;
localBlinkData = new BlinkData(1000, 1000);
continue;
localBlinkData = new BlinkData(500, 500);
continue;
localBlinkData = new BlinkData(150, 150);
continue;
localBlinkData = new BlinkData(2000, 2000);
continue;
localBlinkData = new BlinkData(2000, 5000);
continue;
localBlinkData = new BlinkData(2000, 10000);
continue;
localBlinkData = new BlinkData(2000, 30000);
continue;
localBlinkData = new BlinkData(2000, 60000);
}
}

static int getColorFromPosition(int paramInt1, int paramInt2)
{
int i = getBaseIntensity(paramInt2);
int j;
switch (paramInt1)
{
default:
j = -1;
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
}
while (true)
{
return j;
j = -16777216 + 65536 * i;
continue;
j = -16777216 + i * 256;
continue;
j = -16777216 + i;
continue;
j = -16777216 + 65536 * i + i * 256;
continue;
j = i + (-16777216 + i * 256);
continue;
j = i + (-16777216 + 65536 * i);
continue;
j = i + (-16777216 + 65536 * i + i * 256);
}
}

static ArrayListgetDefaultApps()
{
ArrayList localArrayList = new ArrayList();
localArrayList.add(new AppNotificationData("com.android.calendar", "Calendar"));
localArrayList.add(new AppNotificationData("com.android.email", "Email"));
localArrayList.add(new AppNotificationData("com.facebook.katana", "Facebook"));
localArrayList.add(new AppNotificationData("com.google.android.gm", "Gmail"));
localArrayList.add(new AppNotificationData("com.google.android.apps.plus", "Google+"));
localArrayList.add(new AppNotificationData("com.google.android.gsf", "Google Talk"));
localArrayList.add(new AppNotificationData("com.twitter.android", "Twitter"));
localArrayList.add(new AppNotificationData("com.whatsapp", "WhatsApp"));
return localArrayList;
}

static int getDefaultLedNumForDevice()
{
if (Build.MODEL.contains("ST25"));
for (int i = 1; ; i = 0)
return i;
}

private TextView getHeadlineView(String paramString)
{
TextView localTextView = new TextView(this);
localTextView.setGravity(17);
localTextView.setText(paramString);
localTextView.setBackgroundColor(-12303292);
localTextView.setTextColor(-1);
return localTextView;
}

static String getLedIdFromNumber(int paramInt)
{
if (paramInt == 1);
for (String str = "com.sonyericsson.illumination.intent.extra.value.BUTTON_RGB"; ; str = "com.sonyericsson.illumination.intent.extra.value.BUTTON_2")
return str;
}

public static void illuminate(ContextWrapper paramContextWrapper, int paramInt1, int paramInt2, BlinkData paramBlinkData, int paramInt3)
{
Intent localIntent;
if ((paramBlinkData == null) || (paramBlinkData.onTime == 0))
{
localIntent = new Intent("com.sonyericsson.illumination.intent.action.START_LED");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_ON_TIME", paramInt2);
}
while (true)
{
localIntent.putExtra("com.sonyericsson.illumination.intent.extra.PACKAGE_NAME", "com.rundgong.illuminationcontrol");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_ID", getLedIdFromNumber(paramInt3));
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_COLOR", paramInt1);
 paramContextWrapper.startService(localIntent);
 return;
 localIntent = new Intent("com.sonyericsson.illumination.intent.action.START_LED_PULSE");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_NO_OF_PULSES", paramInt2 / (paramBlinkData.offTime + paramBlinkData.onTime));
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_PULSE_ON_TIME", paramBlinkData.onTime);
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_PULSE_OFF_TIME", paramBlinkData.offTime);
}
}

private void refreshGUI()
{
this.mNightModeSummary.update();
this.mSelectThemeColorSummary.update();
Iterator localIterator = this.mPhoneConfigs.iterator();
while (true)
{
if (!localIterator.hasNext())
{
addAppNotifications();
return;
}
((ConfigItemSummary)localIterator.next()).update();
}
}

private void startBackgroundService()
{
startService(new Intent(this, BackgroundService.class));
startService(new Intent(this, NotificationService.class));
}

public void addMoreAppsButtonClicked(View paramView)
{
startActivity(new Intent(this, AddAppsActivity.class));
}

public void donateButtonClicked(View paramView)
{
startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H7LW4D3XWK9GC")));
}

AlertDialog getAccessibilityDialog()
{
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setMessage(2131034157).setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramDialogInterface, int paramInt)
{
IlluminationControlActivity.this.startActivity(new Intent("android.settings.ACCESSIBILITY_SETTINGS"));
}
}).setNegativeButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramDialogInterface, int paramInt)
{
paramDialogInterface.cancel();
}
});
return localBuilder.create();
}

public void helpButtonClicked(View paramView)
{
startActivity(new Intent(this, HelpActivity.class));
}

public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
this.mMainView = ((LayoutInflater)getSystemService("layout_inflater")).inflate(2130903043, null);
setContentView(this.mMainView);
this.mGeneralSettingsSummary = new GeneralSettingsSummary(this);
this.mAlwaysOnSummary = new BooleanItemSummary(this, getString(2131034129), "keyLightAlwaysOn");
this.mTempDisable = new BooleanItemSummary(this, getString(2131034130), "tempDisableIllumination");
this.mTempDisable.setEnableText(2131034131);
this.mTempDisable.setDisableText(2131034132);
this.mNightModeSummary = new NightModeSummary(this);
this.mSelectThemeColorSummary = new SelectThemeColorSummary(this);
this.mPhoneConfigs = new ArrayList();
this.mAppConfigs = new ArrayList();
startBackgroundService();
this.mLayoutParams = new LinearLayout.LayoutParams(-1, -2);
this.mLayoutParams.setMargins(0, 1, 0, 0);
LinearLayout localLinearLayout1 = (LinearLayout)this.mMainView.findViewById(2131165196);
localLinearLayout1.addView(getHeadlineView(getString(2131034114)), this.mLayoutParams);
localLinearLayout1.addView(this.mGeneralSettingsSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mAlwaysOnSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mTempDisable, this.mLayoutParams);
localLinearLayout1.addView(this.mNightModeSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mSelectThemeColorSummary, this.mLayoutParams);
LinearLayout localLinearLayout2 = (LinearLayout)this.mMainView.findViewById(2131165197);
localLinearLayout2.addView(getHeadlineView(getString(2131034116)), this.mLayoutParams);
ConfigItemSummary localConfigItemSummary1 = new ConfigItemSummary(this, "SMS", "sms", false);
this.mPhoneConfigs.add(localConfigItemSummary1);
localLinearLayout2.addView(localConfigItemSummary1, this.mLayoutParams);
ConfigItemSummary localConfigItemSummary2 = new ConfigItemSummary(this, "Missed Calls", "missedCalls", false);
localLinearLayout2.addView(localConfigItemSummary2, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary2);
ConfigItemSummary localConfigItemSummary3 = new ConfigItemSummary(this, "Battery Full", "batteryFull", false);
localLinearLayout2.addView(localConfigItemSummary3, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary3);
ConfigItemSummary localConfigItemSummary4 = new ConfigItemSummary(this, "Battery Empty", "batteryEmpty", false);
localLinearLayout2.addView(localConfigItemSummary4, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary4);
}

public void onResume()
{
super.onResume();
refreshGUI();
if (sAccessibilityIsMissing)
getAccessibilityDialog().show();
}

public static class BlinkData
{
int offTime = 0;
int onTime = 0;

public BlinkData(int paramInt1, int paramInt2)
{
this.onTime = paramInt1;
this.offTime = paramInt2;
}
}
}
Advertisements