Guest User

FastDorm.class

a guest
Sep 1st, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.83 KB | None | 0 0
  1. package com.android.internal.telephony.gsm;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.IntentFilter;
  7. import android.content.SharedPreferences;
  8. import android.database.Cursor;
  9. import android.database.sqlite.SQLiteDatabase;
  10. import android.database.sqlite.SQLiteException;
  11. import android.util.Log;
  12. import com.android.internal.telephony.PhoneBase;
  13. import java.io.File;
  14.  
  15. public class FastDorm
  16. {
  17.   private static final boolean DBG = false;
  18.   private static final String FD_PREFERENCES_NAME = "fdormancy.preferences_name";
  19.   private static final String KEY_FD_STATE = "fdormancy.key.state";
  20.   protected final String LOG_TAG = "GSM";
  21.   File databaseFile;
  22.   private boolean dormLCDOffPolicy = 0;
  23.   private boolean dormLCDOnPolicy = 0;
  24.   private int mDefaultDormTime = 5000;
  25.   SQLiteDatabase mDormDb;
  26.   private boolean mDormancyFlag;
  27.   private BroadcastReceiver mFastDormancyLCDRcvr;
  28.   private IntentFilter mIntentFilter;
  29.   private boolean mIsScreenOn = 1;
  30.   private int mScreenOffDormTime = -1;
  31.   private int mScreenOnDormTime = -1;
  32.   protected PhoneBase phone;
  33.  
  34.   public FastDorm()
  35.   {
  36.   }
  37.  
  38.   public FastDorm(PhoneBase paramPhoneBase)
  39.   {
  40.     this.phone = paramPhoneBase;
  41.     int i = Log.e("GSM", "[FD] FastDormancy Constructor No plmn");
  42.     IntentFilter localIntentFilter1 = new IntentFilter();
  43.     this.mIntentFilter = localIntentFilter1;
  44.     this.mIntentFilter.addAction("android.intent.action.SCREEN_ON");
  45.     this.mIntentFilter.addAction("android.intent.action.SCREEN_OFF");
  46.     FastDorm.1 local1 = new FastDorm.1(this);
  47.     this.mFastDormancyLCDRcvr = local1;
  48.     Context localContext = paramPhoneBase.getContext();
  49.     BroadcastReceiver localBroadcastReceiver = this.mFastDormancyLCDRcvr;
  50.     IntentFilter localIntentFilter2 = this.mIntentFilter;
  51.     Intent localIntent = localContext.registerReceiver(localBroadcastReceiver, localIntentFilter2);
  52.   }
  53.  
  54.   public FastDorm(PhoneBase paramPhoneBase, String paramString)
  55.   {
  56.     this.phone = paramPhoneBase;
  57.     String str = "[FD] FastDormancy Constructor plmn: " + paramString;
  58.     int i = Log.e("GSM", str);
  59.   }
  60.  
  61.   private void readNwkinfoDb()
  62.   {
  63.     File localFile1 = new File("/data/data/com.android.providers.telephony/databases", "nwk_info.db");
  64.     this.databaseFile = localFile1;
  65.     if (!this.databaseFile.exists())
  66.     {
  67.       File localFile2 = new File("/system/csc", "nwk_info.db");
  68.       this.databaseFile = localFile2;
  69.       if (!this.databaseFile.exists())
  70.       {
  71.         int i = Log.e("GSM", "[FD] no nwk info db");
  72.         return;
  73.       }
  74.       int j = Log.e("GSM", "[FD] csc system area");
  75.     }
  76.     while (true)
  77.     {
  78.       try
  79.       {
  80.         SQLiteDatabase localSQLiteDatabase = SQLiteDatabase.openDatabase(this.databaseFile.getPath(), null, 1);
  81.         this.mDormDb = localSQLiteDatabase;
  82.         return;
  83.       }
  84.       catch (SQLiteException localSQLiteException)
  85.       {
  86.         int k = Log.e("GSM", "[FD] nwk info db open exception");
  87.         return;
  88.       }
  89.       int m = Log.e("GSM", "[FD] provider data area");
  90.     }
  91.   }
  92.  
  93.   private void setDormancyTime(String paramString)
  94.   {
  95.     String str1 = "(plmn = '" + paramString + "')";
  96.     String str2 = "[FD] setDormancyTime: " + paramString;
  97.     int i = Log.e("GSM", str2);
  98.     while (true)
  99.     {
  100.       try
  101.       {
  102.         if (this.mDormDb == null)
  103.           break label457;
  104.         Cursor localCursor = this.mDormDb.query("dormpolicy", null, str1, null, null, null, null);
  105.         if (localCursor == null)
  106.           break;
  107.         int j = Log.e("GSM", "[FD] (cursor != null) ");
  108.         if (!localCursor.moveToFirst())
  109.           break label363;
  110.         int k = Log.e("GSM", "[FD] (cursor.moveToFirst()) ");
  111.         int m = localCursor.getColumnIndexOrThrow("lcdonfdtime");
  112.         int n = localCursor.getInt(m) * 1000;
  113.         this.mScreenOnDormTime = n;
  114.         if (this.mScreenOnDormTime <= 0)
  115.           continue;
  116.         this.dormLCDOnPolicy = 1;
  117.         int i1 = localCursor.getColumnIndexOrThrow("lcdofffdtime");
  118.         int i2 = localCursor.getInt(i1) * 1000;
  119.         this.mScreenOffDormTime = i2;
  120.         if (this.mScreenOffDormTime > 0)
  121.         {
  122.           this.dormLCDOffPolicy = 1;
  123.           StringBuilder localStringBuilder1 = new StringBuilder().append("[FD] mScreenOnDormTime: ");
  124.           int i3 = this.mScreenOnDormTime;
  125.           StringBuilder localStringBuilder2 = localStringBuilder1.append(i3).append(" dormLCDOnPolicy: ");
  126.           boolean bool1 = this.dormLCDOnPolicy;
  127.           StringBuilder localStringBuilder3 = localStringBuilder2.append(bool1).append(" \t ").append(" mScreenOffDormTime: ");
  128.           int i4 = this.mScreenOffDormTime;
  129.           StringBuilder localStringBuilder4 = localStringBuilder3.append(i4).append(" dormLCDOffPolicy: ");
  130.           boolean bool2 = this.dormLCDOffPolicy;
  131.           String str3 = bool2 + " in DB";
  132.           int i5 = Log.e("GSM", str3);
  133.           localCursor.close();
  134.           return;
  135.           this.mScreenOnDormTime = 0;
  136.           this.dormLCDOnPolicy = 0;
  137.           continue;
  138.         }
  139.       }
  140.       catch (SQLiteException localSQLiteException)
  141.       {
  142.         int i6 = Log.e("GSM", "[FD] Exception during getDormancyTime");
  143.         return;
  144.       }
  145.       int i7 = 0;
  146.       this.mScreenOffDormTime = i7;
  147.       this.dormLCDOffPolicy = 0;
  148.       continue;
  149.       label363: int i8 = this.mDefaultDormTime;
  150.       this.mScreenOnDormTime = i8;
  151.       int i9 = this.mDefaultDormTime;
  152.       this.mScreenOffDormTime = i9;
  153.       this.dormLCDOnPolicy = 1;
  154.       this.dormLCDOffPolicy = 1;
  155.       int i10 = Log.e("GSM", "[FD] By default FD, !(cursor.moveToFirst()) ");
  156.     }
  157.     int i11 = this.mDefaultDormTime;
  158.     this.mScreenOnDormTime = i11;
  159.     int i12 = this.mDefaultDormTime;
  160.     this.mScreenOffDormTime = i12;
  161.     this.dormLCDOnPolicy = 1;
  162.     this.dormLCDOffPolicy = 1;
  163.     int i13 = Log.e("GSM", "[FD] By default FD, No Cursor ");
  164.     return;
  165.     label457: int i14 = Log.e("GSM", "[FD] There's no mDormDb in setDormancyTime");
  166.   }
  167.  
  168.   public void close()
  169.   {
  170.     Context localContext = this.phone.getContext();
  171.     BroadcastReceiver localBroadcastReceiver = this.mFastDormancyLCDRcvr;
  172.     localContext.unregisterReceiver(localBroadcastReceiver);
  173.     int i = Log.e("GSM", "[FD] FastDormancy Constructor closed");
  174.   }
  175.  
  176.   public int getDefaultDormTime()
  177.   {
  178.     return this.mDefaultDormTime;
  179.   }
  180.  
  181.   public boolean getDormancyFlag(String paramString)
  182.   {
  183.     int i = 1;
  184.     if (paramString == null)
  185.       int k = Log.e("GSM", "[FD] No op numeric");
  186.     for (int m = 1; ; m = 0)
  187.     {
  188.       return m;
  189.       if (!paramString.equals("45001"))
  190.         break;
  191.       int n = Log.e("GSM", "[FD] Now Samsung Test Bed");
  192.     }
  193.     SharedPreferences localSharedPreferences = this.phone.getContext().getSharedPreferences("fdormancy.preferences_name", 3);
  194.     int j;
  195.     if ((localSharedPreferences != null) && (localSharedPreferences.contains("fdormancy.key.state")))
  196.     {
  197.       if (localSharedPreferences.getBoolean("fdormancy.key.state", 1));
  198.       for (i = 1; ; j = 0)
  199.       {
  200.         String str = "[FD] Dormant flag(" + i + ") from key string";
  201.         int i1 = Log.e("GSM", str);
  202.         m = i;
  203.         break;
  204.       }
  205.     }
  206.     if (this.mIsScreenOn)
  207.       if (this.dormLCDOnPolicy)
  208.         j = 1;
  209.     while (true)
  210.     {
  211.       m = j;
  212.       break;
  213.       j = 0;
  214.       continue;
  215.       if (this.dormLCDOffPolicy)
  216.       {
  217.         j = 1;
  218.         continue;
  219.       }
  220.       j = 0;
  221.     }
  222.   }
  223.  
  224.   public int getScreenOffDormTime()
  225.   {
  226.     return this.mScreenOffDormTime;
  227.   }
  228.  
  229.   public int getScreenOnDormTime()
  230.   {
  231.     return this.mScreenOnDormTime;
  232.   }
  233.  
  234.   public void init(String paramString)
  235.   {
  236.     readNwkinfoDb();
  237.     setDormancyTime(paramString);
  238.     if (this.mDormDb == null)
  239.       return;
  240.     this.mDormDb.close();
  241.   }
  242. }
Advertisement
Add Comment
Please, Sign In to add comment