Skip to content

Commit

Permalink
support runtime permissions, fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
friedger committed Feb 12, 2017
1 parent 8d8ab9c commit a506c11
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 148 deletions.
8 changes: 4 additions & 4 deletions Flashlight/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ android {

defaultConfig {
applicationId "org.openintents.flashlight"
versionName "1.2"
versionCode 10012
versionName "1.2.1"
versionCode 10013
minSdkVersion 5
targetSdkVersion rootProject.ext.targetSdkVersion
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GoogleAppIndexingWarning'
}

}

dependencies {
compile files('libs/hardware09.jar')
compile 'com.github.openintents:distribution:1.2'
compile 'com.github.openintents:distribution:1.2.1'
}
10 changes: 4 additions & 6 deletions Flashlight/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.openintents.flashlight"
android:installLocation="auto"
android:versionCode="10011"
android:versionName="1.1">
android:installLocation="auto">

<!--
History:
Expand All @@ -44,8 +42,6 @@
<!-- required to keep the backlight turned on -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- required to adjust the brightness -->
<uses-permission android:name="android.permission.HARDWARE_TEST"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.CAMERA"/>

Expand All @@ -65,7 +61,9 @@

<application
android:icon="@drawable/ic_launcher_flashlight"
android:label="@string/app_name">
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules">
android:label="@string/app_name">

<!-- aTrackDog metadata -->
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class BrightnessNew extends Brightness {

public static final String TAG = "BrightnessNew1_5";
static private java.lang.reflect.Field fieldScreenBrightness;

/* class initialization fails when this throws an exception */
Expand All @@ -32,7 +33,7 @@ public static void checkAvailable() {
}

public void setBrightness(float val) {
Log.d("BrightnessNew for SDK 1.5", "brightness set to >" + val);
Log.d(TAG, "brightness set to >" + val);
WindowManager.LayoutParams lp = this.activity.getWindow().getAttributes();

// SDK 1.5 call:
Expand All @@ -41,7 +42,7 @@ public void setBrightness(float val) {
try {
fieldScreenBrightness.setFloat(lp, val);
} catch (IllegalAccessException e) {
Log.d("BrightnessNew for SDK 1.5", "Setting brightness failed");
Log.d(TAG, "Setting brightness failed");
}

this.activity.getWindow().setAttributes(lp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BrightnessOld extends Brightness {
* Not valid value of brightness
*/
private static final int NOT_VALID = -1;
public static final String TAG = "BrightnessOld1_0__1_1";

private static int mUserBrightness = NOT_VALID;
;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void setBrightness(float val) {
}


// boolean res=false;
// boolean res=false;
// set screen brightness
if (mUserBrightness == NOT_VALID) {
mUserBrightness = Settings.System.getInt(mContext.getContentResolver(),
Expand All @@ -62,24 +63,22 @@ public void setBrightness(float val) {

// Unset screen brightness
if (mUserBrightness != NOT_VALID) {
//Settings.System.putInt(mContext.getContentResolver(),
// Settings.System.SCREEN_BRIGHTNESS, mUserBrightness);
setBrightnessOld(mUserBrightness);
mUserBrightness = NOT_VALID;
}
}
}

private void setBrightnessOld(int oldSdkValue) {
Log.d("BrightnessOld for SDK 1.0,1.1", "brightness set to >" + oldSdkValue);
Log.d(TAG, "brightness set to >" + oldSdkValue);
try {
IHardwareService hardware = IHardwareService.Stub.asInterface(
ServiceManager.getService("hardware"));
if (hardware != null) {
hardware.setScreenBacklight(oldSdkValue);
}
} catch (RemoteException doe) {
Log.d("BrightnessOld for SDK 1.0,1.1", "failed to call HardwareService");
Log.d(TAG, "failed to call HardwareService");
}
}
}
Loading

0 comments on commit a506c11

Please sign in to comment.